-
Notifications
You must be signed in to change notification settings - Fork 217
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -59,9 +59,17 @@ func NewGRPCInterceptor(defaultHandler Handler, suffix string) grpc.UnaryClientI | |
|
||
// Only take method name after the last slash | ||
operation := method[strings.LastIndex(method, "/")+1:] | ||
handler = handler.WithTags(map[string]string{OperationTagName: operation}) | ||
tags := map[string]string{OperationTagName: operation} | ||
|
||
// 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. | ||
Comment on lines
+64
to
+66
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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? :) There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
if nsReq, _ := req.(interface{ GetNamespace() string }); nsReq != nil { | ||
tags[NamespaceTagName] = nsReq.GetNamespace() | ||
} | ||
|
||
// Capture time, record start, run, and record end | ||
handler = handler.WithTags(tags) | ||
start := time.Now() | ||
recordRequestStart(handler, longPoll, suffix) | ||
err := invoker(ctx, method, req, reply, cc, opts...) | ||
|
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.