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

Method streamJanitorLoop

coderd/x/chatd/chatd.go:4752–4763  ·  view source on GitHub ↗

streamJanitorLoop periodically reaps idle chat stream states whose grace period has expired. It is the backstop for the grace-window early-return in cleanupStreamIfIdle; without it, a subscriber that detaches inside grace (the common enterprise relay-drain case, relayDrainTimeout = 200ms vs. 5s grac

(ctx context.Context)

Source from the content-addressed store, hash-verified

4750// detaches inside grace (the common enterprise relay-drain case,
4751// relayDrainTimeout = 200ms vs. 5s grace) pins the state forever.
4752func (p *Server) streamJanitorLoop(ctx context.Context) {
4753 ticker := p.clock.NewTicker(streamJanitorInterval, "chatd", "stream-janitor")
4754 defer ticker.Stop()
4755 for {
4756 select {
4757 case <-ctx.Done():
4758 return
4759 case <-ticker.C:
4760 p.safeSweepIdleStreams(ctx)
4761 }
4762 }
4763}
4764
4765// safeSweepIdleStreams runs sweepIdleStreams under a panic recovery
4766// so an unexpected panic in the sweep cannot kill the janitor

Callers 1

NewFunction · 0.95

Calls 3

safeSweepIdleStreamsMethod · 0.95
StopMethod · 0.65
DoneMethod · 0.45

Tested by

no test coverage detected