calculator

package
v1.17.1 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2025 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package calculator implements the calculator.example microservice.

The Calculator microservice performs simple mathematical operations.

Index

Constants

View Source
const Hostname = "calculator.example"

Hostname is the default hostname of the microservice: calculator.example.

View Source
const SourceCodeSHA256 = "6db1fee3e47dd2952c0ed18a4bf0f46f1150278c1d3bfeaca0ae1eff1a300bcc"
View Source
const Timestamp = "2025-10-12T21:58:11.785915Z"
View Source
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.

func NewMock

func NewMock() *Mock

New creates a new mockable version of the microservice.

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

func (svc *Service) Init(initializer func(svc *Service)) *Service

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

func (svc *Service) OnObserveSumOperations(ctx context.Context) (err error)

OnObserveSumOperations observes the value of the SumOperations gauge metric. SumOperations tracks the total sum of the results of all operators.

func (*Service) OnShutdown

func (svc *Service) OnShutdown(ctx context.Context) (err error)

OnShutdown is called when the microservice is shut down.

func (*Service) OnStartup

func (svc *Service) OnStartup(ctx context.Context) (err error)

OnStartup is called when the microservice is started up.

func (*Service) Square

func (svc *Service) Square(ctx context.Context, x int) (xEcho int, result int, err error)

Square prints the square of the integer x.

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.

Jump to

Keyboard shortcuts

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