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

Method publish

enterprise/coderd/usage/publisher.go:183–196  ·  view source on GitHub ↗

publish publishes usage events to Tallyman in a loop until there is an error (or any rejection) or there are no more events to publish.

(ctx context.Context, deploymentID uuid.UUID)

Source from the content-addressed store, hash-verified

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.
183func (p *tallymanPublisher) publish(ctx context.Context, deploymentID uuid.UUID) error {
184 for {
185 publishCtx, publishCtxCancel := context.WithTimeout(ctx, tallymanPublishTimeout)
186 accepted, err := p.publishOnce(publishCtx, deploymentID)
187 publishCtxCancel()
188 if err != nil {
189 return xerrors.Errorf("publish usage events to tallyman: %w", err)
190 }
191 if accepted < tallymanPublishBatchSize {
192 // We published less than the batch size, so we're done.
193 return nil
194 }
195 }
196}
197
198// publishOnce publishes up to tallymanPublishBatchSize usage events to
199// tallyman. It returns the number of successfully published events.

Callers 1

publishLoopMethod · 0.95

Calls 2

publishOnceMethod · 0.95
ErrorfMethod · 0.45

Tested by

no test coverage detected