calc

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2021 License: MIT Imports: 6 Imported by: 0

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

type CalculatorServiceClient struct {
	rpc.Client
}

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

Add accepts two integers and returns a result w/ their sum.

func (*CalculatorServiceClient) Sub

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 (*CalculatorServiceProxy) Sub

Jump to

Keyboard shortcuts

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