endpoints

package
v0.0.0-...-235258f Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2019 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

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 MakeFooEndpoint

func MakeFooEndpoint(svc service.FoosvcService) (ep endpoint.Endpoint)

MakeFooEndpoint returns an endpoint that invokes Foo on the service. Primarily useful in a server.

Types

type Endpoints

type Endpoints struct {
	FooEndpoint endpoint.Endpoint `json:""`
}

Endpoints collects all of the endpoints that compose the foosvc 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.FoosvcService, logger log.Logger, duration metrics.Histogram, otTracer stdopentracing.Tracer, zipkinTracer *stdzipkin.Tracer) (ep Endpoints)

New return a new instance of the endpoint that wraps the provided service.

func (Endpoints) Foo

func (e Endpoints) Foo(ctx context.Context, s string) (res string, err error)

Foo implements the service interface, so Endpoints may be used as a service. This is primarily useful in the context of a client library.

type FooRequest

type FooRequest struct {
	S string `json:"s"`
}

FooRequest collects the request parameters for the Foo method.

type FooResponse

type FooResponse struct {
	Res string `json:"res"`
	Err error  `json:"err"`
}

FooResponse collects the response values for the Foo method.

func (FooResponse) Headers

func (r FooResponse) Headers() http.Header

func (FooResponse) StatusCode

func (r FooResponse) StatusCode() int

type Request

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

Jump to

Keyboard shortcuts

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