pub struct InterestQueue<T, C: CodecType> { /* private fields */ }Expand description
A typed queue with interest-based retention and configurable codec.
Messages are retained until acknowledged by all consumers that were active when the message was published.
§Type Parameters
T- The message type for this queueC- The codec type used for serialization
§Example
use intercom::{Client, MsgPackCodec, jetstream::queue::InterestQueue};
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, Debug)]
struct Event {
id: u64,
data: String,
}
let client = Client::<MsgPackCodec>::connect("nats://localhost:4222").await?;
let jetstream = client.jetstream();
// Create an interest-based queue
let queue = InterestQueue::<Event, MsgPackCodec>::builder(&jetstream, "events")
.subject("events.>")
.create()
.await?;
// Add consumers
let consumer1 = queue.add_consumer("service-a").await?;
let consumer2 = queue.add_consumer("service-b").await?;
// Both consumers must acknowledge for message removalImplementations§
Source§impl<T, C: CodecType> InterestQueue<T, C>
impl<T, C: CodecType> InterestQueue<T, C>
Sourcepub fn builder(
context: &JetStreamContext<C>,
name: &str,
) -> InterestQueueBuilder<T, C>
pub fn builder( context: &JetStreamContext<C>, name: &str, ) -> InterestQueueBuilder<T, C>
Create an interest queue builder.
Sourcepub async fn add_consumer(&self, name: &str) -> Result<PullConsumer<T, C>>
pub async fn add_consumer(&self, name: &str) -> Result<PullConsumer<T, C>>
Add a durable consumer to this queue.
Sourcepub async fn add_consumer_filtered(
&self,
name: &str,
filter: &str,
) -> Result<PullConsumer<T, C>>
pub async fn add_consumer_filtered( &self, name: &str, filter: &str, ) -> Result<PullConsumer<T, C>>
Add a consumer with a filter subject.
Source§impl<T: Serialize, C: CodecType> InterestQueue<T, C>
impl<T: Serialize, C: CodecType> InterestQueue<T, C>
Auto Trait Implementations§
impl<T, C> Freeze for InterestQueue<T, C>
impl<T, C> !RefUnwindSafe for InterestQueue<T, C>
impl<T, C> Send for InterestQueue<T, C>where
T: Send,
impl<T, C> Sync for InterestQueue<T, C>where
T: Sync,
impl<T, C> Unpin for InterestQueue<T, C>
impl<T, C> !UnwindSafe for InterestQueue<T, 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