http

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package http provides primitives to interact with the openapi HTTP API.

Code generated by github.com/oapi-codegen/oapi-codegen/v2 version v2.7.2 DO NOT EDIT.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Handler added in v0.3.2

func Handler(si ServerInterface) http.Handler

Handler creates http.Handler with routing matching OpenAPI spec.

func HandlerFromMux added in v0.3.2

func HandlerFromMux(si ServerInterface, m ServeMux) http.Handler

HandlerFromMux creates http.Handler with routing matching OpenAPI spec based on the provided mux.

func HandlerFromMuxWithBaseURL added in v0.3.2

func HandlerFromMuxWithBaseURL(si ServerInterface, m ServeMux, baseURL string) http.Handler

func HandlerWithOptions added in v0.3.2

func HandlerWithOptions(si ServerInterface, options StdHTTPServerOptions) http.Handler

HandlerWithOptions creates http.Handler with additional options

func NewServer

func NewServer(opts *ServerOptions) http.Handler

NewServer creates new http server that manages work queues.

Types

type BadRequest added in v0.3.2

type BadRequest = Error

BadRequest defines model for BadRequest.

type BadRequestJSONResponse added in v0.3.2

type BadRequestJSONResponse Error

type CreateJob200JSONResponse added in v0.3.2

type CreateJob200JSONResponse JobResponse

func (CreateJob200JSONResponse) VisitCreateJobResponse added in v0.3.2

func (response CreateJob200JSONResponse) VisitCreateJobResponse(w http.ResponseWriter) error

type CreateJob400JSONResponse added in v0.3.2

type CreateJob400JSONResponse struct{ BadRequestJSONResponse }

func (CreateJob400JSONResponse) VisitCreateJobResponse added in v0.3.2

func (response CreateJob400JSONResponse) VisitCreateJobResponse(w http.ResponseWriter) error

type CreateJob500JSONResponse added in v0.3.2

type CreateJob500JSONResponse struct{ ErrorJSONResponse }

func (CreateJob500JSONResponse) VisitCreateJobResponse added in v0.3.2

func (response CreateJob500JSONResponse) VisitCreateJobResponse(w http.ResponseWriter) error

type CreateJobJSONRequestBody added in v0.3.2

type CreateJobJSONRequestBody = CreateJobRequest

CreateJobJSONRequestBody defines body for CreateJob for application/json ContentType.

type CreateJobRequest added in v0.3.2

type CreateJobRequest struct {
	// Delay Optional delay before the job becomes ready, as a Go duration string (e.g. "10s", "1m30s").
	Delay duration `json:"delay,omitempty"`

	// ID Optional job id. If set and already present, the existing job is returned instead of enqueuing a duplicate.
	ID string `json:"id,omitempty"`

	// Namespace Queue namespace.
	Namespace string `json:"namespace"`

	// Payload Opaque job payload as base64-encoded bytes.
	Payload []byte `json:"payload,omitempty"`

	// QueueID Queue id within the namespace.
	QueueID string `json:"queue_id"`
}

CreateJobRequest defines model for CreateJobRequest.

type CreateJobRequestObject added in v0.3.2

type CreateJobRequestObject struct {
	Body *CreateJobJSONRequestBody
}

type CreateJobResponseObject added in v0.3.2

type CreateJobResponseObject interface {
	VisitCreateJobResponse(w http.ResponseWriter) error
}

type DeleteJob200JSONResponse added in v0.3.2

type DeleteJob200JSONResponse JobResponse

func (DeleteJob200JSONResponse) VisitDeleteJobResponse added in v0.3.2

func (response DeleteJob200JSONResponse) VisitDeleteJobResponse(w http.ResponseWriter) error

type DeleteJob400JSONResponse added in v0.3.2

type DeleteJob400JSONResponse struct{ BadRequestJSONResponse }

func (DeleteJob400JSONResponse) VisitDeleteJobResponse added in v0.3.2

func (response DeleteJob400JSONResponse) VisitDeleteJobResponse(w http.ResponseWriter) error

type DeleteJob404Response added in v0.3.2

type DeleteJob404Response = NotSupportedResponse

func (DeleteJob404Response) VisitDeleteJobResponse added in v0.3.2

func (response DeleteJob404Response) VisitDeleteJobResponse(w http.ResponseWriter) error

type DeleteJob500JSONResponse added in v0.3.2

type DeleteJob500JSONResponse struct{ ErrorJSONResponse }

func (DeleteJob500JSONResponse) VisitDeleteJobResponse added in v0.3.2

func (response DeleteJob500JSONResponse) VisitDeleteJobResponse(w http.ResponseWriter) error

