Documentation ¶
Overview ¶
Package messenger includes a messenger and a transporter. The messenger provides interfaces to send a protobuf message through the underlying transporter. It also dispatches messages to installed handlers.
Index ¶
- func UPIDBindingAddress(hostname string, bindingAddress net.IP) (string, error)
- type HTTPTransporter
- func (t *HTTPTransporter) Inject(ctx context.Context, msg *Message) error
- func (t *HTTPTransporter) Install(msgName string)
- func (t *HTTPTransporter) Recv() (*Message, error)
- func (t *HTTPTransporter) Send(ctx context.Context, msg *Message) (sendError error)
- func (t *HTTPTransporter) Start() <-chan error
- func (t *HTTPTransporter) Stop(graceful bool) error
- func (t *HTTPTransporter) UPID() *upid.UPID
- type MesosMessenger
- func (m *MesosMessenger) Install(handler MessageHandler, msg proto.Message) error
- func (m *MesosMessenger) Route(ctx context.Context, upid *upid.UPID, msg proto.Message) error
- func (m *MesosMessenger) Send(ctx context.Context, upid *upid.UPID, msg proto.Message) error
- func (m *MesosMessenger) Start() error
- func (m *MesosMessenger) Stop() error
- func (m *MesosMessenger) UPID() *upid.UPID
- type Message
- type MessageHandler
- type Messenger
- type MockedMessenger
- func (m *MockedMessenger) Install(handler MessageHandler, msg proto.Message) error
- func (m *MockedMessenger) Recv(from *upid.UPID, msg proto.Message)
- func (m *MockedMessenger) Route(ctx context.Context, upid *upid.UPID, msg proto.Message) error
- func (m *MockedMessenger) Send(ctx context.Context, upid *upid.UPID, msg proto.Message) error
- func (m *MockedMessenger) Start() error
- func (m *MockedMessenger) Stop() error
- func (m *MockedMessenger) UPID() *upid.UPID
- type Transporter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func UPIDBindingAddress ¶ added in v0.21.0
UPIDBindingAddress determines the value of UPID.Host that will be used to build a Transport. If a non-nil, non-wildcard bindingAddress is specified then it will be used for both the UPID and Transport binding address. Otherwise hostname is resolved to an IP address and the UPID.Host is set to that address and the bindingAddress is passed through to the Transport.
Types ¶
type HTTPTransporter ¶
type HTTPTransporter struct {
// contains filtered or unexported fields
}
HTTPTransporter implements the interfaces of the Transporter.
func NewHTTPTransporter ¶
func NewHTTPTransporter(upid *upid.UPID, address net.IP) *HTTPTransporter
NewHTTPTransporter creates a new http transporter with an optional binding address.
func (*HTTPTransporter) Inject ¶
func (t *HTTPTransporter) Inject(ctx context.Context, msg *Message) error
Inject places a message into the incoming message queue.
func (*HTTPTransporter) Install ¶
func (t *HTTPTransporter) Install(msgName string)
Install the request URI according to the message's name.
func (*HTTPTransporter) Recv ¶
func (t *HTTPTransporter) Recv() (*Message, error)
Recv returns the message, one at a time.
func (*HTTPTransporter) Send ¶
func (t *HTTPTransporter) Send(ctx context.Context, msg *Message) (sendError error)
Send sends the message to its specified upid.
func (*HTTPTransporter) Start ¶
func (t *HTTPTransporter) Start() <-chan error
Start starts the http transporter
func (*HTTPTransporter) Stop ¶
func (t *HTTPTransporter) Stop(graceful bool) error
Stop stops the http transporter by closing the listener.
func (*HTTPTransporter) UPID ¶
func (t *HTTPTransporter) UPID() *upid.UPID
UPID returns the upid of the transporter.
type MesosMessenger ¶
type MesosMessenger struct {
// contains filtered or unexported fields
}
MesosMessenger is an implementation of the Messenger interface.
func New ¶
func New(upid *upid.UPID, t Transporter) *MesosMessenger
func NewHttp ¶
func NewHttp(upid *upid.UPID) *MesosMessenger
NewMesosMessenger creates a new mesos messenger.
func NewHttpWithBindingAddress ¶
func NewHttpWithBindingAddress(upid *upid.UPID, address net.IP) *MesosMessenger
func (*MesosMessenger) Install ¶
func (m *MesosMessenger) Install(handler MessageHandler, msg proto.Message) error
/ Install installs the handler with the given message.
func (*MesosMessenger) Route ¶
Route puts a message either in the incoming or outgoing queue. This method is useful for: 1) routing internal error to callback handlers 2) testing components without starting remote servers.
func (*MesosMessenger) Send ¶
Send puts a message into the outgoing queue, waiting to be sent. With buffered channels, this will not block under moderate throughput. When an error is generated, the error can be communicated by placing a message on the incoming queue to be handled upstream.
func (*MesosMessenger) Stop ¶
func (m *MesosMessenger) Stop() error
Stop stops the messenger and clean up all the goroutines.
func (*MesosMessenger) UPID ¶
func (m *MesosMessenger) UPID() *upid.UPID
UPID returns the upid of the messenger.
type Message ¶
Message defines the type that passes in the Messenger.
func (*Message) RequestURI ¶
RequestURI returns the request URI of the message.
type MessageHandler ¶
MessageHandler is the callback of the message. When the callback is invoked, the sender's upid and the message is passed to the callback.
type Messenger ¶
type Messenger interface { Install(handler MessageHandler, msg proto.Message) error Send(ctx context.Context, upid *upid.UPID, msg proto.Message) error Route(ctx context.Context, from *upid.UPID, msg proto.Message) error Start() error Stop() error UPID() *upid.UPID }
Messenger defines the interfaces that should be implemented.
type MockedMessenger ¶
MockedMessenger is a messenger that returns error on every operation.
func NewMockedMessenger ¶
func NewMockedMessenger() *MockedMessenger
NewMockedMessenger returns a mocked messenger used for testing.
func (*MockedMessenger) Install ¶
func (m *MockedMessenger) Install(handler MessageHandler, msg proto.Message) error
Install is a mocked implementation.
func (*MockedMessenger) Recv ¶
func (m *MockedMessenger) Recv(from *upid.UPID, msg proto.Message)
Recv receives a upid and a message, it will dispatch the message to its handler with the upid. This is for testing.
func (*MockedMessenger) Start ¶
func (m *MockedMessenger) Start() error
Start is a mocked implementation.
func (*MockedMessenger) Stop ¶
func (m *MockedMessenger) Stop() error
Stop is a mocked implementation.
func (*MockedMessenger) UPID ¶
func (m *MockedMessenger) UPID() *upid.UPID
UPID is a mocked implementation.
type Transporter ¶
type Transporter interface { //Send sends message to remote process. Must use context to determine //cancelled requests. Will stop sending when transport is stopped. Send(ctx context.Context, msg *Message) error //Rcvd receives and delegate message handling to installed handlers. //Will stop receiving when transport is stopped. Recv() (*Message, error) //Inject injects a message to the incoming queue. Must use context to //determine cancelled requests. Injection is aborted if the transport //is stopped. Inject(ctx context.Context, msg *Message) error //Install mount an handler based on incoming message name. Install(messageName string) //Start starts the transporter and returns immediately. The error chan //is never nil. Start() <-chan error //Stop kills the transporter. Stop(graceful bool) error //UPID returns the PID for transporter. UPID() *upid.UPID }
Transporter defines methods for communicating with remote processes.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package testmessage is a generated protocol buffer package.
|
Package testmessage is a generated protocol buffer package. |