spetz commented on code in PR #2621:
URL: https://github.com/apache/iggy/pull/2621#discussion_r2730735516


##########
core/sdk/src/clients/consumer.rs:
##########
@@ -1056,6 +1056,70 @@ impl Stream for IggyConsumer {
     }
 }
 
+impl IggyConsumer {
+    pub async fn shutdown(&mut self) -> Result<(), IggyError> {
+        if self.shutdown.swap(true, ORDERING) {
+            return Ok(());
+        }
+
+        info!("Shutting down consumer: {}...", self.consumer_name);
+
+        for entry in self.last_consumed_offsets.iter() {
+            let partition_id = *entry.key();
+            let consumed_offset = entry.load(ORDERING);
+
+            let stored_offset = self
+                .last_stored_offsets
+                .get(&partition_id)
+                .map(|e| e.load(ORDERING))
+                .unwrap_or(0);
+
+            if consumed_offset > stored_offset {
+                trace!("Flushing final offset: {consumed_offset} for 
partition: {partition_id}");
+                let _ = Self::store_consumer_offset(
+                    &self.client,
+                    &self.consumer,
+                    &self.stream_id,
+                    &self.topic_id,
+                    partition_id,
+                    consumed_offset,
+                    &self.last_stored_offsets,
+                    self.allow_replay,
+                )
+                .await;
+            }
+        }
+
+        if self.is_consumer_group && self.joined_consumer_group.load(ORDERING) 
{
+            let group_id = match self.consumer.id.kind {

Review Comment:
   Good catch, will fix



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to