Documentation
¶
Overview ¶
Package markups stamps the billed cost onto usage entries: the provider cost plus the pricing.markups percentage of the most specific matching selector.
Index ¶
Constants ¶
This section is empty.
Variables ¶
ErrCustomerMarkupsUnavailable reports pricing.user_path_markups configured without the customer_markups capability. Startup fails rather than billing customers at the global rate.
Functions ¶
func NewUsageTap ¶
func NewUsageTap(inner usage.LoggerInterface, service *Service) usage.LoggerInterface
NewUsageTap wraps the logger, or returns it unchanged when there is no markup service.
Types ¶
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service resolves markups from config. It is immutable after New, so it is safe for concurrent use.
func New ¶
func New(cfg config.PricingConfig, catalog modelselectors.Catalog, customerMarkups bool) (*Service, error)
New builds the markup service, validating each selector against the configured provider names. customerMarkups reports whether the customer_markups capability is enabled; without it, configured pricing.user_path_markups fail with ErrCustomerMarkupsUnavailable.
func (*Service) Apply ¶
func (s *Service) Apply(entry *usage.UsageEntry)
Apply sets the entry's markup and billed cost. The provider cost fields are left untouched.
func (*Service) BillCacheHits ¶
BillCacheHits reports whether response-cache hits are billed.
type UsageTap ¶
type UsageTap struct {
// contains filtered or unexported fields
}
UsageTap decorates a usage logger so every recorded entry carries its billed cost. All modalities and response-cache hits funnel through Logger.Write, so one tap covers them all.
func (*UsageTap) SetLivePublisher ¶
func (t *UsageTap) SetLivePublisher(p usage.LiveEventPublisher)
SetLivePublisher forwards the dashboard publisher to the wrapped logger, so wrapping it never silences live usage events.
func (*UsageTap) Write ¶
func (t *UsageTap) Write(entry *usage.UsageEntry)