MCPcopy Index your code
hub / github.com/coder/coder / acquireLoop

Method acquireLoop

coderd/x/chatd/chatd.go:4351–4384  ·  view source on GitHub ↗
(ctx context.Context)

Source from the content-addressed store, hash-verified

4349}
4350
4351func (p *Server) acquireLoop(ctx context.Context) {
4352 acquireTicker := p.clock.NewTicker(
4353 p.pendingChatAcquireInterval,
4354 "chatd",
4355 "acquire",
4356 )
4357 defer acquireTicker.Stop()
4358
4359 staleRecoveryInterval := p.inFlightChatStaleAfter / staleRecoveryIntervalDivisor
4360 staleTicker := p.clock.NewTicker(
4361 staleRecoveryInterval,
4362 "chatd",
4363 "stale-recovery",
4364 )
4365 defer staleTicker.Stop()
4366
4367 for {
4368 select {
4369 case <-ctx.Done():
4370 return
4371 case <-acquireTicker.C:
4372 p.processOnce(ctx)
4373 case <-p.wakeCh:
4374 p.processOnce(ctx)
4375 case <-staleTicker.C:
4376 p.recoverStaleChats(ctx)
4377 if debugSvc := p.existingDebugService(); debugSvc != nil {
4378 if _, err := debugSvc.FinalizeStale(ctx); err != nil {
4379 p.logger.Warn(ctx, "failed to finalize stale chat debug rows", slog.Error(err))
4380 }
4381 }
4382 }
4383 }
4384}
4385
4386// signalWake wakes the run loop so it calls processOnce immediately.
4387// Non-blocking: if a signal is already pending it is a no-op.

Callers 1

StartMethod · 0.95

Calls 7

processOnceMethod · 0.95
recoverStaleChatsMethod · 0.95
existingDebugServiceMethod · 0.95
FinalizeStaleMethod · 0.80
StopMethod · 0.65
DoneMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected