quota

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2022 License: GPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Tracker

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

Tracker keeps track of the used quota of API keys and updates it in batches in order to reduce database traffic

func NewTracker

func NewTracker(repo apikey.Repository) *Tracker

NewTracker creates a new API key quota tracker

func (*Tracker) Accumulate

func (tracker *Tracker) Accumulate(key *apikey.Key)

Accumulate accumulates the used API quota of a specific API key by 1

func (*Tracker) Flush

func (tracker *Tracker) Flush() (int, error)

Flush sends all changed API quota to the database and resets the counters

func (*Tracker) Get

func (tracker *Tracker) Get(key *apikey.Key) int64

Get returns the current used API quota of a specific API key

Jump to

Keyboard shortcuts

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