Documentation ¶
Index ¶
- func GetDefaultStatePath() string
- type Manager
- func (m *Manager) DeleteState(state State) error
- func (m *Manager) GetState(state State) State
- 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 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 Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager handles the persistence and management of various 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) PerformCleanup ¶
PerformCleanup retrieves all states from the state file for the registered states and calls Cleanup on them. If the cleanup is successful, the state is marked for deletion.
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.