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 MakeConcatEndpoint

func MakeConcatEndpoint(svc service.AddsvcService) (ep endpoint.Endpoint)

MakeConcatEndpoint returns an endpoint that invokes Concat on the service. Primarily useful in a server.

func MakeSumEndpoint

func MakeSumEndpoint(svc service.AddsvcService) (ep endpoint.Endpoint)

MakeSumEndpoint returns an endpoint that invokes Sum on the service. Primarily useful in a server.

Types

type ConcatRequest

type ConcatRequest struct {
	A string `json:"a"`
	B string `json:"b"`
}

ConcatRequest collects the request parameters for the Concat method.

type ConcatResponse

type ConcatResponse struct {
	Rs  string `json:"rs"`
	Err error  `json:"err"`
}

ConcatResponse collects the response values for the Concat method.

func (ConcatResponse) Headers

func (r ConcatResponse) Headers() http.Header

func (ConcatResponse) StatusCode

func (r ConcatResponse) StatusCode() int

type Endpoints

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

Endpoints collects all of the endpoints that compose the addsvc 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.AddsvcService, 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) Concat

func (e Endpoints) Concat(ctx context.Context, a string, b string) (rs string, err error)

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

func (Endpoints) Sum

func (e Endpoints) Sum(ctx context.Context, a int64, b int64) (rs int64, err error)

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

type Request

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

type SumRequest

type SumRequest struct {
	A int64 `json:"a"`
	B int64 `json:"b"`
}

SumRequest collects the request parameters for the Sum method.

type SumResponse

type SumResponse struct {
	Rs  int64 `json:"rs"`
	Err error `json:"err"`
}

SumResponse collects the response values for the Sum method.

func (SumResponse) Headers

func (r SumResponse) Headers() http.Header

func (SumResponse) StatusCode

func (r SumResponse) StatusCode() int

Jump to

Keyboard shortcuts

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