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

Method Start

workers/cache/cache.go:221–293  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

219}
220
221func (w *Worker) Start() error {
222 slog.DebugContext(w.ctx, "starting cache worker")
223 w.mux.Lock()
224 defer w.mux.Unlock()
225
226 if w.running {
227 return nil
228 }
229
230 g, _ := errgroup.WithContext(w.ctx)
231
232 g.Go(func() error {
233 ctrlInfo, err := w.store.ControllerInfo()
234 if err != nil {
235 return fmt.Errorf("failed to get controller info: %w", err)
236 }
237 // CachedGARMAgentTools is now populated by the database layer during conversion
238 cache.SetControllerCache(ctrlInfo)
239 return nil
240 })
241
242 g.Go(func() error {
243 if err := w.loadAllGithubCredentials(); err != nil {
244 return fmt.Errorf("loading all github credentials: %w", err)
245 }
246 return nil
247 })
248
249 g.Go(func() error {
250 if err := w.loadAllGiteaCredentials(); err != nil {
251 return fmt.Errorf("loading all gitea credentials: %w", err)
252 }
253 return nil
254 })
255
256 g.Go(func() error {
257 if err := w.loadAllEntities(); err != nil {
258 return fmt.Errorf("loading all entities: %w", err)
259 }
260 return nil
261 })
262
263 g.Go(func() error {
264 if err := w.loadAllInstances(); err != nil {
265 return fmt.Errorf("loading all instances: %w", err)
266 }
267 return nil
268 })
269
270 if err := w.waitForErrorGroupOrContextCancelled(g); err != nil {
271 return fmt.Errorf("waiting for error group: %w", err)
272 }
273
274 consumer, err := watcher.RegisterConsumer(
275 w.ctx, w.consumerID,
276 watcher.WithAll())
277 if err != nil {
278 return fmt.Errorf("registering consumer: %w", err)

Callers 1

mainFunction · 0.95

Calls 15

loadAllEntitiesMethod · 0.95
loadAllInstancesMethod · 0.95
loopMethod · 0.95
rateLimitLoopMethod · 0.95
SetControllerCacheFunction · 0.92
RegisterConsumerFunction · 0.92
WithAllFunction · 0.92
newGARMToolsSyncFunction · 0.85
LockMethod · 0.65

Tested by

no test coverage detected