Documentation
¶
Overview ¶
Package cost computes actual and list-price equivalent USD costs for request log rows.
Index ¶
- type Deps
- type EquivalentSource
- type Mode
- type Pricer
- func (p *Pricer) Equivalent(provider, model string) (prices.Price, bool)
- func (p *Pricer) Mode(provider string) (Mode, *float64)
- func (p *Pricer) Price(row bifrost.Log) store.RequestCost
- func (p *Pricer) Refresh(ctx context.Context) error
- func (p *Pricer) SetEquivalentSource(m Mode, s EquivalentSource)
- func (p *Pricer) SetSource(m Mode, s Source)
- type Source
- type State
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Deps ¶
type Deps struct {
Providers func(ctx context.Context) ([]store.Provider, error)
Billings func(ctx context.Context) ([]store.Billing, error)
Overrides func(ctx context.Context) ([]store.PriceOverride, error)
Catalog func() *prices.Catalog
Since time.Time
}
Deps supplies the read dependencies of a Pricer.
type EquivalentSource ¶ added in v0.10.0
EquivalentSource supplies a provider model's equivalent list price. ok=false falls back to the catalogue.
type Pricer ¶
type Pricer struct {
// contains filtered or unexported fields
}
Pricer turns engine log rows into store.RequestCost records without locks or I/O on the hot path.
func (*Pricer) Equivalent ¶
Equivalent resolves the list-price rates for a public provider and model, applying overrides, mode equivalent sources, and builtin type lookup.
func (*Pricer) Mode ¶
Mode returns the effective billing mode and optional monthly fee for provider.
func (*Pricer) Price ¶
func (p *Pricer) Price(row bifrost.Log) store.RequestCost
Price computes the actual and equivalent USD costs and states for a terminal engine log row.
func (*Pricer) Refresh ¶
Refresh reloads providers, billings, and price overrides and swaps them in atomically.
func (*Pricer) SetEquivalentSource ¶ added in v0.10.0
func (p *Pricer) SetEquivalentSource(m Mode, s EquivalentSource)
SetEquivalentSource registers or clears (when s is nil) a custom EquivalentSource for billing mode m.