calc

package
v0.0.0-...-5a969d9 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2023 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const ServiceName = "calc"

ServiceName is the name of the service as defined in the design. This is the same value that is set in the endpoint request contexts under the ServiceKey key.

Variables

View Source
var MethodNames = [2]string{"divide", "add"}

MethodNames lists the service method names as defined in the design. These are the same values that are set in the endpoint request contexts under the MethodKey key.

Functions

func MakeTimeout

func MakeTimeout(err error) *goa.ServiceError

MakeTimeout builds a goa.ServiceError from an error.

func NewAddEndpoint

func NewAddEndpoint(s Service) goa.Endpoint

NewAddEndpoint returns an endpoint function that calls the method "add" of service "calc".

func NewDivideEndpoint

func NewDivideEndpoint(s Service) goa.Endpoint

NewDivideEndpoint returns an endpoint function that calls the method "divide" of service "calc".

Types

type AddPayload

type AddPayload struct {
	A int
	B int
}

AddPayload is the payload type of the calc service add method.

type Client

type Client struct {
	DivideEndpoint goa.Endpoint
	AddEndpoint    goa.Endpoint
}

Client is the "calc" service client.

func NewClient

func NewClient(divide, add goa.Endpoint) *Client

NewClient initializes a "calc" service client given the endpoints.

func (*Client) Add

func (c *Client) Add(ctx context.Context, p *AddPayload) (res int, err error)

Add calls the "add" endpoint of the "calc" service. Add may return the following errors:

  • "timeout" (type *goa.ServiceError)
  • error: internal error

func (*Client) Divide

func (c *Client) Divide(ctx context.Context, p *DividePayload) (res *DivideResult, err error)

Divide calls the "divide" endpoint of the "calc" service. Divide may return the following errors:

  • "div_by_zero" (type *DivByZero): division by 0
  • "timeout" (type *goa.ServiceError)
  • error: internal error

type DivByZero

type DivByZero struct {
	// division by zero leads to infinity.
	Message string
}

DivByZero is the error returned when using value 0 as divisor.

func (*DivByZero) Error

func (e *DivByZero) Error() string

Error returns an error description.

func (*DivByZero) ErrorName deprecated

func (e *DivByZero) ErrorName() string

ErrorName returns "DivByZero".

Deprecated: Use GoaErrorName - https://github.com/goadesign/goa/issues/3105

func (*DivByZero) GoaErrorName

func (e *DivByZero) GoaErrorName() string

GoaErrorName returns "DivByZero".

type DividePayload

type DividePayload struct {
	Dividend int
	Divisor  int
}

DividePayload is the payload type of the calc service divide method.

type DivideResult

type DivideResult struct {
	Quotient int
	Reminder int
}

DivideResult is the result type of the calc service divide method.

type Endpoints

type Endpoints struct {
	Divide goa.Endpoint
	Add    goa.Endpoint
}

Endpoints wraps the "calc" service endpoints.

func NewEndpoints

func NewEndpoints(s Service) *Endpoints

NewEndpoints wraps the methods of the "calc" service with endpoints.

func (*Endpoints) Use

func (e *Endpoints) Use(m func(goa.Endpoint) goa.Endpoint)

Use applies the given middleware to all the "calc" service endpoints.

type Service

type Service interface {
	// Divide implements divide.
	Divide(context.Context, *DividePayload) (res *DivideResult, err error)
	// Add implements add.
	Add(context.Context, *AddPayload) (res int, err error)
}

Service is the calc service interface.

Jump to

Keyboard shortcuts

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