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
F3380249: D6862.diff
Wed, Nov 27, 10:28 PM
Unknown Object (File)
Sat, Nov 16, 1:03 PM
Unknown Object (File)
Sat, Nov 16, 12:56 PM
Unknown Object (File)
Sat, Nov 16, 12:53 PM
Unknown Object (File)
Sat, Nov 16, 12:38 PM
Unknown Object (File)
Oct 26 2024, 10:12 PM
Unknown Object (File)
Oct 24 2024, 5:25 PM
Unknown Object (File)
Oct 18 2024, 5:42 PM
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
Branch
flags
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

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

Is it case-sensitive? And should URLs be?

49–50

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

50
  • 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

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

Agree, it's more readable.

50

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