Documentation ¶
Overview ¶
Package embed provides a simplified way to run a webmesh node in-process.
Index ¶
Constants ¶
View Source
const ProtocolCode = 613
ProtocolCode is the code for the webmesh libp2p protocol.
Variables ¶
View Source
var Protocol = multiaddr.Protocol{ Name: "webmesh", Code: ProtocolCode, VCode: multiaddr.CodeToVarint(ProtocolCode), Size: -1, Path: false, Transcoder: multiaddr.NewTranscoderFromFunctions(protocolStrToBytes, protocolBytesToStr, validateBytes), }
Protocol is the webmesh libp2p protocol.
Functions ¶
Types ¶
type NewTransportFunc ¶ added in v0.5.1
type NewTransportFunc func(upgrader transport.Upgrader, host host.Host, rcmgr network.ResourceManager, privKey p2pcrypto.PrivKey) (transport.Transport, error)
NewTransportFunc is the signature of a function that returns a new transport.
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.Mesh // 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 NewNodeWithKey ¶ added in v0.5.1
NewNodeWithKey returns a new node using the given key.
func NewNodeWithKeyAndHost ¶ added in v0.5.1
func NewNodeWithKeyAndHost(ctx context.Context, config *config.Config, key crypto.Key, host host.Host) (Node, error)
NewNodeWithKeyAndHost returns a new node using the given key and pre-created libp2p host. This is mostly intended for use with transports.
Click to show internal directories.
Click to hide internal directories.