MCPcopy
hub / github.com/grpc/grpc-go / NewContext

Function NewContext

peer/peer.go:75–77  ·  view source on GitHub ↗

NewContext creates a new context with peer information attached.

(ctx context.Context, p *Peer)

Source from the content-addressed store, hash-verified

73
74// NewContext creates a new context with peer information attached.
75func NewContext(ctx context.Context, p *Peer) context.Context {
76 return context.WithValue(ctx, peerKey{}, p)
77}
78
79// FromContext returns the peer information in ctx if it exists.
80func FromContext(ctx context.Context) (p *Peer, ok bool) {

Callers 7

serveStreamsMethod · 0.92
NewHTTP2ClientFunction · 0.92
NewStreamMethod · 0.92
TestChainEngineMethod · 0.92
TestPeerStringerFunction · 0.85

Calls 1

WithValueMethod · 0.80

Tested by 4

TestChainEngineMethod · 0.74
TestPeerStringerFunction · 0.68