NewTallymanPublisher creates a Publisher that publishes usage events to Coder's Tallyman service.
(ctx context.Context, log slog.Logger, db database.Store, keys map[string]ed25519.PublicKey, opts ...TallymanPublisherOption)
| 67 | // NewTallymanPublisher creates a Publisher that publishes usage events to |
| 68 | // Coder's Tallyman service. |
| 69 | func NewTallymanPublisher(ctx context.Context, log slog.Logger, db database.Store, keys map[string]ed25519.PublicKey, opts ...TallymanPublisherOption) Publisher { |
| 70 | ctx, cancel := context.WithCancel(ctx) |
| 71 | ctx = dbauthz.AsUsagePublisher(ctx) //nolint:gocritic // we intentionally want to be able to process usage events |
| 72 | |
| 73 | publisher := &tallymanPublisher{ |
| 74 | ctx: ctx, |
| 75 | ctxCancel: cancel, |
| 76 | log: log, |
| 77 | db: db, |
| 78 | licenseKeys: keys, |
| 79 | done: make(chan struct{}), |
| 80 | |
| 81 | ingestURL: tallymanIngestURLV1, |
| 82 | httpClient: http.DefaultClient, |
| 83 | clock: quartz.NewReal(), |
| 84 | } |
| 85 | for _, opt := range opts { |
| 86 | opt(publisher) |
| 87 | } |
| 88 | return publisher |
| 89 | } |
| 90 | |
| 91 | type TallymanPublisherOption func(*tallymanPublisher) |
| 92 |