Documentation
¶
Index ¶
- func ParseDuration(s string) (time.Duration, error)
- type AgentExecutor
- type JSONStore
- func (s *JSONStore) Close() error
- func (s *JSONStore) Create(task *Task) error
- func (s *JSONStore) Delete(id string) error
- func (s *JSONStore) Get(id string) (*Task, error)
- func (s *JSONStore) GetAll() ([]*Task, error)
- func (s *JSONStore) GetByAgent(agentName string) ([]*Task, error)
- func (s *JSONStore) GetDue() ([]*Task, error)
- func (s *JSONStore) GetRuns(taskID string, limit int) ([]*TaskRun, error)
- func (s *JSONStore) LogRun(run *TaskRun) error
- func (s *JSONStore) Update(task *Task) error
- type JobResult
- type ScheduleType
- type Scheduler
- func (s *Scheduler) CancelRunningTask(id string) error
- func (s *Scheduler) CreateTask(task *Task) error
- func (s *Scheduler) DeleteTask(id string) error
- func (s *Scheduler) GetAllTasks() ([]*Task, error)
- func (s *Scheduler) GetTask(id string) (*Task, error)
- func (s *Scheduler) GetTaskRuns(taskID string, limit int) ([]*TaskRun, error)
- func (s *Scheduler) GetTasksByAgent(agentName string) ([]*Task, error)
- func (s *Scheduler) PauseTask(id string) error
- func (s *Scheduler) ResumeTask(id string) error
- func (s *Scheduler) Start()
- func (s *Scheduler) Stop()
- func (s *Scheduler) UpdateTask(task *Task) error
- type Task
- type TaskRun
- type TaskStatus
- type TaskStore
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AgentExecutor ¶
type AgentExecutor interface {
Execute(ctx context.Context, agentName string, prompt string) (*JobResult, error)
}
AgentExecutor defines the interface for executing agent tasks
type JSONStore ¶
type JSONStore struct {
// contains filtered or unexported fields
}
JSONStore implements TaskStore using JSON file storage
func NewJSONStore ¶
NewJSONStore creates a new JSON-based task store
func (*JSONStore) GetByAgent ¶
GetByAgent retrieves all tasks for a specific agent
type ScheduleType ¶
type ScheduleType string
const ( ScheduleTypeCron ScheduleType = "cron" ScheduleTypeInterval ScheduleType = "interval" ScheduleTypeOnce ScheduleType = "once" )
type Scheduler ¶
type Scheduler struct {
// contains filtered or unexported fields
}
Scheduler manages scheduled tasks
func NewScheduler ¶
func NewScheduler(store TaskStore, executor AgentExecutor, pollInterval time.Duration) *Scheduler
NewScheduler creates a new scheduler with the given store and executor
func (*Scheduler) CancelRunningTask ¶
CancelRunningTask cancels a currently running task
func (*Scheduler) CreateTask ¶
CreateTask adds a new task
func (*Scheduler) DeleteTask ¶
DeleteTask removes a task
func (*Scheduler) GetAllTasks ¶
GetAllTasks retrieves all tasks
func (*Scheduler) GetTaskRuns ¶
GetTaskRuns retrieves execution history for a task
func (*Scheduler) GetTasksByAgent ¶
GetTasksByAgent retrieves all tasks for a specific agent
func (*Scheduler) ResumeTask ¶
ResumeTask resumes a paused task
func (*Scheduler) UpdateTask ¶
UpdateTask updates an existing task
type Task ¶
type Task struct {
ID string `json:"id"`
AgentName string `json:"agent_name"`
Prompt string `json:"prompt"`
ScheduleType ScheduleType `json:"schedule_type"`
ScheduleValue string `json:"schedule_value"`
Status TaskStatus `json:"status"`
NextRun time.Time `json:"next_run"`
LastRun *time.Time `json:"last_run,omitempty"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
ContextMode string `json:"context_mode"`
Metadata map[string]interface{} `json:"metadata,omitempty"`
}
Task represents a scheduled task
func NewTask ¶
func NewTask(agentName, prompt string, scheduleType ScheduleType, scheduleValue string) (*Task, error)
NewTask creates a new task with the given parameters
func (*Task) CalculateNextRun ¶
CalculateNextRun calculates the next run time based on schedule type
type TaskRun ¶
type TaskRun struct {
ID string `json:"id"`
TaskID string `json:"task_id"`
RunAt time.Time `json:"run_at"`
DurationMs int64 `json:"duration_ms"`
Status string `json:"status"` // "success", "error", "timeout"
Result string `json:"result,omitempty"`
Error string `json:"error,omitempty"`
}
TaskRun represents a single execution of a task
type TaskStatus ¶
type TaskStatus string
const ( TaskStatusActive TaskStatus = "active" TaskStatusPaused TaskStatus = "paused" )
type TaskStore ¶
type TaskStore interface {
// Create adds a new task
Create(task *Task) error
// Get retrieves a task by ID
Get(id string) (*Task, error)
// GetAll retrieves all tasks
GetAll() ([]*Task, error)
// GetDue retrieves tasks that are due for execution
GetDue() ([]*Task, error)
// GetByAgent retrieves all tasks for a specific agent
GetByAgent(agentName string) ([]*Task, error)
// Update updates an existing task
Update(task *Task) error
// Delete removes a task
Delete(id string) error
// LogRun records a task execution
LogRun(run *TaskRun) error
// GetRuns retrieves execution history for a task
GetRuns(taskID string, limit int) ([]*TaskRun, error)
// Close releases resources
Close() error
}
TaskStore defines the interface for task persistence