Documentation
¶
Overview ¶
Package simplesub implements a pub/sub messaging system through the libp2p routed.RoutedHost interface. In contrast with the standard libp2p pub/sub package, simplesub has the advantage of letting developers opt for their own routing solutions (e.g. kadDHT).
Package simplesub implements a pub/sub messaging system through the libp2p routed.RoutedHost interface. In contrast with the standard libp2p pub/sub package, simplesub has the advantage of letting developers opt for their own routing solutions (e.g. kadDHT).
Package simplesub implements a pub/sub messaging system through the libp2p routed.RoutedHost interface. In contrast with the standard libp2p pub/sub package, simplesub has the advantage of letting developers opt for their own routing solutions (e.g. kadDHT).
Package simplesub implements a pub/sub messaging system through the libp2p routed.RoutedHost interface. In contrast with the standard libp2p pub/sub package, simplesub has the advantage of letting developers opt for their own routing solutions (e.g. kadDHT).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Message ¶
type Message struct { Topic string `json:"topic"` // Message topic Data []byte `json:"data"` // Message data }
Message outlines a simplesub message.
func MessageFromBytes ¶
MessageFromBytes attempts to decode a message from a given byte slice.
type Option ¶
Option represents a simplesub configuration option.
func WithRoutePrefix ¶
WithRoutePrefix defines the WithRoutePrefix option. Such an option can used primarily to differentiate between different nodes in a network, or partition such networks.
type SimpleSub ¶
type SimpleSub struct { Host *routed.RoutedHost `json:"host"` // Working host RootRoutePath string `json:"root_path"` // Root route path Handlers map[string]func(inet.Stream, *Message) // Message handlers }
SimpleSub implements the standard simplesub pub/sub messaging system. The simplesub type is in many ways analogous to the host type in libp2p--it serves as a central hub for all pub/sub related operations.
func NewSimpleSub ¶
func NewSimpleSub(host *routed.RoutedHost, opts ...Option) (*SimpleSub, error)
NewSimpleSub initializes a new SimpleSub, and sets up all necessary stream handlers.