Documentation ¶
Index ¶
- Constants
- Variables
- func NewForwardingHost(h host.Host, proxy peer.AddrInfo) host.Host
- type ErrNotRegistered
- type ForwardingHost
- func (fh *ForwardingHost) Close() error
- func (fh *ForwardingHost) Connect(ctx context.Context, pi peer.AddrInfo) error
- func (fh *ForwardingHost) NewStream(ctx context.Context, p peer.ID, protocols ...protocol.ID) (network.Stream, error)
- func (fh *ForwardingHost) RemoveStreamHandler(pid protocol.ID)
- func (fh *ForwardingHost) SetStreamHandler(pid protocol.ID, handler network.StreamHandler)
- type ProtocolProxy
- func (pp *ProtocolProxy) Close()
- func (pp *ProtocolProxy) Connected(n network.Network, c network.Conn)
- func (pp *ProtocolProxy) Disconnected(n network.Network, c network.Conn)
- func (pp *ProtocolProxy) Listen(network.Network, multiaddr.Multiaddr)
- func (pp *ProtocolProxy) ListenClose(network.Network, multiaddr.Multiaddr)
- func (pp *ProtocolProxy) Start(ctx context.Context)
Constants ¶
const ForwardingProtocolID protocol.ID = "/libp2p/balancer/forwarding/0.0.1"
ForwardingProtocolID identifies the protocol for requesting forwarding of a protocol for the libp2p load balancer
Variables ¶
var ErrInboundRequestsAreSingleProtocol = errors.New("inbound requests are single protocol")
ErrInboundRequestsAreSingleProtocol is thrown by the service node when it receives and outbound request
var ErrNoInboundRequests = errors.New("inbound requests not accepted")
ErrNoInboundRequests is thrown by the load balancer when it receives and inbound request
var ErrNoOutboundRequests = errors.New("outbound requests not accepted")
ErrNoOutboundRequests is thrown by the service node when it receives and outbound request
Functions ¶
func NewForwardingHost ¶
NewForwardingHost node constructs a service node connected to the given proxy on the passed in host. A forwarding host behaves exactly like a host.Host but setting up new protocol handlers registers routes on the proxy node.
Types ¶
type ErrNotRegistered ¶
type ErrNotRegistered struct {
// contains filtered or unexported fields
}
ErrNotRegistered indicates a peer has not registered a given protocol but is trying to extend or terminate the registration
func (ErrNotRegistered) Error ¶
func (e ErrNotRegistered) Error() string
type ForwardingHost ¶
ForwardingHost is a host that behaves as a service node connected to a proxy -- all traffic is routed through the proxy for each registered protocol
func (*ForwardingHost) Close ¶
func (fh *ForwardingHost) Close() error
Close shuts down a service node host's forwarding
func (*ForwardingHost) NewStream ¶
func (fh *ForwardingHost) NewStream(ctx context.Context, p peer.ID, protocols ...protocol.ID) (network.Stream, error)
Calls to "NewStream" open an outbound forwarding request to the proxy, that is then sent on the the specified peer
func (*ForwardingHost) RemoveStreamHandler ¶
func (fh *ForwardingHost) RemoveStreamHandler(pid protocol.ID)
RemoveStreamHandler removes a stream handler by shutting down registered route with the original host
func (*ForwardingHost) SetStreamHandler ¶
func (fh *ForwardingHost) SetStreamHandler(pid protocol.ID, handler network.StreamHandler)
SetStreamHandler interrupts the normal process of setting up stream handlers by also registering a route on the connected protocol proxy. All traffic on the forwarding protocol will go through the forwarding handshake with the proxy, then the native handler will be called
type ProtocolProxy ¶
type ProtocolProxy struct {
// contains filtered or unexported fields
}
func NewProtocolProxy ¶
func (*ProtocolProxy) Close ¶
func (pp *ProtocolProxy) Close()
func (*ProtocolProxy) Connected ¶
func (pp *ProtocolProxy) Connected(n network.Network, c network.Conn)
Connected checks the peersConfig and begins listening any time a service node connects
func (*ProtocolProxy) Disconnected ¶
func (pp *ProtocolProxy) Disconnected(n network.Network, c network.Conn)
Disconnected checks the peersConfig and removes listening when a service node disconnects
func (*ProtocolProxy) Listen ¶
func (pp *ProtocolProxy) Listen(network.Network, multiaddr.Multiaddr)
Listen satifies the network.Notifee interface but does nothing
func (*ProtocolProxy) ListenClose ¶
func (pp *ProtocolProxy) ListenClose(network.Network, multiaddr.Multiaddr)
ListenClose satifies the network.Notifee interface but does nothing
func (*ProtocolProxy) Start ¶
func (pp *ProtocolProxy) Start(ctx context.Context)