server

package
v0.0.0-...-c0b5b33 Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2021 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddSpinBrokerPath

func AddSpinBrokerPath(id string) string

AddSpinBrokerPath returns the URL path to the spin-broker service add HTTP endpoint.

func CompleteSpinBrokerPath

func CompleteSpinBrokerPath() string

CompleteSpinBrokerPath returns the URL path to the spin-broker service complete HTTP endpoint.

func DecodeAddRequest

func DecodeAddRequest(mux goahttp.Muxer, decoder func(*http.Request) goahttp.Decoder) func(*http.Request) (interface{}, error)

DecodeAddRequest returns a decoder for requests sent to the spin-broker add endpoint.

func DecodeCompleteRequest

func DecodeCompleteRequest(mux goahttp.Muxer, decoder func(*http.Request) goahttp.Decoder) func(*http.Request) (interface{}, error)

DecodeCompleteRequest returns a decoder for requests sent to the spin-broker complete endpoint.

func DecodeEnqueueRequest

func DecodeEnqueueRequest(mux goahttp.Muxer, decoder func(*http.Request) goahttp.Decoder) func(*http.Request) (interface{}, error)

DecodeEnqueueRequest returns a decoder for requests sent to the spin-broker enqueue endpoint.

func DecodeNextRequest

func DecodeNextRequest(mux goahttp.Muxer, decoder func(*http.Request) goahttp.Decoder) func(*http.Request) (interface{}, error)

DecodeNextRequest returns a decoder for requests sent to the spin-broker next endpoint.

func DecodeStatusRequest

func DecodeStatusRequest(mux goahttp.Muxer, decoder func(*http.Request) goahttp.Decoder) func(*http.Request) (interface{}, error)

DecodeStatusRequest returns a decoder for requests sent to the spin-broker status endpoint.

func EncodeAddResponse

func EncodeAddResponse(encoder func(context.Context, http.ResponseWriter) goahttp.Encoder) func(context.Context, http.ResponseWriter, interface{}) error

EncodeAddResponse returns an encoder for responses returned by the spin-broker add endpoint.

func EncodeCompleteResponse

func EncodeCompleteResponse(encoder func(context.Context, http.ResponseWriter) goahttp.Encoder) func(context.Context, http.ResponseWriter, interface{}) error

EncodeCompleteResponse returns an encoder for responses returned by the spin-broker complete endpoint.

func EncodeEnqueueResponse

func EncodeEnqueueResponse(encoder func(context.Context, http.ResponseWriter) goahttp.Encoder) func(context.Context, http.ResponseWriter, interface{}) error

EncodeEnqueueResponse returns an encoder for responses returned by the spin-broker enqueue endpoint.

func EncodeNewResponse

func EncodeNewResponse(encoder func(context.Context, http.ResponseWriter) goahttp.Encoder) func(context.Context, http.ResponseWriter, interface{}) error

EncodeNewResponse returns an encoder for responses returned by the spin-broker new endpoint.

func EncodeNextError

func EncodeNextError(encoder func(context.Context, http.ResponseWriter) goahttp.Encoder, formatter func(err error) goahttp.Statuser) func(context.Context, http.ResponseWriter, error) error

EncodeNextError returns an encoder for errors returned by the next spin-broker endpoint.

func EncodeNextResponse

func EncodeNextResponse(encoder func(context.Context, http.ResponseWriter) goahttp.Encoder) func(context.Context, http.ResponseWriter, interface{}) error

EncodeNextResponse returns an encoder for responses returned by the spin-broker next endpoint.

func EncodeStatusError

func EncodeStatusError(encoder func(context.Context, http.ResponseWriter) goahttp.Encoder, formatter func(err error) goahttp.Statuser) func(context.Context, http.ResponseWriter, error) error

EncodeStatusError returns an encoder for errors returned by the status spin-broker endpoint.

func EncodeStatusResponse

func EncodeStatusResponse(encoder func(context.Context, http.ResponseWriter) goahttp.Encoder) func(context.Context, http.ResponseWriter, interface{}) error

EncodeStatusResponse returns an encoder for responses returned by the spin-broker status endpoint.

func EnqueueSpinBrokerPath

func EnqueueSpinBrokerPath(id string) string

EnqueueSpinBrokerPath returns the URL path to the spin-broker service enqueue HTTP endpoint.

func Mount

