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>
impl<'a, E: Engine> TableViewBuilder<'a, E>
Sourcepub fn subscription_name(self, name: impl Into<String>) -> Self
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.
Sourcepub fn receiver_queue_size(self, size: usize) -> Self
pub fn receiver_queue_size(self, size: usize) -> Self
Override the receiver-queue size used by the underlying consumer.
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
Append a (key, value) consumer-metadata entry advertised on the underlying
CommandSubscribe.metadata. Mirrors Java TableViewBuilder#consumerProperty.
Sourcepub fn subscription_property(
self,
key: impl Into<String>,
value: impl Into<String>,
) -> Self
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.
Sourcepub fn start_message_id(self, id: MessageId) -> Self
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.
Sourcepub fn crypto_failure_action(self, action: CryptoFailureAction) -> Self
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.
Sourcepub fn auto_update_partitions_interval(self, interval: Duration) -> Self
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.
Sourcepub fn on_update(self, listener: TableViewListener) -> Self
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.
Sourcepub async fn create(
self,
) -> Result<TableView<<E::ClientState as SubscribeApi>::Consumer>, PulsarError>
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
PulsarError::Otherif a decryptor was configured viaSelf::encryption— callcreate_with_decryption()instead.PulsarError::Otheron broker rejection or wire failure (stringified).
Source§impl TableViewBuilder<'_, TokioEngine>
Tokio-engine-specific TableViewBuilder methods that need the
tokio MessageDecryptor extension (PIP-4 not yet wired on moonpool).
impl TableViewBuilder<'_, TokioEngine>
Tokio-engine-specific TableViewBuilder methods that need the
tokio MessageDecryptor extension (PIP-4 not yet wired on moonpool).
Sourcepub fn encryption(self, decryptor: Arc<dyn MessageDecryptor>) -> Self
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).
Sourcepub async fn create_with_decryption(self) -> Result<TableView, PulsarError>
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
PulsarError::Clienton broker rejection or wire failure.