package
0.0.0-20230720142802-055f8dac88b4
Repository: https://github.com/wetware/casm.git
Documentation: pkg.go.dev
# README
Peer Exchange (PeX)
Gossip-based sampling service for robust connectivity.
Overview
Once a host has successfully joined a cluster, it ceases to rely on the bootstrap service for peer-discovery, and instead relies on the cluster itself to discover new peers. This process of "ambient peer discovery" is provided as an unstructured service called PeX (short for peer exchange). In contrast to DHT and PubSub-based methods, PeX can be used to repair cluster partitions, or to rejoin a cluster after having been disconnected.
See PEX.md for more details.
Quickstart
package main
import (
"fmt"
"context"
"github.com/libp2p/go-libp2p"
"github.com/wetware/casm/pkg/pex"
)
const ns = "example_namespace"
var ctx = context.Background()
func main() {
h, _ := libp2p.New(ctx) // start libp2p host
px, _ := pex.New(ctx, ns) // create peer exchange
// Join an existing cluster and start gossiping. The 'info' parameter
// is a 'peer.AddrInfo' instance that points to a bootstrap peer. This
// is usually obtained through a discovery service (not shown).
_ = px.Join(ctx, info)
// Print the local view. The records can be used to repair partitions
// or to reconnect to a cluster after becoming isolated.
for _, rec := range px.View() {
fmt.Println(rec.PeerID)
}
}
# Functions
New PeerExchange.
No description provided by the author
WithBootstrapPeers sets the bootstrap discovery service for the PeX instance to bootstrap with specific peers.
WithDatastore sets the storage backend for gossip records.
WithDiscovery sets the bootstrap discovery service for the PeX instance.
WithGossip sets the parameters for gossiping.
WithLogger sets the logger for the peer exchange.
# Constants
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
# Variables
No description provided by the author
ErrClosed is returned from an operation performed against a closed PeerExchange or namespace.
ErrInvalidRange is returned as a cause in a ValidationError when a field's value falls outside the expected range.
ErrNoListenAddrs is returned from 'New' if the supplied host is not accepting peer connections.
ErrNotFound is returned from an operation performed against a non-existent namespace.
# Structs
GossipConfig contains parameters for the PeX gossip algorithm.
No description provided by the author
PeerExchange is a collection of passive views of various p2p clusters.
No description provided by the author
# Type aliases
No description provided by the author
No description provided by the author
No description provided by the author