meter

package
v1.9.0 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type QueryOpts

type QueryOpts struct {
	FeatureKey string
	Start      time.Time
	End        time.Time
	Limit      int
	Offset     int
}

type Store

type Store interface {
	IngestBatch(ctx context.Context, events []*UsageEvent) error
	Aggregate(ctx context.Context, tenantID, appID, featureKey string, period plan.Period) (int64, error)
	AggregateMulti(ctx context.Context, tenantID, appID string, featureKeys []string, period plan.Period) (map[string]int64, error)
	Query(ctx context.Context, tenantID, appID string, opts QueryOpts) ([]*UsageEvent, error)
	Purge(ctx context.Context, before time.Time) (int64, error)
}

type UsageEvent

type UsageEvent struct {
	ID             id.UsageEventID   `json:"id"`
	TenantID       string            `json:"tenant_id"`
	AppID          string            `json:"app_id"`
	FeatureKey     string            `json:"feature_key"`
	Quantity       int64             `json:"quantity"`
	Timestamp      time.Time         `json:"timestamp"`
	IdempotencyKey string            `json:"idempotency_key,omitempty"`
	Metadata       map[string]string `json:"metadata,omitempty"`
}

Jump to

Keyboard shortcuts

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