Documentation
¶
Index ¶
- Constants
- type Manager
- func (m *Manager) AddAfterSnapshotHook(hook func(snapshotID string))
- func (m *Manager) AddAfterTransitionHook(hook func(transition interfaces.StateTransition))
- func (m *Manager) AddBeforeSnapshotHook(hook func() error)
- func (m *Manager) AddBeforeTransitionHook(hook func(transition interfaces.StateTransition) error)
- func (m *Manager) ApplyStateTransition(transition interfaces.StateTransition) error
- func (m *Manager) BeginStateTransition() interfaces.StateTransition
- func (m *Manager) CreateSnapshot() (string, error)
- func (m *Manager) DeleteSnapshot(snapshotID string) error
- func (m *Manager) DeleteState(key string) error
- func (m *Manager) GetState(key string) (any, error)
- func (m *Manager) GetStateHash() ([]byte, error)
- func (m *Manager) ListSnapshots() ([]string, error)
- func (m *Manager) RestoreSnapshot(snapshotID string) error
- func (m *Manager) SetState(key string, value any) error
- func (m *Manager) ValidateState() error
- type Snapshot
- type StateTransitionImpl
- type SyncHooks
- func (h *SyncHooks) AddAfterSnapshot(hook func(snapshotID string))
- func (h *SyncHooks) AddAfterTransition(hook func(transition interfaces.StateTransition))
- func (h *SyncHooks) AddBeforeSnapshot(hook func() error)
- func (h *SyncHooks) AddBeforeTransition(hook func(transition interfaces.StateTransition) error)
Constants ¶
const ( // StateKeyPrefix is the prefix for state keys in storage StateKeyPrefix = "state:" // SnapshotKeyPrefix is the prefix for snapshot keys in storage SnapshotKeyPrefix = "snapshot:" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager implements the StateManager interface
func NewManager ¶
func NewManager(storage interfaces.Storage) *Manager
NewManager creates a new state manager
func (*Manager) AddAfterSnapshotHook ¶
AddAfterSnapshotHook adds a hook to run after snapshots
func (*Manager) AddAfterTransitionHook ¶
func (m *Manager) AddAfterTransitionHook(hook func(transition interfaces.StateTransition))
AddAfterTransitionHook adds a hook to run after state transitions
func (*Manager) AddBeforeSnapshotHook ¶
AddBeforeSnapshotHook adds a hook to run before snapshots
func (*Manager) AddBeforeTransitionHook ¶
func (m *Manager) AddBeforeTransitionHook(hook func(transition interfaces.StateTransition) error)
AddBeforeTransitionHook adds a hook to run before state transitions
func (*Manager) ApplyStateTransition ¶
func (m *Manager) ApplyStateTransition(transition interfaces.StateTransition) error
ApplyStateTransition applies a state transition
func (*Manager) BeginStateTransition ¶
func (m *Manager) BeginStateTransition() interfaces.StateTransition
BeginStateTransition creates a new state transition
func (*Manager) CreateSnapshot ¶
CreateSnapshot creates a new state snapshot
func (*Manager) DeleteSnapshot ¶
DeleteSnapshot deletes a snapshot
func (*Manager) DeleteState ¶
DeleteState removes a state value
func (*Manager) GetStateHash ¶
GetStateHash returns the hash of the current state
func (*Manager) ListSnapshots ¶
ListSnapshots returns all snapshot IDs
func (*Manager) RestoreSnapshot ¶
RestoreSnapshot restores state from a snapshot
func (*Manager) ValidateState ¶
ValidateState validates the current state
type StateTransitionImpl ¶
type StateTransitionImpl struct {
// contains filtered or unexported fields
}
StateTransitionImpl implements the StateTransition interface
func (*StateTransitionImpl) AddChange ¶
func (t *StateTransitionImpl) AddChange(key string, oldValue, newValue any)
AddChange adds a state change to the transition
func (*StateTransitionImpl) Apply ¶
func (t *StateTransitionImpl) Apply() error
Apply applies the transition
func (*StateTransitionImpl) GetChanges ¶
func (t *StateTransitionImpl) GetChanges() map[string]interfaces.StateChange
GetChanges returns all changes in the transition
func (*StateTransitionImpl) Rollback ¶
func (t *StateTransitionImpl) Rollback() error
Rollback rolls back the transition
func (*StateTransitionImpl) Validate ¶
func (t *StateTransitionImpl) Validate() error
Validate validates the transition
type SyncHooks ¶
type SyncHooks struct {
// contains filtered or unexported fields
}
SyncHooks contains hooks for state synchronization
func (*SyncHooks) AddAfterSnapshot ¶
AddAfterSnapshot adds an after-snapshot hook
func (*SyncHooks) AddAfterTransition ¶
func (h *SyncHooks) AddAfterTransition(hook func(transition interfaces.StateTransition))
AddAfterTransition adds an after-transition hook
func (*SyncHooks) AddBeforeSnapshot ¶
AddBeforeSnapshot adds a before-snapshot hook
func (*SyncHooks) AddBeforeTransition ¶
func (h *SyncHooks) AddBeforeTransition(hook func(transition interfaces.StateTransition) error)
AddBeforeTransition adds a before-transition hook