Skip to content

Commit

Permalink
Implement custom stickiness for flexible rollout
Browse files Browse the repository at this point in the history
  • Loading branch information
aruizs committed Dec 28, 2023
1 parent 23bf404 commit 187e1e3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/strategies/flexiblerollout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <nlohmann/json.hpp>
#include <random>


namespace unleash {
FlexibleRollout::FlexibleRollout(std::string_view parameters, std::string_view constraints)
: Strategy("flexibleRollout", constraints) {
Expand Down Expand Up @@ -34,6 +35,10 @@ bool FlexibleRollout::isEnabled(const Context &context) {
std::mt19937 rng(dev());
std::uniform_int_distribution<std::mt19937::result_type> dist6(1, 100);
return dist6(rng) <= m_rollout;
} else {
auto customFieldIt = context.properties.find(stickinessConfiguration);
if (customFieldIt == context.properties.end()) return false;
return normalizedMurmur3(m_groupId + ":" + customFieldIt->second) <= m_rollout;
}
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion test/tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ std::vector<TestParam> readSpecificationTestFromDisk(const std::string &testPath
// range-based to read each test
for (auto &element : j) { // Only features implemented for now
auto testNumber = std::stoi(element.get<std::string>().substr(0, 2));
if (testNumber <= 11) {
if (testNumber <= 12) {
std::cout << testPath + element.get<std::string>() << std::endl;
std::ifstream testFile(testPath + element.get<std::string>());
nlohmann::json testJson;
Expand Down

0 comments on commit 187e1e3

Please sign in to comment.