changing UpdateEndpointsMap to Update

changing UpdateEndpointsMap to be a function of the EndpointsMap object
This commit is contained in:
Jacob Tanenbaum
2019-04-29 15:28:47 -04:00
parent 5201cc994c
commit 9d4693a70f
6 changed files with 12 additions and 12 deletions

View File

@@ -197,18 +197,18 @@ type UpdateEndpointMapResult struct {
}
// UpdateEndpointsMap updates endpointsMap base on the given changes.
func UpdateEndpointsMap(endpointsMap EndpointsMap, changes *EndpointChangeTracker) (result UpdateEndpointMapResult) {
func (em EndpointsMap) Update(changes *EndpointChangeTracker) (result UpdateEndpointMapResult) {
result.StaleEndpoints = make([]ServiceEndpoint, 0)
result.StaleServiceNames = make([]ServicePortName, 0)
result.LastChangeTriggerTimes = make([]time.Time, 0)
endpointsMap.apply(
em.apply(
changes, &result.StaleEndpoints, &result.StaleServiceNames, &result.LastChangeTriggerTimes)
// TODO: If this will appear to be computationally expensive, consider
// computing this incrementally similarly to endpointsMap.
result.HCEndpointsLocalIPSize = make(map[types.NamespacedName]int)
localIPs := endpointsMap.getLocalEndpointIPs()
localIPs := em.getLocalEndpointIPs()
for nsn, ips := range localIPs {
result.HCEndpointsLocalIPSize[nsn] = len(ips)
}