Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ClientMsgWrapper ¶
type ClientMsgWrapper struct { Msg interface{} Timestamp hlc.Timestamp C chan interface{} // reply channel created by request receiver }
generic client protocol msg with HLC
func (*ClientMsgWrapper) Reply ¶
func (c *ClientMsgWrapper) Reply(reply interface{})
Reply replies to current client session
func (*ClientMsgWrapper) SetReplier ¶
func (c *ClientMsgWrapper) SetReplier(encoder *gob.Encoder)
func (ClientMsgWrapper) String ¶
func (c ClientMsgWrapper) String() string
type Codec ¶
type Codec interface { Scheme() string Encode(interface{}) Decode(interface{}) }
Codec interface provide methods for serialization and deserialization combines json and gob encoder decoder interface
type Communication ¶
type Communication interface { AddAddress(id idservice.ID, addr string) GetAddresses() map[idservice.ID]string GetKnownIDs() []idservice.ID // Send put message to outbound queue Send(to idservice.ID, m interface{}) error // MulticastZone send msg to all nodes in the same site MulticastZone(zone int, m interface{}) // MulticastQuorum sends msg to random number of nodes MulticastQuorum(quorum int, m interface{}) // Broadcast send to all peers Broadcast(m interface{}) // BroadcastOneDifferent sends m1 to one random peer, and m2 to the rest BroadcastOneDifferent(m1 interface{}, m2 interface{}) // Recv receives a message Recv() interface{} Close() // Fault injection Drop(id idservice.ID, t int) // drops every message send to NodeId last for t seconds Slow(id idservice.ID, d int, t int) // delays every message send to NodeId for d ms and last for t seconds Flaky(id idservice.ID, p float64, t int) // drop message by chance p for t seconds Crash(t int) // node crash for t seconds }
Communication integrates all networking interface and fault injections
func NewClientCommunicator ¶
func NewClientCommunicator(addrs map[idservice.ID]string) Communication
NewCommunicator return Communication interface instance given self NodeId, node list, transportLink and codec name
func NewCommunicator ¶
NewCommunicator return Communication interface instance given self NodeId, node list, transportLink and codec name
type HandshakeMsg ¶
type HandshakeMsg struct { IsClient bool // whether this is a client connecting, if not we should have a NodeId NodeId idservice.ID }
Initial Handshake
func (HandshakeMsg) String ¶
func (h HandshakeMsg) String() string
type ProtocolMsg ¶
generic protocol msg with HLC
func (ProtocolMsg) String ¶
func (p ProtocolMsg) String() string
type Read ¶
Read can be used as a special request that directly read the value of key without go through replication protocol in Replica
type Reply ¶
type Request ¶
type Request struct { Command db.Command // Commands for the request Properties map[string]string // any additional metadata Timestamp int64 NodeID idservice.ID // forward by node. This means the request is not directly from client and is forwarded }
Request is client request with http response channel
type TransportLink ¶
type TransportLink interface { // Scheme returns transportLink scheme Scheme() string // Mode returns whether this transportLink is a listener of a dialer Mode() TransportMode // Send sends message into t.send chan Send(interface{}) // Recv waits for message from t.recv chan Recv() interface{} // Dial connects to remote server non-blocking once connected Dial() error // StartOutgoing starts sending any messages in outbound channel on an existing connection StartOutgoing(conn net.Conn) // Starts handling incoming messages from the remote endpoint StartIncoming(conn net.Conn, tm TransportLinkManager) // Listen waits for connections, non-blocking once listener starts Listen(tm TransportLinkManager) // Close closes send channel and stops listener Close() }
TransportLink = client & server
func NewTransportLink ¶
func NewTransportLink(endpointAddr string, nodeId idservice.ID, isClientTransport bool) TransportLink
NewTransportLink creates new transportLink object with end point url, this node's NodeId and client flag for transports that dial to remote server, endpoint is address of the remote server for transports that listen for incoming connection, endpointAddr does not matter nodeId is this node isClientTransport should be set to true if this transportLink is on the client side and there is no nodeId
type TransportLinkManager ¶
type TransportLinkManager interface { // Adds transportLink to an existing pool of all transports AddTransportLink(t TransportLink, to idservice.ID) }
type TransportMode ¶
type TransportMode int
const ( ModeNone TransportMode = iota ModeListener // for server that listens for connections ModeDialer // for client that dials the server ModeClosed )
func (TransportMode) String ¶
func (m TransportMode) String() string