diff --git a/CHANGELOG.md b/CHANGELOG.md index ed9d7e0..0bca6d4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Add communication timeouts to client settings, [PR-101](https://github.com/reductstore/reduct-cpp/pull/101) - Support replication modes (`enabled`, `paused`, `disabled`) and mode updates via PATCH, [PR-103](https://github.com/reductstore/reduct-cpp/pull/103) +- Add batch protocol v2 support for multiple entries and entry-aware records/batches, [PR-107](https://github.com/reductstore/reduct-cpp/pull/107) ### Fixed diff --git a/LICENSE b/LICENSE index 8b1984c..5c99808 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2025 ReductSoftware UG +Copyright (c) 2025-2026 ReductSoftware UG Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/examples/subscription.cc b/examples/subscription.cc index 02c6231..1a7ddcc 100644 --- a/examples/subscription.cc +++ b/examples/subscription.cc @@ -1,4 +1,4 @@ -// Copyright 2023 Alexey Timin +// Copyright 2023 ReductSoftware UG #include diff --git a/examples/usage_example.cc b/examples/usage_example.cc index a71f990..a777b50 100644 --- a/examples/usage_example.cc +++ b/examples/usage_example.cc @@ -1,4 +1,4 @@ -// Copyright 2022 Alexey Timin +// Copyright 2022 ReductSoftware UG #include diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index a09c0e3..4d786cd 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,4 +1,6 @@ set(SRC_FILES + reduct/internal/batch_v1.cc + reduct/internal/batch_v2.cc reduct/internal/http_client.cc reduct/internal/serialisation.cc reduct/bucket.cc diff --git a/src/reduct/bucket.cc b/src/reduct/bucket.cc index 18fa507..a25fd73 100644 --- a/src/reduct/bucket.cc +++ b/src/reduct/bucket.cc @@ -1,9 +1,8 @@ -// Copyright 2022-2024 Alexey Timin +// Copyright 2022-2024 ReductSoftware UG #include "reduct/bucket.h" #define FMT_HEADER_ONLY 1 #include -#include #ifdef CONCURRENTQUEUE_H_FILEPATH #include CONCURRENTQUEUE_H_FILEPATH #else @@ -12,11 +11,18 @@ #include +#include +#include +#include +#include #include #include -#include +#include +#include #include +#include "reduct/internal/batch_v1.h" +#include "reduct/internal/batch_v2.h" #include "reduct/internal/http_client.h" #include "reduct/internal/serialisation.h" @@ -27,11 +33,17 @@ using internal::ParseStatus; using internal::QueryOptionsToJsonString; class Bucket : public IBucket { + using BatchType = internal::BatchType; + public: - Bucket(std::string_view url, std::string_view name, const HttpOptions& options) - : path_(fmt::format("/b/{}", name)), stop_{} { + Bucket(std::string_view url, std::string_view name, const HttpOptions& options, + std::optional api_version = std::nullopt) + : path_(fmt::format("/b/{}", name)), io_path_(fmt::format("/io/{}", name)), stop_{} { name_ = name; client_ = IHttpClient::Build(url, options); + if (api_version) { + client_->SetApiVersion(api_version); + } worker_ = std::thread([this] { while (!stop_) { @@ -130,7 +142,7 @@ class Bucket : public IBucket { } Error RemoveRecord(std::string_view entry_name, Time timestamp) const noexcept override { - return client_->Delete(fmt::format("{}/{}?ts={}", path_, entry_name, ToMicroseconds(timestamp))); + return client_->Delete(fmt::format("{}/{}?ts={}", path_, entry_name, internal::ToMicroseconds(timestamp))); } Error Write(std::string_view entry_name, std::optional