Documentation
¶
Overview ¶
Code generated by Frodo from calc/calculator_service.go - DO NOT EDIT
https://github.com/monadicstack/frodo
Code generated by Frodo from calc/calculator_service.go - DO NOT EDIT
https://github.com/monadicstack/frodo
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewCalculatorServiceGateway ¶
func NewCalculatorServiceGateway(service calc.CalculatorService, options ...rpc.GatewayOption) rpc.Gateway
NewCalculatorServiceGateway accepts your "real" CalculatorService instance (the thing that really does the work), and exposes it to other services/clients over RPC. The rpc.Gateway it returns implements http.Handler, so you can pass it to any standard library HTTP server of your choice.
// How to fire up your service for RPC and/or your REST API
service := calc.CalculatorService{ /* set up to your liking */ }
gateway := calc.NewCalculatorServiceGateway(service)
http.ListenAndServe(":8080", gateway)
The default instance works well enough, but you can supply additional options such as WithMiddleware() which accepts any negroni-compatible middleware handlers.
Types ¶
type CalculatorServiceClient ¶
CalculatorServiceClient manages all interaction w/ a remote CalculatorService instance by letting you invoke functions on this instance as if you were doing it locally (hence... RPC client). You shouldn't instantiate this manually. Instead, you should utilize the NewCalculatorServiceClient() function to properly set this up.
func NewCalculatorServiceClient ¶
func NewCalculatorServiceClient(address string, options ...rpc.ClientOption) *CalculatorServiceClient
NewCalculatorServiceClient 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 add and subtract at WEB SCALE!
func (*CalculatorServiceClient) Add ¶
func (client *CalculatorServiceClient) Add(ctx context.Context, request *calc.AddRequest) (*calc.AddResponse, error)
Add accepts two integers and returns a result w/ their sum.
func (*CalculatorServiceClient) Sub ¶
func (client *CalculatorServiceClient) Sub(ctx context.Context, request *calc.SubRequest) (*calc.SubResponse, error)
Sub accepts two integers and returns a result w/ their difference.
type CalculatorServiceProxy ¶
type CalculatorServiceProxy struct {
Service calc.CalculatorService
}
CalculatorServiceProxy fully implements the CalculatorService interface, but delegates all operations to a "real" instance of the service. You can embed this type in a struct of your choice so you can "override" or decorate operations as you see fit. Any operations on CalculatorService that you don't explicitly define will simply delegate to the default implementation of the underlying 'Service' value.
Since you have access to the underlying service, you are able to both implement custom handling logic AND call the "real" implementation, so this can be used as special middleware that applies to only certain operations.
func (*CalculatorServiceProxy) Add ¶
func (proxy *CalculatorServiceProxy) Add(ctx context.Context, request *calc.AddRequest) (*calc.AddResponse, error)
func (*CalculatorServiceProxy) Sub ¶
func (proxy *CalculatorServiceProxy) Sub(ctx context.Context, request *calc.SubRequest) (*calc.SubResponse, error)