streamctx

package
v1.0.442 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 9, 2026 License: MIT Imports: 3 Imported by: 0

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL