consumption

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2025 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Consumption

type Consumption struct {
	TeaID uuid.UUID
	Time  time.Time
}

Consumption represents a single tea consumption event.

type MemoryStore

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

MemoryStore is a simple in-memory implementation of Store. It is process-local and not persisted across restarts.

func NewMemoryStore

func NewMemoryStore(retention time.Duration) *MemoryStore

func (*MemoryStore) Recent

func (m *MemoryStore) Recent(_ context.Context, userID uuid.UUID, since time.Time) ([]Consumption, error)

func (*MemoryStore) Record

func (m *MemoryStore) Record(_ context.Context, userID uuid.UUID, teaID uuid.UUID, ts time.Time) error

type Store

type Store interface {
	Record(ctx context.Context, userID uuid.UUID, teaID uuid.UUID, ts time.Time) error
	// Recent returns consumptions since the provided time (inclusive) for the given user.
	Recent(ctx context.Context, userID uuid.UUID, since time.Time) ([]Consumption, error)
}

Store defines operations for recording and querying recent tea consumption.

Jump to

Keyboard shortcuts

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