discovery

package
v0.69.23 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2025 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const PeerExchangeProtocol = "/debros/peer-exchange/1.0.0"

Protocol ID for peer exchange

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	DiscoveryInterval time.Duration
	MaxConnections    int
}

Config contains discovery configuration

type Manager

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

Manager handles peer discovery operations without a DHT dependency. Note: The constructor intentionally accepts a second parameter of type interface{} to remain source-compatible with previous call sites that passed a DHT instance. The value is ignored.

func NewManager

func NewManager(h host.Host, _ interface{}, logger *zap.Logger) *Manager

NewManager creates a new discovery manager.

The second parameter is intentionally typed as interface{} so callers that previously passed a DHT instance can continue to do so; the value is ignored.

func NewManagerSimple

func NewManagerSimple(h host.Host, logger *zap.Logger) *Manager

NewManagerSimple creates a manager with a cleaner signature (host + logger).

func (*Manager) Start

func (d *Manager) Start(config Config) error

Start begins periodic peer discovery

func (*Manager) StartProtocolHandler added in v0.51.1

func (d *Manager) StartProtocolHandler()

StartProtocolHandler registers the peer exchange protocol handler on the host

func (*Manager) Stop

func (d *Manager) Stop()

Stop stops peer discovery

func (*Manager) TriggerPeerExchange added in v0.53.2

func (d *Manager) TriggerPeerExchange(ctx context.Context) int

TriggerPeerExchange manually triggers peer exchange with all connected peers This is useful for pre-startup cluster discovery to populate the peerstore with RQLite metadata

type PeerExchangeRequest added in v0.51.1

type PeerExchangeRequest struct {
	Limit int `json:"limit"`
}

PeerExchangeRequest represents a request for peer information

type PeerExchangeResponse added in v0.51.1

type PeerExchangeResponse struct {
	Peers          []PeerInfo          `json:"peers"`
	RQLiteMetadata *RQLiteNodeMetadata `json:"rqlite_metadata,omitempty"`
}

PeerExchangeResponse represents a list of peers to exchange

type PeerExchangeResponseV2 added in v0.53.2

type PeerExchangeResponseV2 struct {
	Peers          []PeerInfo          `json:"peers"`
	RQLiteMetadata *RQLiteNodeMetadata `json:"rqlite_metadata,omitempty"`
}

PeerExchangeResponseV2 extends the original response with RQLite metadata

type PeerInfo added in v0.51.1

type PeerInfo struct {
	ID    string   `json:"id"`
	Addrs []string `json:"addrs"`
}

PeerInfo contains peer identity and addresses

type RQLiteNodeMetadata added in v0.53.2

type RQLiteNodeMetadata struct {
	NodeID         string    `json:"node_id"`         // RQLite node ID (from config)
	RaftAddress    string    `json:"raft_address"`    // Raft port address (e.g., "51.83.128.181:7001")
	HTTPAddress    string    `json:"http_address"`    // HTTP API address (e.g., "51.83.128.181:5001")
	NodeType       string    `json:"node_type"`       // "bootstrap" or "node"
	RaftLogIndex   uint64    `json:"raft_log_index"`  // Current Raft log index (for data comparison)
	LastSeen       time.Time `json:"last_seen"`       // Updated on every announcement
	ClusterVersion string    `json:"cluster_version"` // For compatibility checking
}

RQLiteNodeMetadata contains RQLite-specific information announced via LibP2P

Jump to

Keyboard shortcuts

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