func Mount(mux goahttp.Muxer, h *Server)

Mount configures the mux to serve the spin-broker endpoints.

func MountAddHandler

func MountAddHandler(mux goahttp.Muxer, h http.Handler)

MountAddHandler configures the mux to serve the "spin-broker" service "add" endpoint.

func MountCompleteHandler

func MountCompleteHandler(mux goahttp.Muxer, h http.Handler)

MountCompleteHandler configures the mux to serve the "spin-broker" service "complete" endpoint.

func MountEnqueueHandler

func MountEnqueueHandler(mux goahttp.Muxer, h http.Handler)

MountEnqueueHandler configures the mux to serve the "spin-broker" service "enqueue" endpoint.

func MountNewHandler

func MountNewHandler(mux goahttp.Muxer, h http.Handler)

MountNewHandler configures the mux to serve the "spin-broker" service "new" endpoint.

func MountNextHandler

func MountNextHandler(mux goahttp.Muxer, h http.Handler)

MountNextHandler configures the mux to serve the "spin-broker" service "next" endpoint.

func MountStatusHandler

func MountStatusHandler(mux goahttp.Muxer, h http.Handler)

MountStatusHandler configures the mux to serve the "spin-broker" service "status" endpoint.

func NewAddHandler

func NewAddHandler(
	endpoint goa.Endpoint,
	mux goahttp.Muxer,
	decoder func(*http.Request) goahttp.Decoder,
	encoder func(context.Context, http.ResponseWriter) goahttp.Encoder,
	errhandler func(context.Context, http.ResponseWriter, error),
	formatter func(err error) goahttp.Statuser,
) http.Handler

NewAddHandler creates a HTTP handler which loads the HTTP request and calls the "spin-broker" service "add" endpoint.

func NewAddPayload

func NewAddPayload(body *AddRequestBody, id string) *spinbroker.AddPayload

NewAddPayload builds a spin-broker service add endpoint payload.

func NewCompleteHandler

func NewCompleteHandler(
	endpoint goa.Endpoint,
	mux goahttp.Muxer,
	decoder func(*http.Request) goahttp.Decoder,
	encoder func(context.Context, http.ResponseWriter) goahttp.Encoder,
	errhandler func(context.Context, http.ResponseWriter, error),
	formatter func(err error) goahttp.Statuser,
) http.Handler

NewCompleteHandler creates a HTTP handler which loads the HTTP request and calls the "spin-broker" service "complete" endpoint.

func NewCompletePayload

func NewCompletePayload(body *CompleteRequestBody) *spinbroker.CompletePayload

NewCompletePayload builds a spin-broker service complete endpoint payload.

func NewEnqueueHandler

func NewEnqueueHandler(
	endpoint goa.Endpoint,
	mux goahttp.Muxer,
	decoder func(*http.Request) goahttp.Decoder,
	encoder func(context.Context, http.ResponseWriter) goahttp.Encoder,
	errhandler func(context.Context, http.ResponseWriter, error),
	formatter func(err error) goahttp.Statuser,
) http.Handler

NewEnqueueHandler creates a HTTP handler which loads the HTTP request and calls the "spin-broker" service "enqueue" endpoint.

func NewEnqueuePayload

func NewEnqueuePayload(id string) *spinbroker.EnqueuePayload

NewEnqueuePayload builds a spin-broker service enqueue endpoint payload.

func NewNewHandler

func NewNewHandler(
	endpoint goa.Endpoint,
	mux goahttp.Muxer,
	decoder func(*http.Request) goahttp.Decoder,
	encoder func(context.Context, http.ResponseWriter) goahttp.Encoder,
	errhandler func(context.Context, http.ResponseWriter, error),
	formatter func(err error) goahttp.Statuser,
) http.Handler

NewNewHandler creates a HTTP handler which loads the HTTP request and calls the "spin-broker" service "new" endpoint.

func NewNextHandler

func NewNextHandler(
	endpoint goa.Endpoint,
	mux goahttp.Muxer,
	decoder func(*http.Request) goahttp.Decoder,
	encoder func(context.Context, http.ResponseWriter) goahttp.Encoder,
	errhandler func(context.Context, http.ResponseWriter, error),
	formatter func(err error) goahttp.Statuser,
) http.Handler

NewNextHandler creates a HTTP handler which loads the HTTP request and calls the "spin-broker" service "next" endpoint.

