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) 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 = "26fc05e3cf9a118e58d84d3d28bd19f2b3b8005b1008b70a6c33ec40bef51073"
const Timestamp = "2024-08-01T15:49:26.328173Z"
const Version = 242
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
}
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) 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. |