GoMM

package module
v0.0.0-...-d4bea61 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2014 License: MIT Imports: 12 Imported by: 1

README

build status

GoMM

Distributed computing with varying cluster size in Go

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChannelMessenger

type ChannelMessenger struct {
	ResolverMap map[string]chan Message // Used by the resolver function to send messages
	Incoming    chan Message
}

Implements the messenger interface over channels. Useful for local testing and debugging.

func GetChannelMessenger

func GetChannelMessenger(name string, resolverMap map[string]chan Message) ChannelMessenger

func GetChannelMessengers

func GetChannelMessengers(names []string, resolverMap map[string]chan Message) []ChannelMessenger

Returns the ChannelMessengers and adds them all to the supplied resolver map.

func (ChannelMessenger) Recv

func (messenger ChannelMessenger) Recv(channel chan Message) error

func (ChannelMessenger) Send

func (messenger ChannelMessenger) Send(msg Message) error

type Client

type Client struct {
	ActiveMembersLock sync.Mutex
	ActiveMembers     map[string]Node // Members that are online and active, mapped by the memberlist.Node.Name
	Name              string          // Unique name of the Client

	// Channel for recieve broadcast messages
	BroadcastChannel chan Message
	// contains filtered or unexported fields
}

func GetLocalClients

func GetLocalClients(num int) []*Client

Get Clients for the test

func GetTCPClient

func GetTCPClient(factory ClientFactory) (*Client, error)

func GetTCPClients

func GetTCPClients(num int) ([]*Client, error)

Get TCP clients

func (*Client) Barrier

func (c *Client) Barrier()

Barrier that blacks for all active nodes

func (*Client) Broadcast

func (c *Client) Broadcast(stringData []string, floatData []float64)

Send message to all nodes TODO implement a tree rather than naive send to all

func (*Client) Close

func (c *Client) Close()

func (*Client) GetAddrId

func (c *Client) GetAddrId(addr string) (int, error)

func (*Client) GetId

func (c *Client) GetId() int

func (*Client) GetNumPendingMembers

func (c *Client) GetNumPendingMembers() int

func (*Client) HandleMessage

func (c *Client) HandleMessage(msg Message)

func (*Client) IsActive

func (c *Client) IsActive() bool

Determine if the given Client is in the active pool

func (*Client) Join

func (c *Client) Join(address string) error

Cause a node to join another memberlist group. This function removes this node from the active list. Further more, this should only be called when a node is alone in it's undelying memberlist. Therefore, a group of nodes cannot merge with another group, but the sub group must all join individually. Should this be blocking until the node is made active?

func (*Client) JoinAddr

func (c *Client) JoinAddr() string

func (*Client) NotifyJoin

func (c *Client) NotifyJoin(n *memberlist.Node)

func (*Client) NotifyLeave

func (c *Client) NotifyLeave(n *memberlist.Node)

func (*Client) NotifyUpdate

func (c *Client) NotifyUpdate(n *memberlist.Node)

func (*Client) NumActiveMembers

func (c *Client) NumActiveMembers() int

func (*Client) NumMembers

func (c *Client) NumMembers() int

func (*Client) ResolveId

func (c *Client) ResolveId(id int) (string, error)

Resolve the id to a client address. The id is currently based on the sorted string order of the nodes address.

func (*Client) Start

func (c *Client) Start() error

func (*Client) UpdateActiveMembers

func (c *Client) UpdateActiveMembers() int

Allows members currently waiting to become active to become active, this method blocks and requires that all current active members have also called this method.

func (*Client) WaitActive

func (c *Client) WaitActive()

Wait until the Client is active

type ClientFactory

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

func (*ClientFactory) NewClient

func (f *ClientFactory) NewClient() *Client

type Listener

type Listener struct {
	sync.Mutex // Embedded lock
	// contains filtered or unexported fields
}

Listener for messengers

func NewListener

func NewListener(msgHandler MessageHandler) *Listener

func (*Listener) Listen

func (l *Listener) Listen(messenger Messenger) error

Blocking call that polls for call

func (*Listener) Stop

func (l *Listener) Stop() error

type Message

type Message struct {
	Type       messageType
	Target     string
	Origin     int // Origin of the message
	StringData []string
	FloatData  []float64
}

Messages that can be sent by messengers

func CreateBroadcastMsg

func CreateBroadcastMsg(stringData []string, floatData []float64) Message

type MessageHandler

type MessageHandler interface {
	HandleMessage(msg Message)
}

type Messenger

type Messenger interface {
	// Blocking call to send a message
	Send(msg Message) error
	// Blocking call to receive a message
	Recv(channel chan Message) error
	// contains filtered or unexported methods
}

Interface for sending peer to peer messages

type Node

type Node struct {
	Name           string
	Addr           net.IP // The address this node can be access at
	Port           int    // The port this node listens for connections on
	MemberlistPort int
}

func (Node) GetMemberlistStringAddr

func (n Node) GetMemberlistStringAddr() string

func (Node) GetStringAddr

func (n Node) GetStringAddr() string

func (Node) GetTCPAddr

func (n Node) GetTCPAddr() net.TCPAddr

Retruns the connection address for this node

type TCPMessenger

type TCPMessenger struct {
	Name string
	// contains filtered or unexported fields
}

Messenger over TCP http://stackoverflow.com/questions/19167970/mock-functions-in-golang Good thoughts on how to mock out the messageing https://eclipse.org/paho/clients/golang/ http://golang.org/pkg/net/textproto/ Good messaging library

func GetTCPMessenger

func GetTCPMessenger(name string, localAddr string) (*TCPMessenger, error)

func (*TCPMessenger) Close

func (messenger *TCPMessenger) Close() error

func (*TCPMessenger) Decode

func (messenger *TCPMessenger) Decode(b []byte) (Message, error)

func (*TCPMessenger) Encode

func (messenger *TCPMessenger) Encode(msg Message) (outputMsg string, err error)

Encodes a messafe for sending over a tcp connection. Format is: {len in}\n{msgbody}

func (*TCPMessenger) Recv

func (messenger *TCPMessenger) Recv(channel chan Message) error

func (*TCPMessenger) Send

func (messenger *TCPMessenger) Send(msg Message) error

Jump to

Keyboard shortcuts

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