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

Function NewTallymanPublisher

enterprise/coderd/usage/publisher.go:69–89  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

67// NewTallymanPublisher creates a Publisher that publishes usage events to
68// Coder's Tallyman service.
69func 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
91type TallymanPublisherOption func(*tallymanPublisher)
92

Callers 7

TestIntegrationFunction · 0.92
TestPublisherClaimExpiryFunction · 0.92
ServerMethod · 0.92

Calls 1

AsUsagePublisherFunction · 0.92

Tested by 6

TestIntegrationFunction · 0.74
TestPublisherClaimExpiryFunction · 0.74