handler

package
v0.5.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var OpenAPISpec []byte

OpenAPISpec holds the embedded OpenAPI specification. This is set during initialization from the api/openapi.yaml file.

Functions

This section is empty.

Types

type APIHandler

type APIHandler struct {
	// contains filtered or unexported fields
}

APIHandler handles HTTP requests for the management API.

func NewAPIHandler

func NewAPIHandler(
	b broker.Broker,
	execRepo ExecutionRepository,
	dlqRepo DLQRepository,
	logger zerolog.Logger,
) *APIHandler

NewAPIHandler creates a new APIHandler.

func (*APIHandler) CreateJob

func (h *APIHandler) CreateJob(w http.ResponseWriter, r *http.Request)

CreateJob creates and enqueues a new job.

func (*APIHandler) DeleteDLQJob

func (h *APIHandler) DeleteDLQJob(w http.ResponseWriter, r *http.Request)

DeleteDLQJob removes a job from the DLQ.

func (*APIHandler) DeleteJob

func (h *APIHandler) DeleteJob(w http.ResponseWriter, r *http.Request)

DeleteJob cancels/deletes a job.

func (*APIHandler) GetDLQJob

func (h *APIHandler) GetDLQJob(w http.ResponseWriter, r *http.Request)

GetDLQJob retrieves a specific DLQ job.

func (*APIHandler) GetExecutions

func (h *APIHandler) GetExecutions(w http.ResponseWriter, r *http.Request)

GetExecutions returns execution history for a specific job.

func (*APIHandler) GetJob

func (h *APIHandler) GetJob(w http.ResponseWriter, r *http.Request)

GetJob retrieves a job by ID.

func (*APIHandler) GetQueueDepth

func (h *APIHandler) GetQueueDepth(w http.ResponseWriter, r *http.Request)

GetQueueDepth returns the depth of a specific queue.

func (*APIHandler) GetStats

func (h *APIHandler) GetStats(w http.ResponseWriter, r *http.Request)

GetStats returns overall statistics.

func (*APIHandler) Health

func (h *APIHandler) Health(w http.ResponseWriter, r *http.Request)

Health returns a simple health check response.

func (*APIHandler) ListDLQ

func (h *APIHandler) ListDLQ(w http.ResponseWriter, r *http.Request)

ListDLQ returns jobs in the dead letter queue.

func (*APIHandler) ListExecutions

func (h *APIHandler) ListExecutions(w http.ResponseWriter, r *http.Request)

ListExecutions returns job execution history.

func (*APIHandler) ListQueues

func (h *APIHandler) ListQueues(w http.ResponseWriter, r *http.Request)

ListQueues returns all queues with their depths.

func (*APIHandler) OpenAPISpec

func (h *APIHandler) OpenAPISpec(w http.ResponseWriter, r *http.Request)

OpenAPISpec serves the OpenAPI specification.

func (*APIHandler) Ready

func (h *APIHandler) Ready(w http.ResponseWriter, r *http.Request)

Ready checks if all dependencies are ready.

func (*APIHandler) RegisterRoutes

func (h *APIHandler) RegisterRoutes(mux *http.ServeMux)

RegisterRoutes registers all API routes.

func (*APIHandler) RetryDLQJob

func (h *APIHandler) RetryDLQJob(w http.ResponseWriter, r *http.Request)

RetryDLQJob moves a job from DLQ back to the queue.

type CreateJobRequest

type CreateJobRequest struct {
	Type        string            `json:"type"`
	Payload     json.RawMessage   `json:"payload"`
	Queue       string            `json:"queue,omitempty"`
	Priority    string            `json:"priority,omitempty"`
	MaxRetries  int               `json:"max_retries,omitempty"`
	Timeout     string            `json:"timeout,omitempty"`
	ScheduledAt *time.Time        `json:"scheduled_at,omitempty"`
	Delay       string            `json:"delay,omitempty"`
	Metadata    map[string]string `json:"metadata,omitempty"`
}

CreateJobRequest is the request body for creating a job.

type DLQRepository added in v0.5.0

type DLQRepository interface {
	List(ctx context.Context, filter repository.DLQFilter) ([]*repository.DeadLetterJob, error)
	GetByID(ctx context.Context, id string) (*repository.DeadLetterJob, error)
	MarkRequeued(ctx context.Context, id string) error
	Delete(ctx context.Context, id string) error
	Count(ctx context.Context) (int64, error)
}

DLQRepository defines the interface for dead letter queue repository operations.

type ExecutionRepository added in v0.5.0

type ExecutionRepository interface {
	List(ctx context.Context, filter repository.ExecutionFilter) ([]*repository.JobExecution, error)
	GetByJobID(ctx context.Context, jobID string) ([]*repository.JobExecution, error)
	GetStats(ctx context.Context, fromDate, toDate time.Time) (*repository.ExecutionStats, error)
}

ExecutionRepository defines the interface for execution repository operations.

Jump to

Keyboard shortcuts

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