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)
Thu, Nov 28, 1:57 AM
Unknown Object (File)
Thu, Nov 28, 12:35 AM
Unknown Object (File)
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
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