Skip to content

Commit

Permalink
Improve print in case if consumer is not initialized (#1394)
Browse files Browse the repository at this point in the history
  • Loading branch information
hubcio authored Dec 23, 2024
1 parent 7402f43 commit 96e8df5
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion sdk/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "iggy"
version = "0.6.60"
version = "0.6.61"
description = "Iggy is the persistent message streaming platform written in Rust, supporting QUIC, TCP and HTTP transport protocols, capable of processing millions of messages per second."
edition = "2021"
license = "MIT"
Expand Down
7 changes: 6 additions & 1 deletion sdk/src/clients/consumer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,8 @@ impl IggyConsumer {
}

/// Initializes the consumer by subscribing to diagnostic events, initializing the consumer group if needed, storing the offsets in the background etc.
///
/// Note: This method must be called before polling messages.
pub async fn init(&mut self) -> Result<(), IggyError> {
if self.initialized {
return Ok(());
Expand Down Expand Up @@ -338,7 +340,7 @@ impl IggyConsumer {

fn send_store_offset(&self, partition_id: u32, offset: u64) {
if let Err(error) = self.store_offset_sender.send((partition_id, offset)) {
error!("Failed to send offset to store: {error}");
error!("Failed to send offset to store: {error}, please verify if `init()` on IggyConsumer object has been called.");
}
}

Expand Down Expand Up @@ -985,6 +987,9 @@ impl IggyConsumerBuilder {
}
}

/// Builds the consumer.
///
/// Note: After building the consumer, `init()` must be invoked before producing messages.
pub fn build(self) -> IggyConsumer {
IggyConsumer::new(
self.client,
Expand Down
5 changes: 5 additions & 0 deletions sdk/src/clients/producer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ impl IggyProducer {
}

/// Initializes the producer by subscribing to diagnostic events, creating the stream and topic if they do not exist etc.
///
/// Note: This method must be invoked before producing messages.
pub async fn init(&mut self) -> Result<(), IggyError> {
if self.initialized {
return Ok(());
Expand Down Expand Up @@ -609,6 +611,9 @@ impl IggyProducerBuilder {
}
}

/// Builds the producer.
///
/// Note: After building the producer, `init()` must be invoked before producing messages.
pub fn build(self) -> IggyProducer {
IggyProducer::new(
self.client,
Expand Down

0 comments on commit 96e8df5

Please sign in to comment.