var ( // ErrTwoZeroes is an arbitrary business rule for the Add method. ErrTwoZeroes = errors.New("can't sum two zeroes") // ErrIntOverflow protects the Add method. We've decided that this error // indicates a misbehaving service and should count against e.g. circuit // breakers. So, we return it directly in endpoints, to illustrate the // difference. In a real service, this probably wouldn't be the case. ErrIntOverflow = errors.New("integer overflow") // ErrMaxSizeExceeded protects the Concat method. ErrMaxSizeExceeded = errors.New("result exceeds maximum size") )
Middleware describes a service (as opposed to endpoint) middleware.
InstrumentingMiddleware returns a service middleware that instruments the number of integers summed and characters concatenated over the lifetime of the service.
LoggingMiddleware takes a logger as a dependency and returns a ServiceMiddleware.
Service describes a service that adds things together.
New returns a basic Service with all of the expected middlewares wired in.
NewBasicService returns a naïve, stateless implementation of Service.