balance

package
v1.0.0-beta.150 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2024 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 Map

type Map map[string]float64

Represents a point in time balance of grants

func (Map) Balance

func (g Map) Balance() float64

returns the combined balance of all grants

func (Map) Burn

func (g Map) Burn(grantID string, amount float64)

func (Map) Copy

func (g Map) Copy() Map

func (Map) ExactlyForGrants

func (g Map) ExactlyForGrants(grants []grant.Grant) bool

Whether the contents of the Map exactly matches the list of provided grants. Return false if it has additional grants or if it misses any grants

func (Map) OverrideWith

func (g Map) OverrideWith(gbm Map)

func (Map) Set

func (g Map) Set(grantID string, amount float64)

type NoSavedBalanceForOwnerError

type NoSavedBalanceForOwnerError struct {
	Owner grant.NamespacedOwner
	Time  time.Time
}

No balance has been saved since start of measurement for the owner

func (NoSavedBalanceForOwnerError) Error

type Snapshot

type Snapshot struct {
	Balances Map
	Overage  float64
	At       time.Time
}

func (Snapshot) Balance

func (g Snapshot) Balance() float64

type SnapshotRepo

type SnapshotRepo interface {
	InvalidateAfter(ctx context.Context, owner grant.NamespacedOwner, at time.Time) error
	GetLatestValidAt(ctx context.Context, owner grant.NamespacedOwner, at time.Time) (Snapshot, error)
	Save(ctx context.Context, owner grant.NamespacedOwner, balances []Snapshot) error

	entutils.TxCreator
	entutils.TxUser[SnapshotRepo]
}

Jump to

Keyboard shortcuts

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