slbotbm commented on code in PR #4022:
URL: https://github.com/apache/iggy/pull/4022#discussion_r3991304146


##########
foreign/cpp/include/iggy.hpp:
##########
@@ -98,186 +876,613 @@ class SnapshotCompression final : private 
detail::StringTag<SnapshotCompression>
     /** @brief Returns the uncompressed storage option. */
     static SnapshotCompression Stored() { return 
SnapshotCompression("stored"); }
 
-    /** @brief Returns the Deflate compression option. */
-    static SnapshotCompression Deflated() { return 
SnapshotCompression("deflated"); }
+    /** @brief Returns the Deflate compression option. */
+    static SnapshotCompression Deflated() { return 
SnapshotCompression("deflated"); }
+
+    /** @brief Uses bzip2 for better compression with slower processing. */
+    static SnapshotCompression Bzip2() { return SnapshotCompression("bzip2"); }
+
+    /** @brief Uses Zstandard for fast compression and decompression. */
+    static SnapshotCompression Zstd() { return SnapshotCompression("zstd"); }
+
+    /** @brief Uses LZMA for high compression, especially for larger files. */
+    static SnapshotCompression Lzma() { return SnapshotCompression("lzma"); }
+
+    /** @brief Uses XZ for LZMA-like compression with faster decompression. */
+    static SnapshotCompression Xz() { return SnapshotCompression("xz"); }
+
+    /**
+     * @brief Returns the snapshot compression algorithm name.
+     * @return Snapshot compression algorithm name.
+     */
+    [[nodiscard]] std::string_view Value() const { return 
detail::StringTag<SnapshotCompression>::Value(); }
+
+  private:
+    explicit SnapshotCompression(std::string snapshot_compression)
+        : 
detail::StringTag<SnapshotCompression>(std::move(snapshot_compression)) {}
+};
+
+/**
+ * @brief Selects data to include in a system snapshot.
+ */
+class SystemSnapshotType final : private detail::StringTag<SystemSnapshotType> 
{
+  public:
+    /** @brief Includes an overview of the file-system structure. */
+    static SystemSnapshotType FilesystemOverview() { return 
SystemSnapshotType("filesystem_overview"); }
+
+    /** @brief Includes currently running processes. */
+    static SystemSnapshotType ProcessList() { return 
SystemSnapshotType("process_list"); }
+
+    /** @brief Includes CPU, memory, and other resource usage statistics. */
+    static SystemSnapshotType ResourceUsage() { return 
SystemSnapshotType("resource_usage"); }
+
+    /** @brief Includes the test snapshot used for development and testing. */
+    static SystemSnapshotType Test() { return SystemSnapshotType("test"); }
+
+    /** @brief Includes server logs from the configured logging directory. */
+    static SystemSnapshotType ServerLogs() { return 
SystemSnapshotType("server_logs"); }
+
+    /** @brief Includes server configuration. */
+    static SystemSnapshotType ServerConfig() { return 
SystemSnapshotType("server_config"); }
+
+    /** @brief Includes all available snapshot data. */
+    static SystemSnapshotType All() { return SystemSnapshotType("all"); }
+
+    /**
+     * @brief Returns the value passed to the client implementation.
+     * @return System snapshot type name.
+     */
+    [[nodiscard]] std::string_view SnapshotTypeValue() const { return Value(); 
}
+
+  private:
+    explicit SystemSnapshotType(std::string snapshot_type)
+        : detail::StringTag<SystemSnapshotType>(std::move(snapshot_type)) {}
+};
+
+/**
+ * @brief Maximum retained size of a topic.
+ *
+ * A topic may use the server default, have no size limit, or use an explicit
+ * byte limit.
+ *
+ * Use ServerDefault(), Unlimited(), or FromBytes() to select the retention
+ * limit.
+ */
+class MaxTopicSize final : private detail::StringTag<MaxTopicSize> {
+  public:
+    /** @brief Returns the server-default size option. */
+    static MaxTopicSize ServerDefault() { return 
MaxTopicSize("server_default"); }
+
+    /** @brief Returns the unlimited size option. */
+    static MaxTopicSize Unlimited() { return MaxTopicSize("unlimited"); }
+
+    /**
+     * @brief Creates an explicit topic size limit.
+     * @param bytes Maximum topic size in bytes.
+     * @return Server-default size for zero, unlimited size for
+     *         std::numeric_limits<std::uint64_t>::max(), or the requested 
limit.
+     * @note The configured limit cannot be smaller than the server segment 
size.
+     */
+    static MaxTopicSize FromBytes(std::uint64_t bytes) {
+        if (bytes == 0) {
+            return ServerDefault();
+        }
+        if (bytes == std::numeric_limits<std::uint64_t>::max()) {
+            return Unlimited();
+        }
+        return MaxTopicSize(std::to_string(bytes));
+    }
+
+    /**
+     * @brief Returns the value passed to the client implementation.
+     * @return Topic size option or decimal byte count.
+     */
+    [[nodiscard]] std::string_view Value() const { return 
detail::StringTag<MaxTopicSize>::Value(); }
+
+  private:
+    explicit MaxTopicSize(std::string max_topic_size) : 
detail::StringTag<MaxTopicSize>(std::move(max_topic_size)) {}
+};
+
+/**
+ * @brief Message retention policy for a topic.
+ *
+ * Use ServerDefault(), NeverExpire(), or Duration() to select the retention
+ * policy.
+ */
+class Expiry final {
+  public:
+    /** @brief Returns the server-default expiry policy. */
+    static Expiry ServerDefault() { return Expiry("server_default", 0); }
+
+    /**
+     * @brief Keeps messages until another operation removes them, such as
+     *        topic deletion.
+     */
+    static Expiry NeverExpire() { return Expiry("never_expire", 
std::numeric_limits<std::uint64_t>::max()); }
+
+    /**
+     * @brief Creates a time-based expiry policy.
+     * @param micros Message lifetime in microseconds.
+     * @return Time-based expiry policy.
+     */
+    static Expiry Duration(std::uint64_t micros) { return Expiry("duration", 
micros); }

Review Comment:
   done



##########
foreign/cpp/src/type_conversion.rs:
##########
@@ -525,6 +528,167 @@ impl From<RustOptionSpec> for ffi::OptionSpec {
     }
 }
 
