-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
feat(flags): more flags production-readiness #26998
Conversation
This PR hasn't seen activity in a week! Should it be merged, closed, or further worked on? If you want to keep it open, post a comment or remove the |
This PR was closed due to lack of activity. Feel free to reopen if it's still relevant. |
This PR hasn't seen activity in a week! Should it be merged, closed, or further worked on? If you want to keep it open, post a comment or remove the |
…feat/flags-to-prod
@flags { | ||
path /flags | ||
path /flags* | ||
} |
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 puts the flags service behind the reverse proxy that's handling our other rust services.
handle @flags { | ||
reverse_proxy feature-flags:3001 | ||
} |
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.
we run on port 3001, and then route it to port 8000
pub async fn options() -> Result<Json<FlagsOptionsResponse>, FlagError> { | ||
Ok(Json(FlagsOptionsResponse { | ||
status: FlagsResponseCode::Ok, | ||
})) | ||
} |
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.
handle options requests like we do in /decide
(see: https://github.com/PostHog/posthog/blob/feat/flags-to-prod/posthog/api/decide.py#L167-L169)
#[error("billing limit reached")] | ||
BillingLimit, |
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.
will implement the quota limiting in another PR; I started on it and then it got kinda beefy. Leaving this in for now though since it's harmless to add the error type, the PR will land shortly anyway.
Gzip, | ||
Base64, |
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.
we explicitly won't support b64 encoding for new flags traffic; gzip or bust babay
@@ -0,0 +1,118 @@ | |||
use axum::{ |
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 file is for testing request traffic without hitting any of the services; not helpful for testing evaluation, but helpful for testing that the various types of requests that we can send are handled correctly.
pub feature_flag_payloads: HashMap<String, Value>, // flag key -> payload | ||
pub feature_flag_payloads: HashMap<String, Value>, | ||
#[serde(skip_serializing_if = "Option::is_none")] | ||
pub quota_limited: Option<Vec<String>>, // list of quota limited resources |
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.
will add quota limiting in a future PR
@@ -0,0 +1,388 @@ | |||
use common_metrics::inc; |
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.
none of this is new code, it was just pulled out of flag_request
along with the tests. Should work fine.
// TODO: the following fields are used for the `/decide` response, | ||
// but they're not used for flags and they don't live in redis. | ||
// At some point I'll need to differentiate between teams in Redis and teams | ||
// with additional fields in Postgres, since the Postgres team is a superset of the fields | ||
// we use for flags, anyway. | ||
// pub surveys_opt_in: bool, | ||
// pub heatmaps_opt_in: bool, | ||
// pub capture_performance_opt_in: bool, | ||
// pub autocapture_web_vitals_opt_in: bool, | ||
// pub autocapture_opt_out: bool, | ||
// pub autocapture_exceptions_opt_in: bool, |
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.
RemoteConfig will handle decide, so I'm explicitly not going to parse any of this stuff from our teams table for flags.
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.
LGTM!
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 my first time reading Rust, yet I felt like I could follow along. I appreciate the clarity of the code. Code looks good to me, but I wouldn't trust that I would notice a bug given my lack of Rust experience. 😄
Changes
error_while_computing_flags
->errors_while_computing_flags
(to match current behavior)flag_request
intoflag_request
andflag_service
, where the request module just handles the request, and the service handles fetching data from sources. This will make it so that we don't go to any databases, etc if we have missing/malformed data in the requestDoes this work well for both Cloud and self-hosted?
No impact yet, since nothing is hitting the
/flags
endpoint.How did you test this code?
Have been locally testing it by creating flags locally, pointing the SDK at the flags endpoint, and confirming that they evaluate as expected.