state

package
v1.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 10, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AppliedConfig

type AppliedConfig struct {
	Tasks     map[string]AppliedTaskConfig     `json:"tasks"`
	Reminders map[string]AppliedReminderConfig `json:"reminders"`
}

AppliedConfig stores the config as it was when `orbit apply` was last run. This is the source of truth for _run, _notify, and all non-apply commands.

type AppliedReminderConfig

type AppliedReminderConfig struct {
	Command  string `json:"command,omitempty"`
	Schedule string `json:"schedule"`
	Message  string `json:"message"`
	Snooze   string `json:"snooze,omitempty"`
	Check    string `json:"check,omitempty"`
}

AppliedReminderConfig is the applied (saved) version of a reminder's configuration.

type AppliedRetryConfig

type AppliedRetryConfig struct {
	Attempts int    `json:"attempts"`
	Delay    string `json:"delay"`
}

AppliedRetryConfig is the applied version of retry settings.

func (AppliedRetryConfig) ToRetryConfig

func (r AppliedRetryConfig) ToRetryConfig() config.RetryConfig

ToRetryConfig converts an applied retry config back to a config.RetryConfig.

type AppliedTaskConfig

type AppliedTaskConfig struct {
	Command  string                `json:"command"`
	Schedule string                `json:"schedule"`
	OnMissed config.OnMissedPolicy `json:"on_missed"`
	Retry    AppliedRetryConfig    `json:"retry"`
}

AppliedTaskConfig is the applied (saved) version of a task's configuration.

type ReminderState

type ReminderState struct {
	State             ReminderStatus `json:"state"`
	FiredAt           time.Time      `json:"fired_at"`
	SnoozedUntil      *time.Time     `json:"snoozed_until,omitempty"`
	OverdueCount      int            `json:"overdue_count"`
	LastCheckExitCode *int           `json:"last_check_exit_code,omitempty"`
	LastCheckAt       time.Time      `json:"last_check_at"`
	Disabled          bool           `json:"disabled,omitempty"`
}

ReminderState tracks the state of a reminder.

type ReminderStatus

type ReminderStatus string

ReminderStatus represents the current state of a reminder.

const (
	StatePending      ReminderStatus = "pending"
	StateAcknowledged ReminderStatus = "acknowledged"
	StateSnoozed      ReminderStatus = "snoozed"
)

Reminder state constants.

func (ReminderStatus) String

func (rs ReminderStatus) String() string

type State

type State struct {
	// contains filtered or unexported fields
}

State represents the orbit state store.

func NewState

func NewState(dataDir string) (*State, error)

NewState creates a new state instance, loading existing state from disk if available.

func (*State) DeleteReminderState

func (s *State) DeleteReminderState(name string)

DeleteReminderState removes a reminder's state entry.

func (*State) DeleteTaskState

func (s *State) DeleteTaskState(name string)

DeleteTaskState removes a task's state entry.

func (*State) GetAppliedConfig

func (s *State) GetAppliedConfig() *AppliedConfig

GetAppliedConfig returns the applied configuration, or nil if none has been applied yet.

func (*State) GetAppliedReminder

func (s *State) GetAppliedReminder(name string) (AppliedReminderConfig, bool)

GetAppliedReminder returns the applied config for a reminder, and whether it exists.

func (*State) GetAppliedTask

func (s *State) GetAppliedTask(name string) (AppliedTaskConfig, bool)

GetAppliedTask returns the applied config for a task, and whether it exists.

func (*State) GetEmbedVersion

func (s *State) GetEmbedVersion() int

GetEmbedVersion returns the stored embed version.

func (*State) GetReminderState

func (s *State) GetReminderState(name string) ReminderState

GetReminderState returns the state for a reminder.

func (*State) GetTaskState

func (s *State) GetTaskState(name string) TaskState

GetTaskState returns the state for a task.

func (*State) Pending

func (s *State) Pending() int

Pending returns the current count of pending reminders, computed from the map.

func (*State) Save

func (s *State) Save() error

Save writes the state to disk atomically and updates the sentinel file. It uses flock to prevent concurrent orbit processes from clobbering each other.

func (*State) SetAppliedConfig

func (s *State) SetAppliedConfig(ac *AppliedConfig)

SetAppliedConfig stores the applied configuration. This is called by `orbit apply`.

func (*State) SetEmbedVersion

func (s *State) SetEmbedVersion(v int)

SetEmbedVersion updates the stored embed version.

func (*State) SetReminderState

func (s *State) SetReminderState(name string, rs ReminderState)

SetReminderState updates the state for a reminder.

func (*State) SetTaskState

func (s *State) SetTaskState(name string, ts TaskState)

SetTaskState updates the state for a task.

type TaskState

type TaskState struct {
	LastRun             time.Time `json:"last_run"`
	LastExitCode        int       `json:"last_exit_code"`
	LastDurationMs      int64     `json:"last_duration_ms"`
	ConsecutiveFailures int       `json:"consecutive_failures"`
	RetryAttempt        int       `json:"retry_attempt"`
	Disabled            bool      `json:"disabled,omitempty"`
}

TaskState tracks the state of a task.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL