Documentation
¶
Index ¶
- Constants
- Variables
- func DecodeJSONPayload(task Task, dst any) error
- func NormalizeQueueAction(raw string) (string, bool)
- func SupportedQueueActions() []string
- type Config
- type EnqueuePolicy
- type HandlerFunc
- type Inspector
- type Manager
- type QueueActionResult
- type RuntimeQueueSnapshot
- type RuntimeScheduleSnapshot
- type RuntimeServerSnapshot
- type RuntimeSnapshot
- type RuntimeWorkerSnapshot
- type Scheduler
- type Task
Constants ¶
const ( QueueActionPause = "pause" QueueActionUnpause = "unpause" QueueActionRetry = "retry" QueueActionArchiveRetry = "archive-retry" QueueActionRetryArchived = "retry-archived" QueueActionPurgeArchived = "purge-archived" )
Variables ¶
Functions ¶
func DecodeJSONPayload ¶
DecodeJSONPayload unmarshals a generic JSON task payload into dst.
func NormalizeQueueAction ¶
func SupportedQueueActions ¶
func SupportedQueueActions() []string
Types ¶
type Config ¶
type Config struct {
RedisURL string // Used if Provider needs Redis (e.g. Asynq)
Concurrency int // Number of concurrent workers
Queues map[string]int // Queue names and their priority weights
StrictPriority bool // If true, strict priority ordering is enforced
}
Config configures task enqueueing and worker runtime.
type EnqueuePolicy ¶
type EnqueuePolicy struct {
Queue string
MaxRetry int
Timeout time.Duration
ProcessIn time.Duration
Retention time.Duration
}
EnqueuePolicy describes the supported explicit enqueue-policy subset. MaxRetry uses -1 to keep provider defaults; 0 disables retries.
func DefaultEnqueuePolicy ¶
func DefaultEnqueuePolicy() EnqueuePolicy
type HandlerFunc ¶
HandlerFunc is a function that processes a Task.
type Inspector ¶
type Inspector interface {
InspectRuntime() RuntimeSnapshot
OperateQueue(queue, action string) (QueueActionResult, error)
}
Inspector defines an interface for queue introspection and operations.
type Manager ¶
type Manager interface {
// Worker methods
HandleFunc(taskType string, handler HandlerFunc) error
Run(ctx context.Context) error
Close() error
// Client methods
EnqueueJSON(taskType string, payload any) (string, error)
EnqueueJSONCtx(ctx context.Context, taskType string, payload any) (string, error)
EnqueueJSONWithPolicy(taskType string, payload any, policy EnqueuePolicy) (string, error)
EnqueueJSONCtxWithPolicy(ctx context.Context, taskType string, payload any, policy EnqueuePolicy) (string, error)
}
Manager is the unified interface for a Task Queue Provider.
type QueueActionResult ¶
type QueueActionResult struct {
Enabled bool `json:"enabled"`
GeneratedAt string `json:"generated_at"`
Queue string `json:"queue"`
Action string `json:"action"`
Applied bool `json:"applied"`
Affected int `json:"affected,omitempty"`
Message string `json:"message,omitempty"`
}
QueueActionResult is the result of one operational queue action.
type RuntimeQueueSnapshot ¶
type RuntimeQueueSnapshot struct {
Name string `json:"name"`
Paused bool `json:"paused"`
LatencyMS int64 `json:"latency_ms"`
Size int `json:"size"`
Pending int `json:"pending"`
Active int `json:"active"`
Scheduled int `json:"scheduled"`
Retry int `json:"retry"`
Archived int `json:"archived"`
Completed int `json:"completed"`
Aggregating int `json:"aggregating"`
ProcessedToday int `json:"processed_today"`
FailedToday int `json:"failed_today"`
ProcessedAll int `json:"processed_all"`
FailedAll int `json:"failed_all"`
}
RuntimeQueueSnapshot holds one queue aggregate.
type RuntimeScheduleSnapshot ¶
type RuntimeScheduleSnapshot struct {
ID string `json:"id"`
Spec string `json:"spec"`
TaskType string `json:"task_type"`
NextEnqueueAt string `json:"next_enqueue_at,omitempty"`
PrevEnqueueAt string `json:"prev_enqueue_at,omitempty"`
}
RuntimeScheduleSnapshot holds one registered periodic task entry.
type RuntimeServerSnapshot ¶
type RuntimeServerSnapshot struct {
ID string `json:"id"`
Host string `json:"host"`
PID int `json:"pid"`
Status string `json:"status"`
StartedAt string `json:"started_at,omitempty"`
Concurrency int `json:"concurrency"`
StrictPriority bool `json:"strict_priority"`
Queues map[string]int `json:"queues"`
ActiveWorkers int `json:"active_workers"`
}
RuntimeServerSnapshot holds one server aggregate.
type RuntimeSnapshot ¶
type RuntimeSnapshot struct {
Enabled bool `json:"enabled"`
GeneratedAt string `json:"generated_at"`
Reason string `json:"reason,omitempty"`
Queues []RuntimeQueueSnapshot `json:"queues"`
Schedules []RuntimeScheduleSnapshot `json:"schedules"`
Servers []RuntimeServerSnapshot `json:"servers"`
Workers []RuntimeWorkerSnapshot `json:"workers"`
TotalSchedules int `json:"total_schedules"`
TotalQueues int `json:"total_queues"`
TotalServers int `json:"total_servers"`
TotalWorkers int `json:"total_workers"`
TotalSize int `json:"total_size"`
TotalPending int `json:"total_pending"`
TotalActive int `json:"total_active"`
TotalScheduled int `json:"total_scheduled"`
TotalRetry int `json:"total_retry"`
TotalArchived int `json:"total_archived"`
TotalCompleted int `json:"total_completed"`
TotalAggregating int `json:"total_aggregating"`
TotalProcessed int `json:"total_processed_today"`
TotalFailed int `json:"total_failed_today"`
TotalProcessedAll int `json:"total_processed_all"`
TotalFailedAll int `json:"total_failed_all"`
}
RuntimeSnapshot describes queue/worker state discoverable from the provider runtime.
type RuntimeWorkerSnapshot ¶
type RuntimeWorkerSnapshot struct {
ServerID string `json:"server_id"`
Host string `json:"host"`
PID int `json:"pid"`
Queue string `json:"queue"`
TaskID string `json:"task_id"`
TaskType string `json:"task_type"`
StartedAt string `json:"started_at,omitempty"`
Deadline string `json:"deadline,omitempty"`
}
RuntimeWorkerSnapshot describes one active worker task.