@@ -240,13 +240,14 @@ pub struct BatchProducerBuilder {
240
240
}
241
241
242
242
impl BatchProducerBuilder {
243
- /// Build a new `BatchProducer`
243
+ /// Build a new `BatchProducer`.
244
244
pub fn new ( client : Arc < PartitionClient > ) -> Self {
245
245
Self :: new_with_client ( client)
246
246
}
247
247
248
- /// Internal API for creating with any `dyn ProducerClient`
249
- fn new_with_client ( client : Arc < dyn ProducerClient > ) -> Self {
248
+ /// Construct a [`BatchProducer`] with a dynamically dispatched
249
+ /// [`ProducerClient`] implementation.
250
+ pub fn new_with_client ( client : Arc < dyn ProducerClient > ) -> Self {
250
251
Self {
251
252
client,
252
253
linger : Duration :: from_millis ( 5 ) ,
@@ -283,8 +284,18 @@ impl BatchProducerBuilder {
283
284
}
284
285
}
285
286
286
- // A trait wrapper to allow mocking
287
- trait ProducerClient : std:: fmt:: Debug + Send + Sync {
287
+ /// The [`ProducerClient`] provides an abstraction over a Kafka client than can
288
+ /// produce a record.
289
+ ///
290
+ /// Implementing this trait allows user code to inspect the low-level Kafka
291
+ /// [`Record`] instances being published to Kafka, as well as the result of the
292
+ /// produce call.
293
+ ///
294
+ /// Most users will want to use the [`BatchProducer`] implementation of this
295
+ /// trait.
296
+ pub trait ProducerClient : std:: fmt:: Debug + Send + Sync {
297
+ /// Write the set of `records` to the Kafka broker, using the specified
298
+ /// `compression` algorithm.
288
299
fn produce (
289
300
& self ,
290
301
records : Vec < Record > ,
0 commit comments