Documentation
¶
Overview ¶
Package metering writes per-send ledger rows and exposes a query for the billing surface. Rows land in the `meter` collection synchronously (one INSERT per send); the optional rollup goroutine sweeps them daily into S3 prefixed by tenant.
Two cost numbers per row:
vendor_cost_micros — what the provider charged Hanzo (Plivo, Twilio, …) retail_price_micros — what Hanzo charges the tenant
The markup factor lives in the catalog, not here — metering only persists the snapshot the caller passes in.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ProviderRoll ¶
type ProviderRoll struct {
Units int `json:"units"`
VendorMicros int64 `json:"vendor_cost_micros"`
RetailMicros int64 `json:"retail_price_micros"`
}
ProviderRoll is the per-(provider,channel) breakdown.
type Record ¶
type Record struct {
TenantSlug string
Event string
Provider string
Channel types.Channel
Units int
VendorCostMicros int64
RetailPriceMicros int64
MessageID string
}
Record is the input shape callers pass to Write — a flat, pre-priced row ready for insertion.
type Summary ¶
type Summary struct {
TenantSlug string `json:"tenant_slug"`
TotalUnits int `json:"total_units"`
TotalVendorMicros int64 `json:"total_vendor_cost_micros"`
TotalRetailMicros int64 `json:"total_retail_price_micros"`
ByProviderChannel map[string]ProviderRoll `json:"by_provider_channel"`
}
Summary aggregates meter rows for one tenant in a time window. Used by GET /v1/notify/metering. The from/to params are ISO-8601 strings; empty means open-ended.