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

Function Group

internal/hierarchy/hierarchy.go:95–108  ·  view source on GitHub ↗

Group splits a slice of endpoints into groups based on the first hierarchy path. The first hierarchy path will be removed from the result. Input: [ {endpoint0, path: [p0, wt0]} {endpoint1, path: [p0, wt1]} {endpoint2, path: [p1, wt2]} {endpoint3, path: [p1, wt3]} ] Endpoints will be split in

(endpoints []resolver.Endpoint)

Source from the content-addressed store, hash-verified

93// If hierarchical path is not set, or has no path in it, the endpoint is
94// dropped.
95func Group(endpoints []resolver.Endpoint) map[string][]resolver.Endpoint {
96 ret := make(map[string][]resolver.Endpoint)
97 for _, endpoint := range endpoints {
98 oldPath := FromEndpoint(endpoint)
99 if len(oldPath) == 0 {
100 continue
101 }
102 curPath := oldPath[0]
103 newPath := oldPath[1:]
104 newEndpoint := SetInEndpoint(endpoint, newPath)
105 ret[curPath] = append(ret[curPath], newEndpoint)
106 }
107 return ret
108}

Callers 5

UpdateClientConnStateMethod · 0.92
TestGroupFunction · 0.92
TestGroupE2EFunction · 0.92
UpdateClientConnStateMethod · 0.92
updateChildrenMethod · 0.92

Calls 2

SetInEndpointFunction · 0.85
FromEndpointFunction · 0.70

Tested by 2

TestGroupFunction · 0.74
TestGroupE2EFunction · 0.74