MCPcopy
hub / github.com/grafana/dskit / CloseStream

Method CloseStream

middleware/grpc_stats.go:160–179  ·  view source on GitHub ↗
(connID string)

Source from the content-addressed store, hash-verified

158}
159
160func (st *StreamTracker) CloseStream(connID string) {
161 st.mu.RLock()
162 conn := st.connMap[connID]
163 st.mu.RUnlock()
164 if conn == nil {
165 return
166 }
167 if res := conn.Dec(); res == 0 {
168 // Delete the entry if it's empty.
169 st.mu.Lock()
170
171 // Get the entry again to avoid race condition.
172 conn = st.connMap[connID]
173 if conn == nil || conn.Load() == 0 {
174 delete(st.connMap, connID)
175 }
176
177 st.mu.Unlock()
178 }
179}
180
181// MaxStreams returns the number of streams in the connection with the most streams.
182func (st *StreamTracker) MaxStreams() int {

Callers 4

TestGrpcStreamTrackerFunction · 0.95
BenchmarkStreamTrackerFunction · 0.95
HandleRPCMethod · 0.80

Calls

no outgoing calls

Tested by 3

TestGrpcStreamTrackerFunction · 0.76
BenchmarkStreamTrackerFunction · 0.76