forked from scylladb/scylladb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
per_partition_rate_limit_extension.hh
44 lines (33 loc) · 1.31 KB
/
per_partition_rate_limit_extension.hh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/*
* Copyright (C) 2022-present ScyllaDB
*/
/*
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
#pragma once
#include "db/per_partition_rate_limit_options.hh"
#include "schema.hh"
#include "serializer.hh"
namespace db {
class per_partition_rate_limit_extension : public schema_extension {
per_partition_rate_limit_options _options;
public:
static constexpr auto NAME = "per_partition_rate_limit";
per_partition_rate_limit_extension() = default;
per_partition_rate_limit_extension(const per_partition_rate_limit_options& opts) : _options(opts) {}
explicit per_partition_rate_limit_extension(const std::map<sstring, sstring>& tags) : _options(tags) {}
explicit per_partition_rate_limit_extension(const bytes& b) : _options(deserialize(b)) {}
explicit per_partition_rate_limit_extension(const sstring& s) {
throw std::logic_error("Cannot create per partition rate limit info from string");
}
bytes serialize() const override {
return ser::serialize_to_buffer<bytes>(_options.to_map());
}
static std::map<sstring, sstring> deserialize(const bytes_view& buffer) {
return ser::deserialize_from_buffer(buffer, boost::type<std::map<sstring, sstring>>());
}
const per_partition_rate_limit_options& get_options() const {
return _options;
}
};
}