type DeleteJobParams added in v0.3.2

type DeleteJobParams struct {
	// Namespace Queue namespace.
	Namespace Namespace `form:"namespace" json:"namespace"`

	// QueueID Queue id within the namespace.
	QueueID QueueID `form:"queue_id" json:"queue_id"`

	// JobID Job id.
	JobID JobID `form:"job_id" json:"job_id"`
}

DeleteJobParams defines parameters for DeleteJob.

type DeleteJobRequestObject added in v0.3.2

type DeleteJobRequestObject struct {
	Params DeleteJobParams
}

type DeleteJobResponseObject added in v0.3.2

type DeleteJobResponseObject interface {
	VisitDeleteJobResponse(w http.ResponseWriter) error
}

type Error added in v0.3.2

type Error struct {
	Error string `json:"error"`
}

Error defines model for Error.

type ErrorJSONResponse added in v0.3.2

type ErrorJSONResponse Error

type GetJob200JSONResponse added in v0.3.2

type GetJob200JSONResponse JobStatusResponse

func (GetJob200JSONResponse) VisitGetJobResponse added in v0.3.2

func (response GetJob200JSONResponse) VisitGetJobResponse(w http.ResponseWriter) error

type GetJob400JSONResponse added in v0.3.2

type GetJob400JSONResponse struct{ BadRequestJSONResponse }

func (GetJob400JSONResponse) VisitGetJobResponse added in v0.3.2

func (response GetJob400JSONResponse) VisitGetJobResponse(w http.ResponseWriter) error

type GetJob404Response added in v0.3.2

type GetJob404Response = NotSupportedResponse

func (GetJob404Response) VisitGetJobResponse added in v0.3.2

func (response GetJob404Response) VisitGetJobResponse(w http.ResponseWriter) error

type GetJob500JSONResponse added in v0.3.2

type GetJob500JSONResponse struct{ ErrorJSONResponse }

func (GetJob500JSONResponse) VisitGetJobResponse added in v0.3.2

func (response GetJob500JSONResponse) VisitGetJobResponse(w http.ResponseWriter) error

type GetJobParams added in v0.3.2

type GetJobParams struct {
	// Namespace Queue namespace.
	Namespace Namespace `form:"namespace" json:"namespace"`

	// JobID Job id.
	JobID JobID `form:"job_id" json:"job_id"`
}

GetJobParams defines parameters for GetJob.

type GetJobRequestObject added in v0.3.2

type GetJobRequestObject struct {
	Params GetJobParams
}

type GetJobResponseObject added in v0.3.2

type GetJobResponseObject interface {
	VisitGetJobResponse(w http.ResponseWriter) error
}

type GetMetrics200JSONResponse added in v0.3.2

type GetMetrics200JSONResponse QueueMetricsResponse

func (GetMetrics200JSONResponse) VisitGetMetricsResponse added in v0.3.2

func (response GetMetrics200JSONResponse) VisitGetMetricsResponse(w http.ResponseWriter) error

type GetMetrics400JSONResponse added in v0.3.2

type GetMetrics400JSONResponse struct{ BadRequestJSONResponse }

func (GetMetrics400JSONResponse) VisitGetMetricsResponse added in v0.3.2

func (response GetMetrics400JSONResponse) VisitGetMetricsResponse(w http.ResponseWriter) error

type GetMetrics404Response added in v0.3.2

type GetMetrics404Response = NotSupportedResponse

func (GetMetrics404Response) VisitGetMetricsResponse added in v0.3.2

func (response GetMetrics404Response) VisitGetMetricsResponse(w http.ResponseWriter) error

type GetMetrics500JSONResponse added in v0.3.2

type GetMetrics500JSONResponse struct{ ErrorJSONResponse }

func (GetMetrics500JSONResponse) VisitGetMetricsResponse added in v0.3.2

func (response GetMetrics500JSONResponse) VisitGetMetricsResponse(w http.ResponseWriter) error

type GetMetricsParams added in v0.3.2

type GetMetricsParams struct {
	// Namespace Queue namespace.
	Namespace Namespace `form:"namespace" json:"namespace"`

	// QueueID Queue id within the namespace.
	QueueID QueueID `form:"queue_id" json:"queue_id"`
}

GetMetricsParams defines parameters for GetMetrics.

type GetMetricsRequestObject added in v0.3.2

type GetMetricsRequestObject struct {
	Params GetMetricsParams
}

type GetMetricsResponseObject added in v0.3.2

type GetMetricsResponseObject interface {
	VisitGetMetricsResponse(w http.ResponseWriter) error
}

type InvalidParamFormatError added in v0.3.2

