storage

package
v0.0.0-...-da01245 Latest Latest
Warning

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

Go to latest
Published: May 5, 2022 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// BucketHooks name of the hooks bucket
	BucketHooks = []byte("hooks")
	// BucketReqs name of the requests bucket
	BucketReqs = []byte("requests")
	// BucketTTL name of the ttl bucket
	BucketTTL = []byte("ttl")
	// BucketCounters name of the counters bucket
	BucketCounters = []byte("counters")
)

Functions

This section is empty.

Types

type BoltDB

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

BoltDB is a wrapper over Bolt DB

func New

func New(path string) (*BoltDB, error)

New returns a wrapper over Bolt DB

func (*BoltDB) Close

func (b *BoltDB) Close() error

Close releases all database resources

func (*BoltDB) Count

func (b *BoltDB) Count(name []byte) (int, error)

Count returns number of keys in bucket

func (*BoltDB) Counters

func (b *BoltDB) Counters() (map[string]int, error)

Counters returns list of counters

func (*BoltDB) Expired

func (b *BoltDB) Expired(ttlName []byte, maxAge time.Duration) (keys [][]byte, err error)

Expired returns list of keys that have ttl older than maxAge

func (*BoltDB) Hook

func (b *BoltDB) Hook(name string) (*models.Hook, error)

Hook returns hook model by name

func (*BoltDB) PutHook

func (b *BoltDB) PutHook(hook *models.Hook) error

PutHook save hook model into storage

func (*BoltDB) PutRequest

func (b *BoltDB) PutRequest(hook string, req *models.Request) error

PutRequest save request model into storage

func (*BoltDB) RecentHooks

func (b *BoltDB) RecentHooks(max int) ([]*models.Hook, error)

RecentHooks returns recent public hooks

func (*BoltDB) Requests

func (b *BoltDB) Requests(hook string) ([]*models.Request, error)

Requests returns hook requests by hook name

func (*BoltDB) SweepHooks

func (b *BoltDB) SweepHooks(maxAge time.Duration) (err error)

SweepHooks performs a batch delete of all bucket items using the keys picked up from expired func

Jump to

Keyboard shortcuts

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