MCPcopy Create free account
hub / github.com/coder/coder / publishLoop

Method publishLoop

enterprise/coderd/usage/publisher.go:158–179  ·  view source on GitHub ↗
(ctx context.Context, deploymentID uuid.UUID)

Source from the content-addressed store, hash-verified

156}
157
158func (p *tallymanPublisher) publishLoop(ctx context.Context, deploymentID uuid.UUID) {
159 defer close(p.done)
160
161 // Start the ticker with the initial delay. We will reset it to the interval
162 // after the first tick.
163 ticker := p.clock.NewTicker(p.initialDelay)
164 defer ticker.Stop()
165
166 for {
167 select {
168 case <-ctx.Done():
169 return
170 case <-ticker.C:
171 }
172
173 err := p.publish(ctx, deploymentID)
174 if err != nil {
175 p.log.Warn(ctx, "publish usage events to tallyman", slog.Error(err))
176 }
177 ticker.Reset(tallymanPublishInterval)
178 }
179}
180
181// publish publishes usage events to Tallyman in a loop until there is an error
182// (or any rejection) or there are no more events to publish.

Callers 1

StartMethod · 0.95

Calls 5

publishMethod · 0.95
StopMethod · 0.65
ResetMethod · 0.65
DoneMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected