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§
- Batch
Stream - Stream of messages from batch fetch operations.
- GetBatch
Builder - Builder for batch fetching messages from a stream.
- GetLast
Builder - Builder for fetching last messages for multiple subjects.
- NoSeq
- NoTime
- WithSeq
- With
Time
Enums§
- Batch
Fetch Error Kind - Kinds of errors that can occur during batch fetch operations.
Traits§
- Batch
Fetch Ext - Extension trait for batch fetching messages from JetStream streams.
Type Aliases§
- Batch
Fetch Error - Error type for batch fetch operations.