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

Streaming Interceptors #3641

Open
wants to merge 23 commits into
base: v3
Choose a base branch
from
Open

Streaming Interceptors #3641

wants to merge 23 commits into from

Conversation

douglaswth
Copy link
Member

@douglaswth douglaswth commented Feb 1, 2025

  • Initial implementation of Streaming Interceptors generation based on Interceptors Proposal #3614
  • Add SendWithContext and RecvWithContext methods to the stream interfaces
  • Fix several generation bugs

Copy link
Member

@raphael raphael left a 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 {
Copy link
Member

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

@@ -9,8 +9,10 @@ type (
Service string
Copy link
Member

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

@@ -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
Copy link
Member

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?

Copy link
Member Author

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 intercepting Send
  • The interceptor will need to grab the tracing data from the message and add it to the context.Context when intercepting Recv
    Having both of these fields allows the interceptor to know whether it is Send, Recv, or the initial request.

Copy link
Member

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?

Copy link
Member Author

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.

Copy link
Member Author

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.

Copy link
Member

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?

@douglaswth douglaswth requested a review from raphael February 3, 2025 20:11
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.

2 participants