Skip to content

Commit

Permalink
4099 produce config debug (#4143)
Browse files Browse the repository at this point in the history
* creating new methods and exposing properties

* removing unneded file

* fixing a comment

* fixing warning
  • Loading branch information
diogopontual committed Aug 20, 2024
1 parent 826b83a commit 790b7fd
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 2 deletions.
45 changes: 43 additions & 2 deletions crates/fluvio/src/producer/config.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::fmt::{Debug, Display, Formatter};
use std::fmt::{self, Debug, Display, Formatter};
use std::str::FromStr;
use std::time::Duration;

Expand Down Expand Up @@ -51,11 +51,18 @@ fn default_delivery() -> DeliverySemantic {
DeliverySemantic::default()
}

// This is needed only to bypass the partitioner property when debugging
impl fmt::Debug for Box<dyn Partitioner + Send + Sync> {
fn fmt(&self, _f: &mut fmt::Formatter<'_>) -> fmt::Result {
Ok(())
}
}

/// Options used to adjust the behavior of the Producer.
/// Create this struct with [`TopicProducerConfigBuilder`].
///
/// Create a producer with a custom config with [`crate::Fluvio::topic_producer_with_config()`].
#[derive(Builder)]
#[derive(Debug, Builder)]
#[builder(pattern = "owned")]
pub struct TopicProducerConfig {
/// Maximum amount of bytes accumulated by the records before sending the batch.
Expand Down Expand Up @@ -102,6 +109,40 @@ pub struct TopicProducerConfig {
pub(crate) smartmodules: Vec<SmartModuleInvocation>,
}

impl TopicProducerConfig {
pub fn linger(&self) -> Duration {
self.linger
}

pub fn batch_size(&self) -> usize {
self.batch_size
}

pub fn batch_queue_size(&self) -> usize {
self.batch_queue_size
}

pub fn compression(&self) -> Option<Compression> {
self.compression
}

pub fn timeout(&self) -> Duration {
self.timeout
}

pub fn isolation(&self) -> Isolation {
self.isolation
}

pub fn delivery_semantic(&self) -> DeliverySemantic {
self.delivery_semantic
}

pub fn smartmodules(&self) -> &Vec<SmartModuleInvocation> {
&self.smartmodules
}
}

impl Default for TopicProducerConfig {
fn default() -> Self {
Self {
Expand Down
8 changes: 8 additions & 0 deletions crates/fluvio/src/producer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,14 @@ where
})
}

pub fn topic(&self) -> &str {
&self.inner.topic
}

pub fn config(&self) -> &TopicProducerConfig {
&self.inner.config
}

/// Send all the queued records in the producer batches.
///
/// # Example
Expand Down

0 comments on commit 790b7fd

Please sign in to comment.