Documentation
¶
Index ¶
- Variables
- func IsValidKey(name string) bool
- func IsValidStoreName(name string) bool
- func IsValidationError(err error) bool
- type Entry
- type KeyDeleteEvent
- type KeyEvent
- type KeySetEvent
- type Manager
- func (m *Manager) Create(ctx context.Context, store string, key string, value *anypb.Any) (uint64, error)
- func (m *Manager) Delete(ctx context.Context, store string, key string) error
- func (m *Manager) DeleteWithRevision(ctx context.Context, store string, key string, revision uint64) error
- func (m *Manager) Destroy()
- func (m *Manager) EnsureStore(ctx context.Context, config *StoreConfig) error
- func (m *Manager) Get(ctx context.Context, store string, key string) (*Entry, error)
- func (m *Manager) Set(ctx context.Context, store string, key string, value *anypb.Any) (uint64, error)
- func (m *Manager) Update(ctx context.Context, store string, key string, value *anypb.Any, ...) (uint64, error)
- func (m *Manager) Watch(ctx context.Context, store string, key string) (*Watcher, error)
- func (m *Manager) WatchAll(ctx context.Context, store string) (*Watcher, error)
- type SetResult
- type StoreConfig
- type Watcher
Constants ¶
This section is empty.
Variables ¶
var ErrKeyAlreadyExists = errors.New("key already exists")
ErrKeyAlreadyExists is returned when a key already exists in a store and cannot be created.
var ErrKeyNotFound = errors.New("key not found")
ErrKeyNotFound is returned when a key is not found in a store.
var ErrRevisionMismatch = errors.New("revision mismatch")
ErrRevisionMismatch is returned when a revision does not match the current revision of a key.
var ErrStoreNotFound = &validationError{err: "store not found"}
ErrStoreNotFound is returned when a store is not found.
Functions ¶
func IsValidKey ¶
IsValidKey checks if the key name is valid. The NATS documentation says that keys follow the same rules as subjects so we delegate to events.IsValidSubject.
func IsValidStoreName ¶
IsValidStoreName checks if the store name is valid.
func IsValidationError ¶
Types ¶
type KeyDeleteEvent ¶
type KeySetEvent ¶
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
func NewManager ¶
func NewManager( logger *zap.Logger, tracer trace.Tracer, js jetstream.JetStream, ) (*Manager, error)
NewManager creates a new state manager.
func (*Manager) Create ¶
func (m *Manager) Create(ctx context.Context, store string, key string, value *anypb.Any) (uint64, error)
Create creates the value for the given key in the given store. If the key already exists, ErrKeyAlreadyExists is returned.
func (*Manager) DeleteWithRevision ¶
func (m *Manager) DeleteWithRevision(ctx context.Context, store string, key string, revision uint64) error
DeleteWithRevision deletes the value for the given key in the given store only if the revision matches.
func (*Manager) EnsureStore ¶
func (m *Manager) EnsureStore(ctx context.Context, config *StoreConfig) error
func (*Manager) Get ¶
Get returns the value for the given key in the given store. If the key doesn't exist, ErrKeyNotFound is returned.
func (*Manager) Set ¶
func (m *Manager) Set(ctx context.Context, store string, key string, value *anypb.Any) (uint64, error)
Set sets the value for the given key in the given store.
func (*Manager) Update ¶
func (m *Manager) Update(ctx context.Context, store string, key string, value *anypb.Any, revision uint64) (uint64, error)
Update updates the value for the given key in the given store only if the revision matches.
type StoreConfig ¶
type StoreConfig struct {
Name string
}