-
Notifications
You must be signed in to change notification settings - Fork 4
fix: Ensure that serialization of a variation or rollout uses the correct overload. #483
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
df91388
24b2629
fd3bd44
5ad90f6
813a37c
aa1250c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,3 @@ | ||
| #include <boost/json.hpp> | ||
| #include <launchdarkly/serialization/json_context_aware_reference.hpp> | ||
| #include <launchdarkly/serialization/json_flag.hpp> | ||
|
|
@@ -255,7 +255,7 @@ | |
| void tag_invoke( | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When the situation arose this function was not getting called for serialization. Instead the standard handling for std::variant was being called. This resulted in the value being directly serialized. So for example |
||
| boost::json::value_from_tag const& unused, | ||
| boost::json::value& json_value, | ||
| data_model::Flag::VariationOrRollout const& variation_or_rollout) { | ||
| data_model::Flag::VariationOrRollout const& variation_or_rollout, const VariationOrRolloutContext&) { | ||
| auto& obj = json_value.emplace_object(); | ||
| std::visit( | ||
| [&obj](auto&& arg) { | ||
|
|
@@ -273,6 +273,13 @@ | |
| variation_or_rollout); | ||
| } | ||
|
|
||
| void tag_invoke( | ||
| boost::json::value_from_tag const& unused, | ||
| boost::json::value& json_value, | ||
| data_model::Flag::VariationOrRollout const& variation_or_rollout) { | ||
| tag_invoke(unused, json_value, variation_or_rollout, VariationOrRolloutContext()); | ||
| } | ||
|
|
||
| void tag_invoke(boost::json::value_from_tag const& unused, | ||
| boost::json::value& json_value, | ||
| data_model::Flag::Prerequisite const& prerequisite) { | ||
|
|
@@ -364,7 +371,7 @@ | |
| } | ||
| }, | ||
| flag.fallthrough); | ||
| }); | ||
| }, VariationOrRolloutContext()); | ||
| WriteMinimal(obj, "clientSideAvailability", flag.clientSideAvailability, | ||
| [&]() { | ||
| return flag.clientSideAvailability.usingEnvironmentId || | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is effectively a "tag" which can be used as a discriminator.