spinsvc

package module
v0.0.0-...-582566e Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2022 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoParticipants = errors.New("no participants")
	ErrNoTickets      = errors.New("none of the participants have tickets")
	ErrNoSpin         = errors.New("no spin yet to return")
)

Functions

func MakeGetLastEndpoint

func MakeGetLastEndpoint(svc Service) endpoint.Endpoint

func MakeHTTPHandler

func MakeHTTPHandler(e EndpointSet, logger log.Logger) http.Handler

func MakeSpinEndpoint

func MakeSpinEndpoint(svc Service) endpoint.Endpoint

Types

type EndpointSet

type EndpointSet struct {
	SpinEndpoint    endpoint.Endpoint
	GetLastEndpoint endpoint.Endpoint
}

func MakeClientEndpoints

func MakeClientEndpoints(instance string) (EndpointSet, error)

func MakeServerEndpoints

func MakeServerEndpoints(svc Service) EndpointSet

func (*EndpointSet) GetLast

func (e *EndpointSet) GetLast(ctx context.Context) (SpinResult, error)

func (*EndpointSet) Spin

func (e *EndpointSet) Spin(ctx context.Context, participantids []int) (SpinResult, error)

func (*EndpointSet) SpinUnweighted

func (e *EndpointSet) SpinUnweighted(ctx context.Context, participantids []int) (SpinResult, error)

type Service

type Service interface {
	Spin(ctx context.Context, participantIds []int) (SpinResult, error)
	SpinUnweighted(ctx context.Context, particantIds []int) (SpinResult, error)
	GetLast(ctx context.Context) (SpinResult, error)
}

func NewService

func NewService(logger log.Logger, ticketService ticketsvc.Service) Service

type ServiceMiddleware

type ServiceMiddleware func(Service) Service

func LoggingMiddleware

func LoggingMiddleware(logger log.Logger) ServiceMiddleware

type SpinResult

type SpinResult struct {
	ParticipantIds []int `json:"participantIds"`
	WinnerId       int   `json:"winnerId"`
}

func (SpinResult) String

func (t SpinResult) String() string

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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