streamctx

package
v1.1.457 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2026 License: MIT Imports: 3 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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