+impl TryFrom<ffi::TopicCreateOptions> for RustTopicCreateOptions {
+    type Error = String;
+
+    fn try_from(options: ffi::TopicCreateOptions) -> Result<Self, Self::Error> 
{
+        use std::str::FromStr;
+        let compression_algorithm = if options.has_compression_algorithm {
+            Some(
+                
RustCompressionAlgorithm::from_str(&options.compression_algorithm).map_err(
+                    |error| {
+                        format!(
+                            "invalid compression algorithm '{}': {error}",
+                            options.compression_algorithm
+                        )
+                    },
+                )?,
+            )
+        } else {
+            None
+        };
+        let message_expiry = if options.has_message_expiry {
+            Some(match options.message_expiry_kind.as_str() {
+                "server_default" | "default" => RustIggyExpiry::ServerDefault,
+                "never_expire" => RustIggyExpiry::NeverExpire,
+                "duration" => 
RustIggyExpiry::ExpireDuration(iggy::prelude::IggyDuration::from(
+                    options.message_expiry_value,
+                )),
+                _ => {
+                    return Err(format!(
+                        "invalid message expiry kind '{}'",
+                        options.message_expiry_kind
+                    ));
+                }
+            })
+        } else {
+            None
+        };
+        let max_topic_size = if options.has_max_topic_size {
+            Some(
+                
RustMaxTopicSize::from_str(&options.max_topic_size).map_err(|error| {
+                    format!(
+                        "invalid max topic size '{}': {error}",
+                        options.max_topic_size
+                    )
+                })?,
+            )
+        } else {
+            None
+        };
+        let durability = if options.has_durability {

Review Comment:
   done



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