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

Fix a few streaming interceptor bugs #3655

Merged
merged 2 commits into from
Feb 19, 2025
Merged

Fix a few streaming interceptor bugs #3655

merged 2 commits into from
Feb 19, 2025

Conversation

douglaswth
Copy link
Member

@douglaswth douglaswth commented Feb 18, 2025

  • The wrap function for server interceptors was working as if it were a client interceptor: expecting the stream to be the result of calling the endpoint or the next unary interceptor in the chain. It now properly wraps the stream in the raw payload (which is actually a special EndpointStruct with the stream and optionally the unary payload).
  • The unary Payload methods of server interceptor info structs for a streaming method assumed that the raw payload would be the payload type rather than the special EndpointStruct type. Now, the Payload methods properly expect the raw payload to either be the EndpointStruct or the payload type in the case when the server interceptor info struct is also used for a client interceptor.
  • With the change of goa.InterceptorInfo from a struct to an interface, the generation of implementation of the interface methods on the generated interceptor info structs became necessary. The code for those methods was included in a section of the template that was conditional on the interceptor having accessors. Now, the conditional has been moved to a more appropriate place so the interface methods are implemented.

- The wrap function for server interceptors was working as if it were a
  client interceptor: expecting the stream to be the result of calling
  the endpoint or the next unary interceptor in the chain. It now
  properly wraps the stream in the raw payload (which is actually a
  special `EndpointStruct` with the stream and optionally the unary
  payload).
- The unary `Payload` methods of server interceptor info structs for a
  streaming method assumed that the raw payload would be the payload
  type rather than the special `EndpointStruct` type. Now, the `Payload`
  methods properly expect the raw payload to either be the `EndpointStruct`
  or the payload type in the case when the server interceptor info
  struct is also used for a client interceptor.
@douglaswth douglaswth requested a review from raphael February 18, 2025 19:58
douglaswth added a commit to goadesign/examples that referenced this pull request Feb 18, 2025
douglaswth added a commit to goadesign/clue that referenced this pull request Feb 18, 2025
@douglaswth douglaswth marked this pull request as draft February 19, 2025 19:58
@douglaswth
Copy link
Member Author

I've found one more bug to fix which I'll push here.

- With the change of `goa.InterceptorInfo` from a struct to an
  interface, the generation of implementation of the interface methods
  on the generated interceptor info structs became necessary. The
  code for those methods was included in a section of the template that
  was conditional on the interceptor having accessors. Now, the
  conditional has been moved to a more appropriate place so the
  interface methods are implemented.
@douglaswth douglaswth changed the title Fix a couple streaming interceptor bugs Fix a few streaming interceptor bugs Feb 19, 2025
@douglaswth douglaswth marked this pull request as ready for review February 19, 2025 21:27
@raphael
Copy link
Member

raphael commented Feb 19, 2025

This is great, thank you!

@raphael raphael merged commit fcf44e9 into v3 Feb 19, 2025
11 checks passed
@raphael raphael deleted the streaming-interceptors-fix branch February 19, 2025 23:57
raphael added a commit to goadesign/examples that referenced this pull request Feb 22, 2025
* Add interceptors example

* go mod tidy

* Improve interceptors example README

* Progress on streaming interceptors in example which uncovered a generation bug

* Fix Goa generation with goadesign/goa#3652

* Generate with interceptor fixes from goadesign/goa#3655

---------

Co-authored-by: Douglas Thrift <[email protected]>
raphael pushed a commit to goadesign/clue that referenced this pull request Feb 22, 2025
…520)

* Add interceptors package with useful typed Goa interceptor functions

- Add Trace Stream family of interceptor functions which allow for
  tracing of individual messages sent on bidirectional, client to
  server, and server to client streams.
- Fix typos in several READMEs.

[ ] Add tests for the interceptor functions.

* Retrieve receive context via context rendezvous since we decided against changing the Goa interceptor interface to return a context

* Add embeddable structs for interceptors as more terse option (only somewhat since Go needs more explicit type parameters than it should)

* Add tests for the Trace Stream interceptors and wrappers

* Improve naming with input from @xeger

* Point to Goa with interceptor fixes from goadesign/goa#3655
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