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)
| 144 | // |
| 145 | // If channelz is not turned ON, the channelz database is not mutated. |
| 146 | func 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. |