Documentation
¶
Index ¶
- Constants
- type Intermediate
- type Mock
- func (svc *Mock) Arithmetic(ctx context.Context, x int, op string, y int) (xEcho int, opEcho string, yEcho int, result int, err error)
- func (svc *Mock) Distance(ctx context.Context, p1 calculatorapi.Point, p2 calculatorapi.Point) (d float64, err error)
- func (svc *Mock) MockArithmetic(...) *Mock
- func (svc *Mock) MockDistance(...) *Mock
- func (svc *Mock) MockOnObserveSumOperations(handler func(ctx context.Context) (err error)) *Mock
- func (svc *Mock) MockSquare(handler func(ctx context.Context, x int) (xEcho int, result int, err error)) *Mock
- func (svc *Mock) OnObserveSumOperations(ctx context.Context) (err error)
- func (svc *Mock) OnShutdown(ctx context.Context) (err error)
- func (svc *Mock) OnStartup(ctx context.Context) (err error)
- func (svc *Mock) Square(ctx context.Context, x int) (xEcho int, result int, err error)
- type Service
- func (svc *Service) Arithmetic(ctx context.Context, x int, op string, y int) (xEcho int, opEcho string, yEcho int, result int, err error)
- func (svc *Service) Distance(ctx context.Context, p1 calculatorapi.Point, p2 calculatorapi.Point) (d float64, err error)
- func (svc *Service) Init(initializer func(svc *Service) (err error)) *Service
- func (svc *Service) OnObserveSumOperations(ctx context.Context) (err error)
- func (svc *Service) OnShutdown(ctx context.Context) (err error)
- func (svc *Service) OnStartup(ctx context.Context) (err error)
- func (svc *Service) Square(ctx context.Context, x int) (xEcho int, result int, err error)
- type ToDo
Constants ¶
const ( Hostname = calculatorapi.Hostname Version = 352 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Intermediate ¶ added in v1.22.0
Intermediate extends and customizes the generic base connector.
func NewIntermediate ¶ added in v1.22.0
func NewIntermediate(impl ToDo) *Intermediate
NewIntermediate creates a new instance of the intermediate.
func (*Intermediate) IncrementUsedOperators ¶ added in v1.22.0
func (svc *Intermediate) IncrementUsedOperators(ctx context.Context, num int, op string) (err error)
IncrementUsedOperators counts the types of the arithmetic operators used.
func (*Intermediate) RecordSumOperations ¶ added in v1.22.0
RecordSumOperations records the total sum of the results of all operators.
type Mock ¶
type Mock struct {
*Intermediate
// contains filtered or unexported fields
}
Mock is a mockable version of the microservice, allowing functions, event sinks and web handlers to be mocked.
func (*Mock) Arithmetic ¶ added in v1.22.0
func (svc *Mock) Arithmetic(ctx context.Context, x int, op string, y int) (xEcho int, opEcho string, yEcho int, result int, err error)
Arithmetic executes the mock handler.
func (*Mock) Distance ¶ added in v1.22.0
func (svc *Mock) Distance(ctx context.Context, p1 calculatorapi.Point, p2 calculatorapi.Point) (d float64, err error)
Distance executes the mock handler.
func (*Mock) MockArithmetic ¶ added in v1.22.0
func (svc *Mock) MockArithmetic(handler func(ctx context.Context, x int, op string, y int) (xEcho int, opEcho string, yEcho int, result int, err error)) *Mock
MockArithmetic sets up a mock handler for Arithmetic.
func (*Mock) MockDistance ¶ added in v1.22.0
func (svc *Mock) MockDistance(handler func(ctx context.Context, p1 calculatorapi.Point, p2 calculatorapi.Point) (d float64, err error)) *Mock
MockDistance sets up a mock handler for Distance.
func (*Mock) MockOnObserveSumOperations ¶ added in v1.22.0
MockOnObserveSumOperations sets up a mock handler for OnObserveSumOperations.
func (*Mock) MockSquare ¶ added in v1.22.0
func (svc *Mock) MockSquare(handler func(ctx context.Context, x int) (xEcho int, result int, err error)) *Mock
MockSquare sets up a mock handler for Square.
func (*Mock) OnObserveSumOperations ¶ added in v1.22.0
OnObserveSumOperations executes the mock handler.
func (*Mock) OnShutdown ¶ added in v1.22.0
OnShutdown is called when the microservice is shut down.
type Service ¶
type Service struct {
*Intermediate // IMPORTANT: Do not remove
// contains filtered or unexported fields
}
Service implements the calculator.example microservice.
The Calculator microservice performs simple mathematical operations.
func (*Service) Arithmetic ¶
func (svc *Service) Arithmetic(ctx context.Context, x int, op string, y int) (xEcho int, opEcho string, yEcho int, result int, err error)
Arithmetic perform an arithmetic operation between two integers x and y given an operator op.
func (*Service) Distance ¶
func (svc *Service) Distance(ctx context.Context, p1 calculatorapi.Point, p2 calculatorapi.Point) (d float64, err error)
Distance calculates the distance between two points. It demonstrates the use of the defined type Point.
func (*Service) OnObserveSumOperations ¶ added in v1.13.1
OnObserveSumOperations observes the value of the SumOperations gauge metric. SumOperations tracks the total sum of the results of all operators.
func (*Service) OnShutdown ¶
OnShutdown is called when the microservice is shut down.
type ToDo ¶ added in v1.22.0
type ToDo interface {
OnStartup(ctx context.Context) (err error)
OnShutdown(ctx context.Context) (err error)
OnObserveSumOperations(ctx context.Context) (err error) // MARKER: SumOperations
Arithmetic(ctx context.Context, x int, op string, y int) (xEcho int, opEcho string, yEcho int, result int, err error) // MARKER: Arithmetic
Square(ctx context.Context, x int) (xEcho int, result int, err error) // MARKER: Square
Distance(ctx context.Context, p1 calculatorapi.Point, p2 calculatorapi.Point) (d float64, err error) // MARKER: Distance
}
ToDo is implemented by the service or mock. The intermediate delegates handling to this interface.