MCPcopy Create free account
hub / github.com/cloudbase/garm / Start

Method Start

workers/entity/controller.go:132–163  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

130}
131
132func (c *Controller) Start() error {
133 c.mux.Lock()
134 defer c.mux.Unlock()
135
136 if c.running {
137 return nil
138 }
139 c.quit = nil
140
141 c.loadAllEnterprises()
142 c.loadAllOrganizations()
143 c.loadAllRepositories()
144
145 consumer, err := watcher.RegisterConsumer(
146 c.ctx, c.consumerID,
147 composeControllerWatcherFilters(),
148 )
149 if err != nil {
150 return fmt.Errorf("failed to create consumer for entity controller: %w", err)
151 }
152
153 c.consumer = consumer
154 c.running = true
155 c.quit = make(chan struct{})
156 c.eventQueue = workersCommon.NewUnboundedChan[dbCommon.ChangePayload](c.ctx, c.quit)
157
158 go c.loop()
159 go c.eventQueue.Process(c.handleWatcherEvent)
160 go workersCommon.RetryLoop(c.ctx, c.quit, retryLoopInterval, c.retryFailedWorkers)
161
162 return nil
163}
164
165func (c *Controller) Stop() error {
166 slog.DebugContext(c.ctx, "stopping entity controller", "entity", c.consumerID)

Callers 2

mainFunction · 0.95
StartMethod · 0.95

Calls 9

loadAllEnterprisesMethod · 0.95
loadAllOrganizationsMethod · 0.95
loadAllRepositoriesMethod · 0.95
loopMethod · 0.95
RegisterConsumerFunction · 0.92
ProcessMethod · 0.80
LockMethod · 0.65
UnlockMethod · 0.65

Tested by

no test coverage detected