(entityID string, pools []params.Pool)
| 163 | } |
| 164 | |
| 165 | func (e *EntityCache) ReplaceEntityPools(entityID string, pools []params.Pool) { |
| 166 | e.mux.Lock() |
| 167 | defer e.mux.Unlock() |
| 168 | |
| 169 | cache, ok := e.entities[entityID] |
| 170 | if !ok { |
| 171 | return |
| 172 | } |
| 173 | |
| 174 | // Remove all old pools from the global map. |
| 175 | for oldPoolID := range cache.Pools { |
| 176 | delete(e.pools, oldPoolID) |
| 177 | } |
| 178 | |
| 179 | // Add the new set. |
| 180 | poolsByID := map[string]struct{}{} |
| 181 | for _, pool := range pools { |
| 182 | poolEntity, err := pool.GetEntity() |
| 183 | if err != nil || poolEntity.ID != entityID { |
| 184 | continue |
| 185 | } |
| 186 | e.pools[pool.ID] = pool |
| 187 | // map the pool ID to the entity. We have to do an extra lookup |
| 188 | // in the pools map, but it makes it easier to lookup just pools later |
| 189 | // when we want to find the pool for the instance. |
| 190 | poolsByID[pool.ID] = struct{}{} |
| 191 | } |
| 192 | |
| 193 | cache.Pools = poolsByID |
| 194 | e.entities[entityID] = cache |
| 195 | } |
| 196 | |
| 197 | func (e *EntityCache) ReplaceEntityScaleSets(entityID string, scaleSets []params.ScaleSet) { |
| 198 | e.mux.Lock() |
no test coverage detected