Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AdditionRequest ¶
AdditionRequest is used to request the Calculator.Addition service
type AdditionResponse ¶
type AdditionResponse struct {
Result float64 `json:"result"`
}
AdditionResponse is used for the answer of the Calculator.Addition service
type Calculator ¶
type Calculator interface { Addition(a, b float64) float64 Subtraction(subtrahend, minuend float64) float64 Multiplication(a, b float64) float64 Division(dividend, divisor float64) (float64, error) Graphql(ctx context.Context, request *handler.RequestOptions) *graphql.Result }
Calculator expose a simple calculator
func NewBasicCalculatorService ¶
func NewBasicCalculatorService() (Calculator, error)
NewBasicCalculatorService returns a naive, stateless implementation of CalculatorService.
func NewCalculatorService ¶
func NewCalculatorService(logger *logrus.Logger, metrics MetricSet) (Calculator, error)
NewCalculatorService returns a basic CalculatorService with all of the expected middlewares wired in.
type DivisionRequest ¶
DivisionRequest is used to request the Calculator.Division service
type DivisionResponse ¶
type DivisionResponse struct { Result float64 `json:"result"` Error string `json:"error,omitempty"` // errors do not JSON-marshal, so we use a string }
DivisionResponse is used to request the Calculator.Division service
type MetricSet ¶
type MetricSet struct { RequestCount metrics.Counter RequestLatency metrics.Histogram CountResult metrics.Histogram GraphqlRequestCount metrics.Counter GraphqlRequestLatency metrics.Histogram }
MetricSet collects all of the metrics which are observable within the service.
type Middleware ¶
type Middleware func(Calculator) Calculator
Middleware is a chainable behavior modifier for Calculator
func InstrumentingMiddleware ¶
func InstrumentingMiddleware(metrics MetricSet) Middleware
InstrumentingMiddleware returns a service middleware that instruments the number of integers summed and characters concatenated over the lifetime of the service.
func LoggingMiddleware ¶
func LoggingMiddleware(logger *logrus.Logger) Middleware
LoggingMiddleware takes a logger as a dependency and returns a service Middleware.
type MultiplicationRequest ¶
MultiplicationRequest is used to request the Calculator.Multiplication service
type MultiplicationResponse ¶
type MultiplicationResponse struct {
Result float64 `json:"result"`
}
MultiplicationResponse is used to request the Calculator.Multiplication service
type SubtractionRequest ¶
type SubtractionRequest struct { Subtrahend float64 `json:"subtrahend"` Minuend float64 `json:"minuend"` }
SubtractionRequest is used to request the Calculator.Subtraction service
type SubtractionResponse ¶
type SubtractionResponse struct {
Result float64 `json:"result"`
}
SubtractionResponse is used to request the Calculator.Subtraction service