Skip to main content

ClusterResourceListener

Trait ClusterResourceListener 

Source
pub trait ClusterResourceListener: Send {
    // Required method
    fn on_update(&self, cluster_resource: &ClusterResource);
}
Expand description

A callback trait that users can implement when they wish to get notified about changes in the Cluster metadata.

Users who need access to cluster metadata in interceptors, metric reporters, serializers and deserializers can implement this trait. The order of method calls for each of these types is described below.

§Clients

There will be one invocation of ClusterResourceListener::on_update after each metadata response.

ProducerInterceptor: the on_update method will be invoked after ProducerInterceptor::on_send but before ProducerInterceptor::on_acknowledgement.

ConsumerInterceptor: the on_update method will be invoked before ConsumerInterceptor::on_consume.

Serializer: the on_update method will be invoked before Serializer::serialize.

Deserializer: the on_update method will be invoked before Deserializer::deserialize.

MetricsReporter: the on_update method will be invoked after first KafkaProducer::send invocation for Producer metrics reporter and after first KafkaConsumer::poll invocation for Consumer metrics reporters. The reporter may receive metric events from the network layer before this method is invoked.

§Translation notes

WARNING: no client registers a user’s listener, so on_update is never called.

Required Methods§

Source

fn on_update(&self, cluster_resource: &ClusterResource)

A callback method that a user can implement to get updates for ClusterResource.

§Arguments
  • cluster_resource - cluster metadata

Implementors§