Documentation
¶
Index ¶
- Constants
- Variables
- type ArithmeticIn
- type ArithmeticOut
- type ArithmeticResponse
- type Client
- func (_c Client) Arithmetic(ctx context.Context, x int, op string, y int) (xEcho int, opEcho string, yEcho int, result int, err error)
- func (_c Client) Distance(ctx context.Context, p1 Point, p2 Point) (d float64, err error)
- func (_c Client) ForHost(host string) Client
- func (_c Client) Square(ctx context.Context, x int) (xEcho int, result int, err error)
- func (_c Client) WithOptions(opts ...pub.Option) Client
- type DistanceIn
- type DistanceOut
- type DistanceResponse
- type MulticastClient
- func (_c MulticastClient) Arithmetic(ctx context.Context, x int, op string, y int) iter.Seq[*ArithmeticResponse]
- func (_c MulticastClient) Distance(ctx context.Context, p1 Point, p2 Point) iter.Seq[*DistanceResponse]
- func (_c MulticastClient) ForHost(host string) MulticastClient
- func (_c MulticastClient) Square(ctx context.Context, x int) iter.Seq[*SquareResponse]
- func (_c MulticastClient) WithOptions(opts ...pub.Option) MulticastClient
- type Point
- type SquareIn
- type SquareOut
- type SquareResponse
Constants ¶
const Description = `The Calculator microservice performs simple mathematical operations.`
Description is the human-readable summary of the microservice, surfaced in OpenAPI and discovery.
const Hostname = "calculator.example"
Hostname is the default hostname of the microservice.
const Name = "Calculator"
Name is the decorative PascalCase name of the microservice.
const Version = 353
Version is a generation counter bumped on each regeneration, not a semantic version.
Variables ¶
var Arithmetic = define.Function{ Host: Hostname, Method: "GET", Route: ":443/arithmetic", In: ArithmeticIn{}, Out: ArithmeticOut{}, }
Arithmetic performs an arithmetic operation between two integers x and y given an operator op.
var Distance = define.Function{ Host: Hostname, Method: "ANY", Route: ":443/distance", In: DistanceIn{}, Out: DistanceOut{}, }
Distance calculates the distance between two points. It demonstrates the use of the defined type Point.
var Square = define.Function{ Host: Hostname, Method: "GET", Route: ":443/square", In: SquareIn{}, Out: SquareOut{}, }
Square prints the square of the integer x.
var SumOperations = define.Metric{ Kind: define.Gauge, Value: int(0), Labels: []string{"op"}, OTelName: "sum_operations", Observable: true, }
SumOperations tracks the total sum of the results of all operators.
var UsedOperators = define.Metric{ Kind: define.Counter, Value: int(0), Labels: []string{"op"}, OTelName: "used_operators", }
UsedOperators tracks the types of the arithmetic operators used.
Functions ¶
This section is empty.
Types ¶
type ArithmeticIn ¶
type ArithmeticIn struct {
X int `json:"x,omitzero" jsonschema_description:"X is the left operand"`
Op string `json:"op,omitzero" jsonschema_description:"Op is the operator: + - * /"`
Y int `json:"y,omitzero" jsonschema_description:"Y is the right operand"`
}
ArithmeticIn are the input arguments of Arithmetic.
type ArithmeticOut ¶
type ArithmeticOut struct {
XEcho int `json:"xEcho,omitzero" jsonschema_description:"XEcho echoes the left operand"`
OpEcho string `json:"opEcho,omitzero" jsonschema_description:"OpEcho echoes the operator"`
YEcho int `json:"yEcho,omitzero" jsonschema_description:"YEcho echoes the right operand"`
Result int `json:"result,omitzero" jsonschema_description:"Result is the result of the operation"`
}
ArithmeticOut are the output arguments of Arithmetic.
type ArithmeticResponse ¶
type ArithmeticResponse multicastResponse // MARKER: Arithmetic
ArithmeticResponse packs the response of Arithmetic.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a lightweight proxy for making unicast calls to the microservice.
func (Client) Arithmetic ¶
func (_c Client) Arithmetic(ctx context.Context, x int, op string, y int) (xEcho int, opEcho string, yEcho int, result int, err error)
Arithmetic performs an arithmetic operation between two integers x and y given an operator op.
func (Client) Distance ¶
Distance calculates the distance between two points. It demonstrates the use of the defined type Point.
func (Client) ForHost ¶
ForHost returns a copy of the client with a different hostname to be applied to requests.
type DistanceIn ¶
type DistanceIn struct {
P1 Point `json:"p1,omitzero" jsonschema_description:"P1 is the first point"`
P2 Point `json:"p2,omitzero" jsonschema_description:"P2 is the second point"`
}
DistanceIn are the input arguments of Distance.
type DistanceOut ¶
type DistanceOut struct {
D float64 `json:"d,omitzero" jsonschema_description:"D is the Euclidean distance between P1 and P2"`
}
DistanceOut are the output arguments of Distance.
type DistanceResponse ¶
type DistanceResponse multicastResponse // MARKER: Distance
DistanceResponse packs the response of Distance.
func (*DistanceResponse) Get ¶
func (_res *DistanceResponse) Get() (d float64, err error)
Get unpacks the return arguments of Distance.
type MulticastClient ¶
type MulticastClient struct {
// contains filtered or unexported fields
}
MulticastClient is a lightweight proxy for making multicast calls to the microservice.
func NewMulticastClient ¶
func NewMulticastClient(caller service.Publisher) MulticastClient
NewMulticastClient creates a new multicast client proxy to the microservice.
func (MulticastClient) Arithmetic ¶
func (_c MulticastClient) Arithmetic(ctx context.Context, x int, op string, y int) iter.Seq[*ArithmeticResponse]
Arithmetic performs an arithmetic operation between two integers x and y given an operator op.
func (MulticastClient) Distance ¶
func (_c MulticastClient) Distance(ctx context.Context, p1 Point, p2 Point) iter.Seq[*DistanceResponse]
Distance calculates the distance between two points. It demonstrates the use of the defined type Point.
func (MulticastClient) ForHost ¶
func (_c MulticastClient) ForHost(host string) MulticastClient
ForHost returns a copy of the client with a different hostname to be applied to requests.
func (MulticastClient) Square ¶
func (_c MulticastClient) Square(ctx context.Context, x int) iter.Seq[*SquareResponse]
Square prints the square of the integer x.
func (MulticastClient) WithOptions ¶ added in v1.13.1
func (_c MulticastClient) WithOptions(opts ...pub.Option) MulticastClient
WithOptions returns a copy of the client with options to be applied to requests.
type Point ¶
type Point struct {
X float64 `json:"x,omitzero" jsonschema_description:"X coordinate" jsonschema:"example=6"`
Y float64 `json:"y,omitzero" jsonschema_description:"Y coordinate" jsonschema:"example=8"`
}
Point is a 2D (X,Y) coordinate.
type SquareIn ¶
type SquareIn struct {
X int `json:"x,omitzero" jsonschema_description:"X is the integer to square"`
}
SquareIn are the input arguments of Square.
type SquareOut ¶
type SquareOut struct {
XEcho int `json:"xEcho,omitzero" jsonschema_description:"XEcho echoes the input integer"`
Result int `json:"result,omitzero" jsonschema_description:"Result is X squared"`
}
SquareOut are the output arguments of Square.
type SquareResponse ¶
type SquareResponse multicastResponse // MARKER: Square
SquareResponse packs the response of Square.