pub struct KafkaRetryPublisher { /* private fields */ }Expand description
A publisher minted from an unconnected KafkaBroker, for the one
wiring that cannot take a policy.
BrokerScope::retry_via - the deferred
republish behind retry_after, which Kafka relies on because it has no native delayed
redelivery - is configured while the app builder runs and takes a live Publisher, since
a publisher that cannot send would be a lie. This type is the sanctioned exception that
makes the pair work on a lazy-connect broker: it holds the cell
Broker::connect fills, not a connection. The policy path
(KafkaPublish and its transitions) is untouched and stays connection-free by
construction.
Its two runtime checks are the aliasing rule the broker contract deliberately keeps
dynamic: a handle that predates the connection, or outlives it, must surface an error rather
than silently succeed. Publishing before connect reports KafkaError::NotConnected;
publishing after the connected broker shut down reports KafkaError::Closed.
§Examples
use ruststream_rdkafka::KafkaBroker;
let broker = KafkaBroker::new(["localhost:9092"]);
let retries = broker.retry_publisher();
// ... `b.retry_via(retries)` while the app builder runs.Trait Implementations§
Source§impl Clone for KafkaRetryPublisher
impl Clone for KafkaRetryPublisher
Source§fn clone(&self) -> KafkaRetryPublisher
fn clone(&self) -> KafkaRetryPublisher
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for KafkaRetryPublisher
impl Debug for KafkaRetryPublisher
Source§impl Publisher for KafkaRetryPublisher
impl Publisher for KafkaRetryPublisher
Source§async fn publish(&self, msg: OutgoingMessage<'_>) -> Result<(), Self::Error>
async fn publish(&self, msg: OutgoingMessage<'_>) -> Result<(), Self::Error>
Publishes msg through the broker’s shared producer and awaits the delivery report.
§Errors
Returns KafkaError::NotConnected before the broker connects,
KafkaError::Closed once it has shut down, and KafkaError::Publish when the
cluster rejects the record or the delivery times out.
§Cancel safety
Not cancel safe: dropping the future may leave the record in flight, delivered or not.
Source§type Error = KafkaError
type Error = KafkaError
publish.