Skip to content

ServerInterceptorContext should provide closeFuture similar to ServerCallContext #1552

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

Closed
octo47 opened this issue Jan 11, 2023 · 0 comments · Fixed by #1553
Closed

ServerInterceptorContext should provide closeFuture similar to ServerCallContext #1552

octo47 opened this issue Jan 11, 2023 · 0 comments · Fixed by #1553
Labels
kind/enhancement Improvements to existing feature.

Comments

@octo47
Copy link

octo47 commented Jan 11, 2023

Is your feature request related to a problem? Please describe it.

As for today ServerInterceptorContext does not have any way to handle abnormal stream termination (task cancelled, client resets connection in streaming calls).
In such an event interceptor will have no chance to be called as no .end() messages will be passed down ServerInterceptorPipeline.

Result of such behaviour may affect many use cases: tracing (lingering open spans), metrics (some calls will not be recorded), logging (errors will not be logged)

Describe the solution you'd like

Add closeFuture to ServerInterceptorContext (similar to ServerCallContext):

  • var closeFuture: EventLoopFuture { get }

Describe alternatives you've considered

Proposed solution is in line how it currently works for ServerCallContext

Additional context

swift-interceptors.tar.gz

# server
swift run route-server
# client
swift run route-client

to make client die in bidir route chat

# run with kill-switch
swift run route-client --kill-process

so as a result normal run

2023-01-11T11:41:21+0000 debug route-server : grpc.path=/routeguide.RouteGuide/RouteChat [RouteGuideServer] RECV metadata
2023-01-11T11:41:21+0000 debug route-server : grpc.path=/routeguide.RouteGuide/RouteChat [RouteGuideServer] RECV message
....
2023-01-11T11:41:24+0000 debug route-server : grpc.path=/routeguide.RouteGuide/RouteChat [RouteGuideServer] SEND message
2023-01-11T11:41:24+0000 debug route-server : grpc.path=/routeguide.RouteGuide/RouteChat [RouteGuideServer] RECV end
2023-01-11T11:41:24+0000 debug route-server : grpc.path=/routeguide.RouteGuide/RouteChat grpc.status=ok (0) [RouteGuideServer] SEND end

and with kill switch

2023-01-11T11:42:49+0000 debug route-server : grpc.path=/routeguide.RouteGuide/RouteChat [RouteGuideServer] RECV metadata
2023-01-11T11:42:49+0000 debug route-server : grpc.path=/routeguide.RouteGuide/RouteChat [RouteGuideServer] RECV message
...
2023-01-11T11:42:50+0000 debug route-server : grpc.path=/routeguide.RouteGuide/RouteChat [RouteGuideServer] SEND message
2023-01-11T11:42:50+0000 debug route-server : grpc.path=/routeguide.RouteGuide/RouteChat [RouteGuideServer] SEND message

Note no SEND end messages (edited)

@octo47 octo47 added the kind/enhancement Improvements to existing feature. label Jan 11, 2023
glbrntt added a commit to glbrntt/grpc-swift that referenced this issue Jan 11, 2023
Motivation:

Server calls expose a `closeFuture` where users can register callbacks
to tear things down when the RPC ends. Interceptors don't have this
capability and must rely on observing an `.end`.

Modifications:

Expose the `closeFuture` from `ServerCallContext` to
the `ServerInterceptorContext`.

Result:

- Users can be notified in interceptors when the call ends.
- Resolves grpc#1552
glbrntt added a commit that referenced this issue Jan 11, 2023
Motivation:

Server calls expose a `closeFuture` where users can register callbacks
to tear things down when the RPC ends. Interceptors don't have this
capability and must rely on observing an `.end`.

Modifications:

Expose the `closeFuture` from `ServerCallContext` to
the `ServerInterceptorContext`.

Result:

- Users can be notified in interceptors when the call ends.
- Resolves #1552
WendellXY pushed a commit to sundayfun/grpc-swift that referenced this issue Aug 24, 2023
Motivation:

Server calls expose a `closeFuture` where users can register callbacks
to tear things down when the RPC ends. Interceptors don't have this
capability and must rely on observing an `.end`.

Modifications:

Expose the `closeFuture` from `ServerCallContext` to
the `ServerInterceptorContext`.

Result:

- Users can be notified in interceptors when the call ends.
- Resolves grpc#1552
pinlin168 pushed a commit to sundayfun/grpc-swift that referenced this issue Aug 24, 2023
Motivation:

Server calls expose a `closeFuture` where users can register callbacks
to tear things down when the RPC ends. Interceptors don't have this
capability and must rely on observing an `.end`.

Modifications:

Expose the `closeFuture` from `ServerCallContext` to
the `ServerInterceptorContext`.

Result:

- Users can be notified in interceptors when the call ends.
- Resolves grpc#1552
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/enhancement Improvements to existing feature.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant