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

Method setCacheForEntity

workers/cache/cache.go:65–90  ·  view source on GitHub ↗
(entityGetter params.EntityGetter, pools []params.Pool, scaleSets []params.ScaleSet)

Source from the content-addressed store, hash-verified

63}
64
65func (w *Worker) setCacheForEntity(entityGetter params.EntityGetter, pools []params.Pool, scaleSets []params.ScaleSet) error {
66 entity, err := entityGetter.GetEntity()
67 if err != nil {
68 return fmt.Errorf("getting entity: %w", err)
69 }
70 cache.SetEntity(entity)
71 var entityPools []params.Pool
72 var entityScaleSets []params.ScaleSet
73
74 for _, pool := range pools {
75 if pool.BelongsTo(entity) {
76 entityPools = append(entityPools, pool)
77 }
78 }
79
80 for _, scaleSet := range scaleSets {
81 if scaleSet.BelongsTo(entity) {
82 entityScaleSets = append(entityScaleSets, scaleSet)
83 }
84 }
85
86 cache.ReplaceEntityPools(entity.ID, entityPools)
87 cache.ReplaceEntityScaleSets(entity.ID, entityScaleSets)
88
89 return nil
90}
91
92func (w *Worker) loadAllEntities() error {
93 endpoints, err := w.store.ListGiteaEndpoints(w.ctx)

Callers 1

loadAllEntitiesMethod · 0.95

Calls 5

SetEntityFunction · 0.92
ReplaceEntityPoolsFunction · 0.92
ReplaceEntityScaleSetsFunction · 0.92
GetEntityMethod · 0.65
BelongsToMethod · 0.45

Tested by

no test coverage detected