Documentation ¶
Index ¶
Constants ¶
View Source
const ( BROADCAST = -1 BUFF_SIZE = 10000 )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type CServer ¶
type CServer struct { CSPid int CSPeers []int ChannelIn chan *Envelope ChannelOut chan *Envelope ChannelClose chan bool Address string }
Structure of the Server object
func New ¶
Start a server with a json config file It also starts two go routines to handle the incoming and outgoing traffic for the server
type Envelope ¶
type Envelope struct { // On the sender side, Pid identifies the receiving peer. If instead, Pid is // set to cluster.BROADCAST, the message is sent to all peers. On the receiver side, the // Id is always set to the original sender. If the Id is not found, the message is silently dropped Pid int // An id that globally and uniquely identifies the message, meant for duplicate detection at // higher levels. It is opaque to this package. MsgId int64 // the actual message. Msg interface{} }
func DeSerialize ¶
Deserialization of the Envelope object after receiving from network
type Server ¶
type Server interface { // Id of this server Pid() int // array of other servers' ids in the same cluster Peers() []int // the channel to use to send messages to other peers // Note that there are no guarantees of message delivery, and messages // are silently dropped Outbox() chan *Envelope // the channel to receive messages from other peers. Inbox() chan *Envelope }
Click to show internal directories.
Click to hide internal directories.