pub struct Stream<C: CodecType> { /* private fields */ }Expand description
A JetStream stream with configurable codec.
§Type Parameters
C- The codec type used for message serialization
Implementations§
Source§impl<C: CodecType> Stream<C>
impl<C: CodecType> Stream<C>
Sourcepub async fn info(&self) -> Result<StreamInfo>
pub async fn info(&self) -> Result<StreamInfo>
Get stream information.
Sourcepub fn pull_consumer_builder<T>(&self, name: &str) -> PullConsumerBuilder<T, C>
pub fn pull_consumer_builder<T>(&self, name: &str) -> PullConsumerBuilder<T, C>
Create a pull consumer builder.
§Type Parameters
T- The message type for this consumer
§Example
use intercom::{Client, MsgPackCodec};
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, Debug)]
struct Event { id: u64 }
let client = Client::<MsgPackCodec>::connect("nats://localhost:4222").await?;
let jetstream = client.jetstream();
let stream = jetstream.get_stream("events").await?;
let consumer = stream
.pull_consumer_builder::<Event>("my-consumer")
.durable()
.filter_subject("events.user.>")
.create()
.await?;Sourcepub fn push_consumer_builder<T>(&self, name: &str) -> PushConsumerBuilder<T, C>
pub fn push_consumer_builder<T>(&self, name: &str) -> PushConsumerBuilder<T, C>
Create a push consumer builder.
§Type Parameters
T- The message type for this consumer
§Example
use intercom::{Client, MsgPackCodec};
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, Debug)]
struct Event { id: u64 }
let client = Client::<MsgPackCodec>::connect("nats://localhost:4222").await?;
let jetstream = client.jetstream();
let stream = jetstream.get_stream("events").await?;
let consumer = stream
.push_consumer_builder::<Event>("my-push-consumer")
.deliver_subject("deliver.events")
.create()
.await?;Sourcepub async fn get_pull_consumer<T>(
&self,
name: &str,
) -> Result<PullConsumer<T, C>>
pub async fn get_pull_consumer<T>( &self, name: &str, ) -> Result<PullConsumer<T, C>>
Get an existing pull consumer by name.
Sourcepub async fn get_push_consumer<T>(
&self,
name: &str,
) -> Result<PushConsumer<T, C>>
pub async fn get_push_consumer<T>( &self, name: &str, ) -> Result<PushConsumer<T, C>>
Get an existing push consumer by name.
Sourcepub async fn delete_consumer(&self, name: &str) -> Result<()>
pub async fn delete_consumer(&self, name: &str) -> Result<()>
Delete a consumer by name.
Sourcepub async fn purge_subject(&self, filter: &str) -> Result<u64>
pub async fn purge_subject(&self, filter: &str) -> Result<u64>
Purge messages matching a filter subject.
Trait Implementations§
Auto Trait Implementations§
impl<C> Freeze for Stream<C>
impl<C> !RefUnwindSafe for Stream<C>
impl<C> Send for Stream<C>
impl<C> Sync for Stream<C>
impl<C> Unpin for Stream<C>where
C: Unpin,
impl<C> !UnwindSafe for Stream<C>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more