ilikepi63 commented on code in PR #1624:
URL: https://github.com/apache/iggy/pull/1624#discussion_r1990908265


##########
server/src/state/system.rs:
##########
@@ -241,6 +241,26 @@ impl SystemState {
                         topic.partitions.remove(&(last_partition_id - i));
                     }
                 }
+                EntryCommand::DeleteSegments(command) => {
+                    let stream_id = find_stream_id(&streams, 
&command.stream_id);
+                    let stream = streams
+                        .get_mut(&stream_id)
+                        .unwrap_or_else(|| panic!("{}", format!("Stream: 
{stream_id} not found")));
+                    let topic_id = find_topic_id(&stream.topics, 
&command.topic_id);
+                    let topic = stream
+                        .topics
+                        .get_mut(&topic_id)
+                        .unwrap_or_else(|| panic!("{}", format!("Topic: 
{topic_id} not found")));
+                    if topic.partitions.is_empty() {
+                        continue;
+                    }
+
+                    let partition_id = command.partition_id;
+
+                    let _partition = 
topic.partitions.get(&command.partition_id).unwrap_or_else(|| panic!("{}", 
format!("Partition {partition_id} not found.")));
+
+                    // HOWTO: get the segments from PartitionState?

Review Comment:
   I am not sure exactly what partition state is here, or how it is used?



##########
sdk/src/http/segments.rs:
##########
@@ -0,0 +1,38 @@
+use crate::client::SegmentClient;
+use crate::error::IggyError;
+use crate::http::client::HttpClient;
+use crate::http::HttpTransport;
+use crate::identifier::Identifier;
+use crate::segments::delete_segments::DeleteSegments;
+use async_trait::async_trait;
+
+#[async_trait]
+impl SegmentClient for HttpClient {
+    async fn delete_segments(
+        &self,
+        stream_id: &Identifier,
+        topic_id: &Identifier,
+        partition_id: u32,
+        segments_count: u32,
+    ) -> Result<(), IggyError> {
+        self.delete_with_query(
+            &get_path(
+                &stream_id.as_cow_str(),
+                &topic_id.as_cow_str(),
+                partition_id,
+            ),
+            &DeleteSegments {
+                stream_id: stream_id.clone(),
+                topic_id: topic_id.clone(),
+                partition_id,
+                segments_count,
+            },
+        )
+        .await?;
+        Ok(())
+    }
+}
+
+fn get_path(stream_id: &str, topic_id: &str, partition_id: u32) -> String {
+    format!("streams/{stream_id}/topics/{topic_id}/partitions/{partition_id}")

Review Comment:
   I am not certain if this is how the file structure is set out. 



-- 
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