MCPcopy
hub / github.com/etcd-io/etcd / withVersion

Function withVersion

client/v3/ctx.go:41–51  ·  view source on GitHub ↗

embeds client version

(ctx context.Context)

Source from the content-addressed store, hash-verified

39
40// embeds client version
41func withVersion(ctx context.Context) context.Context {
42 md, ok := metadata.FromOutgoingContext(ctx)
43 if !ok { // no outgoing metadata ctx key, create one
44 md = metadata.Pairs(rpctypes.MetadataClientAPIVersionKey, version.APIVersion)
45 return metadata.NewOutgoingContext(ctx, md)
46 }
47 copied := md.Copy() // avoid racey updates
48 // overwrite/add version key/value
49 copied.Set(rpctypes.MetadataClientAPIVersionKey, version.APIVersion)
50 return metadata.NewOutgoingContext(ctx, copied)
51}

Callers 3

Calls 2

CopyMethod · 0.65
SetMethod · 0.65

Tested by 1

Used in the wild real call sites across dependent graphs

searching dependent graphs…