Documentation
¶
Overview ¶
Code generated by Abide - DO NOT EDIT.
Timestamp: Mon, 03 Jul 2023 14:45:08 EDT Source: ../basic/calc/calc_service.go Generator: https://github.com/monadicstack/abide
Code generated by Abide - DO NOT EDIT.
Timestamp: Sun, 06 Nov 2022 16:46:37 EST Source: calc/calc_service.go Generator: https://github.com/monadicstack/abide
Code generated by Abide - DO NOT EDIT.
Timestamp: Mon, 03 Jul 2023 14:45:08 EDT Source: ../basic/calc/calc_service.go Generator: https://github.com/monadicstack/abide
Index ¶
- func CalculatorServiceClient(address string, options ...clients.ClientOption) calc.CalculatorService
- func CalculatorServiceServer(handler calc.CalculatorService, middleware ...services.MiddlewareFunc) *services.Service
- type MockCalculatorService
- func (mock *MockCalculatorService) Add(ctx context.Context, request *calc.AddRequest) (*calc.AddResponse, error)
- func (mock *MockCalculatorService) Double(ctx context.Context, request *calc.DoubleRequest) (*calc.DoubleResponse, error)
- func (mock *MockCalculatorService) Mul(ctx context.Context, request *calc.MulRequest) (*calc.MulResponse, error)
- func (mock *MockCalculatorService) Sub(ctx context.Context, request *calc.SubRequest) (*calc.SubResponse, error)
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 abide 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 (mock *MockCalculatorService) Add(ctx context.Context, request *calc.AddRequest) (*calc.AddResponse, error)
func (*MockCalculatorService) Double ¶
func (mock *MockCalculatorService) Double(ctx context.Context, request *calc.DoubleRequest) (*calc.DoubleResponse, error)
func (*MockCalculatorService) Mul ¶
func (mock *MockCalculatorService) Mul(ctx context.Context, request *calc.MulRequest) (*calc.MulResponse, error)
func (*MockCalculatorService) Sub ¶
func (mock *MockCalculatorService) Sub(ctx context.Context, request *calc.SubRequest) (*calc.SubResponse, error)