Documentation ¶
Index ¶
- 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)
- type KeyValuer
- type Marshaler
- type MarshalerUnmarshaler
- type NilValue
- type StringValue
- type UInt64Value
- type Unmarshaler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type KeyValue ¶
type KeyValue[T MarshalerUnmarshaler] struct { // contains filtered or unexported fields }
func (*KeyValue[T]) LastRevision ¶
type KeyValuer ¶
type KeyValuer[T any] 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 }
func BucketKeyValuer ¶
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.
Click to show internal directories.
Click to hide internal directories.