Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Share connection across different clients #881

Merged
merged 3 commits into from
Aug 10, 2022

Conversation

cretz
Copy link
Member

@cretz cretz commented Aug 9, 2022

What was changed

  • Added NewClientFromExisting function to create a new client with the same connection but different client options
  • Made sure to support the different namespaces in the gRPC interceptor metrics

Why?

Users want to use the same connection for multiple namespaces

Checklist

  1. Closes Support creating new client from existing client's connection #861

…ction

# Conflicts:
#	test/integration_test.go
@cretz cretz requested a review from dnr August 9, 2022 17:18
// this package and cannot be wrapped. Currently, this always attempts an eager
// connection even if the existing client was created with NewLazyClient and has
// not made any calls yet.
func NewClientFromExisting(existingClient Client, options Options) (Client, error) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might make sense to make a narrower options type here with just the stuff that won't be ignored.

If that can be re-used in a backwards compat way inside the existing options, that's gravy. If not it might still be worth it just to make this less potentially confusing, but up to you.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In theory I like splitting the struct into "connection options" and "other options" but I don't think it's worth it for this feature that most people won't ever use

Copy link
Member Author

@cretz cretz Aug 10, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might make sense to make a narrower options type here with just the stuff that won't be ignored.

This can't be done in a backwards compatible way. I'd have to make a whole new struct. This would entail just copying all but two fields of the existing struct just for this method and hoping I properly keep them and their docs in sync when adding more. I think it's reasonable to reuse these options explaining which are unused.

// this package and cannot be wrapped. Currently, this always attempts an eager
// connection even if the existing client was created with NewLazyClient and has
// not made any calls yet.
func NewClientFromExisting(existingClient Client, options Options) (Client, error) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In theory I like splitting the struct into "connection options" and "other options" but I don't think it's worth it for this feature that most people won't ever use

Comment on lines +64 to +66
// Since this interceptor can be used for clients of different name, we
// attempt to extract the namespace out of the request. All namespace-based
// requests have been confirmed to have a top-level namespace field.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this deserve a comment in the proto file? I mean I wouldn't do a PR just for that, but bundle it into your next api PR? :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, if I remember on my next one I'll add something like "Some clients expect all namespace-based RPC calls to have a single namespace string field in the request".

@cretz cretz merged commit f150e45 into temporalio:master Aug 10, 2022
@cretz cretz deleted the share-connection branch August 10, 2022 12:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support creating new client from existing client's connection
3 participants