store

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = errors.New("store: not found")

Functions

This section is empty.

Types

type OnDeleteFn added in v0.8.20

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

type OnNotFoundFn added in v0.8.21

type OnNotFoundFn[T any, U protoMessage[T]] func(ctx context.Context, key string) (U, error)

type OnUpdateFn added in v0.8.20

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

type Option added in v0.8.21

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

type Store

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

func New

func New[T any, U protoMessage[T]](ctx context.Context, logger *zap.Logger, js *events.JSWrapper, bucket string, opts ...Option[T, U]) (*Store[T, U], error)

func NewWithLocks added in v0.8.20

func NewWithLocks[T any, U protoMessage[T]](ctx context.Context, logger *zap.Logger, js *events.JSWrapper, bucket string, l *locks.Locks, opts ...Option[T, U]) (*Store[T, U], error)

func (*Store[T, U]) ComputeUpdate

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

func (*Store[T, U]) Delete

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

func (*Store[T, U]) Get

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

Get copy of data from local data

func (*Store[T, U]) GetOrLoad

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

func (*Store[T, U]) Keys

func (s *Store[T, U]) Keys(ctx context.Context, 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(ctx context.Context, key string) (U, error)

Load data from kv store (this will add/update any existing local data entry) If no key is found, the original nats error is returned.

func (*Store[T, U]) Put

func (s *Store[T, U]) Put(ctx context.Context, 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

Jump to

Keyboard shortcuts

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