Lifecycle
PulsarBroker::new records configuration, connect builds the
client, startup opens a consumer per subscription, and
shutdown closes the producers.
The diagram as text
- Broker: PulsarBroker::new (url); ConnectedPulsarBroker; Closed: ()
- On Pulsar: Configuration only, no I/O; The client is built: URL, token, retries; Each subscription: a consumer and its driver task; The first publish to a topic opens its producer; Marked closed, producers closed
- PulsarBroker::new (url) → ConnectedPulsarBroker: connect(self)
- ConnectedPulsarBroker → Closed: (): shutdown(self)
- Configuration only, no I/O → The client is built: URL, token, retries
- The client is built: URL, token, retries → Each subscription: a consumer and its driver task
- Each subscription: a consumer and its driver task → The first publish to a topic opens its producer
- The first publish to a topic opens its producer → Marked closed, producers closed
- A publisher or a seek that outlives the connection answers PulsarError::NotConnected, never a silent success
new does no I/O, so the service's builder stays synchronous. The runtime connects the broker when
the app starts. Connect builds the client from the URL, the token and the
operation retries, and a client that cannot be built fails the start with
PulsarError::Connect. A publisher taken from the
broker before it connected shares its connection once it has.
Each subscription's descriptor is checked first: a subscription name, valid topic names or a valid
pattern, and a retry declaration Pulsar can apply. Then the client consumer opens, on the runtime
the broker connected on, and a driver task starts beside it. A refusal from the server fails the
start with PulsarError::Subscribe, naming the
topic.
A service that only consumes opens no producer. The first publish to a topic opens that topic's.
Shutdown marks the connection closed, then closes every producer. The client has no close of its own, so the closed state carries nothing. A subscription that is dropped stops its driver task. The driver keeps settling until every delivery it handed out has settled or been dropped, then closes the consumer.