Documentation
¶
Index ¶
- type Address
- type Identifier
- type Message
- type RPCServer
- func (rpcs *RPCServer) Close()
- func (rpcs *RPCServer) LearnHostname() (err error)
- func (rpcs *RPCServer) Ping(a Address) error
- func (rpcs *RPCServer) RegisterHandler(handler interface{}) Address
- func (rpcs *RPCServer) SendAsyncMessage(m Message) chan error
- func (rpcs *RPCServer) SendMessage(m Message) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Address ¶
type Address struct {
Host string
Port uint16
ID Identifier
}
An Address couples an Identifier with its network address.
type Message ¶
A Message is for sending requests over the network. It consists of an Address and an RPC.
type RPCServer ¶
type RPCServer struct {
// contains filtered or unexported fields
}
An RPCServer handles all RPCs for a given hostname and port. It routes each RPC according to its Identifier. Objects must register themselves with the RPCServer in order to receive an Address. This implementation currently uses the JSON codec over TCP.
func NewRPCServer ¶
NewRPCServer creates and initializes a server that listens for TCP connections on a specified port. It then spawns a serverHandler with a specified message. It is the caller's responsibility to close the TCP listener, via RPCServer.Close().
func (*RPCServer) Close ¶
func (rpcs *RPCServer) Close()
Close closes the connection associated with the TCP server. This causes tcpServ.Accept() to return an err, ending the serverHandler process.
func (*RPCServer) LearnHostname ¶
LearnHostname determines the external IP of the RPCserver by asking an external source. This will be updated in the future to ask a Participant instead of a third-party service.
func (*RPCServer) Ping ¶
Ping calls the Participant.Ping method on the specified address. Note that neither Ping nor any of the SendMessage functions really need to be methods of RPCServer. This may change in the future.
func (*RPCServer) RegisterHandler ¶
RegisterHandler registers a message handler to the RPC server. The handler is assigned an Identifier, which is returned to the caller. The Identifier is appended to the service name before registration.
func (*RPCServer) SendAsyncMessage ¶
SendAsyncMessage (asynchronously) delivers a Message to its recipient. It returns a channel that will contain an error value when the request completes. Like SendMessage, it times out after 'timeout' seconds.
func (*RPCServer) SendMessage ¶
SendMessage synchronously delivers a Message to its recipient and returns any errors. It times out after waiting for 'timeout' seconds.