greeterendpoint

package
v0.0.0-...-cb8cfd3 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2022 License: MIT Imports: 5 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

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 MakeGreetingEndpoint

func MakeGreetingEndpoint(s greeterservice.Service) endpoint.Endpoint

MakeGreetingEndpoint constructs a Greeter endpoint wrapping the service.

func MakeHealthEndpoint

func MakeHealthEndpoint(s greeterservice.Service) endpoint.Endpoint

MakeHealthEndpoint constructs a Health endpoint wrapping the service.

Types

type Endpoints

type Endpoints struct {
	HealthEndpoint   endpoint.Endpoint // used by Consul for the healthcheck
	GreetingEndpoint endpoint.Endpoint
}

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

func MakeServerEndpoints

func MakeServerEndpoints(s greeterservice.Service, logger log.Logger) Endpoints

MakeServerEndpoints returns service Endoints, and wires in all the provided middlewares.

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 GreetingRequest

type GreetingRequest struct {
	Name string `json:"name,omitempty"`
}

GreetingRequest collects the request parameters for the Greeting method.

type GreetingResponse

type GreetingResponse struct {
	Greeting string `json:"greeting,omitempty"`
	Err      error  `json:"err,omitempty"`
}

GreetingResponse collects the response values for the Greeting method.

func (GreetingResponse) Failed

func (r GreetingResponse) Failed() error

Failed implements Failer.

type HealthRequest

type HealthRequest struct{}

HealthRequest collects the request parameters for the Health method.

type HealthResponse

type HealthResponse struct {
	Healthy bool  `json:"healthy,omitempty"`
	Err     error `json:"err,omitempty"`
}

HealthResponse collects the response values for the Health method.

func (HealthResponse) Failed

func (r HealthResponse) Failed() error

Failed implements Failer.

Jump to

Keyboard shortcuts

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