Documentation
¶
Index ¶
- type Job
- type JobHandler
- type JobState
- type Payload
- type Schedule
- type Service
- func (s *Service) AddJob(name, message string, schedule Schedule, channel, chatID string, deliver bool) (*Job, error)
- func (s *Service) EnableJob(id string, enabled bool) (*Job, error)
- func (s *Service) GetJob(id string) (*Job, bool)
- func (s *Service) ListJobs(includeDisabled bool) []*Job
- func (s *Service) RemoveJob(id string) error
- func (s *Service) RunJob(id string) (*Job, error)
- func (s *Service) Start() error
- func (s *Service) Status() map[string]any
- func (s *Service) Stop()
- type Store
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Job ¶
type Job struct {
ID string `json:"id"`
Name string `json:"name"`
Enabled bool `json:"enabled"`
Schedule Schedule `json:"schedule"`
Payload Payload `json:"payload"`
State JobState `json:"state"`
CreatedAtMS int64 `json:"created_at_ms"`
UpdatedAtMS int64 `json:"updated_at_ms"`
DeleteAfterRun bool `json:"delete_after_run,omitempty"`
}
Job represents a scheduled task.
func (*Job) ScheduleDescription ¶
ScheduleDescription returns a human-readable schedule summary.
type JobState ¶
type JobState struct {
NextRunAtMS *int64 `json:"next_run_at_ms,omitempty"`
LastRunAtMS *int64 `json:"last_run_at_ms,omitempty"`
LastStatus string `json:"last_status,omitempty"`
LastError string `json:"last_error,omitempty"`
}
JobState holds runtime state for a job.
type Payload ¶
type Payload struct {
Kind string `json:"kind"` // "agent_turn"
Message string `json:"message"` // message sent to agent
Channel string `json:"channel"` // target channel name
ChatID string `json:"chat_id"` // target chat ID
Deliver bool `json:"deliver"` // true=deliver directly, false=agent processes
}
Payload defines what a job does when triggered.
type Schedule ¶
type Schedule struct {
Kind string `json:"kind"` // "at" | "every" | "cron"
AtMS *int64 `json:"at_ms,omitempty"` // one-shot timestamp (milliseconds)
EveryMS *int64 `json:"every_ms,omitempty"` // interval (milliseconds)
Expr string `json:"expr,omitempty"` // cron expression (5-field)
}
Schedule defines when a job should run.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service manages scheduled jobs with a ticker-based polling loop.
func NewService ¶
func NewService(storePath string, handler JobHandler) *Service
NewService creates a cron service backed by the given store path.
func (*Service) AddJob ¶
func (s *Service) AddJob(name, message string, schedule Schedule, channel, chatID string, deliver bool) (*Job, error)
AddJob creates and persists a new job.
func (*Service) RunJob ¶ added in v0.2.1
RunJob executes a single job immediately by ID, regardless of next-run timing. It reuses the same execution semantics as scheduled runs.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store persists cron jobs as a JSON file.
Click to show internal directories.
Click to hide internal directories.