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

Function RegisterChannel

internal/channelz/funcs.go:117–137  ·  view source on GitHub ↗

RegisterChannel registers the given channel c in the channelz database with target as its target and reference name, and adds it to the child list of its parent. parent == nil means no parent. Returns a unique channelz identifier assigned to this channel. If channelz is not turned ON, the channel

(parent *Channel, target string)

Source from the content-addressed store, hash-verified

115//
116// If channelz is not turned ON, the channelz database is not mutated.
117func RegisterChannel(parent *Channel, target string) *Channel {
118 id := IDGen.genID()
119
120 if !IsOn() {
121 return &Channel{ID: id}
122 }
123
124 isTopChannel := parent == nil
125
126 cn := &Channel{
127 ID: id,
128 RefName: target,
129 nestedChans: make(map[int64]string),
130 subChans: make(map[int64]string),
131 Parent: parent,
132 trace: &ChannelTrace{CreationTime: time.Now(), Events: make([]*traceEvent, 0, getMaxTraceEntry())},
133 }
134 cn.ChannelMetrics.Target.Store(&target)
135 db.addChannel(id, cn, isTopChannel, cn.getParentID())
136 return cn
137}
138
139// RegisterSubChannel registers the given subChannel c in the channelz database
140// with ref as its reference name, and adds it to the child list of its parent

Callers 8

channelzRegistrationMethod · 0.92
channelzSubChannelFunction · 0.92
setupFunction · 0.92
TestGetTopChannelsMethod · 0.92
TestGetChannelMethod · 0.92
TestGetSubChannelMethod · 0.92

Calls 6

getParentIDMethod · 0.95
IsOnFunction · 0.85
getMaxTraceEntryFunction · 0.85
genIDMethod · 0.80
NowMethod · 0.80
addChannelMethod · 0.80

Tested by 7

channelzSubChannelFunction · 0.74
setupFunction · 0.74
TestGetTopChannelsMethod · 0.74
TestGetChannelMethod · 0.74
TestGetSubChannelMethod · 0.74