pub struct Stream { /* private fields */ }
Expand description
Ockam stream protocol controller
Each stream has a sending and consuming worker (publisher and consumer) that are created and managed on the fly by this abstraction.
Implementations§
source§impl Stream
impl Stream
sourcepub async fn new(ctx: &Context) -> Result<Self>
pub async fn new(ctx: &Context) -> Result<Self>
Create a new Ockam stream controller
By default, the created stream will poll for new messages every 250 milliseconds.
sourcepub fn with_interval<D: Into<Duration>>(self, duration: D) -> Self
pub fn with_interval<D: Into<Duration>>(self, duration: D) -> Self
Customize the polling interval for the stream consumer
sourcepub fn stream_service<S: Into<String>>(self, serv: S) -> Self
pub fn stream_service<S: Into<String>>(self, serv: S) -> Self
Specify the stream service running on the remote
sourcepub fn index_service<S: Into<String>>(self, serv: S) -> Self
pub fn index_service<S: Into<String>>(self, serv: S) -> Self
Specify the index service running on the remote
sourcepub fn client_id<S: Into<String>>(self, client_id: S) -> Self
pub fn client_id<S: Into<String>>(self, client_id: S) -> Self
Specify the client_id for the stream consumer
When setting up a stream without calling this function a random client id will be assigned.
sourcepub fn with_recipient<A: Into<Address>>(self, addr: A) -> Self
pub fn with_recipient<A: Into<Address>>(self, addr: A) -> Self
Specify an address to forward incoming messages to
When setting up a stream without calling this function
messages will be buffered by the StreamConsumer and must be
polled via the StreamWorkerCmd
.
sourcepub async fn connect<R, S>(
&self,
route: R,
sender_name: S,
receiver_name: S
) -> Result<(SenderAddress, ReceiverAddress)>
pub async fn connect<R, S>( &self, route: R, sender_name: S, receiver_name: S ) -> Result<(SenderAddress, ReceiverAddress)>
Connect to a bi-directional stream by remote and stream pair
When using the stream protocol for bi-directional communication a sending and receiving stream name is required. These two identifiers MUST be known between nodes that wish to exchange messages.
The route
parameter is the route to a remote which hosts a
stream_service
and stream_index_service
, such as
hub.ockam.io.
Streams that do not already exists will be created, and existing stream identifiers will automatically be re-used.