about summary refs log tree commit diff stats
path: root/archive/2025/summer/bsc_karidas/examples/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'archive/2025/summer/bsc_karidas/examples/main.cpp')
-rw-r--r--archive/2025/summer/bsc_karidas/examples/main.cpp68
1 files changed, 68 insertions, 0 deletions
diff --git a/archive/2025/summer/bsc_karidas/examples/main.cpp b/archive/2025/summer/bsc_karidas/examples/main.cpp
new file mode 100644
index 000000000..e589e92e0
--- /dev/null
+++ b/archive/2025/summer/bsc_karidas/examples/main.cpp
@@ -0,0 +1,68 @@
+#include "LoggingManager.hpp"
+#include <iostream>
+#include <thread>
+#include <chrono>
+#include <vector>
+#include <future>
+#include <optional>
+#include <filesystem>
+#include <numeric>
+
+int main()
+{
+    // system parameters
+    LoggingConfig config;
+    config.basePath = "./logs";
+    config.baseFilename = "default";
+    config.maxSegmentSize = 1 * 1024 * 1024; // 1 MB
+    config.maxAttempts = 5;
+    config.baseRetryDelay = std::chrono::milliseconds(1);
+    config.queueCapacity = 1000;
+    config.maxExplicitProducers = 1;
+    config.batchSize = 10;
+    config.numWriterThreads = 1;
+    config.appendTimeout = std::chrono::seconds(5);
+    config.useEncryption = true;
+    config.compressionLevel = 4;
+    config.maxOpenFiles = 32;
+
+    if (std::filesystem::exists(config.basePath))
+    {
+        std::filesystem::remove_all(config.basePath);
+    }
+
+    LoggingManager loggingManager(config);
+    loggingManager.start();
+
+    auto producerToken = loggingManager.createProducerToken();
+
+    LogEntry entry1(LogEntry::ActionType::READ,
+                   "users/user01",
+                   "controller1",
+                   "processor1",
+                   "user01");
+
+    loggingManager.append(entry1, producerToken);
+
+    LogEntry entry2(LogEntry::ActionType::UPDATE,
+                    "users/user02",
+                    "controller2",
+                    "processor2",
+                    "user02");
+
+    LogEntry entry3(LogEntry::ActionType::DELETE,
+                    "users/user03",
+                    "controller3",
+                    "processor3",
+                    "user03");
+
+    std::vector<LogEntry> batch{
+        LogEntry(LogEntry::ActionType::UPDATE, "users/user02", "controller2", "processor2", "user02"),
+        LogEntry(LogEntry::ActionType::DELETE, "users/user03", "controller3", "processor3", "user03")};
+
+    loggingManager.appendBatch(batch, producerToken);
+
+    loggingManager.stop();
+
+    return 0;
+}
\ No newline at end of file