calc

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Code generated by Frodo - DO NOT EDIT.

Timestamp: Mon, 03 Jul 2023 14:45:08 EDT
Source:    ../basic/calc/calc_service.go
Generator: https://github.com/bridgekitio/frodo

Code generated by Frodo - DO NOT EDIT.

Timestamp: Sun, 06 Nov 2022 16:46:37 EST
Source:    calc/calc_service.go
Generator: https://github.com/bridgekitio/frodo

Code generated by Frodo - DO NOT EDIT.

Timestamp: Mon, 03 Jul 2023 14:45:08 EDT
Source:    ../basic/calc/calc_service.go
Generator: https://github.com/bridgekitio/frodo

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CalculatorServiceClient

func CalculatorServiceClient(address string, options ...clients.ClientOption) calc.CalculatorService

CalculatorServiceClient creates an RPC client that conforms to the CalculatorService interface, but delegates work to remote instances. You must supply the base address of the remote service gateway instance or the load balancer for that service.

CalculatorService provides the ability to perform basic arithmetic on two numbers.

func CalculatorServiceServer

func CalculatorServiceServer(handler calc.CalculatorService, middleware ...services.MiddlewareFunc) *services.Service

CalculatorServiceServer accepts your "real" CalculatorService instance (the thing that really does the work), and returns a set of endpoint routes which allow this service to be consumed via the gateways/listeners you configure in main().

// Example
serviceHandler := calc.CalculatorServiceHandler{ /* set up to your liking */ }
server := services.New(
	services.Listen(apis.NewGateway()),
	services.Register(calcgen.CalculatorServiceServer(serviceHandler)),
)
server.Listen()

From there, you can add middleware, event sourcing support and more. Look at the frodo documentation for more details/examples on how to make your service production ready.

Types

type MockCalculatorService

type MockCalculatorService struct {
	AddFunc    func(context.Context, *calc.AddRequest) (*calc.AddResponse, error)
	DoubleFunc func(context.Context, *calc.DoubleRequest) (*calc.DoubleResponse, error)
	MulFunc    func(context.Context, *calc.MulRequest) (*calc.MulResponse, error)
	SubFunc    func(context.Context, *calc.SubRequest) (*calc.SubResponse, error)

	Calls struct {
		Add    callsCalculatorServiceAdd
		Double callsCalculatorServiceDouble
		Mul    callsCalculatorServiceMul
		Sub    callsCalculatorServiceSub
	}
}

MockCalculatorService allows you to program behaviors into a mock instance of CalculatorService. You supply dynamic functions named "XxxFunc" to provide the custom behavior; so if your service has a function called 'CreateUser', you supply a function for 'CreateUserFunc'.

You do not need to supply behaviors for every single service function; just the ones you plan to test. If you do invoke a function without a programmed behavior, it will just return an error with a message indicating that it wasn't implemented.

func (*MockCalculatorService) Add

func (*MockCalculatorService) Double

func (*MockCalculatorService) Mul

func (*MockCalculatorService) Sub

Jump to

Keyboard shortcuts

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