Documentation
¶
Index ¶
- type AgentTaskConfig
- type BackupTaskConfig
- type CommandTaskConfig
- type CreateTaskRequest
- type DB
- func (db *DB) CleanupOldExecutions(olderThan time.Duration) (int64, error)
- func (db *DB) Close() error
- func (db *DB) CreateExecution(exec *TaskExecution) (int64, error)
- func (db *DB) CreateTask(task *ScheduledTask) (int64, error)
- func (db *DB) DeleteTask(id int64) error
- func (db *DB) GetAllTasks() ([]ScheduledTask, error)
- func (db *DB) GetDueTasks() ([]ScheduledTask, error)
- func (db *DB) GetEnabledTasks() ([]ScheduledTask, error)
- func (db *DB) GetExecutionsByTask(taskID int64, limit int) ([]TaskExecution, error)
- func (db *DB) GetRecentExecutions(limit int) ([]TaskExecution, error)
- func (db *DB) GetTask(id int64) (*ScheduledTask, error)
- func (db *DB) GetTasksByDeployment(deploymentName string) ([]ScheduledTask, error)
- func (db *DB) UpdateExecution(id int64, status TaskStatus, output, errMsg string, endedAt time.Time, ...) error
- func (db *DB) UpdateTask(id int64, req *UpdateTaskRequest) error
- func (db *DB) UpdateTaskNextRun(id int64, nextRun time.Time) error
- func (db *DB) UpdateTaskRun(id int64, lastRun, nextRun time.Time) error
- type Executor
- func (e *Executor) ExecuteAgent(ctx context.Context, config *AgentTaskConfig) (string, error)
- func (e *Executor) ExecuteBackup(ctx context.Context, deploymentName string, config *BackupTaskConfig) (string, error)
- func (e *Executor) ExecuteCommand(ctx context.Context, deploymentName string, config *CommandTaskConfig) (string, error)
- func (e *Executor) SetAgentRunner(fn func(ctx context.Context, agentName string) (string, error))
- type Manager
- func (m *Manager) Cleanup(olderThan time.Duration) (int64, error)
- func (m *Manager) CreateTask(req *CreateTaskRequest) (*ScheduledTask, error)
- func (m *Manager) DeleteTask(id int64) error
- func (m *Manager) GetAllTasks() ([]ScheduledTask, error)
- func (m *Manager) GetRecentExecutions(limit int) ([]TaskExecution, error)
- func (m *Manager) GetTask(id int64) (*ScheduledTask, error)
- func (m *Manager) GetTaskExecutions(taskID int64, limit int) ([]TaskExecution, error)
- func (m *Manager) GetTasksByDeployment(deploymentName string) ([]ScheduledTask, error)
- func (m *Manager) RemoveAgentTask(agentName string) error
- func (m *Manager) RunTaskNow(id int64) error
- func (m *Manager) Start()
- func (m *Manager) Stop()
- func (m *Manager) SyncAgentTask(agentName, cronExpr, deployment string) error
- func (m *Manager) UpdateTask(id int64, req *UpdateTaskRequest) (*ScheduledTask, error)
- func (m *Manager) ValidateCronExpr(cronExpr string) error
- type ScheduledTask
- type TaskConfig
- type TaskExecution
- type TaskExecutor
- type TaskStatus
- type TaskType
- type UpdateTaskRequest
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AgentTaskConfig ¶
type AgentTaskConfig struct {
AgentName string `json:"agent_name"`
}
type BackupTaskConfig ¶
type CommandTaskConfig ¶
type CreateTaskRequest ¶
type CreateTaskRequest struct {
Name string `json:"name" binding:"required"`
Type TaskType `json:"type" binding:"required"`
DeploymentName string `json:"deployment_name" binding:"required"`
CronExpr string `json:"cron_expr" binding:"required"`
Enabled bool `json:"enabled"`
Config TaskConfig `json:"config"`
}
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
func (*DB) CleanupOldExecutions ¶
func (*DB) CreateExecution ¶
func (db *DB) CreateExecution(exec *TaskExecution) (int64, error)
func (*DB) CreateTask ¶
func (db *DB) CreateTask(task *ScheduledTask) (int64, error)
func (*DB) DeleteTask ¶
func (*DB) GetAllTasks ¶
func (db *DB) GetAllTasks() ([]ScheduledTask, error)
func (*DB) GetDueTasks ¶
func (db *DB) GetDueTasks() ([]ScheduledTask, error)
func (*DB) GetEnabledTasks ¶
func (db *DB) GetEnabledTasks() ([]ScheduledTask, error)
func (*DB) GetExecutionsByTask ¶
func (db *DB) GetExecutionsByTask(taskID int64, limit int) ([]TaskExecution, error)
func (*DB) GetRecentExecutions ¶
func (db *DB) GetRecentExecutions(limit int) ([]TaskExecution, error)
func (*DB) GetTasksByDeployment ¶
func (db *DB) GetTasksByDeployment(deploymentName string) ([]ScheduledTask, error)
func (*DB) UpdateExecution ¶
func (*DB) UpdateTask ¶
func (db *DB) UpdateTask(id int64, req *UpdateTaskRequest) error
type Executor ¶
type Executor struct {
// contains filtered or unexported fields
}
func NewExecutor ¶
func (*Executor) ExecuteAgent ¶
func (*Executor) ExecuteBackup ¶
func (*Executor) ExecuteCommand ¶
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
func NewManager ¶
func NewManager(deploymentsPath string, executor TaskExecutor) (*Manager, error)
func (*Manager) CreateTask ¶
func (m *Manager) CreateTask(req *CreateTaskRequest) (*ScheduledTask, error)
func (*Manager) DeleteTask ¶
func (*Manager) GetAllTasks ¶
func (m *Manager) GetAllTasks() ([]ScheduledTask, error)
func (*Manager) GetRecentExecutions ¶
func (m *Manager) GetRecentExecutions(limit int) ([]TaskExecution, error)
func (*Manager) GetTaskExecutions ¶
func (m *Manager) GetTaskExecutions(taskID int64, limit int) ([]TaskExecution, error)
func (*Manager) GetTasksByDeployment ¶
func (m *Manager) GetTasksByDeployment(deploymentName string) ([]ScheduledTask, error)
func (*Manager) RemoveAgentTask ¶
RemoveAgentTask drops an agent's scheduled task, if any. Called when an agent loses its schedule or is deleted.
func (*Manager) RunTaskNow ¶
func (*Manager) SyncAgentTask ¶
SyncAgentTask makes the scheduler reflect an agent's schedule: it creates the backing task, updates its cron when it changed, or does nothing when already in sync. Called whenever an agent with a schedule is written.
func (*Manager) UpdateTask ¶
func (m *Manager) UpdateTask(id int64, req *UpdateTaskRequest) (*ScheduledTask, error)
func (*Manager) ValidateCronExpr ¶
type ScheduledTask ¶
type ScheduledTask struct {
ID int64 `json:"id"`
Name string `json:"name"`
Type TaskType `json:"type"`
DeploymentName string `json:"deployment_name"`
CronExpr string `json:"cron_expr"`
Enabled bool `json:"enabled"`
Config TaskConfig `json:"config"`
LastRun *time.Time `json:"last_run,omitempty"`
NextRun *time.Time `json:"next_run,omitempty"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
type TaskConfig ¶
type TaskConfig struct {
// For backup tasks
BackupConfig *BackupTaskConfig `json:"backup_config,omitempty"`
// For command tasks
CommandConfig *CommandTaskConfig `json:"command_config,omitempty"`
// For agent tasks
AgentConfig *AgentTaskConfig `json:"agent_config,omitempty"`
}
type TaskExecution ¶
type TaskExecution struct {
ID int64 `json:"id"`
TaskID int64 `json:"task_id"`
Status TaskStatus `json:"status"`
Output string `json:"output,omitempty"`
Error string `json:"error,omitempty"`
StartedAt time.Time `json:"started_at"`
EndedAt *time.Time `json:"ended_at,omitempty"`
Duration int64 `json:"duration_ms,omitempty"`
}
type TaskExecutor ¶
type TaskExecutor interface {
ExecuteBackup(ctx context.Context, deploymentName string, config *BackupTaskConfig) (string, error)
ExecuteCommand(ctx context.Context, deploymentName string, config *CommandTaskConfig) (string, error)
ExecuteAgent(ctx context.Context, config *AgentTaskConfig) (string, error)
}
type TaskStatus ¶
type TaskStatus string
const ( TaskStatusPending TaskStatus = "pending" TaskStatusRunning TaskStatus = "running" TaskStatusCompleted TaskStatus = "completed" TaskStatusFailed TaskStatus = "failed" )
type UpdateTaskRequest ¶
type UpdateTaskRequest struct {
Name *string `json:"name,omitempty"`
CronExpr *string `json:"cron_expr,omitempty"`
Enabled *bool `json:"enabled,omitempty"`
Config *TaskConfig `json:"config,omitempty"`
}
Click to show internal directories.
Click to hide internal directories.