store

package
v0.1.18 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultDBPath

func DefaultDBPath() (string, error)

DefaultDBPath returns the default path for the usage database.

func Today

func Today() string

Today returns today's date in YYYY-MM-DD format.

Types

type UsageRecord

type UsageRecord struct {
	Provider            string `json:"provider"`
	Model               string `json:"model"`
	Date                string `json:"date"`
	Requests            int64  `json:"requests"`
	SuccessRequests     int64  `json:"success_requests"`
	ErrorRequests       int64  `json:"error_requests"`
	InputTokens         int64  `json:"input_tokens"`
	OutputTokens        int64  `json:"output_tokens"`
	CacheCreationTokens int64  `json:"cache_creation_tokens"`
	CacheReadTokens     int64  `json:"cache_read_tokens"`
	TotalTokens         int64  `json:"total_tokens"`
}

UsageRecord represents a single usage data point.

type UsageStore

type UsageStore struct {
	// contains filtered or unexported fields
}

UsageStore provides async SQLite storage for usage statistics.

func NewUsageStore

func NewUsageStore(dbPath string) (*UsageStore, error)

NewUsageStore creates a new UsageStore with the database at the given path.

func (*UsageStore) AsyncRecord

func (s *UsageStore) AsyncRecord(record UsageRecord)

AsyncRecord queues a usage record for async writing.

func (*UsageStore) Close

func (s *UsageStore) Close() error

Close stops the processing loop and closes the database.

func (*UsageStore) QueryUsage

func (s *UsageStore) QueryUsage(provider, model, startDate, endDate string) ([]UsageRecord, error)

QueryUsage retrieves usage records with optional filters.

Jump to

Keyboard shortcuts

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