Documentation
¶
Overview ¶
Package scheduler provides cron-based scheduling for agent runs.
Index ¶
- type RunFunc
- type RunRecord
- type Schedule
- type Scheduler
- func (s *Scheduler) Add(agentID, cronExpr, input string, newSession bool) (*Schedule, error)
- func (s *Scheduler) Get(id string) (*Schedule, error)
- func (s *Scheduler) History(scheduleID string) []RunRecord
- func (s *Scheduler) List() []*Schedule
- func (s *Scheduler) Remove(id string) error
- func (s *Scheduler) Start(ctx context.Context)
- func (s *Scheduler) Stop()
- func (s *Scheduler) WithTickInterval(d time.Duration) *Scheduler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type RunFunc ¶
RunFunc is called when a schedule fires. It receives the agent ID, input, and session ID.
type RunRecord ¶
type RunRecord struct {
ID string `json:"id"`
ScheduleID string `json:"schedule_id"`
AgentID string `json:"agent_id"`
SessionID string `json:"session_id"`
Input string `json:"input"`
Status string `json:"status"` // success, error
Error string `json:"error,omitempty"`
StartedAt time.Time `json:"started_at"`
FinishedAt time.Time `json:"finished_at"`
}
RunRecord is a historical record of a scheduled run.
type Schedule ¶
type Schedule struct {
ID string `json:"id"`
AgentID string `json:"agent_id"`
CronExpr string `json:"cron_expr"`
Input string `json:"input"`
NewSession bool `json:"new_session"` // true = new session per run, false = reuse
SessionID string `json:"session_id,omitempty"`
Enabled bool `json:"enabled"`
CreatedAt time.Time `json:"created_at"`
LastRunAt time.Time `json:"last_run_at,omitempty"`
NextRunAt time.Time `json:"next_run_at,omitempty"`
RunCount int64 `json:"run_count"`
}
Schedule defines a cron-scheduled agent run.
type Scheduler ¶
type Scheduler struct {
// contains filtered or unexported fields
}
Scheduler manages cron-scheduled agent runs.
Click to show internal directories.
Click to hide internal directories.