Documentation ¶
Index ¶
- Constants
- type Connection
- type ConnectionEntry
- type DirectReplyChannel
- type HandshakeRequest
- type HandshakeResponse
- type LocalConnection
- type ReplyChannel
- type RequestHandler
- type Service
- func (s *Service) ConnectToRemoteNode(address string, callback func(node *state.Node))
- func (s *Service) GetConnectedPeers() ([]string, []state.Node)
- func (s *Service) GetConnection(id string) ConnectionEntry
- func (s *Service) GetLocalNode() state.Node
- func (s *Service) GetNodeByAddress(address string) *state.Node
- func (s *Service) GetSeedHosts() []string
- func (s *Service) RegisterRequestHandler(action string, handler RequestHandler)
- func (s *Service) SendRequest(node state.Node, action string, req []byte, callback func(response []byte))
- func (s *Service) SendRequestConn(conn Connection, action string, req []byte, callback func(response []byte))
- func (s *Service) SetConnection(key string, conn ConnectionEntry)
- func (s *Service) Start(port int)
- type Transport
Constants ¶
View Source
const ( HANDSHAKE_REQ = "HANDSHAKE_REQ" HANDSHAKE_ACK = "HANDSHAKE_ACK" HANDSHAKE_FAIL = "HANDSHAKE_FAIL" PEERFIND_REQ = "PEERFIND_REQ" PEERFIND_ACK = "PEERFIND_ACK" PEERFIND_FAIL = "PEERFIND_FAIL" PREVOTE_REQ = "PREVOTE_REQ" PREVOTE_RES = "PREVOTE_RES" PREVOTE_FAIL = "PREVOTE_FAIL" START_JOIN_REQ = "START_JOIN" START_JOIN_ACK = "START_JOIN_ACK" START_JOIN_FAIL = "START_JOIN_FAIL" JOIN_REQ = "JOIN_REQ" PUBLISH_REQ = "PUBLISH_REQ" PUBLISH_ACK = "PUBLISH_ACK" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Connection ¶
type Connection interface { SendRequest(action string, req []byte, callback func(byte []byte)) GetSourceAddress() string GetDestAddress() string GetMessage() string }
Interfaces
type ConnectionEntry ¶
type ConnectionEntry struct {
// contains filtered or unexported fields
}
type DirectReplyChannel ¶
type DirectReplyChannel struct {
// contains filtered or unexported fields
}
func (*DirectReplyChannel) GetDestAddress ¶
func (c *DirectReplyChannel) GetDestAddress() string
func (*DirectReplyChannel) GetSourceAddress ¶
func (c *DirectReplyChannel) GetSourceAddress() string
func (*DirectReplyChannel) SendMessage ¶
func (c *DirectReplyChannel) SendMessage(action string, b []byte) (int, error)
type HandshakeRequest ¶
type HandshakeRequest struct {
RemoteAddress string
}
Handshake
func HandshakeRequestFromBytes ¶
func HandshakeRequestFromBytes(b []byte) *HandshakeRequest
func (*HandshakeRequest) ToBytes ¶
func (h *HandshakeRequest) ToBytes() []byte
type HandshakeResponse ¶
func HandshakeResponseFromBytes ¶
func HandshakeResponseFromBytes(b []byte) *HandshakeResponse
func (*HandshakeResponse) ToBytes ¶
func (h *HandshakeResponse) ToBytes() []byte
type LocalConnection ¶
type LocalConnection struct {
// contains filtered or unexported fields
}
func (*LocalConnection) GetDestAddress ¶
func (c *LocalConnection) GetDestAddress() string
func (*LocalConnection) GetMessage ¶
func (c *LocalConnection) GetMessage() string
func (*LocalConnection) GetSourceAddress ¶
func (c *LocalConnection) GetSourceAddress() string
func (*LocalConnection) SendRequest ¶
func (c *LocalConnection) SendRequest(action string, req []byte, callback func(response []byte))
type ReplyChannel ¶
type Service ¶
type Service struct { LocalNode *state.Node Transport Transport ConnectionManager map[string]ConnectionEntry ConnectionLock sync.RWMutex }
func NewService ¶
func (*Service) ConnectToRemoteNode ¶
func (*Service) GetConnection ¶
func (s *Service) GetConnection(id string) ConnectionEntry
func (*Service) GetLocalNode ¶
func (*Service) GetSeedHosts ¶
func (*Service) RegisterRequestHandler ¶
func (s *Service) RegisterRequestHandler(action string, handler RequestHandler)
func (*Service) SendRequest ¶
func (*Service) SendRequestConn ¶
func (s *Service) SendRequestConn(conn Connection, action string, req []byte, callback func(response []byte))
func (*Service) SetConnection ¶
func (s *Service) SetConnection(key string, conn ConnectionEntry)
type Transport ¶
type Transport interface { OpenConnection(address string, callback func(conn Connection)) Start(port int) Register(action string, handler RequestHandler) GetLocalAddress() string GetSeedHosts() []string GetNodeId() string GetHandler(action string) RequestHandler }
Click to show internal directories.
Click to hide internal directories.