enqueue

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Enqueue201JSONResponse

type Enqueue201JSONResponse Response

Enqueue201JSONResponse renders an HTTP 201 success response. Marshals the underlying Response DTO as a JSON body.

type Enqueue400ErrorResponse

type Enqueue400ErrorResponse struct {
	Body errcode.Error
}

Enqueue400ErrorResponse renders an HTTP 400 error response. Body carries an errcode.Error whose Kind/Code/Message/Details follow the canonical wire schema in contracts/shared/errors/error-response-v1.schema.json (5xx Details are stripped by Error.MarshalJSON; Internal never serializes).

type Enqueue413ErrorResponse

type Enqueue413ErrorResponse struct {
	Body errcode.Error
}

Enqueue413ErrorResponse renders an HTTP 413 error response. Body carries an errcode.Error whose Kind/Code/Message/Details follow the canonical wire schema in contracts/shared/errors/error-response-v1.schema.json (5xx Details are stripped by Error.MarshalJSON; Internal never serializes).

type EnqueueResponseObject

type EnqueueResponseObject interface {
	// contains filtered or unexported methods
}

EnqueueResponseObject is the typed response envelope for http.device.command.enqueue.v1. Service.Enqueue must return one of the Enqueue{Status}{Suffix} structs declared below; the generated handler dispatches via the unexported method, which keeps the implementation set closed to types declared in this package.

ref: oapi-codegen pkg/codegen/templates/strict/strict-responses.tmpl@main

(buffer-then-commit pattern: encode to bytes.Buffer first so encode
 failures don't commit a half-written response status to wire)

type Handler

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

Handler wires HTTP decode/encode + auth.Mount for http.device.command.enqueue.v1.

func NewHandler

func NewHandler(svc Service, policy auth.Policy) *Handler

NewHandler creates a Handler for http.device.command.enqueue.v1.

func (*Handler) RegisterRoutes

func (h *Handler) RegisterRoutes(mux cell.RouteHandler) error

RegisterRoutes mounts the handler on mux via auth.Mount. Uses http.HandlerFunc(h.handle) so governance CH-04/CH-05 AST scans can resolve the handler function body via the Contract→Handler correlation.

func (*Handler) ServeHTTP

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

ServeHTTP implements http.Handler so *Handler can be used directly in tests and as an http.Handler argument without wrapping.

type Request

type Request struct {
	ID          string `json:"id"`
	CommandType string `json:"commandType,omitempty"`
	Payload     string `json:"payload"`
}

Request — http.device.command.enqueue.v1.request

type Response

type Response struct {
	Data *ResponseData `json:"data"`
}

Response — http.device.command.enqueue.v1.response

type ResponseData

type ResponseData struct {
	ID          string `json:"id"`
	DeviceID    string `json:"deviceId"`
	CommandType string `json:"commandType"`
	Payload     string `json:"payload"`
	Status      string `json:"status"`
	Attempt     int64  `json:"attempt"`
	// format: date-time
	CreatedAt string `json:"createdAt"`
	// format: date-time
	SentAt string `json:"sentAt,omitempty"`
	// format: date-time
	DeliveredAt string `json:"deliveredAt,omitempty"`
	// format: date-time
	CompletedAt string `json:"completedAt,omitempty"`
}

ResponseData is a generated DTO for contract http.device.command.enqueue.v1.

type Service

type Service interface {
	Enqueue(ctx context.Context, req *Request) (EnqueueResponseObject, error)
}

Service is the business interface that the http.device.command.enqueue.v1 server cell must implement.

The signature follows the typed-response-envelope strict-server pattern (PR-V1-CONTRACT-TYPED-RESPONSE-ENVELOPE):

  • The Service implementation returns one of the generated typed Enqueue{Status}{Suffix} structs (each implements EnqueueResponseObject declared in types_gen.go). CH-04 governance enforces that this typed-response set matches contract.yaml http.responses[] declaration exactly.
  • The Go error return is reserved for *un-declared* framework 5xx situations (panics, infrastructure faults). The generated handler falls back to httputil.WriteError(err) on this path, which derives the response status from errcode.Kind (or returns 500 for non-errcode errors). Business 4xx / 5xx must be returned as a typed struct.

ref: oapi-codegen pkg/codegen/templates/strict/strict-interface.tmpl@main

Jump to

Keyboard shortcuts

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