Documentation ¶
Overview ¶
Package plugin provides support for RPC plugins with registration server. It also implements middleware calling all the registered and alive plugins
Index ¶
Constants ¶
const CtxMatch = conductorCtxtKey("match")
CtxMatch key used to retrieve matching request info from the request context
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Conductor ¶
type Conductor struct { Address string RPCDialer RPCDialer // contains filtered or unexported fields }
Conductor accepts registrations from rpc plugins, keeps list of active/current plugins and provides middleware calling all of them.
func (*Conductor) Middleware ¶
Middleware hits all registered, alive-only plugins and modifies the original request accordingly Failed plugin calls ignored. Status code from any plugin may stop the chain of calls if not 200. This is needed to allow plugins like auth which has to terminate request in some cases.
type Handler ¶
type Handler struct { Address string Method string // full method name for rpc call, i.e. Plugin.Thing Alive bool // contains filtered or unexported fields }
Handler contains information about a plugin's handler
type RPCClientMock ¶
type RPCClientMock struct { // CallFunc mocks the Call method. CallFunc func(serviceMethod string, args interface{}, reply interface{}) error // contains filtered or unexported fields }
RPCClientMock is a mock implementation of RPCClient.
func TestSomethingThatUsesRPCClient(t *testing.T) { // make and configure a mocked RPCClient mockedRPCClient := &RPCClientMock{ CallFunc: func(serviceMethod string, args interface{}, reply interface{}) error { panic("mock out the Call method") }, } // use mockedRPCClient in code that requires RPCClient // and then make assertions. }
func (*RPCClientMock) Call ¶
func (mock *RPCClientMock) Call(serviceMethod string, args interface{}, reply interface{}) error
Call calls CallFunc.
func (*RPCClientMock) CallCalls ¶
func (mock *RPCClientMock) CallCalls() []struct { ServiceMethod string Args interface{} Reply interface{} }
CallCalls gets all the calls that were made to Call. Check the length with:
len(mockedRPCClient.CallCalls())
type RPCDialerFunc ¶
RPCDialerFunc is an adapter to allow the use of an ordinary functions as the RPCDialer.
type RPCDialerMock ¶
type RPCDialerMock struct { // DialFunc mocks the Dial method. DialFunc func(network string, address string) (RPCClient, error) // contains filtered or unexported fields }
RPCDialerMock is a mock implementation of RPCDialer.
func TestSomethingThatUsesRPCDialer(t *testing.T) { // make and configure a mocked RPCDialer mockedRPCDialer := &RPCDialerMock{ DialFunc: func(network string, address string) (RPCClient, error) { panic("mock out the Dial method") }, } // use mockedRPCDialer in code that requires RPCDialer // and then make assertions. }
func (*RPCDialerMock) Dial ¶
func (mock *RPCDialerMock) Dial(network string, address string) (RPCClient, error)
Dial calls DialFunc.
func (*RPCDialerMock) DialCalls ¶
func (mock *RPCDialerMock) DialCalls() []struct { Network string Address string }
DialCalls gets all the calls that were made to Dial. Check the length with:
len(mockedRPCDialer.DialCalls())