-
Notifications
You must be signed in to change notification settings - Fork 3
feat: Add json serialization support for contexts. #14
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
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
3ae3cda
feat: Add json serialization support for contexts.
kinyoklion b94922d
Merge branch 'rlamb/flag-data-model' into rlamb/serialize-context
kinyoklion c2794ea
Context serialization and tests.
kinyoklion 2c0bed4
Move serialization into different files.
kinyoklion bf03024
Remove boost json header from context and attributes.
kinyoklion 2c02740
Cleanup includes.
kinyoklion 4ce0548
Rename EvaluationDetail to EvaluationDetailInternal
kinyoklion File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,14 @@ | ||
| #pragma once | ||
|
|
||
| #include <boost/json.hpp> | ||
| #include "attributes.hpp" | ||
|
|
||
| namespace launchdarkly { | ||
| /** | ||
| * Method used by boost::json for converting launchdarkly::Attributes into a | ||
| * boost::json::value. | ||
| */ | ||
| void tag_invoke(boost::json::value_from_tag const&, | ||
| boost::json::value& json_value, | ||
| Attributes const& attributes); | ||
| } // namespace launchdarkly | ||
This file contains hidden or 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,15 @@ | ||
| #pragma once | ||
|
|
||
| #include <boost/json.hpp> | ||
|
|
||
| #include "context.hpp" | ||
|
|
||
| namespace launchdarkly { | ||
| /** | ||
| * Method used by boost::json for converting a launchdarkly::Context into a | ||
| * boost::json::value. | ||
| */ | ||
| void tag_invoke(boost::json::value_from_tag const&, | ||
| boost::json::value& json_value, | ||
| Context const& ld_context); | ||
| } // namespace launchdarkly |
16 changes: 16 additions & 0 deletions
16
libs/common/include/serialization/json_evaluation_reason.hpp
This file contains hidden or 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,16 @@ | ||
| #pragma once | ||
|
|
||
| #include <boost/json.hpp> | ||
|
|
||
| #include "data/evaluation_reason.hpp" | ||
|
|
||
| namespace launchdarkly { | ||
| /** | ||
| * Method used by boost::json for converting a boost::json::value into a | ||
| * launchdarkly::EvaluationReason. | ||
| * @return A EvaluationReason representation of the boost::json::value. | ||
| */ | ||
| EvaluationReason tag_invoke( | ||
| boost::json::value_to_tag<EvaluationReason> const& unused, | ||
| boost::json::value const& json_value); | ||
| } // namespace launchdarkly |
16 changes: 16 additions & 0 deletions
16
libs/common/include/serialization/json_evaluation_result.hpp
This file contains hidden or 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,16 @@ | ||
| #pragma once | ||
|
|
||
| #include <boost/json.hpp> | ||
|
|
||
| #include "data/evaluation_result.hpp" | ||
|
|
||
| namespace launchdarkly { | ||
| /** | ||
| * Method used by boost::json for converting a boost::json::value into a | ||
| * launchdarkly::EvaluationResult. | ||
| * @return A EvaluationResult representation of the boost::json::value. | ||
| */ | ||
| EvaluationResult tag_invoke( | ||
| boost::json::value_to_tag<EvaluationResult> const& unused, | ||
| boost::json::value const& json_value); | ||
| } // namespace launchdarkly |
This file contains hidden or 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,23 @@ | ||
| #pragma once | ||
|
|
||
| #include <boost/json.hpp> | ||
|
|
||
| #include "value.hpp" | ||
|
|
||
| namespace launchdarkly { | ||
| /** | ||
| * Method used by boost::json for converting a boost::json::value into a | ||
| * launchdarkly::Value. | ||
| * @return A Value representation of the boost::json::value. | ||
| */ | ||
| Value tag_invoke(boost::json::value_to_tag<Value> const&, | ||
| boost::json::value const&); | ||
|
|
||
| /** | ||
| * Method used by boost::json for converting a launchdarkly::Value into a | ||
| * boost::json::value. | ||
| */ | ||
| void tag_invoke(boost::json::value_from_tag const&, | ||
| boost::json::value& json_value, | ||
| Value const& ld_value); | ||
| } // namespace launchdarkly |
File renamed without changes.
This file contains hidden or 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 hidden or 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 was deleted.
Oops, something went wrong.
This file contains hidden or 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,25 @@ | ||
| #include "data/evaluation_detail_internal.hpp" | ||
|
|
||
| namespace launchdarkly { | ||
|
|
||
| Value const& EvaluationDetailInternal::value() const { | ||
| return value_; | ||
| } | ||
|
|
||
| std::optional<std::size_t> EvaluationDetailInternal::variation_index() const { | ||
| return variation_index_; | ||
| } | ||
|
|
||
| std::optional<std::reference_wrapper<EvaluationReason const>> | ||
| EvaluationDetailInternal::reason() const { | ||
| return reason_; | ||
| } | ||
| EvaluationDetailInternal::EvaluationDetailInternal( | ||
| Value value, | ||
| std::optional<std::size_t> variation_index, | ||
| std::optional<EvaluationReason> reason) | ||
| : value_(std::move(value)), | ||
| variation_index_(variation_index), | ||
| reason_(std::move(reason)) {} | ||
|
|
||
| } // namespace launchdarkly |
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I prefixed
json. Maybe we would wantprotobuforbinaryor some other thing in the future. /shrug