Page MenuHomePhabricator

[services][feature-flags] Connect http service with database
ClosedPublic

Authored by tomek on Feb 23 2023, 8:46 AM.
Tags
None
Referenced Files
Unknown Object (File)
Feb 21 2024, 2:15 PM
Unknown Object (File)
Feb 21 2024, 2:05 PM
Unknown Object (File)
Feb 21 2024, 2:05 PM
Unknown Object (File)
Feb 21 2024, 2:05 PM
Unknown Object (File)
Feb 21 2024, 9:06 AM
Unknown Object (File)
Feb 21 2024, 9:06 AM
Unknown Object (File)
Feb 21 2024, 9:06 AM
Unknown Object (File)
Feb 12 2024, 6:44 AM
Subscribers

Details

Summary

Query the db, transform the result and return it as a response from an endpoint.

Depends on D6861

Test Plan

Send GET request and check it the response is correctly read from AWS.

Diff Detail

Repository
rCOMM Comm
Lint
No Lint Coverage
Unit
No Test Coverage

Event Timeline

tomek requested review of this revision.Feb 23 2023, 8:59 AM
bartek requested changes to this revision.Feb 24 2023, 4:40 AM
bartek added inline comments.
services/feature-flags/src/service.rs
35–54 ↗(On Diff #23016)

I'd prefer to return early (pasted code here instead of suggestion because it was so unreadable)

let platform = match query.platform.as_str() {
  "iOS" => Platform::IOS,
  "Android" => Platform::ANDROID,
  _ => {
    return HttpResponse::BadRequest().finish()
  },
};
match Self::enabled_features_set(
  client.get_ref(),
  platform,
  query.code_version,
  query.is_staff,
)
.await
{
  Ok(features) => HttpResponse::Ok()
    .body(features.into_iter().collect::<Vec<_>>().join(", ")),
  _ => HttpResponse::InternalServerError().finish(),
}
36–37 ↗(On Diff #23016)

Is it case-sensitive? And should URLs be?

49–50 ↗(On Diff #23016)

I'm wondering if this isn't more readable than a one-liner. Up to you

50 ↗(On Diff #23016)
  • It'd be easier to parse if the separator didn't contain whitespaces, so just a comma or semicolon
  • Is the response Content-Type automatically set to text/plain?
This revision now requires changes to proceed.Feb 24 2023, 4:40 AM
services/feature-flags/src/service.rs
36–37 ↗(On Diff #23016)

Query part of url is case-sensitive. I guess we can make the check on service side case-insensitive, just for the convenience.

49–50 ↗(On Diff #23016)

Agree, it's more readable.

50 ↗(On Diff #23016)

Makes sense!

The docs don't mention that the content is set automatically, so I added it explicitly.

Make code more readable and make platfor case-insensitive

This revision is now accepted and ready to land.Feb 27 2023, 6:17 AM