embed

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2023 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Overview

Package embed provides a simplified way to run a webmesh node in-process.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithLiteWebmeshTransport added in v0.6.0

func WithLiteWebmeshTransport(opts transport.LiteOptions, laddrs ...ma.Multiaddr) p2pconfig.Option

WithLiteWebmeshTransport returns a libp2p option that configures the transport to use the lite webmesh transport.

func WithWebmeshTransport added in v0.5.1

func WithWebmeshTransport(topts TransportOptions) p2pconfig.Option

WithWebmeshTransport returns a libp2p option that configures the transport to use an embedded webmesh node.

Types

type Node

type Node interface {
	transport.Dialer
	transport.NodeDialer
	transport.LeaderDialer

	// Start starts the node.
	Start(ctx context.Context) error
	// Stop stops the node.
	Stop(ctx context.Context) error
	// Errors returns a channel of errors that occur during the lifetime of the node.
	// At the moment, any error is fatal and will cause the node to stop.
	Errors() <-chan error
	// Mesh returns the underlying mesh instance.
	Mesh() mesh.Node
	// Raft is the underlying Raft instance.
	Raft() raft.Raft
	// Storage is the underlying storage instance.
	Storage() storage.MeshStorage
	// Services returns the underlying services instance if it is running.
	Services() *services.Server
	// MeshDNS returns the underlying MeshDNS instance if it is running.
	MeshDNS() *meshdns.Server
	// AddressV4 returns the IPv4 address of the node.
	AddressV4() netip.Prefix
	// AddressV6 returns the IPv6 address of the node.
	AddressV6() netip.Prefix
}

Node is an embedded webmesh node.

func NewNode

func NewNode(ctx context.Context, opts Options) (Node, error)

NewNode creates a new embedded webmesh node.

type Options added in v0.6.0

type Options struct {
	// Config is the configuration for the node.
	Config *config.Config
	// Key is the key for the node.
	Key crypto.PrivateKey
	// Host is the libp2p host for the node.
	Host host.Host
}

Options are the options for creating a new embedded webmesh node.

type TransportOptions added in v0.6.0

type TransportOptions struct {
	Config     *config.Config
	Laddrs     []ma.Multiaddr
	Rendezvous string
	LogLevel   string
}

TransportOptions are options for configuring a libp2p transport.

Directories

Path Synopsis
Package protocol defines the libp2p webmesh protocol.
Package protocol defines the libp2p webmesh protocol.
Package transport defines the libp2p webmesh transport.
Package transport defines the libp2p webmesh transport.

Jump to

Keyboard shortcuts

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