MCPcopy Create free account
hub / github.com/cloudbase/garm / ReplaceEntityScaleSets

Method ReplaceEntityScaleSets

cache/entity_cache.go:197–224  ·  view source on GitHub ↗
(entityID string, scaleSets []params.ScaleSet)

Source from the content-addressed store, hash-verified

195}
196
197func (e *EntityCache) ReplaceEntityScaleSets(entityID string, scaleSets []params.ScaleSet) {
198 e.mux.Lock()
199 defer e.mux.Unlock()
200
201 cache, ok := e.entities[entityID]
202 if !ok {
203 return
204 }
205
206 // Remove all old scale sets from the global map.
207 for oldScaleSetID := range cache.ScaleSets {
208 delete(e.scalesets, oldScaleSetID)
209 }
210
211 // Add the new set.
212 scaleSetsByID := map[uint]struct{}{}
213 for _, scaleSet := range scaleSets {
214 scaleSetEntity, err := scaleSet.GetEntity()
215 if err != nil || scaleSetEntity.ID != entityID {
216 continue
217 }
218 e.scalesets[scaleSet.ID] = scaleSet
219 scaleSetsByID[scaleSet.ID] = struct{}{}
220 }
221
222 cache.ScaleSets = scaleSetsByID
223 e.entities[entityID] = cache
224}
225
226func (e *EntityCache) DeleteEntity(entityID string) {
227 e.mux.Lock()

Callers 1

ReplaceEntityScaleSetsFunction · 0.80

Calls 3

LockMethod · 0.65
UnlockMethod · 0.65
GetEntityMethod · 0.65

Tested by

no test coverage detected