store

package
v0.9.4 Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2024 License: Apache-2.0 Imports: 17 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

type OnDeleteFn[T any, U protoutils.ProtoMessageWithMerge[T]] func(s *Store[T, U], entry jetstream.KeyValueEntry, value U) error

type OnNotFoundFn

type OnNotFoundFn[T any, U protoutils.ProtoMessageWithMerge[T]] func(s *Store[T, U], ctx context.Context, key string) (U, error)

type OnUpdateFn

type OnUpdateFn[T any, U protoutils.ProtoMessageWithMerge[T]] func(s *Store[T, U], value U) (U, error)

type Option

type Option[T any, U protoutils.ProtoMessageWithMerge[T]] func(s *Store[T, U])

func WithJetstreamKV added in v0.9.3

func WithJetstreamKV[T any, U protoutils.ProtoMessageWithMerge[T]](kv jetstream.KeyValue) Option[T, U]

func WithKVPrefix added in v0.9.3

func WithKVPrefix[T any, U protoutils.ProtoMessageWithMerge[T]](prefix string) Option[T, U]

func WithLocks added in v0.9.3

func WithLocks[T any, U protoutils.ProtoMessageWithMerge[T]](l *locks.Locks) Option[T, U]

func WithOnDeleteFn added in v0.9.3

func WithOnDeleteFn[T any, U protoutils.ProtoMessageWithMerge[T]](fn OnDeleteFn[T, U]) Option[T, U]

func WithOnNotFoundFn added in v0.9.3

func WithOnNotFoundFn[T any, U protoutils.ProtoMessageWithMerge[T]](fn OnNotFoundFn[T, U]) Option[T, U]

func WithOnUpdateFn added in v0.9.3

func WithOnUpdateFn[T any, U protoutils.ProtoMessageWithMerge[T]](fn OnUpdateFn[T, U]) Option[T, U]

type Store

type Store[T any, U protoutils.ProtoMessageWithMerge[T]] struct {
	// contains filtered or unexported fields
}

func New

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

func (*Store[T, U]) Clear added in v0.9.4

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

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]) Range added in v0.9.4

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

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