type InvalidParamFormatError struct {
	ParamName string
	Err       error
}

func (*InvalidParamFormatError) Error added in v0.3.2

func (e *InvalidParamFormatError) Error() string

func (*InvalidParamFormatError) Unwrap added in v0.3.2

func (e *InvalidParamFormatError) Unwrap() error

type Job added in v0.3.2

type Job struct {
	// CreatedAt When the job was first created.
	CreatedAt time.Time `json:"created_at"`

	// EnqueuedAt When the job will be executed next.
	EnqueuedAt time.Time `json:"enqueued_at"`

	// ID Unique id of the job.
	ID string `json:"id"`

	// LastError Error string from the most recent failure, if any.
	LastError string `json:"last_error"`

	// Payload Opaque job payload as base64-encoded bytes; null when empty.
	Payload *[]byte `json:"payload"`

	// Retries Number of times the job has failed and been retried.
	Retries int64 `json:"retries"`

	// UpdatedAt When the job was last executed.
	UpdatedAt time.Time `json:"updated_at"`
}

Job defines model for Job.

type JobID added in v0.3.2

type JobID = string

JobID defines model for JobID.

type JobResponse added in v0.3.2

type JobResponse struct {
	Job       Job    `json:"job"`
	Namespace string `json:"namespace"`
	QueueID   string `json:"queue_id"`
}

JobResponse defines model for JobResponse.

type JobStatus added in v0.3.2

type JobStatus string

JobStatus Derived from EnqueuedAt — `completed` when unset, `scheduled` when in the future, `ready` when due.

const (
	Completed JobStatus = "completed"
	Ready     JobStatus = "ready"
	Scheduled JobStatus = "scheduled"
)

Defines values for JobStatus.

func (JobStatus) Valid added in v0.3.2

func (e JobStatus) Valid() bool

Valid indicates whether the value is a known member of the JobStatus enum.

type JobStatusResponse added in v0.3.2

type JobStatusResponse struct {
	Job       Job    `json:"job"`
	Namespace string `json:"namespace"`

	// Status Derived from EnqueuedAt — `completed` when unset, `scheduled` when in the future, `ready` when due.
	Status JobStatus `json:"status"`
}

JobStatusResponse defines model for JobStatusResponse.

type MiddlewareFunc added in v0.3.2

type MiddlewareFunc func(http.Handler) http.Handler

type Namespace added in v0.3.2

type Namespace = string

Namespace defines model for Namespace.

type NotSupportedResponse added in v0.3.2

type NotSupportedResponse struct {
}

type QueueID added in v0.3.2

type QueueID = string

QueueID defines model for QueueID.

type QueueMetricsResponse added in v0.3.2

type QueueMetricsResponse struct {
	// Latency Processing delay from the oldest ready job, in nanoseconds.
	Latency   time.Duration `json:"latency"`
	Namespace string        `json:"namespace"`
	QueueID   string        `json:"queue_id"`

	// ReadyTotal Jobs that can be executed right now.
	ReadyTotal int64 `json:"ready_total"`

	// ScheduledTotal Jobs scheduled to run in the future.
	ScheduledTotal int64 `json:"scheduled_total"`

	// Total ready_total + scheduled_total.
	Total int64 `json:"total"`
}

QueueMetricsResponse defines model for QueueMetricsResponse.

type RequiredHeaderError added in v0.3.2

type RequiredHeaderError struct {
	ParamName string
	Err       error
}

func (*RequiredHeaderError) Error added in v0.3.2

func (e *RequiredHeaderError) Error() string

func (*RequiredHeaderError) Unwrap added in v0.3.2

func (e *RequiredHeaderError) Unwrap() error

type RequiredParamError added in v0.3.2

type RequiredParamError struct {
	ParamName string
}

func (*RequiredParamError) Error added in v0.3.2

func (e *RequiredParamError) Error() string

type ServeMux added in v0.3.2

type ServeMux interface {
	HandleFunc(pattern string, handler func(http.ResponseWriter, *http.Request))
	http.Handler
}

ServeMux is an abstraction of http.ServeMux.

type ServerInterface added in v0.3.2

type ServerInterface interface {
	// Delete a job
	// (DELETE /jobs)
	DeleteJob(w http.ResponseWriter, r *http.Request, params DeleteJobParams)
	// Get job status
	// (GET /jobs)
	GetJob(w http.ResponseWriter, r *http.Request, params GetJobParams)
	// Create (enqueue) a job
	// (POST /jobs)
	CreateJob(w http.ResponseWriter, r *http.Request)
	// Get queue metrics
	// (GET /metrics)
	GetMetrics(w http.ResponseWriter, r *http.Request, params GetMetricsParams)
}

