forked from redpanda-data/redpanda
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
features: Introduce enterprise_features
- features::license_required_feature Enumeration of redpanda features that require an enterprise license. - features::enterprise_feature_report A thin wrapper around a couple of sets to account for the status of enterprise features (usually based on cluster configs). Signed-off-by: Oren Leiman <oren.leiman@redpanda.com>
- Loading branch information
Showing
4 changed files
with
140 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* | ||
* Copyright 2024 Redpanda Data, Inc. | ||
* | ||
* Use of this software is governed by the Business Source License | ||
* included in the file licenses/BSL.md | ||
* | ||
* As of the Change Date specified in that file, in accordance with | ||
* the Business Source License, use of this software will be governed | ||
* by the Apache License, Version 2.0 | ||
*/ | ||
|
||
#include "enterprise_features.h" | ||
|
||
#include "base/vassert.h" | ||
|
||
#include <iostream> | ||
|
||
namespace features { | ||
|
||
std::ostream& operator<<(std::ostream& os, license_required_feature f) { | ||
switch (f) { | ||
case license_required_feature::audit_logging: | ||
return os << "audit_logging"; | ||
case license_required_feature::cloud_storage: | ||
return os << "cloud_storage"; | ||
case license_required_feature::partition_auto_balancing_continuous: | ||
return os << "partition_auto_balancing_continuous"; | ||
case license_required_feature::core_balancing_continuous: | ||
return os << "core_balancing_continuous"; | ||
case license_required_feature::gssapi: | ||
return os << "gssapi"; | ||
case license_required_feature::oidc: | ||
return os << "oidc"; | ||
case license_required_feature::schema_id_validation: | ||
return os << "schema_id_validation"; | ||
case license_required_feature::rbac: | ||
return os << "rbac"; | ||
case license_required_feature::fips: | ||
return os << "fips"; | ||
} | ||
__builtin_unreachable(); | ||
} | ||
|
||
void enterprise_feature_report::set( | ||
license_required_feature feat, bool enabled) { | ||
auto insert = [feat](vtype& dest, const vtype& other) { | ||
vassert( | ||
!other.contains(feat), | ||
"feature {{{}}} cannot be both enabled and disabled", | ||
feat); | ||
dest.insert(feat); | ||
}; | ||
|
||
if (enabled) { | ||
insert(_enabled, _disabled); | ||
} else { | ||
insert(_disabled, _enabled); | ||
} | ||
} | ||
|
||
} // namespace features |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* | ||
* Copyright 2024 Redpanda Data, Inc. | ||
* | ||
* Use of this software is governed by the Business Source License | ||
* included in the file licenses/BSL.md | ||
* | ||
* As of the Change Date specified in that file, in accordance with | ||
* the Business Source License, use of this software will be governed | ||
* by the Apache License, Version 2.0 | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <absl/container/flat_hash_set.h> | ||
#include <boost/range/iterator_range.hpp> | ||
|
||
#include <iosfwd> | ||
|
||
namespace features { | ||
|
||
enum class license_required_feature { | ||
audit_logging, | ||
cloud_storage, | ||
partition_auto_balancing_continuous, | ||
core_balancing_continuous, | ||
gssapi, | ||
oidc, | ||
schema_id_validation, | ||
rbac, | ||
fips, | ||
}; | ||
|
||
std::ostream& operator<<(std::ostream&, license_required_feature); | ||
|
||
/** | ||
* Thin wrapper around two sets to indicate the current state of enterprise | ||
* features in the cluster. | ||
*/ | ||
class enterprise_feature_report { | ||
using vtype = absl::flat_hash_set<license_required_feature>; | ||
using range = boost::iterator_range<vtype::const_iterator>; | ||
|
||
public: | ||
void set(license_required_feature feat, bool enabled); | ||
range enabled() const { return _enabled; } | ||
range disabled() const { return _disabled; } | ||
bool any() const { return !_enabled.empty(); } | ||
|
||
private: | ||
vtype _enabled; | ||
vtype _disabled; | ||
}; | ||
|
||
} // namespace features |