rendezvous

package
v0.8.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 17, 2023 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
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

View Source
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

func ShardToNamespace(cluster uint16, shard uint16) string

ShardToNamespace translates a cluster and shard index into a rendezvous namespace

Types

type DB

type DB struct {
	// contains filtered or unexported fields
}

func NewDB

func NewDB(db *sql.DB, logger *zap.Logger) *DB

func (*DB) Close

func (db *DB) Close() error

func (*DB) CountRegistrations

func (db *DB) CountRegistrations(p peer.ID) (int, error)

func (*DB) Discover

func (db *DB) Discover(ns string, cookie []byte, limit int) ([]dbi.RegistrationRecord, []byte, error)

func (*DB) Register

func (db *DB) Register(p peer.ID, ns string, signedPeerRecord []byte, ttl int) (uint64, error)

func (*DB) Start

func (db *DB) Start(ctx context.Context) error

func (*DB) Unregister

func (db *DB) Unregister(p peer.ID, ns string) error

func (*DB) ValidCookie

func (db *DB) ValidCookie(ns string, cookie []byte) bool

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) Start

func (r *Rendezvous) Start(ctx context.Context) error

func (*Rendezvous) Stop

func (r *Rendezvous) Stop()

type RendezvousPoint added in v0.8.0

type RendezvousPoint struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

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

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL