[][src]Trait rdkafka::client::ClientContext

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

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

fn log(&self, level: RDKafkaLogLevel, fac: &str, log_message: &str)

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.

fn stats(&self, statistics: Statistics)

Receives the 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.

fn error(&self, error: KafkaError, reason: &str)

Receives global errors from the librdkafka client.

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

Loading content...

Implementors

impl ClientContext for DefaultClientContext[src]

impl ClientContext for DefaultConsumerContext[src]

impl ClientContext for DefaultProducerContext[src]

impl<C: ClientContext + 'static> ClientContext for FutureProducerContext<C>[src]

impl<C: ConsumerContext + 'static> ClientContext for StreamConsumerContext<C>[src]

Loading content...