Skip to main content

ConnectionEvent

Enum ConnectionEvent 

Source
pub enum ConnectionEvent {
Show 31 variants Connected { protocol_version: i32, max_message_size: u32, feature_flags: FeatureFlags, }, AuthChallenge { method: Option<String>, challenge: Option<Bytes>, }, ProducerReady { handle: ProducerHandle, producer_name: String, last_sequence_id: i64, schema_version: Bytes, }, ProducerOpenFailed { handle: ProducerHandle, code: i32, message: String, }, ProducerOpenFailedTransient { handle: ProducerHandle, code: i32, message: String, }, SubscribeAcked { handle: ConsumerHandle, }, SubscribeFailed { handle: ConsumerHandle, code: i32, message: String, }, SubscribeFailedTransient { handle: ConsumerHandle, code: i32, message: String, }, Message { handle: ConsumerHandle, message: IncomingMessage, }, MessageReceivedFromShadow { handle: ConsumerHandle, source_topic: String, source_message_id: MessageId, shadow_message_id: MessageId, message: IncomingMessage, }, ReplicatedSubscriptionMarkerObserved { handle: ConsumerHandle, marker: ReplicatedSubscriptionMarker, }, SendReceipt { handle: ProducerHandle, sequence_id: SequenceId, message_id: MessageId, }, SendError { handle: ProducerHandle, sequence_id: SequenceId, code: i32, message: String, }, AckResponse { request_id: Option<RequestId>, result: Result<(), String>, }, LookupResponse { request_id: RequestId, result: LookupOutcome, }, PartitionedMetadataResponse { request_id: RequestId, partitions: u32, error: Option<(i32, String)>, }, TopicListSnapshot { request_id: RequestId, topics: Vec<String>, }, TopicListChanged { added: Vec<String>, removed: Vec<String>, }, ReachedEndOfTopic { handle: ConsumerHandle, }, ActiveConsumerChanged { handle: ConsumerHandle, active: bool, }, ConsumerStalled { handle: ConsumerHandle, permit_balance: u32, stalled_for: Duration, }, TopicMigrated { producer: Option<ProducerHandle>, consumer: Option<ConsumerHandle>, broker_service_url: Option<String>, broker_service_url_tls: Option<String>, }, RedirectUrlRejected { source: &'static str, broker_service_url: Option<String>, broker_service_url_tls: Option<String>, }, ProducerClosedByBroker { handle: ProducerHandle, assigned_broker_service_url: Option<String>, }, ConsumerClosedByBroker { handle: ConsumerHandle, assigned_broker_service_url: Option<String>, }, ChecksumMismatch { computed: u32, expected: u32, }, Closed { reason: Option<String>, }, TxnResponse { request_id: RequestId, outcome: TxnRoundTrip, }, GetSchemaResponse { request_id: RequestId, result: Result<(Schema, Option<Bytes>), (i32, String)>, }, AntiThrashCooldown { until: Instant, }, AntiThrashCleared,
}
Expand description

A semantic event surfaced by the state machine.

Variants§

§

Connected

Handshake completed. The driver should now allow producer/consumer opens.

Fields

§protocol_version: i32

Protocol version negotiated with the broker.

§max_message_size: u32

Maximum message size declared by the broker (0 if unset).

§feature_flags: FeatureFlags

Capabilities negotiated with the broker.

§

AuthChallenge

The broker sent a CommandAuthChallenge mid-connection.

The auth layer (above magnetar-proto) is expected to compute the response and feed it back via Connection::submit_auth_response.

Fields

§method: Option<String>

Auth method requested by the broker, if it differs from the original.

§challenge: Option<Bytes>

Server-supplied challenge data (opaque to the protocol layer).

§

ProducerReady

A producer that was queued via create_producer is now ready to send.

Fields

§handle: ProducerHandle

The producer handle this event refers to.

§producer_name: String

Producer name assigned by the broker (server-side if user did not specify one).

§last_sequence_id: i64

Last sequence id seen by the broker for this producer (-1 if none).

§schema_version: Bytes

Schema version assigned by the broker (empty if none).

§

ProducerOpenFailed

The broker rejected a CommandProducer open with CommandError.

Emitted from the CommandError handler when the failing request id correlates with a pending producer-open. The corresponding producer state has already been dropped from the connection — the user-facing handle is dead. Pair with ConnectionEvent::ProducerReady as the success/failure split for an open_producer round-trip.

Fields

§handle: ProducerHandle

The producer that failed to open.

§code: i32

Pulsar wire-protocol ServerError code (pb::ServerError).

§message: String

Human-readable error from the broker.

§

ProducerOpenFailedTransient

An established producer’s reattachment was rejected with a retryable ADR-0080 code.

This event is emitted only after the producer has attached successfully at least once. The state is retained and the runtime driver must back off, re-run lookup, and call crate::Connection::retry_producer_open. A provisional first-open rejection instead emits Self::ProducerOpenFailed and is retried by the routing-aware client.

Fields

§handle: ProducerHandle

The producer that failed to open.

§code: i32

Pulsar wire-protocol ServerError code (pb::ServerError).

§message: String

Human-readable error from the broker.

§

SubscribeAcked

A subscribe request was acknowledged by the broker.

Fields

§handle: ConsumerHandle

The consumer handle this event refers to.

§

SubscribeFailed

The broker rejected a CommandSubscribe with CommandError.

Emitted from the CommandError handler when the failing request id correlates with a pending subscribe. The corresponding consumer state has already been dropped from the connection. Pair with ConnectionEvent::SubscribeAcked as the success/failure split for a subscribe round-trip.

Fields

§handle: ConsumerHandle

The consumer that failed to subscribe.

§code: i32

Pulsar wire-protocol ServerError code (pb::ServerError).

§message: String

Human-readable error from the broker.

§

SubscribeFailedTransient

Established-consumer companion to Self::ProducerOpenFailedTransient.

The consumer has attached successfully at least once, so its state is retained for driver-owned reattachment through crate::Connection::retry_consumer_subscribe. A provisional subscribe rejection emits Self::SubscribeFailed and is retried by the routing-aware client.

Fields

§handle: ConsumerHandle

The consumer that failed to subscribe.

§code: i32

Pulsar wire-protocol ServerError code (pb::ServerError).

§message: String

Human-readable error from the broker.

§

Message

An incoming message was delivered by the broker.

Fields

§handle: ConsumerHandle

The consumer that received it.

§message: IncomingMessage

The decoded message.

§

MessageReceivedFromShadow

PIP-180 / ADR-0033: an incoming message was delivered by the broker on a shadow topic, originating from a source topic. Emitted in place of Self::Message when the consumer was subscribed to a shadow topic (resolved at subscribe time via the admin REST getShadowTopics(source) hint, see crate::consumer::ConsumerState::set_shadow_metadata) AND the inbound entry’s pb::MessageMetadata::replicated_from is set.

source_message_id and message.message_id compare equal under the PIP-180 structural-equality contract documented on crate::types::MessageId — the broker presents shadow-side entries with the source-topic (ledger_id, entry_id, batch_index, partition), so cross-side deduplication needs no out-of-band correlation key.

Callers that don’t care about the shadow context can collapse this variant onto Self::Message by inspecting message. The variant is non-breaking by convention (ConnectionEvent is treated as #[non_exhaustive] per ADR-0033’s “new sum-variant is additive” risk note).

Fields

§handle: ConsumerHandle

The consumer that received it.

§source_topic: String

Source-topic name (resolved via admin REST getShadowTopics(source) at subscribe time, cached on crate::consumer::ConsumerState::shadow_metadata).

§source_message_id: MessageId

Source-topic MessageId. Equal to message.message_id under crate::types::MessageId’s structural-equality contract.

§shadow_message_id: MessageId

Shadow-side MessageId — same fields as source_message_id, but surfaced separately so callers don’t have to derive it from message.

§message: IncomingMessage

The decoded message — same payload + metadata the consumer would have surfaced via Self::Message on a non-shadow topic.

§

ReplicatedSubscriptionMarkerObserved

PIP-33: the broker emitted a REPLICATED_SUBSCRIPTION_* marker on this consumer’s topic. Surfaced for observability only — the marker is filtered off the user-visible message stream (never appears as Self::Message) because it carries broker-side snapshot/update payload, not application data. Magnetar never originates these markers; the broker generates them when the namespace has replicated_subscription_status=true and a peer cluster’s snapshot/update cycle fires. See crate::markers for the payload typing and ADR-0034 for scope.

Fields

§handle: ConsumerHandle

The consumer that received the marker.

§marker: ReplicatedSubscriptionMarker

Decoded marker payload (kind + details).

§

SendReceipt

A CommandSendReceipt correlated with one of our pending publishes.

Fields

§handle: ProducerHandle

The producer that owns the publish.

§sequence_id: SequenceId

Publisher-side sequence id of the receipt.

§message_id: MessageId

Broker-assigned message id.

§

SendError

A CommandSendError correlated with one of our pending publishes.

Fields

§handle: ProducerHandle

The producer that owns the publish.

§sequence_id: SequenceId

Publisher-side sequence id of the failed publish.

§code: i32

Pulsar wire-protocol ServerError code.

§message: String

Human-readable error from the broker.

§

AckResponse

Response to a CommandAck request.

Fields

§request_id: Option<RequestId>

Request id of the originating CommandAck (when set; the broker may omit it).

§result: Result<(), String>

Ok(()) on success, Err(error) with the broker message on failure.

§

LookupResponse

Response to a CommandLookupTopic request.

Fields

§request_id: RequestId

Request id of the originating CommandLookupTopic.

§result: LookupOutcome

Resolved broker URL on success, None on failure or redirect.

§

PartitionedMetadataResponse

Response to a CommandPartitionedTopicMetadata request.

Fields

§request_id: RequestId

Request id of the originating CommandPartitionedTopicMetadata.

§partitions: u32

Number of partitions (0 = non-partitioned topic).

§error: Option<(i32, String)>

Pulsar wire-protocol ServerError if the request failed.

§

TopicListSnapshot

Topic list watcher initial snapshot.

Fields

§request_id: RequestId

Request id of the originating CommandWatchTopicList.

§topics: Vec<String>

Initial list of topics matching the pattern.

§

TopicListChanged

Topic list watcher delta (PIP-145).

Fields

§added: Vec<String>

Topics that newly match the pattern.

§removed: Vec<String>

Topics that no longer match the pattern.

§

ReachedEndOfTopic

The broker signalled end-of-topic on a non-durable subscription.

Fields

§handle: ConsumerHandle

The consumer that reached end-of-topic.

§

ActiveConsumerChanged

A consumer’s active/passive state changed (failover).

Fields

§handle: ConsumerHandle

The consumer whose active state changed.

§active: bool

true if the consumer became active, false if it became passive.

§

ConsumerStalled

A consumer has held un-spent broker permits over an empty receive queue, in a dispatch-eligible state, for ConnectionConfig::consumer_stall_timeout without a single dispatch unit arriving (issue #414).

Emitted at most once per stall episode: the next dispatch unit re-arms the watchdog, so a consumer that recovers and wedges again reports twice. None of the client’s own state explains the silence — not pause, not an in-flight seek, not end-of-topic, not a re-attach in progress; all of those suppress the watchdog.

The wire protocol carries only monotonic client → broker permit increments (CommandFlow), so the client cannot itself drive the broker’s counter negative: this event says the BROKER stopped dispatching against a grant it acknowledged. The connection is otherwise healthy — ADR-0058’s keepalive keeps passing, which is precisely why it cannot detect this.

Purely diagnostic. Recovery is the caller’s explicit choice: Connection::resubscribe_consumer_in_place repairs this client’s own dispatcher slot; a dispatcher-wide broker corruption needs an operator-side pulsar-admin topics unload.

Fields

§handle: ConsumerHandle

The consumer whose dispatch went silent.

§permit_balance: u32

Permits the broker still had un-spent at the moment the stall was reported — the client-side mirror of the broker’s availablePermits for this consumer.

§stalled_for: Duration

How long the silence had lasted when the watchdog fired. At least consumer_stall_timeout; longer when the tick that noticed it ran late.

§

TopicMigrated

Broker requested the producer or consumer to migrate to a different broker URL.

Fields

§producer: Option<ProducerHandle>

Producer handle if the resource type was Producer.

§consumer: Option<ConsumerHandle>

Consumer handle if the resource type was Consumer.

§broker_service_url: Option<String>

New plaintext broker service URL.

§broker_service_url_tls: Option<String>

New TLS broker service URL.

§

RedirectUrlRejected

The broker advertised a redirect URL (PIP-188 TopicMigrated, CommandLookupTopicResponse proxy URL, CommandCloseProducer / CommandCloseConsumer reassignment URL, …) that the configured RedirectUrlAllowList rejected.

The runtime engines surface this event instead of honouring the URL — no CommandConnect is sent to the rejected host under the original AuthProvider. Defence in depth: a compromised broker (or a MITM downstream of TLS termination) cannot harvest the reused credentials by advertising an attacker-controlled URL.

urls carries the rejected URL list (plain + TLS variants, in that order, both Option<String>) so operators can audit the trigger. The runtime keeps using its original URL.

Fields

§source: &'static str

Where the rejected URL came from on the wire (e.g. "CommandTopicMigrated", "CommandLookupTopicResponse").

§broker_service_url: Option<String>

The rejected plaintext URL (if the broker advertised one).

§broker_service_url_tls: Option<String>

The rejected TLS URL (if the broker advertised one).

§

ProducerClosedByBroker

The broker asked us to close a producer (e.g. fenced).

Fields

§handle: ProducerHandle

The producer that was closed.

§assigned_broker_service_url: Option<String>

Optional re-target URL hinted by the broker.

§

ConsumerClosedByBroker

The broker asked us to close a consumer.

Fields

§handle: ConsumerHandle

The consumer that was closed.

§assigned_broker_service_url: Option<String>

Optional re-target URL hinted by the broker.

§

ChecksumMismatch

A CRC32C checksum mismatch was detected on an inbound payload frame.

Per [GUIDELINES.md] §“Protocol-correctness invariants”, the frame is dropped (never delivered) and the event is surfaced for diagnostics.

Fields

§computed: u32

Computed CRC32C.

§expected: u32

Expected CRC32C from the wire.

§

Closed

The connection is closing (locally initiated or peer-triggered).

Fields

§reason: Option<String>

Optional close reason for diagnostics.

§

TxnResponse

A Transaction Coordinator round-trip completed.

Carries the outcome for one of: new_txn, add_partition_to_txn, add_subscription_to_txn, end_txn.

Fields

§request_id: RequestId

Request id correlating the response to the originating request.

§outcome: TxnRoundTrip

The transactional outcome.

§

GetSchemaResponse

Response to a CommandGetSchema request (PIP-87 broker-side schema lookup).

Emitted after the runtime calls Connection::get_schema and the broker replies. The payload is a GetSchemaResultOk carries the registry-resolved pb::Schema and schema version, Err carries the broker’s ServerError code and message.

Fields

§request_id: RequestId

Request id correlating the response to the originating CommandGetSchema.

§result: Result<(Schema, Option<Bytes>), (i32, String)>

The schema-registry round-trip outcome.

§

AntiThrashCooldown

The connection-level anti-thrash detector (ADR-0028) has engaged. The supervisor must sleep until until before its next Transport::connect, even if its per-handle backoff would have retried sooner. Emitted exactly once on each Normal → Cooldown transition by Connection::record_reattach_outcome.

Fields

§until: Instant

Absolute Instant the cooldown expires. Compare to the engine’s Instant::now() to compute the remaining sleep.

§

AntiThrashCleared

The connection-level anti-thrash cooldown (ADR-0028) has lifted — either because the supervisor slept past until and explicitly cleared it via Connection::anti_thrash_state_mut, or because the broker stabilised and the driver called Connection::record_first_op_success.

Trait Implementations§

Source§

impl Clone for ConnectionEvent

Source§

fn clone(&self) -> ConnectionEvent

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ConnectionEvent

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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