Documentation ¶
Index ¶
- func UnwrapValues[T MarshalerUnmarshaler](ctx context.Context, in <-chan WatchValue[T], errs <-chan error) (<-chan T, <-chan error, error)
- func WithNoErrorOnNotFound(ctx context.Context) context.Context
- func WithPurge(ctx context.Context) context.Context
- func WithStopOnZero(ctx context.Context) context.Context
- type KeyValue
- func (s *KeyValue[T]) Create(ctx context.Context, key string, value T) (revision uint64, err error)
- func (s *KeyValue[T]) Delete(ctx context.Context, key string, opts ...nats.DeleteOpt) error
- func (s *KeyValue[T]) Get(ctx context.Context, key string) (T, uint64, error)
- func (s *KeyValue[T]) GetAll(ctx context.Context, keys []string) ([]T, error)
- func (s *KeyValue[T]) Keys(ctx context.Context) ([]string, error)
- func (s *KeyValue[T]) LastRevision(ctx context.Context, key string) (uint64, error)
- func (s *KeyValue[T]) Put(ctx context.Context, key string, value T) (revision uint64, err error)
- func (s *KeyValue[T]) Update(ctx context.Context, key string, value T, lastRevision uint64) (revision uint64, err error)
- func (s *KeyValue[T]) Watch(ctx context.Context, sub string, opts ...nats.WatchOpt) (<-chan WatchValue[T], <-chan error, error)
- func (s *KeyValue[T]) WatchAll(ctx context.Context, opts ...nats.WatchOpt) (<-chan WatchValue[T], <-chan error, error)
- type KeyValuer
- type Marshaler
- type MarshalerUnmarshaler
- type NilValue
- type Op
- type StringValue
- type UInt64Value
- type Unmarshaler
- type WatchValue
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func UnwrapValues ¶ added in v0.0.28
func UnwrapValues[T MarshalerUnmarshaler](ctx context.Context, in <-chan WatchValue[T], errs <-chan error) (<-chan T, <-chan error, error)
func WithNoErrorOnNotFound ¶ added in v0.0.30
Types ¶
type KeyValue ¶
type KeyValue[T MarshalerUnmarshaler] struct { // contains filtered or unexported fields }
func (*KeyValue[T]) LastRevision ¶
type KeyValuer ¶
type KeyValuer[T MarshalerUnmarshaler] interface { Keys(ctx context.Context) ([]string, error) Get(ctx context.Context, key string) (T, uint64, error) GetAll(ctx context.Context, keys []string) ([]T, error) Create(ctx context.Context, key string, value T) (revision uint64, err error) Put(ctx context.Context, key string, value T) (revision uint64, err error) Update(ctx context.Context, key string, value T, lastRevision uint64) (revision uint64, err error) // Status(ctx context.Context, key string) (nats.KeyValueStatus, error) LastRevision(context.Context, string) (uint64, error) Delete(ctx context.Context, key string, opts ...nats.DeleteOpt) error WatchAll(ctx context.Context, opts ...nats.WatchOpt) (<-chan WatchValue[T], <-chan error, error) Watch(ctx context.Context, sub string, opts ...nats.WatchOpt) (<-chan WatchValue[T], <-chan error, error) }
func BucketKeyValuer ¶ added in v0.0.3
func BucketKeyValuer[T MarshalerUnmarshaler](conn *nats.Conn, name string) (KeyValuer[T], error)
func New ¶
func New[T MarshalerUnmarshaler](kv nats.KeyValue) KeyValuer[T]
type Marshaler ¶
A Marshaler can encode itself into bytes. aggregates must implement Marshaler & Unmarshaler for Snapshots to work.
Example using encoding/gob:
type foo struct { aggregate.Aggregate state } type state struct { Name string Age uint8 } func (f *foo) MarshalValue() ([]byte, error) { var buf bytes.Buffer err := gob.NewEncoder(&buf).Encode(f.state) return buf.Bytes(), err } func (f *foo) UnmarshalValue(p []byte) error { return gob.NewDecoder(bytes.NewReader(p)).Decode(&f.state) }
type MarshalerUnmarshaler ¶
type MarshalerUnmarshaler interface { Marshaler Unmarshaler }
type NilValue ¶
type NilValue struct{}
func (*NilValue) MarshalValue ¶
func (*NilValue) UnmarshalValue ¶
type StringValue ¶
type StringValue struct {
Value string `json:"value"`
}
func (*StringValue) MarshalValue ¶
func (v *StringValue) MarshalValue() ([]byte, error)
func (*StringValue) UnmarshalValue ¶
func (v *StringValue) UnmarshalValue(b []byte) error
type UInt64Value ¶
type UInt64Value struct {
Value uint64 `json:"value"`
}
func (*UInt64Value) MarshalValue ¶
func (v *UInt64Value) MarshalValue() ([]byte, error)
func (*UInt64Value) UnmarshalValue ¶
func (v *UInt64Value) UnmarshalValue(b []byte) error
type Unmarshaler ¶
An Unmarshaler can decode itself from bytes.
type WatchValue ¶ added in v0.0.28
type WatchValue[T MarshalerUnmarshaler] struct { Op Op Value T Key string }
Click to show internal directories.
Click to hide internal directories.