bucketstore

package
v0.0.0-...-d3cbdd1 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2022 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNoSuchBucket = errors.New("bucket does not exist. Use CreateWaitForBucket instead")

ErrNoSuchBucket is when a Bucket was requested that does not exist. Use CreateWaitForBucket to create a bucket if it does not exist.

Functions

This section is empty.

Types

type BucketStore

type BucketStore struct {
	Buckets   map[string]*limiter.DurationLimiter
	BucketsMu sync.RWMutex
}

BucketStore is used for managing various limiters.

func NewBucketStore

func NewBucketStore() (bs *BucketStore)

NewBucketStore creates a new Buckets map to store different limits.

func (*BucketStore) CreateBucket

func (bs *BucketStore) CreateBucket(name string, limit int32, duration time.Duration) *limiter.DurationLimiter

CreateBucket will create a new bucket or overwrite.

func (*BucketStore) CreateWaitForBucket

func (bs *BucketStore) CreateWaitForBucket(name string, limit int32, duration time.Duration) (err error)

CreateWaitForBucket will create a bucket if it does not exist and then will wait for it.

func (*BucketStore) ResetBucket

func (bs *BucketStore) ResetBucket(name string) bool

ResetBucket resets the bucket.

func (*BucketStore) WaitForBucket

func (bs *BucketStore) WaitForBucket(name string) (err error)

WaitForBucket will wait for a bucket to be ready.

Jump to

Keyboard shortcuts

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