Documentation
¶
Overview ¶
Package streamctx wraps a grpc.ServerStream so that its Context returns a replacement context. Stream interceptors use it to attach values (identity, correlation ID) to the context seen by the handler:
func interceptor(srv any, ss grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) error {
ctx := context.WithValue(ss.Context(), key, value)
return handler(srv, streamctx.WithContext(ctx, ss))
}
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WithContext ¶
func WithContext(ctx context.Context, ss grpc.ServerStream) grpc.ServerStream
WithContext returns a grpc.ServerStream whose Context method returns ctx. If ss was already produced by WithContext, its context is replaced in place and the same stream is returned (so earlier holders of that stream observe the new context); otherwise ss is wrapped.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.