Documentation
¶
Index ¶
- func StartSupervised(ctx context.Context, label string, run func(context.Context) error) (func(context.Context) error, error)
- type Signal
- type Snapshot
- type StateMap
- func (s *StateMap[K, V]) Apply(ctx context.Context, label string, ...) error
- func (s *StateMap[K, V]) ApplyTyped[R any](ctx context.Context, label string, ...) (R, error)
- func (s *StateMap[K, V]) Drain(ctx context.Context, label string) ([]V, error)
- func (s *StateMap[K, V]) Get(key K) (V, bool)
- func (s *StateMap[K, V]) Remove(ctx context.Context, label string, key K) (V, bool, error)
- func (s *StateMap[K, V]) RemoveWhere(ctx context.Context, label string, predicate func(K, V) bool) ([]V, error)
- func (s *StateMap[K, V]) Store(ctx context.Context, label string, key K, value V) (V, bool, error)
- func (s *StateMap[K, V]) Values() []V
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Signal ¶
type Signal[T any] struct { // contains filtered or unexported fields }
Signal delivers each published value once to every current subscriber. Subscribers run sequentially on the publishing goroutine.
type Snapshot ¶
type Snapshot[T any] struct { // contains filtered or unexported fields }
Snapshot publishes immutable copies of a value for lock-free readers.
type StateMap ¶
type StateMap[K comparable, V any] struct { // contains filtered or unexported fields }
StateMap owns mutable keyed state while publishing immutable snapshots for readers.
func NewStateMap ¶
func NewStateMap[K comparable, V any]() *StateMap[K, V]
NewStateMap creates a locally serialized state map for process-local state.
func (*StateMap[K, V]) Apply ¶
func (s *StateMap[K, V]) Apply(ctx context.Context, label string, mutate func(map[K]V) (changed bool, err error)) error
Apply serializes a mutation and publishes it atomically when changed is true.
func (*StateMap[K, V]) ApplyTyped ¶
func (s *StateMap[K, V]) ApplyTyped[R any]( ctx context.Context, label string, mutate func(map[K]V) (result R, changed bool, err error), ) (R, error)
ApplyTyped serializes a typed mutation and publishes its resulting state.
func (*StateMap[K, V]) Get ¶
Get reads one value from the latest immutable snapshot without acquiring the mutation lock.
func (*StateMap[K, V]) RemoveWhere ¶
func (s *StateMap[K, V]) RemoveWhere(ctx context.Context, label string, predicate func(K, V) bool) ([]V, error)
RemoveWhere atomically removes every value selected by predicate.