Documentation
¶
Overview ¶
Package jobs provides HTTP handlers for job-related API endpoints.
Index ¶
- type ErrorResponse
- type Handler
- func (h *Handler) Cancel(w http.ResponseWriter, r *http.Request)
- func (h *Handler) CreateRecurring(w http.ResponseWriter, r *http.Request)
- func (h *Handler) GetStats(w http.ResponseWriter, r *http.Request)
- func (h *Handler) GetStatus(w http.ResponseWriter, r *http.Request)
- func (h *Handler) List(w http.ResponseWriter, r *http.Request)
- func (h *Handler) RegisterRoutes(r chi.Router)
- func (h *Handler) Schedule(w http.ResponseWriter, r *http.Request)
- func (h *Handler) Submit(w http.ResponseWriter, r *http.Request)
- type JobResponse
- type ListResponse
- type RecurringRequest
- type ScheduleRequest
- type StatsResponse
- type SubmitRequest
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ErrorResponse ¶
type ErrorResponse struct {
Error string `json:"error"`
Details map[string]string `json:"details,omitempty"`
}
ErrorResponse represents an error response.
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler provides HTTP handlers for job operations.
func NewHandler ¶
func NewHandler(scheduler *service.SchedulerService) *Handler
NewHandler creates a new job handler.
func (*Handler) Cancel ¶
func (h *Handler) Cancel(w http.ResponseWriter, r *http.Request)
Cancel handles DELETE /api/v1/jobs/{id}
func (*Handler) CreateRecurring ¶
func (h *Handler) CreateRecurring(w http.ResponseWriter, r *http.Request)
CreateRecurring handles POST /api/v1/jobs/recurring
func (*Handler) GetStats ¶
func (h *Handler) GetStats(w http.ResponseWriter, r *http.Request)
GetStats handles GET /api/v1/jobs/stats
func (*Handler) GetStatus ¶
func (h *Handler) GetStatus(w http.ResponseWriter, r *http.Request)
GetStatus handles GET /api/v1/jobs/{id}
func (*Handler) List ¶
func (h *Handler) List(w http.ResponseWriter, r *http.Request)
List handles GET /api/v1/jobs
func (*Handler) RegisterRoutes ¶
RegisterRoutes registers job API routes on the given router.
type JobResponse ¶
type JobResponse struct {
ID string `json:"id"`
}
JobResponse represents a job response.
type ListResponse ¶
type ListResponse struct {
Jobs []repository.Job `json:"jobs"`
Total int64 `json:"total"`
Limit int `json:"limit"`
Offset int `json:"offset"`
}
ListResponse represents a paginated list of jobs.
type RecurringRequest ¶
type RecurringRequest struct {
SubmitRequest
CronSpec string `json:"cron_spec" validate:"required"`
}
RecurringRequest represents a recurring job creation request.
type ScheduleRequest ¶
type ScheduleRequest struct {
SubmitRequest
ScheduleAt string `json:"schedule_at" validate:"required"` // RFC3339 format
}
ScheduleRequest represents a job scheduling request.
type StatsResponse ¶
type StatsResponse struct {
Queues map[string]service.QueueStats `json:"queues"`
}
StatsResponse represents queue statistics response.
type SubmitRequest ¶
type SubmitRequest struct {
TaskType string `json:"task_type" validate:"required"`
Payload any `json:"payload"`
Queue string `json:"queue,omitempty"`
MaxRetries int `json:"max_retries,omitempty"`
Timeout string `json:"timeout,omitempty"` // e.g., "5m", "1h"
Metadata map[string]any `json:"metadata,omitempty"`
}
SubmitRequest represents a job submission request.