diff options
| author | Dimitris <dimstav23@gmail.com> | 2025-07-15 15:11:36 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-07-15 15:11:36 +0200 |
| commit | 73e505f04d17eba36c41fce7b48bc4d6884b8fd0 (patch) | |
| tree | 44b5f4627309a48d6f22b54bb2ad9a2976e8601b /archive/2025/summer/bsc_karidas/examples/main.cpp | |
| parent | ca92e7ad181a02890496872012ecc6c1d08b1658 (diff) | |
| parent | d8c365681a41961ebe2daea5701a4d56f5400d1d (diff) | |
| download | research-work-archive-artifacts-73e505f04d17eba36c41fce7b48bc4d6884b8fd0.tar.gz research-work-archive-artifacts-73e505f04d17eba36c41fce7b48bc4d6884b8fd0.zip | |
Merge pull request #6 from chriskari/upload-artifacts
Add bsc_karidas
Diffstat (limited to 'archive/2025/summer/bsc_karidas/examples/main.cpp')
| -rw-r--r-- | archive/2025/summer/bsc_karidas/examples/main.cpp | 68 |
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 |