agent

package
v0.0.0-...-831f302 Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2015 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidMessageType = errors.New("Invalid message type")
	ErrNoAvailablePeers   = errors.New("No available peers")
)

Functions

func GenID

func GenID() (n uint64)

Types

type Agent

type Agent interface {
	// Serve starts a standalone agent, waiting for
	// incoming connections.
	Serve() error
	// Join joins the peers.
	Join(peerAddrs ...string) error
	// Leave causes the agent to leave the cluster.
	Leave()
	// Broadcast broadcasts a message to the cluster.
	Broadcast(msg []byte) error
	// RegisterMessageHandler registers a user provided callback.
	RegisterMessageHandler(mh MessageHandler)
	// List prints the infomation in two views.
	List() ([]byte, error)
}

Agent describes the interface of an agent.

func NewAgent

func NewAgent(cfg *config.Config) Agent

NewAgent creates a new agent.

type MessageHandler

type MessageHandler func([]byte)

MessageHandler is the message handler.

Jump to

Keyboard shortcuts

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