Skip to content

Commit

Permalink
RS-289: Support QuotaType::kHard (#75)
Browse files Browse the repository at this point in the history
* add QuotaType::kHard

* update CHANGELOG
  • Loading branch information
atimin authored Sep 12, 2024
1 parent 6a498ba commit 2de5cf3
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added

- RS-418: `IBucket::RemoveRecord`, `IBucket::RemoveRecordBatch`, `IBucket::RemoveQuery` methods for removing records, [PR-74](https://github.com/reductstore/reduct-cpp/pull/74)
- RS-289: Support `QuotaType::kHard`, [PR-75](https://github.com/reductstore/reduct-cpp/pull/75)

## [1.11.0] - 2022-08-19

Expand Down
2 changes: 1 addition & 1 deletion src/reduct/bucket.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class IBucket {
public:
virtual ~IBucket() = default;

enum class QuotaType { kNone, kFifo };
enum class QuotaType { kNone, kFifo, kHard };

/**
* Bucket Settings
Expand Down
5 changes: 5 additions & 0 deletions src/reduct/internal/serialisation.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ nlohmann::json BucketSettingToJsonString(const IBucket::Settings& settings) {
case IBucket::QuotaType::kFifo:
data["quota_type"] = "FIFO";
break;
case IBucket::QuotaType::kHard:
data["quota_type"] = "HARD";
break;
}
}

Expand All @@ -51,6 +54,8 @@ Result<IBucket::Settings> ParseBucketSettings(const nlohmann::json& json) {
settings.quota_type = IBucket::QuotaType::kNone;
} else if (json["quota_type"] == "FIFO") {
settings.quota_type = IBucket::QuotaType::kFifo;
} else if (json["quota_type"] == "HARD") {
settings.quota_type = IBucket::QuotaType::kHard;
}
}

Expand Down
15 changes: 15 additions & 0 deletions tests/reduct/bucket_api_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,21 @@ TEST_CASE("reduct::Client should get or create a bucket", "[bucket_api]") {
REQUIRE(bucket);
}

TEST_CASE("reduct::Client should create a bucket with different quota type", "[bucket_api][1_12]") {
Fixture ctx;

auto quota_type = GENERATE(IBucket::QuotaType::kNone, IBucket::QuotaType::kFifo, IBucket::QuotaType::kHard);
[[maybe_unused]] auto _ = ctx.client->GetOrCreateBucket(kBucketName, {.quota_type = quota_type});
auto [bucket, err] = ctx.client->GetOrCreateBucket(kBucketName);

REQUIRE(err == Error::kOk);
REQUIRE(bucket);

auto [settings, get_error] = bucket->GetSettings();
REQUIRE(get_error == Error::kOk);
REQUIRE(settings.quota_type == quota_type);
}

TEST_CASE("reduct::IBucket should have settings", "[bucket_api]") {
Fixture ctx;
const IBucket::Settings kSettings{
Expand Down

0 comments on commit 2de5cf3

Please sign in to comment.