pub trait ClientContext: Send + Sync {
    fn log(&self, level: RDKafkaLogLevel, fac: &str, log_message: &str) { ... }
fn stats(&self, statistics: Statistics) { ... }
fn stats_raw(&self, statistics: &[u8]) { ... }
fn error(&self, error: KafkaError, reason: &str) { ... } }
Expand description

Client-level context.

Each client (consumers and producers included) has a context object that can be used to customize its behavior. Implementing ClientContext enables the customization of methods common to all clients, while ProducerContext and ConsumerContext are specific to producers and consumers. Refer to the list of methods to see which callbacks can currently be overridden.

Important: implementations of ClientContext must be thread safe, as they might be shared between multiple threads.

Provided methods

Receives log lines from librdkafka.

The default implementation forwards the log lines to the appropriate log crate macro. Consult the RDKafkaLogLevel documentation for details about the log level mapping.

Receives the decoded statistics of the librdkafka client. To enable, the statistics.interval.ms configuration parameter must be specified.

The default implementation logs the statistics at the info log level.

Receives the JSON-encoded statistics of the librdkafka client. To enable, the statistics.interval.ms configuration parameter must be specified.

The default implementation calls ClientContext::stats with the decoded statistics, logging an error if the decoding fails.

Receives global errors from the librdkafka client.

The default implementation logs the error at the error log level.

Implementors