markups

package
v0.1.108 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2026 License: MIT Imports: 5 Imported by: 0

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

This section is empty.

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

New builds the markup service, validating each selector against the configured provider names.

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