-
-
Notifications
You must be signed in to change notification settings - Fork 566
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
Streaming Interceptors #3641
base: v3
Are you sure you want to change the base?
Streaming Interceptors #3641
Conversation
…wrapping streaming methods
…plied; import the correct user types packages when rendering service_interceptors.go; fix an ancient typo
…dpoint field from goa.InterceptorInfo struct since it is redundant with the next goa.Endpoint parameter sent to interceptors
…thod with interceptors even if they do not apply
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.
Really great PR! I left very few minor comments. Overall it all makes sense and follows the existing patterns very well, good job!
{{- range .WrappedClientStreams }} | ||
|
||
{{ comment (printf "wrapped%s is a client interceptor wrapper for the %s stream." .Interface .Interface) }} | ||
type wrapped{{ .Interface }} struct { |
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.
Might be nice to move the type definition to the top of the file
pkg/interceptor.go
Outdated
@@ -9,8 +9,10 @@ type ( | |||
Service string |
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.
We should update the struct header comment to reflect the changes
pkg/interceptor.go
Outdated
@@ -9,8 +9,10 @@ type ( | |||
Service string | |||
// Name of method handling request | |||
Method string | |||
// Endpoint of request, can be used for retrying | |||
Endpoint Endpoint | |||
// Send is true if the request is a streaming Send |
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.
What's the rationale for these two fields? I could see Send
helping differentiate between the initial request and the streaming request in the case of websocket but not sure I understand the point of Recv
?
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.
Let's say you are building an OTel tracing interceptor for a bidirectional stream that needs to send per message trace and span IDs in both directions:
- The interceptor will need to grab the tracing data from the
context.Context
and add it to the message when interceptingSend
- The interceptor will need to grab the tracing data from the message and add it to the
context.Context
when interceptingRecv
Having both of these fields allows the interceptor to know whether it isSend
,Recv
, or the initial request.
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.
Got it, makes sense. I wonder if we could have only one field then?
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.
I suppose we could replace it with an enum.
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.
Maybe something like: goa.InterceptorMethod
, goa.InterceptorStreamingSend
, goa.InterceptorStreamingRecv
.
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.
Yes, goa.InterceptorUnary
instead of Method
maybe?
…ds with a CallType enum; organize interceptor wrappers file sections as types, functions, then methods
…s to modify the context returned by SendWithContext/RecvWithContext even after calling next
…ace to return a context itself
… info structs implement
SendWithContext
andRecvWithContext
methods to the stream interfaces