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)
| 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. |
| 183 | func (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. |
no test coverage detected