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 *zap.Logger) endpoint.Middleware

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

func MakeCreateUserEndpoint

func MakeCreateUserEndpoint(s service.Service, logger *zap.Logger,
	duration metrics.Histogram, otTracer stdopentracing.Tracer,
	zipkinTracer *stdzipkin.Tracer, operationName string) endpoint.Endpoint

MakeCreateUserEndpoint constructs a Create User endpoint wrapping the service.

func MakeGetUserByEmailEndpoint

func MakeGetUserByEmailEndpoint(s service.Service, logger *zap.Logger,
	duration metrics.Histogram, otTracer stdopentracing.Tracer,
	zipkinTracer *stdzipkin.Tracer, operationName string) endpoint.Endpoint

MakeGetUserByEmailEndpoint constructs a Get User By Email endpoint wrapping the service.

func MakeGetUserByIdEndpoint

func MakeGetUserByIdEndpoint(s service.Service, logger *zap.Logger,
	duration metrics.Histogram, otTracer stdopentracing.Tracer,
	zipkinTracer *stdzipkin.Tracer, operationName string) endpoint.Endpoint

MakeGetUserByIdEndpoint constructs a Get User By ID endpoint wrapping the service.

func MakeGetUserByUsernameEndpoint

func MakeGetUserByUsernameEndpoint(s service.Service, logger *zap.Logger,
	duration metrics.Histogram, otTracer stdopentracing.Tracer,
	zipkinTracer *stdzipkin.Tracer, operationName string) endpoint.Endpoint

MakeGetUserByUsernameEndpoint constructs a Get User By Username endpoint wrapping the service.

func MakeLoginEndpoint

func MakeLoginEndpoint(s service.Service, logger *zap.Logger,
	duration metrics.Histogram, otTracer stdopentracing.Tracer,
	zipkinTracer *stdzipkin.Tracer, operationName string) endpoint.Endpoint

MakeLoginEndpoint constructs a Log In endpoint wrapping the service.

func WrapMiddlewares

func WrapMiddlewares(endpoint endpoint.Endpoint, logger *zap.Logger,
	duration metrics.Histogram, otTracer stdopentracing.Tracer,
	zipkinTracer *stdzipkin.Tracer, operationName string) endpoint.Endpoint

WrapMiddlewares wraps endpointes in the following set of middlewares : ratelimiting, circuit breaker, open and zipkin tracing, logging, and instrumentation middlewares

Types

type CreateUserRequest

type CreateUserRequest struct {
	User user_service.UserORM
}

CreateUserRequest collects the request parameters for the CreateUser method.

type CreateUserResponse

type CreateUserResponse struct {
	Err error `json:"err"` // should be intercepted by Failed/errorEncoder
}

CreateUserResponse collects the response values for the CreateUser method.

func (CreateUserResponse) Failed

func (r CreateUserResponse) Failed() error

type GetUserRequest

type GetUserRequest struct {
	Param string
}

type GetUserResponse

type GetUserResponse struct {
	Err  error                `json:"err"`
	User user_service.UserORM `json:"user"`
}

func (GetUserResponse) Failed

func (r GetUserResponse) Failed() error

type LoginRequest

type LoginRequest struct {
	Username string
	Password string
}

type Set

type Set struct {
	CreateUserEndpoint        endpoint.Endpoint
	GetUserByIdEndpoint       endpoint.Endpoint
	GetUserByUsernameEndpoint endpoint.Endpoint
	GetUserByEmailEndpoint    endpoint.Endpoint
	LoginEndpoint             endpoint.Endpoint
}

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

In a server, it's useful for functions that need to operate on a per-endpoint basis. For example, you might pass an Endpoints to a function that produces an http.Handler, with each method (endpoint) wired up to a specific path. (It is probably a mistake in design to invoke the Service methods on the Endpoints struct in a server.)

In a client, it's useful to collect individually constructed endpoints into a single type that implements the Service interface. For example, you might construct individual endpoints using transport/http.NewClient, combine them into an Endpoints, and return it to the caller as a Service.

func MakeServerEndpoints

func MakeServerEndpoints(s service.Service, logger *zap.Logger,
	duration metrics.Histogram, otTracer stdopentracing.Tracer,
	zipkinTracer *stdzipkin.Tracer) Set

MakeServerEndpoints returns an Endpoints struct where each endpoint invokes the corresponding method on the provided service.

func New

func New(svc service.Service, logger *zap.Logger, duration metrics.Histogram, otTracer stdopentracing.Tracer, zipkinTracer *stdzipkin.Tracer) Set

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

func (Set) CreateUser

func (s Set) CreateUser(ctx context.Context, user user_service.UserORM) (err error)

CreateUser implements the service interface so that set may be used as a service.

func (Set) GetUserByEmail

func (s Set) GetUserByEmail(ctx context.Context, email string) (user user_service.UserORM, err error)

GetUserByEmail implements the service interface so that set may be used as a service.

func (Set) GetUserById

func (s Set) GetUserById(ctx context.Context, id string) (user user_service.UserORM, err error)

GetUserById implements the service interface so that set may be used as a service.

func (Set) GetUserByUsername

func (s Set) GetUserByUsername(ctx context.Context, username string) (user user_service.UserORM, err error)

GetUserByUsername implements the service interface so that set may be used as a service.