endpoint

package
v0.0.0-...-3c3176f Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2017 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateInstrumentingMetric

func GenerateInstrumentingMetric() metrics.Histogram

GenerateInstrumentingMetric returns an endpoint-level metrics.

func InstrumentingMiddleware

func InstrumentingMiddleware(duration metrics.Histogram) endpoint.Middleware

InstrumentingMiddleware returns an endpoint middleware that records the duration of each invocation to the passed histogram. The middleware adds a single field: "success", which is "true" if no error is returned, and "false" otherwise.

func LoggingMiddleware

func LoggingMiddleware(logger log.Logger) endpoint.Middleware

LoggingMiddleware returns an endpoint middleware that logs the duration of each invocation, and the resulting error, if any.

func MakeConcatEndpoint

func MakeConcatEndpoint(s service.Service) endpoint.Endpoint

MakeConcatEndpoint constructs a Concat endpoint wrapping the service.

func MakeSumEndpoint

func MakeSumEndpoint(s service.Service) endpoint.Endpoint

MakeSumEndpoint constructs a Sum endpoint wrapping the service.

Types

type ConcatRequest

type ConcatRequest struct {
	A, B string
}

ConcatRequest collects the request parameters for the Concat method.

type ConcatResponse

type ConcatResponse struct {
	V   string `json:"v"`
	Err error  `json:"-"`
}

ConcatResponse collects the response values for the Concat method.

func (ConcatResponse) Failed

func (r ConcatResponse) Failed() error

Failed implements Failer.

type Failer

type Failer interface {
	Failed() error
}

Failer is an interface that should be implemented by response types. Response encoders can check if responses are Failer, and if so if they've failed, and if so encode them using a separate write path based on the error.

type Set

type Set struct {
	SumEndpoint    endpoint.Endpoint
	ConcatEndpoint endpoint.Endpoint
}

Set collects all of the endpoints that compose an add service. It's meant to be used as a helper struct, to collect all of the endpoints into a single parameter.

func New

func New(svc service.Service, logger log.Logger) Set

New returns a Set that wraps the provided server, and wires in all of the expected endpoint middlewares via the various parameters.

type SumRequest

type SumRequest struct {
	A, B int
}

SumRequest collects the request parameters for the Sum method.

type SumResponse

type SumResponse struct {
	V   int   `json:"v"`
	Err error `json:"-"` // should be intercepted by Failed/errorEncoder
}

SumResponse collects the response values for the Sum method.

func (SumResponse) Failed

func (r SumResponse) Failed() error

Failed implements Failer.

Jump to

Keyboard shortcuts

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