state

package
v0.0.0-...-5849f30 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2021 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Type     string   `json:"type"`
	KVConfig KVConfig `json:"kvConfig,omitempty"`
}

Config defines the configuration for a state

type Counter

type Counter struct {
	sync.RWMutex
	Count int
}

Counter is a simple in memory counter

func (*Counter) Close

func (c *Counter) Close()

Close closes the counter (does nothing)

func (*Counter) Increment

func (c *Counter) Increment()

Increment increments the counter

func (*Counter) Init

func (c *Counter) Init() error

Init initialises the counter

func (*Counter) Window

func (c *Counter) Window() int

Window returns the current value and resets the counter

type KVConfig

type KVConfig struct {
	DbFileName string `json:"dbFileName"`
	BucketName string `json:"bucketName"`
}

KVConfig defines the configuration of a KeyValue store

type KVStore

type KVStore struct {
	DbFileName string
	BucketName string
	// contains filtered or unexported fields
}

KVStore provides a persistent KeyValue store

func (*KVStore) Close

func (k *KVStore) Close()

Close closes the KeyValue Store ensuring it is persisted to disk

func (*KVStore) Delete

func (k *KVStore) Delete(key []byte)

Delete deletes the given key

func (*KVStore) ForEach

func (k *KVStore) ForEach(function func(k, v []byte) error) error

ForEach executes the function for each key/value pair

func (*KVStore) Get

func (k *KVStore) Get(key []byte) []byte

Get retrieves the specified value

func (*KVStore) Init

func (k *KVStore) Init() error

Init initialises the KeyValue store

func (*KVStore) Set

func (k *KVStore) Set(key []byte, value []byte) error

Set sets a Key to the defined value

type State

type State interface {
	Init() error
	Close()
}

State is the interface for stateful storage backings for a rule

func Create

func Create(config Config) (State, error)

Create creates the stateful backing

Jump to

Keyboard shortcuts

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