func NewNextPayload

func NewNextPayload(resource string) *spinbroker.NextPayload

NewNextPayload builds a spin-broker service next endpoint payload.

func NewSpinBrokerPath

func NewSpinBrokerPath() string

NewSpinBrokerPath returns the URL path to the spin-broker service new HTTP endpoint.

func NewStatusHandler

func NewStatusHandler(
	endpoint goa.Endpoint,
	mux goahttp.Muxer,
	decoder func(*http.Request) goahttp.Decoder,
	encoder func(context.Context, http.ResponseWriter) goahttp.Encoder,
	errhandler func(context.Context, http.ResponseWriter, error),
	formatter func(err error) goahttp.Statuser,
) http.Handler

NewStatusHandler creates a HTTP handler which loads the HTTP request and calls the "spin-broker" service "status" endpoint.

func NewStatusPayload

func NewStatusPayload(id string) *spinbroker.StatusPayload

NewStatusPayload builds a spin-broker service status endpoint payload.

func NextSpinBrokerPath

func NextSpinBrokerPath(resource string) string

NextSpinBrokerPath returns the URL path to the spin-broker service next HTTP endpoint.

func StatusSpinBrokerPath

func StatusSpinBrokerPath(id string) string

StatusSpinBrokerPath returns the URL path to the spin-broker service status HTTP endpoint.

func ValidateAddRequestBody

func ValidateAddRequestBody(body *AddRequestBody) (err error)

ValidateAddRequestBody runs the validations defined on AddRequestBody

func ValidateCompleteRequestBody

func ValidateCompleteRequestBody(body *CompleteRequestBody) (err error)

ValidateCompleteRequestBody runs the validations defined on CompleteRequestBody

Types

type AddRequestBody

type AddRequestBody struct {
	// Resource name
	Resource *string `form:"resource,omitempty" json:"resource,omitempty" xml:"resource,omitempty"`
	// Action name
	Action *string `form:"action,omitempty" json:"action,omitempty" xml:"action,omitempty"`
	// Action parameters
	Parameters map[string]interface{} `form:"parameters,omitempty" json:"parameters,omitempty" xml:"parameters,omitempty"`
	// Dependency UUIDs
	Dependencies []string `form:"dependencies,omitempty" json:"dependencies,omitempty" xml:"dependencies,omitempty"`
}

AddRequestBody is the type of the "spin-broker" service "add" endpoint HTTP request body.

type CompleteRequestBody

type CompleteRequestBody struct {
	// Command ID
	ID *string `form:"id,omitempty" json:"id,omitempty" xml:"id,omitempty"`
	// status of work
	Status *bool `form:"status,omitempty" json:"status,omitempty" xml:"status,omitempty"`
	// reason of success/failure
	StatusReason *string `form:"status_reason,omitempty" json:"status_reason,omitempty" xml:"status_reason,omitempty"`
}

CompleteRequestBody is the type of the "spin-broker" service "complete" endpoint HTTP request body.

type ErrorNamer

type ErrorNamer interface {
	ErrorName() string
}

ErrorNamer is an interface implemented by generated error structs that exposes the name of the error as defined in the design.

type MountPoint

type MountPoint struct {
	// Method is the name of the service method served by the mounted HTTP handler.
	Method string
	// Verb is the HTTP method used to match requests to the mounted handler.
	Verb string
	// Pattern is the HTTP request path pattern used to match requests to the
	// mounted handler.
	Pattern string
}

MountPoint holds information about the mounted endpoints.

type NextRecordNotFoundResponseBody

type NextRecordNotFoundResponseBody struct {
	// Name is the name of this class of errors.
	Name string `form:"name" json:"name" xml:"name"`
	// ID is a unique identifier for this particular occurrence of the problem.
	ID string `form:"id" json:"id" xml:"id"`
	// Message is a human-readable explanation specific to this occurrence of the
	// problem.
	Message string `form:"message" json:"message" xml:"message"`
	// Is the error temporary?
	Temporary bool `form:"temporary" json:"temporary" xml:"temporary"`
	// Is the error a timeout?
	Timeout bool `form:"timeout" json:"timeout" xml:"timeout"`
	// Is the error a server-side fault?
	Fault bool `form:"fault" json:"fault" xml:"fault"`
}

