Documentation ¶
Index ¶
- func GetDefaultStatePath() string
- type CleanableState
- type Manager
- func (m *Manager) CleanupStateByName(name string) error
- func (m *Manager) DeleteAllStates() (int, error)
- func (m *Manager) DeleteState(state State) error
- func (m *Manager) DeleteStateByName(stateName string) error
- func (m *Manager) GetSavedStateNames() ([]string, error)
- func (m *Manager) GetState(state State) State
- func (m *Manager) LoadState(state State) error
- func (m *Manager) PerformCleanup() error
- func (m *Manager) PersistState(ctx context.Context) error
- func (m *Manager) RegisterState(state State)
- func (m *Manager) Start()
- func (m *Manager) Stop(ctx context.Context) error
- func (m *Manager) UpdateState(state State) error
- type RawState
- type State
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetDefaultStatePath ¶
func GetDefaultStatePath() string
GetDefaultStatePath returns the path to the state file based on the operating system It returns an empty string if the path cannot be determined.
Types ¶
type CleanableState ¶ added in v0.34.0
CleanableState interface extends State with cleanup capability
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager handles the persistence and management of various states
func (*Manager) CleanupStateByName ¶ added in v0.34.0
CleanupStateByName loads and cleans up a specific state by name if it implements CleanableState. Returns an error if the state doesn't exist, isn't registered, or cleanup fails.
func (*Manager) DeleteAllStates ¶ added in v0.34.0
DeleteAllStates removes all states.
func (*Manager) DeleteState ¶
DeleteState removes the state from the manager and marks it as dirty for the next save. Pass an uninitialized state to delete it.
func (*Manager) DeleteStateByName ¶ added in v0.34.0
DeleteStateByName handles deletion of states without cleanup. It doesn't require the state to be registered.
func (*Manager) GetSavedStateNames ¶ added in v0.34.0
GetSavedStateNames returns all state names that are currently saved in the state file.
func (*Manager) PerformCleanup ¶
PerformCleanup retrieves all states from the state file and calls Cleanup on registered states that support it. Unregistered states are preserved in their original state.
func (*Manager) PersistState ¶
PersistState persists the states that have been updated since the last save.
func (*Manager) RegisterState ¶
RegisterState registers a state with the manager but doesn't attempt to persist it. Pass an uninitialized state to register it.
func (*Manager) Start ¶
func (m *Manager) Start()
Start starts the state manager periodic save routine
func (*Manager) UpdateState ¶
UpdateState updates the state in the manager and marks it as dirty for the next save. The state will be replaced with the new one.
type RawState ¶ added in v0.34.0
type RawState struct {
// contains filtered or unexported fields
}
RawState wraps raw JSON data for unregistered states
func (*RawState) MarshalJSON ¶ added in v0.34.0
MarshalJSON implements json.Marshaler to preserve the original JSON