Skip to content
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

refact: Isolate FeatureSnapshot and PropertySnapshot from crate::models types #56

Merged
merged 2 commits into from
Feb 4, 2025

Conversation

jgsogo
Copy link
Collaborator

@jgsogo jgsogo commented Jan 20, 2025

A refactor going in the direction of isolating our logic from the JSON data returned by the server:

  • Remove all crate::models::... members from FeatureSnapshot and PropertySnapshot
  • Encapsulate TargetingRules and Segments into SegmentRules object. This new type handles the logic related to find_applicable_segment_rule_for_entity and also the one to get the Value from the found TargetingRule (now hidden into a SegmentRule)

}

impl FeatureSnapshot {
pub(crate) fn new(
feature: crate::models::Feature,
segments: HashMap<String, crate::models::Segment>,
) -> Self {
Self { feature, segments }
let segment_rules = SegmentRules::new(segments, feature.segment_rules, feature.kind);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probable in a following PR the new method should just take the members and really remove all the references to crate::models from here.

@jgsogo jgsogo requested a review from rainerschoe January 22, 2025 09:03
@jgsogo jgsogo marked this pull request as ready for review January 22, 2025 09:03
@jgsogo jgsogo mentioned this pull request Jan 31, 2025
@rainerschoe rainerschoe merged commit 812cc68 into IBM:main Feb 4, 2025
2 checks passed
@jgsogo jgsogo mentioned this pull request Feb 11, 2025
jgsogo added a commit that referenced this pull request Feb 12, 2025
Following #56, this PR moves the `FeatureSnapshot` and
`PropertySnapshot` inside `Configuration` (closer to JSON data), this
way the json-models doesn't leak into the application.

---------

Signed-off-by: Javier G. Sogo <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants