libp2p

package
v0.3.4 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2023 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Overview

Package libp2p provides discovery mechanisms using Kademlia DHT.

Index

Constants

View Source
const JoinProtocol = protocol.ID("/webmesh/join/0.0.1")

JoinProtocol is the protocol used for joining a mesh.

View Source
const RaftProtocol = protocol.ID("/webmesh/raft/0.0.1")

RaftProtocol is the protocol used for webmesh raft.

Variables

This section is empty.

Functions

func NewDHTAnnouncer

func NewDHTAnnouncer(ctx context.Context, opts DHTAnnounceOptions, join transport.JoinServer) (io.Closer, error)

NewDHTAnnouncer creates a new announcer on the kadmilia DHT and executes received join requests against the given join Server.

func NewJoinRoundTripper

func NewJoinRoundTripper(opts RoundTripOptions) transport.JoinRoundTripper

NewJoinRoundTripper returns a round tripper that uses the libp2p kademlia DHT to join a cluster.

func NewRaftTransport added in v0.3.3

func NewRaftTransport(ctx context.Context, opts RaftTransportOptions) (raft.Transport, error)

NewRaftTransport creates a new Raft transport over the Kademlia DHT.

func NewRoundTripper

func NewRoundTripper[REQ, RESP any](opts RoundTripOptions, method string) transport.RoundTripper[REQ, RESP]

NewRoundTripper returns a round tripper that uses the libp2p kademlia DHT.

Types

type DHTAnnounceOptions

type DHTAnnounceOptions struct {
	// PSK is the pre-shared key to use as a rendezvous point for the DHT.
	PSK string
	// BootstrapPeers is a list of bootstrap peers to use for the DHT.
	// If empty or nil, the default bootstrap peers will be used.
	BootstrapPeers []multiaddr.Multiaddr
	// Options are options for configuring the libp2p host.
	Options []libp2p.Option
	// DiscoveryTTL is the TTL to use for the discovery service.
	// This is only applicable when announcing the host.
	DiscoveryTTL time.Duration
	// LocalAddrs is a list of local addresses to announce the host with.
	// If empty or nil, the default local addresses will be used.
	LocalAddrs []multiaddr.Multiaddr
}

DHTAnnounceOptions are options for announcing the host or discovering peers on the libp2p kademlia DHT.

type RaftTransportOptions added in v0.3.3

type RaftTransportOptions struct {
	// PSK is the pre-shared key to use as a rendezvous point for the DHT.
	PSK string
	// BootstrapPeers is a list of bootstrap peers to use for the DHT.
	// If empty or nil, the default bootstrap peers will be used.
	BootstrapPeers []multiaddr.Multiaddr
	// Options are options for configuring the libp2p host.
	Options []libp2p.Option
	// DiscoveryTTL is the TTL to use for the discovery service.
	DiscoveryTTL time.Duration
	// ConnectTimeout is the timeout to use when connecting to a peer.
	ConnectTimeout time.Duration
	// LeaderDialer is the function that will be used to dial the leader.
	LeaderDialer transport.LeaderDialer
}

RaftTransportOptions are options for the TCP transport.

type RoundTripOptions

type RoundTripOptions struct {
	// PSK is the pre-shared key to use as a rendezvous point for the DHT.
	PSK string
	// BootstrapPeers is a list of bootstrap peers to use for the DHT.
	// If empty or nil, the default bootstrap peers will be used.
	BootstrapPeers []multiaddr.Multiaddr
	// Options are options for configuring the libp2p host.
	Options []libp2p.Option
	// ConnectTimeout is the per-address timeout for connecting to a peer.
	ConnectTimeout time.Duration
	// LocalAddrs is a list of local addresses to listen on.
	// If empty or nil, the default local addresses will be used.
	LocalAddrs []multiaddr.Multiaddr
}

RoundTripOptions are options for performing a round trip against a libp2p host.

Jump to

Keyboard shortcuts

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