Documentation ¶
Index ¶
- func EqualEvent(a, b Event) bool
- type Event
- type EventType
- type MessageStreamHandler
- type Node
- func (n *Node) Addrs() []multiaddr.Multiaddr
- func (n *Node) Close() error
- func (n *Node) ConnectDirectly(m *Node) error
- func (n *Node) Dialer() message.MultiDialer
- func (n *Node) ID() peer.ID
- func (n *Node) RegisterService(sa *api.ServiceAddress, handler MessageStreamHandler) bool
- func (n *Node) SelfDialer() message.Dialer
- func (s *Node) WaitForService(ctx context.Context, addr multiaddr.Multiaddr) error
- type Options
- type ServiceRegisteredEvent
- func (v *ServiceRegisteredEvent) Copy() *ServiceRegisteredEvent
- func (v *ServiceRegisteredEvent) CopyAsInterface() interface{}
- func (v *ServiceRegisteredEvent) Equal(u *ServiceRegisteredEvent) bool
- func (v *ServiceRegisteredEvent) IsValid() error
- func (v *ServiceRegisteredEvent) MarshalBinary() ([]byte, error)
- func (v *ServiceRegisteredEvent) MarshalJSON() ([]byte, error)
- func (*ServiceRegisteredEvent) Type() EventType
- func (v *ServiceRegisteredEvent) UnmarshalBinary(data []byte) error
- func (v *ServiceRegisteredEvent) UnmarshalBinaryFrom(rd io.Reader) error
- func (v *ServiceRegisteredEvent) UnmarshalFieldsFrom(reader *encoding.Reader) error
- func (v *ServiceRegisteredEvent) UnmarshalJSON(data []byte) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EqualEvent ¶
EqualEvent is used to compare the values of the union
Types ¶
type Event ¶
type Event interface { encoding.UnionValue Type() EventType }
func UnmarshalEvent ¶
UnmarshalEvent unmarshals a Event.
func UnmarshalEventFrom ¶
UnmarshalEventFrom unmarshals a Event.
func UnmarshalEventJSON ¶
UnmarshalEventJson unmarshals a Event.
type EventType ¶
type EventType uint64
const EventTypeServiceRegistered EventType = 1
EventTypeServiceRegistered .
func EventTypeByName ¶
EventTypeByName returns the named Event Type.
func (EventType) GetEnumValue ¶
GetEnumValue returns the value of the Event Type
func (EventType) MarshalJSON ¶
MarshalJSON marshals the Event Type to JSON as a string.
func (*EventType) SetEnumValue ¶
SetEnumValue sets the value. SetEnumValue returns false if the value is invalid.
func (*EventType) UnmarshalJSON ¶
UnmarshalJSON unmarshals the Event Type from JSON as a string.
type MessageStreamHandler ¶
A MessageStreamHandler handles an incoming message.Stream.
type Node ¶
type Node struct {
// contains filtered or unexported fields
}
Node implements peer-to-peer routing of API v3 messages over via binary message transport.
func (*Node) ConnectDirectly ¶
ConnectDirectly connects this node directly to another node.
func (*Node) Dialer ¶
func (n *Node) Dialer() message.MultiDialer
Dialer returns a message.MultiDialer that knows how to dial any partition or node in the network.
func (*Node) RegisterService ¶
func (n *Node) RegisterService(sa *api.ServiceAddress, handler MessageStreamHandler) bool
RegisterService registers a service handler.
func (*Node) SelfDialer ¶
SelfDialer returns a message.Dialer that always returns a stream for the current node.
func (*Node) WaitForService ¶
WaitForService blocks until the given service is available. WaitForService will return once the service is registered on the current node or until the node is informed of a peer with the given service. WaitForService will return immediately if the service is already registered or known.
type Options ¶
type Options struct { Logger log.Logger // Network is the network the node is a part of. An empty Network indicates // the node is not part of any network. Network string // Listen is an array of addresses to listen on. Listen []multiaddr.Multiaddr // BootstrapPeers is an array of addresses of the bootstrap peers to connect // to on bootup. BootstrapPeers []multiaddr.Multiaddr // Key is the node's private key. If Key is omitted, the node will // generate a new key. Key ed25519.PrivateKey // DiscoveryMode determines how the node responds to peer discovery // requests. DiscoveryMode dht.ModeOpt // External is the node's external address External multiaddr.Multiaddr }
Options are options for creating a Node.
type ServiceRegisteredEvent ¶
type ServiceRegisteredEvent struct { PeerID p2p.PeerID `json:"peerID,omitempty" form:"peerID" query:"peerID" validate:"required"` Network string `json:"network,omitempty" form:"network" query:"network" validate:"required"` Address *api.ServiceAddress `json:"address,omitempty" form:"address" query:"address" validate:"required"` // contains filtered or unexported fields }
func (*ServiceRegisteredEvent) Copy ¶
func (v *ServiceRegisteredEvent) Copy() *ServiceRegisteredEvent
func (*ServiceRegisteredEvent) CopyAsInterface ¶
func (v *ServiceRegisteredEvent) CopyAsInterface() interface{}
func (*ServiceRegisteredEvent) Equal ¶
func (v *ServiceRegisteredEvent) Equal(u *ServiceRegisteredEvent) bool
func (*ServiceRegisteredEvent) IsValid ¶
func (v *ServiceRegisteredEvent) IsValid() error
func (*ServiceRegisteredEvent) MarshalBinary ¶
func (v *ServiceRegisteredEvent) MarshalBinary() ([]byte, error)
func (*ServiceRegisteredEvent) MarshalJSON ¶
func (v *ServiceRegisteredEvent) MarshalJSON() ([]byte, error)
func (*ServiceRegisteredEvent) Type ¶
func (*ServiceRegisteredEvent) Type() EventType
func (*ServiceRegisteredEvent) UnmarshalBinary ¶
func (v *ServiceRegisteredEvent) UnmarshalBinary(data []byte) error
func (*ServiceRegisteredEvent) UnmarshalBinaryFrom ¶
func (v *ServiceRegisteredEvent) UnmarshalBinaryFrom(rd io.Reader) error
func (*ServiceRegisteredEvent) UnmarshalFieldsFrom ¶
func (v *ServiceRegisteredEvent) UnmarshalFieldsFrom(reader *encoding.Reader) error
func (*ServiceRegisteredEvent) UnmarshalJSON ¶
func (v *ServiceRegisteredEvent) UnmarshalJSON(data []byte) error