store

package
v0.8.20 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const LockTimeout = 350 * time.Millisecond

Variables

This section is empty.

Functions

This section is empty.

Types

type OnDeleteFn added in v0.8.20

type OnDeleteFn[T any, U protoMessage[T]] func(nats.KeyValueEntry, U) error

type OnUpdateFn added in v0.8.20

type OnUpdateFn[T any, U protoMessage[T]] func(U) (U, error)

type Store

type Store[T any, U protoMessage[T]] struct {
	OnUpdate OnUpdateFn[T, U]
	OnDelete OnDeleteFn[T, U]
	// contains filtered or unexported fields
}

func New

func New[T any, U protoMessage[T]](logger *zap.Logger, js nats.JetStreamContext, bucket string, opts ...StoreOption[T, U]) (*Store[T, U], error)

func NewWithLocks added in v0.8.20

func NewWithLocks[T any, U protoMessage[T]](logger *zap.Logger, js nats.JetStreamContext, bucket string, l *locks.Locks, opts ...StoreOption[T, U]) (*Store[T, U], error)

func (*Store[T, U]) ComputeUpdate

func (s *Store[T, U]) ComputeUpdate(key string, load bool, fn func(key string, existing U) (U, error)) error

func (*Store[T, U]) Delete

func (s *Store[T, U]) Delete(key string) error

func (*Store[T, U]) Get

func (s *Store[T, U]) Get(key string) (U, bool)

Get data from local data

func (*Store[T, U]) GetBucket added in v0.8.14

func (s *Store[T, U]) GetBucket() string

func (*Store[T, U]) GetOrLoad

func (s *Store[T, U]) GetOrLoad(key string) (U, error)

func (*Store[T, U]) Keys

func (s *Store[T, U]) Keys(prefix string) ([]string, error)

func (*Store[T, U]) List added in v0.8.20

func (s *Store[T, U]) List() ([]U, error)

func (*Store[T, U]) Load

func (s *Store[T, U]) Load(key string) (U, error)

Load data from kv store (this will add/update any existing local data entry) No record will be returned as nil and not stored

func (*Store[T, U]) Put

func (s *Store[T, U]) Put(key string, msg U) error

Put upload the message to kv and local

func (*Store[T, U]) Start

func (s *Store[T, U]) Start(ctx context.Context) error

type StoreOption added in v0.8.20

type StoreOption[T any, U protoMessage[T]] func(s *Store[T, U]) error

Jump to

Keyboard shortcuts

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