serviceKeys returns a slice containing all keys present for services in the application's State.
()
| 256 | |
| 257 | // serviceKeys returns a slice containing all keys present for services in the application's State. |
| 258 | func (s *State) serviceKeys() []string { |
| 259 | // Pre-allocate with estimated capacity to reduce allocations |
| 260 | keys := make([]string, 0, 8) |
| 261 | s.dependencies.Range(func(key, _ any) bool { |
| 262 | keyStr, ok := key.(string) |
| 263 | if !ok { |
| 264 | return true |
| 265 | } |
| 266 | |
| 267 | if !strings.HasPrefix(keyStr, s.servicePrefix) { |
| 268 | return true // Continue iterating if key doesn't have service prefix |
| 269 | } |
| 270 | |
| 271 | keys = append(keys, keyStr) |
| 272 | return true |
| 273 | }) |
| 274 | |
| 275 | return keys |
| 276 | } |
| 277 | |
| 278 | // Services returns a map containing all services present in the State. |
| 279 | // The key is the hash of the service String() value and the value is the service itself. |