pub struct GossipApi { /* private fields */ }
net
or rpc
only.Expand description
API to control a Gossip
instance.
This has methods to subscribe and join gossip topics, which return handles to publish and receive messages on topics.
Gossip
derefs to GossipApi
, so all functions on GossipApi
are directly callable
from Gossip
.
Additionally, a GossipApi
can be created by connecting to an RPC server. See Gossip::listen
and GossipApi::connect
(*requires the rpc
feature).
Implementations§
Source§impl GossipApi
impl GossipApi
Sourcepub fn connect(endpoint: Endpoint, addr: SocketAddr) -> Self
Available on crate feature rpc
only.
pub fn connect(endpoint: Endpoint, addr: SocketAddr) -> Self
rpc
only.Connect to a remote as a RPC client.
Sourcepub async fn subscribe_with_opts(
&self,
topic_id: TopicId,
opts: JoinOptions,
) -> Result<GossipTopic, ApiError>
pub async fn subscribe_with_opts( &self, topic_id: TopicId, opts: JoinOptions, ) -> Result<GossipTopic, ApiError>
Join a gossip topic with options.
Returns a GossipTopic
instantly. To wait for at least one connection to be established,
you can await GossipTopic::joined
.
Messages will be queued until a first connection is available. If the internal channel becomes full, the oldest messages will be dropped from the channel.
Sourcepub async fn subscribe_and_join(
&self,
topic_id: TopicId,
bootstrap: Vec<NodeId>,
) -> Result<GossipTopic, ApiError>
pub async fn subscribe_and_join( &self, topic_id: TopicId, bootstrap: Vec<NodeId>, ) -> Result<GossipTopic, ApiError>
Join a gossip topic with the default options and wait for at least one active connection.
Sourcepub async fn subscribe(
&self,
topic_id: TopicId,
bootstrap: Vec<NodeId>,
) -> Result<GossipTopic, ApiError>
pub async fn subscribe( &self, topic_id: TopicId, bootstrap: Vec<NodeId>, ) -> Result<GossipTopic, ApiError>
Join a gossip topic with the default options.
Note that this will not wait for any bootstrap node to be available.
To ensure the topic is connected to at least one node, use GossipTopic::joined
or Self::subscribe_and_join