Module batch_fetch

Module batch_fetch 

Source
Expand description

Batch fetch operations for JetStream streams.

This module provides efficient batch fetching of messages from JetStream streams using the DIRECT.GET API as specified in ADR-31.

§Examples

§Fetch a batch of messages

use jetstream_extra::batch_fetch::BatchFetchExt;

// Fetch 100 messages starting from sequence 1
let mut messages = context
    .get_batch("my_stream", 100)
    .send()
    .await?;

while let Some(msg) = messages.next().await {
    let msg = msg?;
    println!("Message at seq {}: {:?}", msg.sequence, msg.payload);
}

§Get last messages for multiple subjects

use jetstream_extra::batch_fetch::BatchFetchExt;

// Get the last message for each subject
let subjects = vec!["events.user.1".to_string(), "events.user.2".to_string()];
let mut messages = context
    .get_last_messages_for("my_stream")
    .subjects(subjects)
    .send()
    .await?;

while let Some(msg) = messages.next().await {
    let msg = msg?;
    println!("Last message for {}: {:?}", msg.subject, msg.payload);
}

Structs§

BatchStream
Stream of messages from batch fetch operations.
GetBatchBuilder
Builder for batch fetching messages from a stream.
GetLastBuilder
Builder for fetching last messages for multiple subjects.
NoSeq
NoTime
WithSeq
WithTime

Enums§

BatchFetchErrorKind
Kinds of errors that can occur during batch fetch operations.

Traits§

BatchFetchExt
Extension trait for batch fetching messages from JetStream streams.

Type Aliases§

BatchFetchError
Error type for batch fetch operations.