(entityID string, scaleSets []params.ScaleSet)
| 195 | } |
| 196 | |
| 197 | func (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 | |
| 226 | func (e *EntityCache) DeleteEntity(entityID string) { |
| 227 | e.mux.Lock() |
no test coverage detected