MCPcopy Create free account
hub / github.com/cortexproject/cortex / NewManager

Function NewManager

pkg/util/services/manager.go:48–73  ·  view source on GitHub ↗

NewManager creates new service manager. It needs at least one service, and all services must be in New state.

(services ...Service)

Source from the content-addressed store, hash-verified

46
47// NewManager creates new service manager. It needs at least one service, and all services must be in New state.
48func NewManager(services ...Service) (*Manager, error) {
49 if len(services) == 0 {
50 return nil, errors.New("no services")
51 }
52
53 m := &Manager{
54 services: services,
55 byState: map[State][]Service{},
56 healthyCh: make(chan struct{}),
57 stoppedCh: make(chan struct{}),
58 }
59
60 for _, s := range services {
61 st := s.State()
62 if st != New {
63 return nil, fmt.Errorf("unexpected service state: %v", st)
64 }
65
66 m.byState[st] = append(m.byState[st], s)
67 }
68
69 for _, s := range services {
70 s.AddListener(newManagerServiceListener(m, s))
71 }
72 return m, nil
73}
74
75// StartAsync initiates service startup on all the services being managed.
76// It is only valid to call this method if all of the services are New.

Callers 15

NewSchedulerFunction · 0.92
startingMethod · 0.92
NewFunction · 0.92
NewFunction · 0.92
startingMethod · 0.92
RunMethod · 0.92
startingMethod · 0.92
startingMethod · 0.92
NewParquetQueryableFunction · 0.92
NewBlocksStoreQueryableFunction · 0.92

Calls 3

StateMethod · 0.65
AddListenerMethod · 0.65