Skip to main content

TableViewBuilder

Struct TableViewBuilder 

Source
pub struct TableViewBuilder<'a, E: Engine = TokioEngine> { /* private fields */ }
Expand description

Builder for a TableView. Mirrors org.apache.pulsar.client.api.TableViewBuilder.

Engine-generic: the type parameter E: Engine (defaults to crate::TokioEngine) selects the per-engine consumer type via the engine-side crate::SubscribeApi extension trait. The decryptor slot is engine-typed via crate::MessageDecryptorApi.

Implementations§

Source§

impl<'a, E: Engine> TableViewBuilder<'a, E>

Source

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

Override the subscription name used by the underlying reader. Defaults to a unique per-instance table-view-<uuid> so two views over the same topic do not share dispatch state.

Source

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

Override the receiver-queue size used by the underlying consumer.

Source

pub fn property(self, key: impl Into<String>, value: impl Into<String>) -> Self

Append a (key, value) consumer-metadata entry advertised on the underlying CommandSubscribe.metadata. Mirrors Java TableViewBuilder#consumerProperty.

Source

pub fn subscription_property( self, key: impl Into<String>, value: impl Into<String>, ) -> Self

Append a (key, value) to the underlying subscription’s subscription_properties. Mirrors Java TableViewBuilder#subscriptionProperty.

Source

pub fn start_message_id(self, id: MessageId) -> Self

Override the initial message id the underlying subscription starts from. Useful for resuming a table view at a specific cursor (e.g. recovery from snapshot). Has no effect on an already-persisted subscription. Mirrors Java TableViewBuilder#startMessageId.

Source

pub fn crypto_failure_action(self, action: CryptoFailureAction) -> Self

PIP-4 decryption failure handling, forwarded to the underlying consumer. Default Fail (propagate the error). Discard silently drops the message; Consume delivers the ciphertext to the listener as-is. Mirrors Java TableViewBuilder#cryptoFailureAction (which itself delegates to ConsumerBuilder#cryptoFailureAction).

Note: the underlying magnetar_runtime_tokio::Consumer receive path currently honours only Fail end-to-end. Discard / Consume plumb through the protocol layer but are applied opportunistically — see the matching ConsumerBuilder::crypto_failure_action doc for the follow-up.

Source

pub fn auto_update_partitions_interval(self, interval: Duration) -> Self

Enable a background timer that signals every interval, intended to drive re-checks of the topic’s partition count. Mirrors Java TableViewBuilder#autoUpdatePartitionsInterval.

The internal timer task signals TableView::partitions_changed_notify on every tick. Callers run TableView::refresh_partitions in response to the signal (or on their own cadence) to actually call PulsarClient::partitions_for_topic — the timer itself is decoupled from the client so the watcher stays compatible with the crate-wide #![forbid(unsafe_code)] invariant. A future revision will wire the watcher to the client directly once PulsarClient is Arc-cloneable.

Default None — no timer is spawned and a TableView over a partitioned topic will not notice partitions added after construction. Pass a non-zero Duration to opt in. The timer is aborted when the TableView is dropped or TableView::closed.

Setting a zero interval is treated as “disable” — same as the default.

Source

pub fn on_update(self, listener: TableViewListener) -> Self

Install a listener invoked for every materialised update. The callback runs inside the drain task; keep it fast and non-blocking.

Source

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

Subscribe, drain backlog, and return the view. The future resolves once the background drain task is running — the initial snapshot continues to populate in the background as compacted messages arrive.

Dispatches through the engine-generic crate::SubscribeApi extension trait — works against any engine whose ClientState implements it.

PIP-4 decryption guardrail (BREAKING since the decryptor-storage lift). If Self::encryption was called on the per-engine specialisation, .create() returns PulsarError::Other instead of silently opening a plaintext consumer. The engine-generic dispatch cannot thread an engine-typed decryptor through subscribe, so the previous “silently drop the decryptor” behaviour was a footgun. Use Self::create_with_decryption on the tokio specialisation instead.

§Errors
Source§

impl TableViewBuilder<'_, TokioEngine>

Tokio-engine-specific TableViewBuilder methods that need the tokio MessageDecryptor extension (PIP-4 not yet wired on moonpool).

Source

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

Configure PIP-4 end-to-end decryption on the underlying consumer. The decryptor is consulted on every received message whose MessageMetadata.encryption_keys is non-empty. Mirrors Java TableViewBuilder#cryptoKeyReader (which delegates to ConsumerBuilder#cryptoKeyReader).

Source

pub async fn create_with_decryption(self) -> Result<TableView, PulsarError>

Subscribe with the configured decryptor (PIP-4). Tokio-engine-only. Use Self::create for the engine-generic path that ignores the decryptor.

§Errors

Trait Implementations§

Source§

impl<E: Engine> Debug for TableViewBuilder<'_, 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> !RefUnwindSafe for TableViewBuilder<'a, E>

§

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

§

impl<'a, E> Freeze for TableViewBuilder<'a, E>

§

impl<'a, E> Send for TableViewBuilder<'a, E>

§

impl<'a, E> Sync for TableViewBuilder<'a, E>

§

impl<'a, E> Unpin for TableViewBuilder<'a, E>

§

impl<'a, E> UnsafeUnpin for TableViewBuilder<'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