Skip to content

Commit 3615c8d

Browse files
authored
Propagate context to server RPC handlers (#2059)
Motivation: The interceptors API has a context which, at the moment, only includes the name of the RPC. This information is generally useful so should be propagated to the server handler too. Information on the context can also be extended later to include things like the identity of the remote peer, or info about the state of the RPC. Modifications: - Rename 'ServerInterceptorContext' to 'ServerContext' - Make the transport the source of the context and have that provide it to the 'listen' method. Propagate this through the server stack to the generated stubs. - Update code generator to include the context - Update generated code - Update services Results: RPC handlers have a context provided by a transport
1 parent 70d91e2 commit 3615c8d

File tree

5 files changed

+286
-109
lines changed

5 files changed

+286
-109
lines changed

Sources/GRPCInterceptors/ServerTracingInterceptor.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ public struct ServerTracingInterceptor: ServerInterceptor {
4444
/// that has been configured when bootstrapping `swift-distributed-tracing` in your application.
4545
public func intercept<Input, Output>(
4646
request: ServerRequest.Stream<Input>,
47-
context: ServerInterceptorContext,
48-
next: @Sendable (ServerRequest.Stream<Input>, ServerInterceptorContext) async throws ->
47+
context: ServerContext,
48+
next: @Sendable (ServerRequest.Stream<Input>, ServerContext) async throws ->
4949
ServerResponse.Stream<Output>
5050
) async throws -> ServerResponse.Stream<Output> where Input: Sendable, Output: Sendable {
5151
var serviceContext = ServiceContext.topLevel

0 commit comments

Comments
 (0)