redisstore

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package redisstore registers a Redis-backed SpendStore. Import with a blank import to activate it:

import _ "github.com/arkonis-dev/ark/pkg/costs/redisstore"

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type RedisSpendStore

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

RedisSpendStore stores SpendEntry values in Redis sorted sets.

Storage layout:

ark:spend:<namespace>.<team>  → sorted set, score = unix ms, value = JSON SpendEntry
ark:spend:_all                → same entries, for cross-namespace queries

func New

func New(url string) (*RedisSpendStore, error)

New creates a RedisSpendStore from a Redis URL (redis://...).

func (*RedisSpendStore) Record

func (s *RedisSpendStore) Record(ctx context.Context, entry costs.SpendEntry) error

Record saves one SpendEntry into the namespace+team sorted set and the global set.

func (*RedisSpendStore) Rollup

func (s *RedisSpendStore) Rollup(
	ctx context.Context, scope costs.SpendScope, period costs.Period, since time.Time,
) ([]costs.RollupEntry, error)

Rollup returns spend grouped into period buckets for the given scope.

func (*RedisSpendStore) Total

func (s *RedisSpendStore) Total(ctx context.Context, scope costs.SpendScope, since time.Time) (float64, error)

Total returns the sum of CostUSD for a scope since the given time.

Jump to

Keyboard shortcuts

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