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

Function RegisterSubChannel

internal/channelz/funcs.go:146–162  ·  view source on GitHub ↗

RegisterSubChannel registers the given subChannel c in the channelz database with ref as its reference name, and adds it to the child list of its parent (identified by pid). Returns a unique channelz identifier assigned to this subChannel. If channelz is not turned ON, the channelz database is not

(parent *Channel, ref string)

Source from the content-addressed store, hash-verified

144//
145// If channelz is not turned ON, the channelz database is not mutated.
146func RegisterSubChannel(parent *Channel, ref string) *SubChannel {
147 id := IDGen.genID()
148 sc := &SubChannel{
149 ID: id,
150 RefName: ref,
151 parent: parent,
152 }
153
154 if !IsOn() {
155 return sc
156 }
157
158 sc.sockets = make(map[int64]string)
159 sc.trace = &ChannelTrace{CreationTime: time.Now(), Events: make([]*traceEvent, 0, getMaxTraceEntry())}
160 db.addSubChannel(id, sc, parent.ID)
161 return sc
162}
163
164// RegisterServer registers the given server s in channelz database. It returns
165// the unique channelz tracking id assigned to this server.

Callers 5

newAddrConnLockedMethod · 0.92
channelzSubChannelFunction · 0.92
TestGetChannelMethod · 0.92
TestGetSubChannelMethod · 0.92

Calls 5

IsOnFunction · 0.85
getMaxTraceEntryFunction · 0.85
genIDMethod · 0.80
NowMethod · 0.80
addSubChannelMethod · 0.80

Tested by 4

channelzSubChannelFunction · 0.74
TestGetChannelMethod · 0.74
TestGetSubChannelMethod · 0.74