// NewCache returns a new Cache with the specified endpointsPerSlice. func NewCache(endpointsPerSlice int32) *Cache { … } type Cache … type EndpointPortCache … type EfficiencyInfo … // NewEndpointPortCache initializes and returns a new EndpointPortCache. func NewEndpointPortCache() *EndpointPortCache { … } // Set updates the EndpointPortCache to contain the provided EfficiencyInfo // for the provided PortMapKey. func (spc *EndpointPortCache) Set(pmKey endpointsliceutil.PortMapKey, eInfo EfficiencyInfo) { … } // numEndpoints returns the total number of endpoints represented by a // EndpointPortCache. func (spc *EndpointPortCache) numEndpoints() int { … } // UpdateEndpointPortCache updates a EndpointPortCache in the global cache for a // given Service and updates the corresponding metrics. // Parameters: // * endpointsNN refers to a NamespacedName representing the Endpoints resource. // * epCache refers to a EndpointPortCache for the specified Endpoints reosource. func (c *Cache) UpdateEndpointPortCache(endpointsNN types.NamespacedName, epCache *EndpointPortCache) { … } // DeleteEndpoints removes references to an Endpoints resource from the global // cache and updates the corresponding metrics. func (c *Cache) DeleteEndpoints(endpointsNN types.NamespacedName) { … } type metricsUpdate … // desiredAndActualSlices returns a metricsUpdate with the desired and actual // number of EndpointSlices given the current values in the cache. // Must be called holding lock. func (c *Cache) desiredAndActualSlices() metricsUpdate { … } // updateMetrics updates metrics with the values from this Cache. // Must be called holding lock. func (c *Cache) updateMetrics() { … } // numDesiredSlices calculates the number of EndpointSlices that would exist // with ideal endpoint distribution. func numDesiredSlices(numEndpoints, maxPerSlice int) int { … }