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

Function encodeEndpoint

resolver/map.go:201–212  ·  view source on GitHub ↗

encodeEndpoint returns a string that uniquely identifies the unordered set of addresses within an endpoint.

(e Endpoint)

Source from the content-addressed store, hash-verified

199// encodeEndpoint returns a string that uniquely identifies the unordered set of
200// addresses within an endpoint.
201func encodeEndpoint(e Endpoint) endpointMapKey {
202 addrs := make([]string, 0, len(e.Addresses))
203 // base64 encoding the address strings restricts the characters present
204 // within the strings. This allows us to use a delimiter without the need of
205 // escape characters.
206 for _, addr := range e.Addresses {
207 addrs = append(addrs, base64.StdEncoding.EncodeToString([]byte(addr.Addr)))
208 }
209 sort.Strings(addrs)
210 // " " should not appear in base64 encoded strings.
211 return endpointMapKey(strings.Join(addrs, " "))
212}
213
214// Get returns the value for the address in the map, if present.
215func (em *EndpointMap[T]) Get(e Endpoint) (value T, ok bool) {

Callers 3

GetMethod · 0.85
SetMethod · 0.85
DeleteMethod · 0.85

Calls 2

endpointMapKeyTypeAlias · 0.85
JoinMethod · 0.80

Tested by

no test coverage detected