ServerInterface represents all server handlers.

func NewStrictHandler added in v0.3.2

func NewStrictHandler(ssi StrictServerInterface, middlewares []StrictMiddlewareFunc) ServerInterface

func NewStrictHandlerWithOptions added in v0.3.2

func NewStrictHandlerWithOptions(ssi StrictServerInterface, middlewares []StrictMiddlewareFunc, options StrictHTTPServerOptions) ServerInterface

type ServerInterfaceWrapper added in v0.3.2

type ServerInterfaceWrapper struct {
	Handler            ServerInterface
	HandlerMiddlewares []MiddlewareFunc
	ErrorHandlerFunc   func(w http.ResponseWriter, r *http.Request, err error)
}

ServerInterfaceWrapper converts contexts to parameters.

func (*ServerInterfaceWrapper) CreateJob added in v0.3.2

func (siw *ServerInterfaceWrapper) CreateJob(w http.ResponseWriter, r *http.Request)

CreateJob operation middleware

func (*ServerInterfaceWrapper) DeleteJob added in v0.3.2

func (siw *ServerInterfaceWrapper) DeleteJob(w http.ResponseWriter, r *http.Request)

DeleteJob operation middleware

func (*ServerInterfaceWrapper) GetJob added in v0.3.2

GetJob operation middleware

func (*ServerInterfaceWrapper) GetMetrics added in v0.3.2

func (siw *ServerInterfaceWrapper) GetMetrics(w http.ResponseWriter, r *http.Request)

GetMetrics operation middleware

type ServerOptions

type ServerOptions struct {
	Queue work.Queue
}

ServerOptions specifies how http server can manage work queues. It implements the generated StrictServerInterface.

func (*ServerOptions) CreateJob added in v0.3.2

func (*ServerOptions) DeleteJob added in v0.3.2

func (*ServerOptions) GetJob added in v0.3.2

func (*ServerOptions) GetMetrics added in v0.3.2

type StdHTTPServerOptions added in v0.3.2

type StdHTTPServerOptions struct {
	BaseURL          string
	BaseRouter       ServeMux
	Middlewares      []MiddlewareFunc
	ErrorHandlerFunc func(w http.ResponseWriter, r *http.Request, err error)
}

type StrictHTTPServerOptions added in v0.3.2

type StrictHTTPServerOptions struct {
	RequestErrorHandlerFunc  func(w http.ResponseWriter, r *http.Request, err error)
	ResponseErrorHandlerFunc func(w http.ResponseWriter, r *http.Request, err error)
}

type StrictHandlerFunc added in v0.3.2

type StrictHandlerFunc func(ctx context.Context, w http.ResponseWriter, r *http.Request, request any) (any, error)

type StrictMiddlewareFunc added in v0.3.2

type StrictMiddlewareFunc func(f StrictHandlerFunc, operationID string) StrictHandlerFunc

type StrictServerInterface added in v0.3.2

type StrictServerInterface interface {
	// Delete a job
	// (DELETE /jobs)
	DeleteJob(ctx context.Context, request DeleteJobRequestObject) (DeleteJobResponseObject, error)
	// Get job status
	// (GET /jobs)
	GetJob(ctx context.Context, request GetJobRequestObject) (GetJobResponseObject, error)
	// Create (enqueue) a job
	// (POST /jobs)
	CreateJob(ctx context.Context, request CreateJobRequestObject) (CreateJobResponseObject, error)
	// Get queue metrics
	// (GET /metrics)
	GetMetrics(ctx context.Context, request GetMetricsRequestObject) (GetMetricsResponseObject, error)
}

StrictServerInterface represents all server handlers.

type TooManyValuesForParamError added in v0.3.2

type TooManyValuesForParamError struct {
	ParamName string
	Count     int
}

func (*TooManyValuesForParamError) Error added in v0.3.2

type UnescapedCookieParamError added in v0.3.2

type UnescapedCookieParamError struct {
	ParamName string
	Err       error
}

func (*UnescapedCookieParamError) Error added in v0.3.2

func (e *UnescapedCookieParamError) Error() string

func (*UnescapedCookieParamError) Unwrap added in v0.3.2

func (e *UnescapedCookieParamError) Unwrap() error

type UnmarshalingParamError added in v0.3.2

type UnmarshalingParamError struct {
	ParamName string
	Err       error
}

func (*UnmarshalingParamError) Error added in v0.3.2

func (e *UnmarshalingParamError) Error() string

func (*UnmarshalingParamError) Unwrap added in v0.3.2

func (e *UnmarshalingParamError) Unwrap() error

Jump to

Keyboard shortcuts

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