transport

package
v0.0.0-...-f691fa7 Latest Latest
Warning

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

Go to latest
Published: May 27, 2022 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChangeStatusRequest

type ChangeStatusRequest struct {
	ID     string `json:"id"`
	Status string `json:"status"`
}

ChangeStatusRequest holds the request parameters for the ChangeStatus method.

type ChangeStatusResponse

type ChangeStatusResponse struct {
	Err error `json:"error,omitempty"`
}

ChangeStatusResponse holds the response values for the ChangeStatus method.

func (ChangeStatusResponse) Error

func (r ChangeStatusResponse) Error() error

func (ChangeStatusResponse) Failed

func (r ChangeStatusResponse) Failed() error

Failed implements Failer

type CreateRequest

type CreateRequest struct {
	Order order.Order
}

CreateRequest holds the request parameters for the Create method.

type CreateResponse

type CreateResponse struct {
	ID  string `json:"id"`
	Err error  `json:"error,omitempty"`
}

CreateResponse holds the response values for the Create method.

func (CreateResponse) Error

func (r CreateResponse) Error() error

We have two options to return errors from the business logic.

We could return the error via the endpoint itself. That makes certain things a little bit easier, like providing non-200 HTTP responses to the client. But Go kit assumes that endpoint errors are (or may be treated as) transport-domain errors. For example, an endpoint error will count against a circuit breaker error count.

Therefore, it's often better to return service (business logic) errors in the response object. This means we have to do a bit more work in the HTTP response encoder to detect e.g. a not-found error and provide a proper HTTP status code. That work is done with the Errorer interface, in transport.go. Response types that may contain business-logic errors implement that interface.

func (CreateResponse) Failed

func (r CreateResponse) Failed() error

Failed implements Failer

type Endpoints

type Endpoints struct {
	Create       endpoint.Endpoint
	GetByID      endpoint.Endpoint
	ChangeStatus endpoint.Endpoint
}

Endpoints holds all Go kit endpoints for the Order service. It's meant to be used as a helper struct, to collect all of the endpoints into a single parameter.

func MakeEndpoints

func MakeEndpoints(s order.Service) Endpoints

MakeEndpoints initializes all Go kit endpoints for the Order service.

type GetByIDRequest

type GetByIDRequest struct {
	ID string
}

GetByIDRequest holds the request parameters for the GetByID method.

type GetByIDResponse

type GetByIDResponse struct {
	Order order.Order `json:"order"`
	Err   error       `json:"error,omitempty"`
}

GetByIDResponse holds the response values for the GetByID method.

func (GetByIDResponse) Error

func (r GetByIDResponse) Error() error

func (GetByIDResponse) Failed

func (r GetByIDResponse) Failed() error

Failed implements Failer

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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