markups

package
v0.2.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 23, 2026 License: MIT Imports: 7 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
var ErrCustomerMarkupsUnavailable = errors.New("pricing.user_path_markups requires a GoModel Pro license with the billing entitlement")

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

func (s *Service) BillCacheHits() bool

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) Close

func (t *UsageTap) Close() error

func (*UsageTap) Config

func (t *UsageTap) Config() usage.Config

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) StampBilling added in v0.2.6

func (t *UsageTap) StampBilling(entry *usage.UsageEntry)

StampBilling implements usage.BillingStamper.

func (*UsageTap) Write

func (t *UsageTap) Write(entry *usage.UsageEntry)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL