// CategorizeEndpoints returns: // // - The service's usable Cluster-traffic-policy endpoints (taking topology into account, if // relevant). This will be nil if the service does not ever use Cluster traffic policy. // // - The service's usable Local-traffic-policy endpoints (including terminating endpoints, if // relevant). This will be nil if the service does not ever use Local traffic policy. // // - The combined list of all endpoints reachable from this node (which is the union of the // previous two lists, but in the case where it is identical to one or the other, we avoid // allocating a separate list). // // - An indication of whether the service has any endpoints reachable from anywhere in the // cluster. (This may be true even if allReachableEndpoints is empty.) func CategorizeEndpoints(endpoints []Endpoint, svcInfo ServicePort, nodeLabels map[string]string) (clusterEndpoints, localEndpoints, allReachableEndpoints []Endpoint, hasAnyEndpoints bool) { … } // canUseTopology returns true if topology aware routing is enabled and properly // configured in this cluster. That is, it checks that: // - The TopologyAwareHints or ServiceTrafficDistribution feature is enabled. // - If ServiceTrafficDistribution feature gate is not enabled, then the // hintsAnnotation should represent an enabled value. // - The node's labels include "topology.kubernetes.io/zone". // - All of the endpoints for this Service have a topology hint. // - At least one endpoint for this Service is hinted for this node's zone. func canUseTopology(endpoints []Endpoint, svcInfo ServicePort, nodeLabels map[string]string) bool { … } // availableForTopology checks if this endpoint is available for use on this node, given // topology constraints. (It assumes that canUseTopology() returned true.) func availableForTopology(endpoint Endpoint, nodeLabels map[string]string) bool { … } // filterEndpoints filters endpoints according to predicate func filterEndpoints(endpoints []Endpoint, predicate func(Endpoint) bool) []Endpoint { … }