pub struct ReaderBuilder<'a, E: Engine = TokioEngine> { /* private fields */ }Expand description
Builder for a Reader.
Mirrors org.apache.pulsar.client.api.ReaderBuilder. Internally a Reader is just a
non-durable Exclusive consumer with an auto-generated subscription name — there’s no
dedicated wire command, so the protocol layer doesn’t need any extra plumbing.
Phantom-generic over E: Engine (defaults to crate::TokioEngine).
Wraps a ConsumerBuilder<E>; the impl methods stay tokio-bound
until the SubscribeApi dispatch path lands in the Builder lift
sub-PR.
Implementations§
Source§impl<'a, E: Engine> ReaderBuilder<'a, E>
impl<'a, E: Engine> ReaderBuilder<'a, E>
Sourcepub fn subscription_name(self, name: impl Into<String>) -> Self
pub fn subscription_name(self, name: impl Into<String>) -> Self
Override the auto-generated subscription name. Rarely needed — Reader subscriptions are not visible on the broker dashboard anyway.
Sourcepub fn receiver_queue_size(self, size: usize) -> Self
pub fn receiver_queue_size(self, size: usize) -> Self
Set the receiver queue size.
Sourcepub fn name(self, name: impl Into<String>) -> Self
pub fn name(self, name: impl Into<String>) -> Self
Set the consumer name advertised to the broker.
Sourcepub fn start_position(self, position: InitialPosition) -> Self
pub fn start_position(self, position: InitialPosition) -> Self
Choose where the reader starts when its non-durable subscription is fresh.
Defaults to pb::command_subscribe::InitialPosition::Latest.
Sourcepub fn read_compacted(self, on: bool) -> Self
pub fn read_compacted(self, on: bool) -> Self
Read from the compacted (key-deduplicated) view of the topic. Mirrors Java
ReaderBuilder#readCompacted. Required for compacted-topic readers.
Sourcepub fn start_message_id(self, id: MessageId) -> Self
pub fn start_message_id(self, id: MessageId) -> Self
Override the initial message id the reader starts from. Mirrors Java
ReaderBuilder#startMessageId. Pass magnetar_proto::MessageId::EARLIEST /
magnetar_proto::MessageId::LATEST for the sentinel positions.
Sourcepub fn property(self, key: impl Into<String>, value: impl Into<String>) -> Self
pub fn property(self, key: impl Into<String>, value: impl Into<String>) -> Self
Mirrors ConsumerBuilder::property. The reader’s underlying consumer carries the
(key, value) pair on its CommandSubscribe.metadata.
Sourcepub fn start_message_rollback_duration(self, seconds: u64) -> Self
pub fn start_message_rollback_duration(self, seconds: u64) -> Self
Roll the reader cursor back by seconds at create time. Mirrors Java
ReaderBuilder#startMessageIdInclusive rollback knob.
Sourcepub async fn create(
self,
) -> Result<Reader<<E::ClientState as SubscribeApi>::Consumer>, PulsarError>where
E::ClientState: SubscribeApi,
pub async fn create(
self,
) -> Result<Reader<<E::ClientState as SubscribeApi>::Consumer>, PulsarError>where
E::ClientState: SubscribeApi,
Create the reader via the engine-generic
crate::SubscribeApi dispatch path. Returns
Reader<<E::ClientState as SubscribeApi>::Consumer> —
resolves to Reader<magnetar_runtime_tokio::Consumer> (the
default Reader<> alias) under the default
E = TokioEngine.
§Errors
PulsarError::Otheron broker rejection or wire failure.
Source§impl ReaderBuilder<'_, TokioEngine>
Tokio-engine-specific ReaderBuilder methods that depend on the
tokio MessageDecryptor extension (PIP-4).
impl ReaderBuilder<'_, TokioEngine>
Tokio-engine-specific ReaderBuilder methods that depend on the
tokio MessageDecryptor extension (PIP-4).
Sourcepub fn encryption(self, decryptor: Arc<dyn MessageDecryptor>) -> Self
pub fn encryption(self, decryptor: Arc<dyn MessageDecryptor>) -> Self
Mirrors Java ReaderBuilder#cryptoKeyReader — supplies a PIP-4 decryptor for the
reader’s underlying subscription.