Documentation
¶
Overview ¶
Package calculator implements the calculator.example microservice.
The Calculator microservice performs simple mathematical operations.
Index ¶
- Constants
- type Mock
- 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)) *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)
Constants ¶
const Hostname = "calculator.example"
Hostname is the default hostname of the microservice: calculator.example.
const SourceCodeSHA256 = "6db1fee3e47dd2952c0ed18a4bf0f46f1150278c1d3bfeaca0ae1eff1a300bcc"
const Timestamp = "2025-10-12T21:58:11.785915Z"
const Version = 329
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Mock ¶
type Mock = intermediate.Mock
Mock is a mockable version of the calculator.example microservice, allowing functions, event sinks and web handlers to be mocked.
type Service ¶
type Service struct {
*intermediate.Intermediate // DO NOT REMOVE
// contains filtered or unexported fields
}
Service implements the calculator.example microservice.
The Calculator microservice performs simple mathematical operations.
func NewService ¶
func NewService() *Service
NewService creates a new calculator.example microservice.
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) Init ¶
Init enables a single-statement pattern for initializing the microservice.
svc.Init(func(svc Service) {
svc.SetGreeting("Hello")
})
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.
Directories
¶
| Path | Synopsis |
|---|---|
|
app
|
|
|
calculator
command
|
|
|
Package calculatorapi implements the public API of the calculator.example microservice, including clients and data structures.
|
Package calculatorapi implements the public API of the calculator.example microservice, including clients and data structures. |
|
Package intermediate serves as the foundation of the calculator.example microservice.
|
Package intermediate serves as the foundation of the calculator.example microservice. |