jobs

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 13, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package jobs provides HTTP handlers for job-related API endpoints.

Index

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

func (h *Handler) RegisterRoutes(r chi.Router)

RegisterRoutes registers job API routes on the given router.

func (*Handler) Schedule

func (h *Handler) Schedule(w http.ResponseWriter, r *http.Request)

Schedule handles POST /api/v1/jobs/schedule

func (*Handler) Submit

func (h *Handler) Submit(w http.ResponseWriter, r *http.Request)

Submit handles POST /api/v1/jobs

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL