cluster

package
v0.0.0-...-805a3e1 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2014 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NotifyPath  = "/kylin/cluster/notify"
	ListPath    = "/kylin/cluster/list"
	ConnectPath = "/kylin/cluster/connect"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Address     string   `json:"address"`
	Description string   `json:"description"`
	Nodes       []string `json:"nodes"`
}

type MessageHandler

type MessageHandler func(message interface{}) (handled bool)

type Node

type Node interface {
	Info() NodeInfo
	Start() error
	Stop() error
	WaitForDone()
	AddNodeJoinListener(NodeJoinListener)
	AddNodeDropListener(NodeDropListener)
	List() []NodeInfo
	RegisterMessage(message interface{})
	Broadcast(message interface{})
	SendTo(address string, message interface{})
}

func NewNode

func NewNode(config Config) Node

type NodeConnection

type NodeConnection interface {
	Info() NodeInfo
	Start() error
	Stop() error
	AddMessageHandler(MessageHandler)
	Send(message interface{})
	Conn() *websocket.Conn
	WaitForDone()
}

type NodeDropListener

type NodeDropListener func(NodeConnection)

type NodeInfo

type NodeInfo struct {
	Address     string `json:"address"`
	Description string `json:"description"`
}

type NodeJoinListener

type NodeJoinListener func(NodeConnection)

type OnPubSubMessage

type OnPubSubMessage func(topic string, message interface{})

type PubSub

type PubSub interface {
	Publish(topic string, message interface{})
	Subscribe(topic string)
	Unsubscribe(topic string)
	GetSubscribersAsync(topic string, resultChan chan []string)
	GetSubscribers(topic string) []string
	Start() error
	Stop() error
	WaitForDone()
}

func NewPubSub

func NewPubSub(node Node, onMessage OnPubSubMessage) PubSub

Jump to

Keyboard shortcuts

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