Documentation
¶
Overview ¶
Package tasks defines task types and handlers for the scheduler.
Index ¶
- Constants
- func HandleAIAgentTask(ctx context.Context, t *asynq.Task) error
- func HandleCleanupTask(ctx context.Context, t *asynq.Task) error
- func HandleDataProcessingTask(ctx context.Context, t *asynq.Task) error
- func HandleTestSuiteTask(ctx context.Context, t *asynq.Task) error
- func HandleWebhookTask(ctx context.Context, t *asynq.Task) error
- type AIAgentHandler
- type AIAgentPayload
- type AIAgentResult
- type CleanupHandler
- type CleanupPayload
- type CleanupResult
- type DataProcessingHandler
- type DataProcessingPayload
- type DataProcessingResult
- type RetryPolicy
- type TaskResult
- type TestResult
- type TestSuiteHandler
- type TestSuitePayload
- type TestSuiteResult
- type WebhookHandler
- type WebhookPayload
- type WebhookResult
Constants ¶
const ( // AI-related tasks TypeAIAgentExecution = "ai:agent:execute" TypeTestSuiteRun = "ai:test:run" TypeDataProcessing = "ai:data:process" // System tasks TypeCleanup = "system:cleanup" TypeWebhook = "system:webhook" TypeNotify = "system:notify" // Code analysis tasks TypeCodeParse = "code:parse" TypeCodeValidate = "code:validate" TypeCodeDeploy = "code:deploy" )
Task type constants.
Variables ¶
This section is empty.
Functions ¶
func HandleAIAgentTask ¶
HandleAIAgentTask is the handler function for AI agent tasks.
func HandleCleanupTask ¶
HandleCleanupTask is the handler function for cleanup tasks.
func HandleDataProcessingTask ¶
HandleDataProcessingTask is the handler function for data processing tasks.
func HandleTestSuiteTask ¶
HandleTestSuiteTask is the handler function for test suite tasks.
Types ¶
type AIAgentHandler ¶
type AIAgentHandler struct {
}
AIAgentHandler handles AI agent execution tasks.
func NewAIAgentHandler ¶
func NewAIAgentHandler() *AIAgentHandler
NewAIAgentHandler creates a new AI agent handler.
func (*AIAgentHandler) ProcessTask ¶
ProcessTask handles the AI agent execution.
type AIAgentPayload ¶
type AIAgentPayload struct {
AgentID string `json:"agent_id"`
AgentType string `json:"agent_type"`
Input json.RawMessage `json:"input"`
Timeout time.Duration `json:"timeout"`
Config map[string]any `json:"config,omitempty"`
CallbackURL string `json:"callback_url,omitempty"`
Metadata map[string]any `json:"metadata,omitempty"`
}
AIAgentPayload represents the payload for an AI agent execution task.
type AIAgentResult ¶
type AIAgentResult struct {
AgentID string `json:"agent_id"`
Output any `json:"output"`
TokensUsed int `json:"tokens_used"`
Duration time.Duration `json:"duration"`
CompletedAt time.Time `json:"completed_at"`
Metadata map[string]any `json:"metadata,omitempty"`
}
AIAgentResult represents the result of an AI agent execution.
type CleanupHandler ¶
type CleanupHandler struct {
}
CleanupHandler handles cleanup tasks.
func NewCleanupHandler ¶
func NewCleanupHandler() *CleanupHandler
NewCleanupHandler creates a new cleanup handler.
func (*CleanupHandler) ProcessTask ¶
ProcessTask handles the cleanup execution.
type CleanupPayload ¶
type CleanupPayload struct {
Type string `json:"type"` // jobs, logs, temp, etc.
OlderThan time.Duration `json:"older_than"` // retention period
BatchSize int `json:"batch_size"` // max items to delete per run
DryRun bool `json:"dry_run"` // if true, only report what would be deleted
TargetTable string `json:"target_table,omitempty"`
TargetPath string `json:"target_path,omitempty"`
}
CleanupPayload represents the payload for a cleanup task.
type CleanupResult ¶
type CleanupResult struct {
Type string `json:"type"`
ItemsDeleted int `json:"items_deleted"`
BytesFreed int64 `json:"bytes_freed"`
Duration time.Duration `json:"duration"`
CompletedAt time.Time `json:"completed_at"`
Errors []string `json:"errors,omitempty"`
DryRun bool `json:"dry_run"`
}
CleanupResult represents the result of a cleanup task.
type DataProcessingHandler ¶
type DataProcessingHandler struct {
}
DataProcessingHandler handles data processing tasks.
func NewDataProcessingHandler ¶
func NewDataProcessingHandler() *DataProcessingHandler
NewDataProcessingHandler creates a new data processing handler.
func (*DataProcessingHandler) ProcessTask ¶
ProcessTask handles the data processing execution.
type DataProcessingPayload ¶
type DataProcessingPayload struct {
OperationType string `json:"operation_type"` // import, export, transform, etc.
SourceType string `json:"source_type"` // file, database, api, etc.
SourcePath string `json:"source_path"`
DestType string `json:"dest_type"`
DestPath string `json:"dest_path"`
Format string `json:"format"` // json, csv, xml, etc.
Options json.RawMessage `json:"options,omitempty"`
BatchSize int `json:"batch_size"`
Timeout time.Duration `json:"timeout"`
}
DataProcessingPayload represents the payload for a data processing task.
type DataProcessingResult ¶
type DataProcessingResult struct {
OperationType string `json:"operation_type"`
RecordsRead int `json:"records_read"`
RecordsWritten int `json:"records_written"`
RecordsFailed int `json:"records_failed"`
BytesProcessed int64 `json:"bytes_processed"`
Duration time.Duration `json:"duration"`
CompletedAt time.Time `json:"completed_at"`
Errors []string `json:"errors,omitempty"`
}
DataProcessingResult represents the result of a data processing task.
type RetryPolicy ¶
type RetryPolicy struct {
MaxRetries int
InitialDelay time.Duration
MaxDelay time.Duration
Multiplier float64
}
RetryPolicy defines retry behavior for tasks.
func DefaultRetryPolicy ¶
func DefaultRetryPolicy() RetryPolicy
DefaultRetryPolicy returns a default exponential backoff retry policy.
type TaskResult ¶
TaskResult represents the result of a task execution.
func NewErrorResult ¶
func NewErrorResult(err error) TaskResult
NewErrorResult creates a failed task result.
func NewSuccessResult ¶
func NewSuccessResult(data any) TaskResult
NewSuccessResult creates a successful task result.
type TestResult ¶
type TestResult struct {
TestID string `json:"test_id"`
Name string `json:"name"`
Status string `json:"status"` // passed, failed, skipped
Duration time.Duration `json:"duration"`
Error string `json:"error,omitempty"`
Output string `json:"output,omitempty"`
}
TestResult represents the result of a single test.
type TestSuiteHandler ¶
type TestSuiteHandler struct {
}
TestSuiteHandler handles test suite execution tasks.
func NewTestSuiteHandler ¶
func NewTestSuiteHandler() *TestSuiteHandler
NewTestSuiteHandler creates a new test suite handler.
func (*TestSuiteHandler) ProcessTask ¶
ProcessTask handles the test suite execution.
type TestSuitePayload ¶
type TestSuitePayload struct {
SuiteID string `json:"suite_id"`
TestIDs []string `json:"test_ids,omitempty"`
Environment string `json:"environment"`
Timeout time.Duration `json:"timeout"`
Config map[string]any `json:"config,omitempty"`
Tags []string `json:"tags,omitempty"`
Parallel bool `json:"parallel"`
}
TestSuitePayload represents the payload for a test suite run task.
type TestSuiteResult ¶
type TestSuiteResult struct {
SuiteID string `json:"suite_id"`
Passed int `json:"passed"`
Failed int `json:"failed"`
Skipped int `json:"skipped"`
Duration time.Duration `json:"duration"`
TestResults []TestResult `json:"test_results"`
CompletedAt time.Time `json:"completed_at"`
Summary string `json:"summary"`
}
TestSuiteResult represents the result of a test suite run.
type WebhookHandler ¶
type WebhookHandler struct {
// contains filtered or unexported fields
}
WebhookHandler handles webhook notification tasks.
func NewWebhookHandler ¶
func NewWebhookHandler() *WebhookHandler
NewWebhookHandler creates a new webhook handler.
func (*WebhookHandler) ProcessTask ¶
ProcessTask handles the webhook notification.
type WebhookPayload ¶
type WebhookPayload struct {
URL string `json:"url"`
Method string `json:"method"`
Headers map[string]string `json:"headers,omitempty"`
Body json.RawMessage `json:"body,omitempty"`
Timeout time.Duration `json:"timeout"`
RetryPolicy RetryPolicy `json:"retry_policy,omitempty"`
}
WebhookPayload represents the payload for a webhook notification task.
type WebhookResult ¶
type WebhookResult struct {
URL string `json:"url"`
StatusCode int `json:"status_code"`
Response string `json:"response"`
Duration time.Duration `json:"duration"`
CompletedAt time.Time `json:"completed_at"`
Success bool `json:"success"`
Error string `json:"error,omitempty"`
}
WebhookResult represents the result of a webhook notification.