Documentation
¶
Overview ¶
Package scheduler provides cron-driven background execution of agent prompts on behalf of the Schedule tool. Jobs are persisted as YAML files under the configured storage directory and hot-reloaded by Service via fsnotify.
Index ¶
- Variables
- func IDFromPath(path string) string
- func ParseCron(expr string) error
- type ChannelLookupFn
- type ExecCommandFn
- type Options
- type Service
- type Store
- func (s *Store) Delete(id string) error
- func (s *Store) Dir() string
- func (s *Store) List() ([]*domain.ScheduledJob, []error)
- func (s *Store) Load(id string) (*domain.ScheduledJob, error)
- func (s *Store) LoadFromPath(path string) (*domain.ScheduledJob, error)
- func (s *Store) Path(id string) string
- func (s *Store) Save(job *domain.ScheduledJob) error
Constants ¶
This section is empty.
Variables ¶
var ErrNotFound = errors.New("scheduled job not found")
ErrNotFound is returned when a job ID does not exist in the store.
Functions ¶
func IDFromPath ¶
IDFromPath returns the job ID derived from a YAML file path. Returns the empty string when the path is not a job file.
Types ¶
type ChannelLookupFn ¶
ChannelLookupFn returns the registered Channel for a name, or nil if unknown.
type ExecCommandFn ¶
ExecCommandFn matches exec.CommandContext. Exposed for tests.
type Options ¶
type Options struct {
Store *Store
ChannelLookup ChannelLookupFn
// ExecCommand defaults to exec.CommandContext when nil.
ExecCommand ExecCommandFn
// BinaryPath defaults to os.Args[0] (current binary) when empty.
BinaryPath string
}
Options bundles dependencies and configuration for NewService.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service runs scheduled jobs inside the channels-manager daemon. Jobs are loaded from the on-disk Store, registered with a robfig/cron scheduler, and hot-reloaded when the storage directory changes (via fsnotify).
On fire, a fresh `infer agent --session-id <uuid>` subprocess is spawned — every fire gets a brand-new session, so no context carries between runs. Each assistant line emitted by the agent is forwarded to the configured channel/recipient via the in-process channel lookup.
func NewService ¶
NewService constructs a Service. Returns an error if required deps are missing.
func (*Service) LoadJobs ¶
LoadJobs replaces all currently-registered cron entries with the jobs currently on disk. Safe to call repeatedly.
func (*Service) ParseCron ¶
ParseCron exposes the same parser the service uses, so the Schedule tool can validate cron expressions identically before persisting them.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store persists ScheduledJob records as YAML files in a directory. One file per job, named "<id>.yaml". Writes are atomic (write to .tmp, then rename) so partial writes never expose half-formed YAML to the daemon's fsnotify watcher.
func NewStore ¶
NewStore creates the storage directory if it does not exist and returns a Store ready to use.
func (*Store) List ¶
func (s *Store) List() ([]*domain.ScheduledJob, []error)
List returns all jobs sorted by CreatedAt ascending. Files that fail to parse are skipped (the corresponding errors are returned alongside the successfully-loaded jobs).
func (*Store) Load ¶
func (s *Store) Load(id string) (*domain.ScheduledJob, error)
Load reads a single job by ID. Returns ErrNotFound if the file does not exist.
func (*Store) LoadFromPath ¶
func (s *Store) LoadFromPath(path string) (*domain.ScheduledJob, error)
LoadFromPath reads a job from an explicit path. Useful when the fsnotify watcher reports a change without a clean ID extraction.