Skip to main content

ReaderBuilder

Struct ReaderBuilder 

Source
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>

Source

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.

Source

pub fn receiver_queue_size(self, size: usize) -> Self

Set the receiver queue size.

Source

pub fn name(self, name: impl Into<String>) -> Self

Set the consumer name advertised to the broker.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub async fn create( self, ) -> Result<Reader<<E::ClientState as SubscribeApi>::Consumer>, PulsarError>

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
Source§

impl ReaderBuilder<'_, TokioEngine>

Tokio-engine-specific ReaderBuilder methods that depend on the tokio MessageDecryptor extension (PIP-4).

Source

pub fn encryption(self, decryptor: Arc<dyn MessageDecryptor>) -> Self

Mirrors Java ReaderBuilder#cryptoKeyReader — supplies a PIP-4 decryptor for the reader’s underlying subscription.

Trait Implementations§

Source§

impl<E: Engine> Debug for ReaderBuilder<'_, E>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a, E = TokioEngine> !Freeze for ReaderBuilder<'a, E>

§

impl<'a, E = TokioEngine> !RefUnwindSafe for ReaderBuilder<'a, E>

§

impl<'a, E = TokioEngine> !UnwindSafe for ReaderBuilder<'a, E>

§

impl<'a, E> Send for ReaderBuilder<'a, E>
where ConsumerBuilder<'a, E>: Send,

§

impl<'a, E> Sync for ReaderBuilder<'a, E>
where ConsumerBuilder<'a, E>: Sync,

§

impl<'a, E> Unpin for ReaderBuilder<'a, E>
where ConsumerBuilder<'a, E>: Unpin,

§

impl<'a, E> UnsafeUnpin for ReaderBuilder<'a, E>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more