Documentation ¶
Index ¶
- Constants
- func ShardToNamespace(cluster uint16, shard uint16) string
- type DB
- func (db *DB) Close() error
- func (db *DB) CountRegistrations(p peer.ID) (int, error)
- func (db *DB) Discover(ns string, cookie []byte, limit int) ([]dbi.RegistrationRecord, []byte, error)
- func (db *DB) Register(p peer.ID, ns string, signedPeerRecord []byte, ttl int) (uint64, error)
- func (db *DB) Start(ctx context.Context) error
- func (db *DB) Unregister(p peer.ID, ns string) error
- func (db *DB) ValidCookie(ns string, cookie []byte) bool
- type PeerConnector
- type Rendezvous
- func (r *Rendezvous) Discover(ctx context.Context, rp *RendezvousPoint, numPeers int)
- func (r *Rendezvous) DiscoverShard(ctx context.Context, rp *RendezvousPoint, cluster uint16, shard uint16, ...)
- func (r *Rendezvous) DiscoverWithNamespace(ctx context.Context, namespace string, rp *RendezvousPoint, numPeers int)
- func (r *Rendezvous) Register(ctx context.Context, rendezvousPoints []*RendezvousPoint)
- func (r *Rendezvous) RegisterRelayShards(ctx context.Context, rs protocol.RelayShards, ...)
- func (r *Rendezvous) RegisterShard(ctx context.Context, cluster uint16, shard uint16, ...)
- func (r *Rendezvous) RegisterWithNamespace(ctx context.Context, namespace string, rendezvousPoints []*RendezvousPoint)
- func (r *Rendezvous) SetHost(h host.Host)
- func (r *Rendezvous) Start(ctx context.Context) error
- func (r *Rendezvous) Stop()
- type RendezvousPoint
- type RendezvousPointIterator
Constants ¶
const RegisterDefaultTTL = rvs.DefaultTTL * time.Second
RegisterDefaultTTL indicates the TTL used by default when registering a node in a rendezvous point TODO: Register* functions should allow setting up a custom TTL
const RendezvousID = rvs.RendezvousProto
RendezvousID is the current protocol ID used for Rendezvous
Variables ¶
This section is empty.
Functions ¶
func ShardToNamespace ¶ added in v0.8.0
ShardToNamespace translates a cluster and shard index into a rendezvous namespace
Types ¶
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
type PeerConnector ¶
type PeerConnector interface {
Subscribe(context.Context, <-chan peermanager.PeerData)
}
PeerConnector will subscribe to a channel containing the information for all peers found by this discovery protocol
type Rendezvous ¶
type Rendezvous struct { *protocol.CommonService // contains filtered or unexported fields }
Rendezvous is the implementation containing the logic to registering a node and discovering new peers using rendezvous protocol
func NewRendezvous ¶
func NewRendezvous(db *DB, peerConnector PeerConnector, log *zap.Logger) *Rendezvous
NewRendezvous creates an instance of Rendezvous struct
func (*Rendezvous) Discover ¶ added in v0.8.0
func (r *Rendezvous) Discover(ctx context.Context, rp *RendezvousPoint, numPeers int)
Discover is used to find a number of peers that use the default pubsub topic
func (*Rendezvous) DiscoverShard ¶ added in v0.8.0
func (r *Rendezvous) DiscoverShard(ctx context.Context, rp *RendezvousPoint, cluster uint16, shard uint16, numPeers int)
DiscoverShard is used to find a number of peers that support an specific cluster and shard index
func (*Rendezvous) DiscoverWithNamespace ¶ added in v0.8.0
func (r *Rendezvous) DiscoverWithNamespace(ctx context.Context, namespace string, rp *RendezvousPoint, numPeers int)
DiscoverWithNamespace is used to find a number of peers using a custom namespace (usually a pubsub topic)
func (*Rendezvous) Register ¶ added in v0.8.0
func (r *Rendezvous) Register(ctx context.Context, rendezvousPoints []*RendezvousPoint)
Register registers the node in the rendezvous points using the default pubsub topic as namespace
func (*Rendezvous) RegisterRelayShards ¶ added in v0.8.0
func (r *Rendezvous) RegisterRelayShards(ctx context.Context, rs protocol.RelayShards, rendezvousPoints []*RendezvousPoint)
RegisterRelayShards registers the node in the rendezvous point by specifying a RelayShards struct (more than one shard index can be registered)
func (*Rendezvous) RegisterShard ¶ added in v0.8.0
func (r *Rendezvous) RegisterShard(ctx context.Context, cluster uint16, shard uint16, rendezvousPoints []*RendezvousPoint)
RegisterShard registers the node in the rendezvous points using a shard as namespace
func (*Rendezvous) RegisterWithNamespace ¶ added in v0.8.0
func (r *Rendezvous) RegisterWithNamespace(ctx context.Context, namespace string, rendezvousPoints []*RendezvousPoint)
RegisterWithNamespace registers the node in the rendezvous point by using an specific namespace (usually a pubsub topic)
func (*Rendezvous) SetHost ¶ added in v0.6.0
func (r *Rendezvous) SetHost(h host.Host)
Sets the host to be able to mount or consume a protocol
func (*Rendezvous) Stop ¶
func (r *Rendezvous) Stop()
type RendezvousPoint ¶ added in v0.8.0
RendezvousPoint is a structure that represent a node that can be used to discover new peers
func NewRendezvousPoint ¶ added in v0.8.0
func NewRendezvousPoint(peerID peer.ID) *RendezvousPoint
NewRendezvousPoint is used to create a RendezvousPoint
func (*RendezvousPoint) Delay ¶ added in v0.8.0
func (rp *RendezvousPoint) Delay()
Delay is used to indicate that the connection to a rendezvous point failed
func (*RendezvousPoint) NextTry ¶ added in v0.8.0
func (rp *RendezvousPoint) NextTry() time.Time
NextTry returns when can a rendezvous point be used again
func (*RendezvousPoint) SetSuccess ¶ added in v0.8.0
func (rp *RendezvousPoint) SetSuccess(cookie []byte)
SetSuccess is used to indicate that a connection to a rendezvous point was succesful
type RendezvousPointIterator ¶ added in v0.8.0
type RendezvousPointIterator struct {
// contains filtered or unexported fields
}
func NewRendezvousPointIterator ¶ added in v0.8.0
func NewRendezvousPointIterator(rendezvousPoints []multiaddr.Multiaddr) *RendezvousPointIterator
NewRendezvousPointIterator creates an iterator with a backoff mechanism to use random rendezvous points taking into account successful/unsuccesful connection attempts
func (*RendezvousPointIterator) Next ¶ added in v0.8.0
func (r *RendezvousPointIterator) Next(ctx context.Context) <-chan *RendezvousPoint
Next will return a channel that will be triggered as soon as the next rendevous point is available to be used (depending on backoff time)
func (*RendezvousPointIterator) RendezvousPoints ¶ added in v0.8.0
func (r *RendezvousPointIterator) RendezvousPoints() []*RendezvousPoint
RendezvousPoints returns the list of rendezvous points registered in this iterator