mathservice

package
v0.0.0-...-14493fd Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2019 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrDivideByZero = errors.New("can't divide by zero")
	ErrNoMax        = errors.New("no maximum value, a and b are the same")
	ErrNoMin        = errors.New("no minimum value, a and b are the same")
)

Functions

This section is empty.

Types

type Middleware

type Middleware func(Service) Service

func ObservabilityMiddleware

func ObservabilityMiddleware(duration metrics.Histogram, logger log.Logger) Middleware

ObservabilityMiddleware implements both logging and prometheus metrics for each Service method

type Service

type Service interface {
	// Divide two integers, a/b
	Divide(ctx context.Context, a, b float64) (float64, error)
	// Max two integers, returns the greater value of a and b
	Max(ctx context.Context, a, b float64) (float64, error)
	// Min two integers, returns the lesser value of a and b
	Min(ctx context.Context, a, b float64) (float64, error)
	// Multiply two integers, a*b
	Multiply(ctx context.Context, a, b float64) (float64, error)
	// Pow two integers, a^b
	Pow(ctx context.Context, a, b float64) (float64, error)
	// Subtract two integers, a-b
	Subtract(ctx context.Context, a, b float64) (float64, error)
	// Sums two integers. a+b
	Sum(ctx context.Context, a, b float64) (float64, error)
}

Service describes a service that adds things together.

func New

func New(duration metrics.Histogram, logger log.Logger) Service

New returns a basic Service with all of the expected middlewares wired in.

func NewBasicService

func NewBasicService() Service

NewBasicService returns a naïve, stateless implementation of Service.

Jump to

Keyboard shortcuts

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