Documentation
¶
Index ¶
- func ComputeCostUSD(promptTokens, completionTokens int64, inputPerMTok, outputPerMTok float64) *float64
- func EncodeUsage(e usage.Event) ([]byte, error)
- func IngestPayload(ctx context.Context, sink UsageSink, prices PriceLookup, payload []byte) error
- func ProcessOnce(ctx context.Context, src OutboxSource, sink UsageSink, prices PriceLookup, ...) (int, error)
- func ProcessPlatformEventsOnce(ctx context.Context, src OutboxSource, pub EventPublisher, ...) (int, error)
- type EventPublisher
- type OutboxRow
- type OutboxSource
- type PriceLookup
- type UsageEnqueuer
- type UsagePayload
- type UsageSink
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ComputeCostUSD ¶
func ComputeCostUSD(promptTokens, completionTokens int64, inputPerMTok, outputPerMTok float64) *float64
ComputeCostUSD returns USD cost from per-million-token prices, or nil if prices are missing or there is no token usage to price.
func IngestPayload ¶ added in v0.3.0
IngestPayload decodes one usage outbox payload and writes usage_events immediately (no worker drain). Used for spoke HTTP ingest and optional sync postgres backends.
func ProcessOnce ¶
func ProcessOnce(ctx context.Context, src OutboxSource, sink UsageSink, prices PriceLookup, metrics ...*telemetry.WorkerMetrics) (int, error)
ProcessOnce claims pending outbox rows and writes usage_events. Optional metrics argument records worker counters when non-nil.
func ProcessPlatformEventsOnce ¶
func ProcessPlatformEventsOnce(ctx context.Context, src OutboxSource, pub EventPublisher, metrics ...*telemetry.WorkerMetrics) (int, error)
ProcessPlatformEventsOnce claims pending platform_event_outbox rows and publishes them.
Types ¶
type EventPublisher ¶
EventPublisher delivers a platform domain event to an external broker.
type OutboxSource ¶
type PriceLookup ¶
type UsageEnqueuer ¶
UsageEnqueuer is the gateway write-side port for usage_outbox.
type UsagePayload ¶
UsagePayload is an alias for the canonical usage.Event carried in the outbox.