Documentation
¶
Index ¶
- Variables
- type HandlerOption
- type IndexedScope
- func (s IndexedScope[T]) Address(id string) (string, error)
- func (s IndexedScope[T]) Define(manager *Manager, id string, initial T, opts ...KeyOption) (*Key[T], error)
- func (s IndexedScope[T]) Lookup(manager *Manager, id string) (*Key[T], error)
- func (s IndexedScope[T]) MustAddress(id string) string
- func (s IndexedScope[T]) Name() string
- func (s IndexedScope[T]) Wildcard() string
- type Key
- func Define[T any](manager *Manager, name string, initial T, opts ...KeyOption) (*Key[T], error)
- func DefineIndexed[T any](manager *Manager, scopeName, id string, initial T, opts ...KeyOption) (*Key[T], error)
- func DefineSingleton[T any](manager *Manager, name string, initial T, opts ...KeyOption) (*Key[T], error)
- func Lookup[T any](manager *Manager, name string) (*Key[T], error)
- func LookupIndexed[T any](manager *Manager, scopeName, id string) (*Key[T], error)
- func LookupSingleton[T any](manager *Manager, name string) (*Key[T], error)
- func (k *Key[T]) Lock(ctx context.Context) (*Locked[T], error)
- func (k *Key[T]) Name() string
- func (k *Key[T]) Set(ctx context.Context, value T, opts ...WriteOption) error
- func (k *Key[T]) Snapshot(ctx context.Context) (T, Meta, error)
- func (k *Key[T]) Update(ctx context.Context, update func(*T), opts ...WriteOption) error
- type KeyOption
- type Locked
- type Manager
- type Message
- type MessageType
- type Meta
- type Option
- type SingletonScope
- type WriteOption
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrAlreadyDefined = errors.New("syncedstate: state name already defined") ErrClosed = errors.New("syncedstate: locked state already closed") ErrInvalidScope = errors.New("syncedstate: invalid state scope") ErrMissingValue = errors.New("syncedstate: message value is required") ErrNotFound = errors.New("syncedstate: state name not found") ErrTypeMismatch = errors.New("syncedstate: state type mismatch") ErrVersionConflict = errors.New("syncedstate: state version conflict") ErrWildcardName = errors.New("syncedstate: wildcard state name requires an exact indexed state name") )
Functions ¶
This section is empty.
Types ¶
type HandlerOption ¶
type HandlerOption func(*handlerConfig)
func WithBlockOnFullBuffer ¶
func WithBlockOnFullBuffer() HandlerOption
func WithOriginPatterns ¶
func WithOriginPatterns(patterns ...string) HandlerOption
func WithSendBuffer ¶
func WithSendBuffer(size int) HandlerOption
func WithWriteTimeout ¶
func WithWriteTimeout(timeout time.Duration) HandlerOption
type IndexedScope ¶
type IndexedScope[T any] struct { // contains filtered or unexported fields }
func MustIndexedScope ¶
func MustIndexedScope[T any](name string) IndexedScope[T]
func NewIndexedScope ¶
func NewIndexedScope[T any](name string) (IndexedScope[T], error)
func (IndexedScope[T]) Lookup ¶
func (s IndexedScope[T]) Lookup(manager *Manager, id string) (*Key[T], error)
func (IndexedScope[T]) MustAddress ¶
func (s IndexedScope[T]) MustAddress(id string) string
func (IndexedScope[T]) Name ¶
func (s IndexedScope[T]) Name() string
func (IndexedScope[T]) Wildcard ¶
func (s IndexedScope[T]) Wildcard() string
type Key ¶
type Key[T any] struct { // contains filtered or unexported fields }
func DefineIndexed ¶
func DefineSingleton ¶
func LookupIndexed ¶
type Message ¶
type Message struct {
Type MessageType `json:"type"`
ID string `json:"id,omitempty"`
Name string `json:"name,omitempty"`
Version uint64 `json:"version,omitempty"`
Value json.RawMessage `json:"value,omitempty"`
Error string `json:"error,omitempty"`
}
type MessageType ¶
type MessageType string
const ( MessageSubscribe MessageType = "subscribe" MessageUnsubscribe MessageType = "unsubscribe" MessageSet MessageType = "set" MessageSnapshot MessageType = "snapshot" MessageUpdate MessageType = "update" MessageError MessageType = "error" )
type SingletonScope ¶
type SingletonScope[T any] struct { // contains filtered or unexported fields }
func MustSingletonScope ¶
func MustSingletonScope[T any](name string) SingletonScope[T]
func NewSingletonScope ¶
func NewSingletonScope[T any](name string) (SingletonScope[T], error)
func (SingletonScope[T]) Address ¶
func (s SingletonScope[T]) Address() string
func (SingletonScope[T]) Define ¶
func (s SingletonScope[T]) Define(manager *Manager, initial T, opts ...KeyOption) (*Key[T], error)
func (SingletonScope[T]) Lookup ¶
func (s SingletonScope[T]) Lookup(manager *Manager) (*Key[T], error)
func (SingletonScope[T]) Name ¶
func (s SingletonScope[T]) Name() string
type WriteOption ¶
type WriteOption func(*writeConfig)
func WithVersion ¶
func WithVersion(version uint64) WriteOption
Source Files
¶
Click to show internal directories.
Click to hide internal directories.