NextRecordNotFoundResponseBody is the type of the "spin-broker" service "next" endpoint HTTP response body for the "record_not_found" error.

func NewNextRecordNotFoundResponseBody

func NewNextRecordNotFoundResponseBody(res *goa.ServiceError) *NextRecordNotFoundResponseBody

NewNextRecordNotFoundResponseBody builds the HTTP response body from the result of the "next" endpoint of the "spin-broker" service.

type NextResponseBody

type NextResponseBody struct {
	// Command ID
	UUID string `form:"uuid" json:"uuid" xml:"uuid"`
	// resource type
	Resource string `form:"resource" json:"resource" xml:"resource"`
	// action name
	Action string `form:"action" json:"action" xml:"action"`
	// Action parameters
	Parameters map[string]json.RawMessage `form:"parameters,omitempty" json:"parameters,omitempty" xml:"parameters,omitempty"`
}

NextResponseBody is the type of the "spin-broker" service "next" endpoint HTTP response body.

func NewNextResponseBody

func NewNextResponseBody(res *spinbroker.NextResult) *NextResponseBody

NewNextResponseBody builds the HTTP response body from the result of the "next" endpoint of the "spin-broker" service.

type Server

type Server struct {
	Mounts   []*MountPoint
	New      http.Handler
	Add      http.Handler
	Enqueue  http.Handler
	Status   http.Handler
	Next     http.Handler
	Complete http.Handler
}

Server lists the spin-broker service endpoint HTTP handlers.

func New

func New(
	e *spinbroker.Endpoints,
	mux goahttp.Muxer,
	decoder func(*http.Request) goahttp.Decoder,
	encoder func(context.Context, http.ResponseWriter) goahttp.Encoder,
	errhandler func(context.Context, http.ResponseWriter, error),
	formatter func(err error) goahttp.Statuser,
) *Server

New instantiates HTTP handlers for all the spin-broker service endpoints using the provided encoder and decoder. The handlers are mounted on the given mux using the HTTP verb and path defined in the design. errhandler is called whenever a response fails to be encoded. formatter is used to format errors returned by the service methods prior to encoding. Both errhandler and formatter are optional and can be nil.

func (*Server) Service

func (s *Server) Service() string

Service returns the name of the service served.

func (*Server) Use

func (s *Server) Use(m func(http.Handler) http.Handler)

Use wraps the server handlers with the given middleware.

type StatusRecordNotFoundResponseBody

type StatusRecordNotFoundResponseBody struct {
	// Name is the name of this class of errors.
	Name string `form:"name" json:"name" xml:"name"`
	// ID is a unique identifier for this particular occurrence of the problem.
	ID string `form:"id" json:"id" xml:"id"`
	// Message is a human-readable explanation specific to this occurrence of the
	// problem.
	Message string `form:"message" json:"message" xml:"message"`
	// Is the error temporary?
	Temporary bool `form:"temporary" json:"temporary" xml:"temporary"`
	// Is the error a timeout?
	Timeout bool `form:"timeout" json:"timeout" xml:"timeout"`
	// Is the error a server-side fault?
	Fault bool `form:"fault" json:"fault" xml:"fault"`
}

StatusRecordNotFoundResponseBody is the type of the "spin-broker" service "status" endpoint HTTP response body for the "record_not_found" error.

func NewStatusRecordNotFoundResponseBody

func NewStatusRecordNotFoundResponseBody(res *goa.ServiceError) *StatusRecordNotFoundResponseBody

NewStatusRecordNotFoundResponseBody builds the HTTP response body from the result of the "status" endpoint of the "spin-broker" service.

type StatusResponseBody

type StatusResponseBody struct {
	// Pass/Fail status
	Status bool `form:"status" json:"status" xml:"status"`
	// Failure reason (if any)
	Reason *string `form:"reason,omitempty" json:"reason,omitempty" xml:"reason,omitempty"`
	// Failure causer as UUID (if any)
	Causer *string `form:"causer,omitempty" json:"causer,omitempty" xml:"causer,omitempty"`
}

StatusResponseBody is the type of the "spin-broker" service "status" endpoint HTTP response body.

func NewStatusResponseBody

func NewStatusResponseBody(res *spinbroker.StatusResult) *StatusResponseBody

NewStatusResponseBody builds the HTTP response body from the result of the "status" endpoint of the "spin-broker" service.

Jump to

Keyboard shortcuts

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