shareds

package
v1.2.85 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2024 License: Apache-2.0 Imports: 12 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrLockTimeout = fmt.Errorf("fns: shared lockers lock timeout failed")
)

Functions

func RegisterLocalStoreBuild

func RegisterLocalStoreBuild(build LocalStoreBuild)

Types

type DefaultLocalSharedStoreConfig

type DefaultLocalSharedStoreConfig struct {
	ShrinkDuration time.Duration `json:"shrinkDuration"`
}

type Entry added in v1.2.83

type Entry struct {
	Value    any
	Deadline time.Time
	// contains filtered or unexported fields
}

func (*Entry) Expired added in v1.2.83

func (entry *Entry) Expired() bool

type LocalSharedConfig

type LocalSharedConfig struct {
	Store json.RawMessage `json:"store,omitempty" yaml:"store,omitempty"`
}

type LocalStoreBuild

type LocalStoreBuild func(log logs.Logger, config configures.Config) (Store, error)

type Locker

type Locker interface {
	Lock(ctx context.Context) (err error)
	Unlock(ctx context.Context) (err error)
}

type Lockers

type Lockers interface {
	Acquire(ctx context.Context, key []byte, ttl time.Duration) (locker Locker, err error)
	Close()
}

func LocalLockers

func LocalLockers() Lockers

type LockersBuilder added in v1.2.0

type LockersBuilder interface {
	Build(ctx context.Context, config configures.Config) (lockers Lockers, err error)
}

type Options

type Options struct {
	Log    logs.Logger
	Config configures.Config
}

type Shared

type Shared interface {
	Construct(options Options) (err error)
	Lockers() (lockers Lockers)
	Store() (store Store)
	Close()
}

func Local

func Local(log logs.Logger, config LocalSharedConfig) (v Shared, err error)

type Store

type Store interface {
	Get(ctx context.Context, key []byte) (value []byte, has bool, err error)
	Set(ctx context.Context, key []byte, value []byte) (err error)
	SetWithTTL(ctx context.Context, key []byte, value []byte, ttl time.Duration) (err error)
	Remove(ctx context.Context, key []byte) (err error)
	Incr(ctx context.Context, key []byte, delta int64) (v int64, err error)
	Expire(ctx context.Context, key []byte, ttl time.Duration) (err error)
	Close()
}

type StoreBuilder added in v1.2.0

type StoreBuilder interface {
	Build(ctx context.Context, config configures.Config) (store Store, err error)
}

Jump to

Keyboard shortcuts

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