-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(flags): reorganized the modules (#26297)
- Loading branch information
Showing
36 changed files
with
298 additions
and
303 deletions.
There are no files selected for viewing
5 changes: 3 additions & 2 deletions
5
rust/feature-flags/src/v0_endpoint.rs → rust/feature-flags/src/api/endpoint.rs
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
55 changes: 2 additions & 53 deletions
55
rust/feature-flags/src/api.rs → rust/feature-flags/src/api/errors.rs
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,4 @@ | ||
pub mod endpoint; | ||
pub mod errors; | ||
pub mod handler; | ||
pub mod types; |
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,21 @@ | ||
use serde::{Deserialize, Serialize}; | ||
use std::collections::HashMap; | ||
|
||
#[derive(Debug, PartialEq, Eq, Deserialize, Serialize)] | ||
pub enum FlagsResponseCode { | ||
Ok = 1, | ||
} | ||
|
||
#[derive(Debug, PartialEq, Eq, Deserialize, Serialize)] | ||
#[serde(untagged)] | ||
pub enum FlagValue { | ||
Boolean(bool), | ||
String(String), | ||
} | ||
|
||
#[derive(Debug, PartialEq, Eq, Deserialize, Serialize)] | ||
#[serde(rename_all = "camelCase")] | ||
pub struct FlagsResponse { | ||
pub error_while_computing_flags: bool, | ||
pub feature_flags: HashMap<String, FlagValue>, | ||
} |
File renamed without changes.
File renamed without changes.
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,3 @@ | ||
pub mod database; | ||
pub mod geoip; | ||
pub mod redis; |
File renamed without changes.
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
2 changes: 1 addition & 1 deletion
2
rust/feature-flags/src/cohort_models.rs → ...feature-flags/src/cohort/cohort_models.rs
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,3 @@ | ||
pub mod cohort_cache_manager; | ||
pub mod cohort_models; | ||
pub mod cohort_operations; |
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
File renamed without changes.
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,70 @@ | ||
use serde::{Deserialize, Serialize}; | ||
|
||
use crate::properties::property_models::PropertyFilter; | ||
|
||
// TRICKY: This cache data is coming from django-redis. If it ever goes out of sync, we'll bork. | ||
// TODO: Add integration tests across repos to ensure this doesn't happen. | ||
pub const TEAM_FLAGS_CACHE_PREFIX: &str = "posthog:1:team_feature_flags_"; | ||
|
||
#[derive(Debug, Clone, Deserialize, Serialize)] | ||
pub struct FlagGroupType { | ||
pub properties: Option<Vec<PropertyFilter>>, | ||
pub rollout_percentage: Option<f64>, | ||
pub variant: Option<String>, | ||
} | ||
|
||
#[derive(Debug, Clone, Deserialize, Serialize)] | ||
pub struct MultivariateFlagVariant { | ||
pub key: String, | ||
pub name: Option<String>, | ||
pub rollout_percentage: f64, | ||
} | ||
|
||
#[derive(Debug, Clone, Deserialize, Serialize)] | ||
pub struct MultivariateFlagOptions { | ||
pub variants: Vec<MultivariateFlagVariant>, | ||
} | ||
|
||
#[derive(Debug, Clone, Deserialize, Serialize)] | ||
pub struct FlagFilters { | ||
pub groups: Vec<FlagGroupType>, | ||
pub multivariate: Option<MultivariateFlagOptions>, | ||
pub aggregation_group_type_index: Option<i32>, | ||
pub payloads: Option<serde_json::Value>, | ||
pub super_groups: Option<Vec<FlagGroupType>>, | ||
} | ||
|
||
// TODO: see if you can combine these two structs, like we do with cohort models | ||
// this will require not deserializing on read and instead doing it lazily, on-demand | ||
// (which, tbh, is probably a better idea) | ||
#[derive(Debug, Clone, Deserialize, Serialize)] | ||
pub struct FeatureFlag { | ||
pub id: i32, | ||
pub team_id: i32, | ||
pub name: Option<String>, | ||
pub key: String, | ||
pub filters: FlagFilters, | ||
#[serde(default)] | ||
pub deleted: bool, | ||
#[serde(default)] | ||
pub active: bool, | ||
#[serde(default)] | ||
pub ensure_experience_continuity: bool, | ||
} | ||
|
||
#[derive(Debug, Serialize, sqlx::FromRow)] | ||
pub struct FeatureFlagRow { | ||
pub id: i32, | ||
pub team_id: i32, | ||
pub name: Option<String>, | ||
pub key: String, | ||
pub filters: serde_json::Value, | ||
pub deleted: bool, | ||
pub active: bool, | ||
pub ensure_experience_continuity: bool, | ||
} | ||
|
||
#[derive(Clone, Debug, Default, Deserialize, Serialize)] | ||
pub struct FeatureFlagList { | ||
pub flags: Vec<FeatureFlag>, | ||
} |
Oops, something went wrong.