Documentation ¶
Index ¶
- func NewHostTransport(transport InternalTransport, resolver Resolver) network.HostNetwork
- type InternalTransport
- type Resolver
- type TransportResolvable
- func (tr *TransportResolvable) BuildResponse(request network.Request, responseData interface{}) network.Response
- func (tr *TransportResolvable) NewRequestBuilder() network.RequestBuilder
- func (tr *TransportResolvable) PublicAddress() string
- func (tr *TransportResolvable) RegisterRequestHandler(t types.PacketType, handler network.RequestHandler)
- func (tr *TransportResolvable) SendRequest(request network.Request, receiver core.RecordRef) (network.Future, error)
- func (tr *TransportResolvable) Start()
- func (tr *TransportResolvable) Stop()
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewHostTransport ¶ added in v0.6.2
func NewHostTransport(transport InternalTransport, resolver Resolver) network.HostNetwork
Types ¶
type InternalTransport ¶ added in v0.6.2
type InternalTransport interface { // Start listening to network requests, should be started in goroutine. Start() // Stop listening to network requests. Stop() // PublicAddress returns public address that can be published for all nodes. PublicAddress() string // SendRequestPacket send request packet to a remote node. SendRequestPacket(request network.Request, receiver *host.Host) (network.Future, error) // RegisterPacketHandler register a handler function to process incoming requests of a specific type. RegisterPacketHandler(t types.PacketType, handler network.RequestHandler) // NewRequestBuilder create packet builder for an outgoing request with sender set to current node. NewRequestBuilder() network.RequestBuilder // BuildResponse create response to an incoming request with Data set to responseData. BuildResponse(request network.Request, responseData interface{}) network.Response }
InternalTransport simple interface to send network requests and process network responses.
func NewInternalTransport ¶ added in v0.6.2
func NewInternalTransport(conf configuration.Configuration) (InternalTransport, error)
type Resolver ¶ added in v0.6.2
type Resolver interface { Resolve(nodeID core.RecordRef) (string, error) AddToKnownHosts(h *host.Host) }
Resolver is an interface that helps TransportResolvable to resolve NodeID -> Address.
type TransportResolvable ¶ added in v0.6.2
type TransportResolvable struct {
// contains filtered or unexported fields
}
TransportResolvable is implementation of HostNetwork interface that is capable of address resolving.
func (*TransportResolvable) BuildResponse ¶ added in v0.6.2
func (tr *TransportResolvable) BuildResponse(request network.Request, responseData interface{}) network.Response
BuildResponse create response to an incoming request with Data set to responseData.
func (*TransportResolvable) NewRequestBuilder ¶ added in v0.6.2
func (tr *TransportResolvable) NewRequestBuilder() network.RequestBuilder
NewRequestBuilder create packet builder for an outgoing request with sender set to current node.
func (*TransportResolvable) PublicAddress ¶ added in v0.6.2
func (tr *TransportResolvable) PublicAddress() string
PublicAddress returns public address that can be published for all nodes.
func (*TransportResolvable) RegisterRequestHandler ¶ added in v0.6.2
func (tr *TransportResolvable) RegisterRequestHandler(t types.PacketType, handler network.RequestHandler)
RegisterRequestHandler register a handler function to process incoming requests of a specific type.
func (*TransportResolvable) SendRequest ¶ added in v0.6.2
func (tr *TransportResolvable) SendRequest(request network.Request, receiver core.RecordRef) (network.Future, error)
SendRequest send request to a remote node.
func (*TransportResolvable) Start ¶ added in v0.6.2
func (tr *TransportResolvable) Start()
Start listening to network requests.
func (*TransportResolvable) Stop ¶ added in v0.6.2
func (tr *TransportResolvable) Stop()
Stop listening to network requests.