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

Method getServers

internal/channelz/channelmap.go:265–289  ·  view source on GitHub ↗
(id int64, maxResults int)

Source from the content-addressed store, hash-verified

263}
264
265func (c *channelMap) getServers(id int64, maxResults int) ([]*Server, bool) {
266 if maxResults <= 0 {
267 maxResults = EntriesPerPage
268 }
269 c.mu.RLock()
270 defer c.mu.RUnlock()
271 ids := make([]int64, 0, len(c.servers))
272 for k := range c.servers {
273 ids = append(ids, k)
274 }
275 sort.Sort(int64Slice(ids))
276 idx := sort.Search(len(ids), func(i int) bool { return ids[i] >= id })
277 end := true
278 var s []*Server
279 for _, v := range ids[idx:] {
280 if len(s) == maxResults {
281 end = false
282 break
283 }
284 if svr, ok := c.servers[v]; ok {
285 s = append(s, svr)
286 }
287 }
288 return s, end
289}
290
291func (c *channelMap) getServerSockets(id int64, startID int64, maxResults int) ([]*Socket, bool) {
292 if maxResults <= 0 {

Callers 1

GetServersFunction · 0.80

Calls 2

int64SliceTypeAlias · 0.85
SearchMethod · 0.65

Tested by

no test coverage detected