Documentation
¶
Overview ¶
Package intermediate serves as the foundation of the calculator.example microservice.
The Calculator microservice performs simple mathematical operations.
Index ¶
- type Intermediate
- func (svc *Intermediate) AddUsedOperators(ctx context.Context, num int, op string) error
- func (svc *Intermediate) IncrementSumOperations(sum int, op string) errordeprecated
- func (svc *Intermediate) IncrementUsedOperators(num int, op string) errordeprecated
- func (svc *Intermediate) ObserveSumOperations(sum int, op string) errordeprecated
- func (svc *Intermediate) RecordSumOperations(ctx context.Context, sum int, op string) error
- 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) 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 ToDo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Intermediate ¶
Intermediate extends and customizes the generic base connector. Code generated microservices then extend the intermediate.
func NewService ¶
func NewService(impl ToDo, version int) *Intermediate
NewService creates a new intermediate service.
func (*Intermediate) AddUsedOperators ¶ added in v1.13.1
AddUsedOperators adds to the value of the counter metric. UsedOperators tracks the types of the arithmetic operators used.
func (*Intermediate) IncrementSumOperations
deprecated
added in
v1.13.1
func (svc *Intermediate) IncrementSumOperations(sum int, op string) error
IncrementSumOperations increments the value of the gauge metric. SumOperations tracks the total sum of the results of all operators.
Deprecated: Use RecordSumOperations
func (*Intermediate) IncrementUsedOperators
deprecated
added in
v1.13.1
func (svc *Intermediate) IncrementUsedOperators(num int, op string) error
IncrementUsedOperators increments the value of the counter metric. UsedOperators tracks the types of the arithmetic operators used.
Deprecated: Use AddUsedOperators
func (*Intermediate) ObserveSumOperations
deprecated
added in
v1.13.1
func (svc *Intermediate) ObserveSumOperations(sum int, op string) error
ObserveSumOperations observes the current value of the gauge metric. SumOperations tracks the total sum of the results of all operators.
Deprecated: Use RecordSumOperations
func (*Intermediate) RecordSumOperations ¶ added in v1.13.1
RecordSumOperations records the current value of the gauge metric. SumOperations tracks 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 calculator.example microservice, allowing functions, event sinks and web handlers to be mocked.
func (*Mock) Arithmetic ¶
func (svc *Mock) Arithmetic(ctx context.Context, x int, op string, y int) (xEcho int, opEcho string, yEcho int, result int, err error)
Arithmetic runs the mock handler set by MockArithmetic.
func (*Mock) Distance ¶
func (svc *Mock) Distance(ctx context.Context, p1 calculatorapi.Point, p2 calculatorapi.Point) (d float64, err error)
Distance runs the mock handler set by MockDistance.
func (*Mock) MockArithmetic ¶
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 the Arithmetic endpoint.
func (*Mock) MockDistance ¶
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 the Distance endpoint.
func (*Mock) MockSquare ¶
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 the Square endpoint.
func (*Mock) OnObserveSumOperations ¶ added in v1.13.1
OnObserveSumOperations is a no op.
func (*Mock) OnShutdown ¶
OnShutdown is a no op.
type ToDo ¶
type ToDo interface {
OnStartup(ctx context.Context) (err error)
OnShutdown(ctx context.Context) (err error)
Arithmetic(ctx context.Context, x int, op string, y int) (xEcho int, opEcho string, yEcho int, result int, err error)
Square(ctx context.Context, x int) (xEcho int, result int, err error)
Distance(ctx context.Context, p1 calculatorapi.Point, p2 calculatorapi.Point) (d float64, err error)
OnObserveSumOperations(ctx context.Context) (err error)
}
ToDo defines the interface that the microservice must implement. The intermediate delegates handling to this interface.