messenger

package module
v0.0.0-...-6600a07 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2014 License: Apache-2.0 Imports: 6 Imported by: 0

README

messenger

A messenger module, that is necessary for every distributed system

![GoDoc] (https://godoc.org/github.com/go-distributed/messenger?status.png) Build Status

####Install

$ go get github.com/tools/godep
$ godep get github.com/go-distributed/messenger

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MessageHandler

type MessageHandler func(interface{})

MessageHandler is a callback that handles the messages. One can register the message with the callback by calling RegisterHandler.

type Messenger

type Messenger struct {
	// contains filtered or unexported fields
}

Messenger is an abstraction that can send and receive messages.

func New

func New(codec codec.Codec, tr transporter.Transporter,
	enableRecv, enableHandler bool) *Messenger

New create a new messenger. If enableRecv is set to true, then the user should be responsible to consume the message via Recv(), otherwise the the underlying reading will stop if the queue is full. At least one of the enableRecv and enableHandler should be set to true.

func (*Messenger) Destroy

func (m *Messenger) Destroy() error

Destroy the messenger.

func (*Messenger) Recv

func (m *Messenger) Recv() (interface{}, error)

Recv a message.

func (*Messenger) RegisterHandler

func (m *Messenger) RegisterHandler(msg interface{}, msgHandler MessageHandler) error

RegisterHandler regists a message with a handler. When such a message comes in, it will be passed to the handler.

func (*Messenger) RegisterMessage

func (m *Messenger) RegisterMessage(msg interface{}) error

RegisterMessage Regists a message in the messenger. It will call the undelying codec to register the message as well.

func (*Messenger) Send

func (m *Messenger) Send(hostport string, msg interface{}) error

Send a message.

func (*Messenger) Start

func (m *Messenger) Start() error

Start the messenger.

func (*Messenger) Stop

func (m *Messenger) Stop() error

Stop the messenger.

Directories

Path Synopsis
Godeps
_workspace/src/code.google.com/p/gogoprotobuf/proto
Package proto converts data structures to and from the wire format of protocol buffers.
Package proto converts data structures to and from the wire format of protocol buffers.
_workspace/src/github.com/golang/glog
Package glog implements logging analogous to the Google-internal C++ INFO/ERROR/V setup.
Package glog implements logging analogous to the Google-internal C++ INFO/ERROR/V setup.
testexample
Package protobuf is a generated protocol buffer package.
Package protobuf is a generated protocol buffer package.

Jump to

Keyboard shortcuts

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