| 321 | } |
| 322 | |
| 323 | func (t *App) generatorRingReader() (ring.PartitionRingReader, error) { |
| 324 | if IsSingleBinary(t.cfg.Target) { |
| 325 | return nil, nil |
| 326 | } |
| 327 | |
| 328 | switch t.cfg.Generator.RingMode { |
| 329 | case generator.RingModePartition: |
| 330 | if t.partitionRing == nil { |
| 331 | return nil, errors.New("metrics-generator ring mode is partition but partition ring is not initialized") |
| 332 | } |
| 333 | return t.partitionRing, nil |
| 334 | case generator.RingModeGenerator: |
| 335 | if t.generatorRingWatcher == nil { |
| 336 | return nil, errors.New("metrics-generator ring mode is generator but generator ring watcher is not initialized") |
| 337 | } |
| 338 | return t.generatorRingWatcher, nil |
| 339 | default: |
| 340 | return nil, fmt.Errorf( |
| 341 | "invalid metrics-generator ring mode %q, must be one of: %q, %q", |
| 342 | t.cfg.Generator.RingMode, |
| 343 | generator.RingModePartition, |
| 344 | generator.RingModeGenerator, |
| 345 | ) |
| 346 | } |
| 347 | } |
| 348 | |
| 349 | func (t *App) initGeneratorNoLocalBlocks() (services.Service, error) { |
| 350 | t.cfg.Generator.RingMode = generator.RingModeGenerator |