Page MenuHomePhabricator

[Identity] Add a database client
ClosedPublic

Authored by varun on Apr 25 2022, 9:11 PM.
Tags
None
Referenced Files
F3391781: D3853.id12290.diff
Sat, Nov 30, 6:02 AM
Unknown Object (File)
Fri, Nov 15, 6:37 PM
Unknown Object (File)
Fri, Nov 15, 9:06 AM
Unknown Object (File)
Wed, Nov 6, 9:12 PM
Unknown Object (File)
Tue, Nov 5, 7:10 PM
Unknown Object (File)
Oct 21 2024, 10:49 AM
Unknown Object (File)
Oct 13 2024, 7:54 PM
Unknown Object (File)
Oct 13 2024, 7:54 PM

Details

Summary

Introduces a DynamoDB client and implements a method to fetch PAKE registration data from a DDB table.

Depends on D3852

Test Plan

Was able to fetch data from a test table in DynamoDB

Diff Detail

Repository
rCOMM Comm
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

varun requested review of this revision.Apr 25 2022, 9:16 PM
services/identity/src/database.rs
30 ↗(On Diff #11904)

This should probably be a const, will fix

40 ↗(On Diff #11904)

This string slice should be a const too

70 ↗(On Diff #11904)

Defaulting to us-east-2 for now, since this is where all our tables are currently. We can revise this later to fetch the region from config

services/identity/src/service.rs
18 ↗(On Diff #11904)

The Rusoto DynamoDbClient doesn't implement Debug so we can't derive Debug for MyIdentityService

29 ↗(On Diff #11904)

Instruments a function to create and enter a tracing span every time the function is called.

We skip self since we don't have a Debug implementation for it currently

services/identity/src/database.rs
23 ↗(On Diff #11904)

this string slice should be a const too

services/identity/src/database.rs
5 ↗(On Diff #11904)

do we use DynamoDb?

15 ↗(On Diff #11904)

so this new method is just a convention, right?

25–26 ↗(On Diff #11904)

can you explain what these do?

32 ↗(On Diff #11904)

so this means that consistent_read is of type Option<bool> and we just want to set its value to true, right?

33 ↗(On Diff #11904)

So that uses default values for the rest of the fields of GetItemInput? And this is done by impl Default for ...?

38 ↗(On Diff #11904)

What does this mean? What is item inside of Some?

40 ↗(On Diff #11904)

shouldn't we use a better name than b?

Shouldn't @jimpo be a blocker reviewer for every identity diff since he was pointed out as one of two devs in the team who knows rust well (next to @varun)?

tomek requested changes to this revision.Apr 26 2022, 11:15 AM
tomek added 1 blocking reviewer(s): jim.

This diff is rather big - is there a way to split it somehow? It also looks like the diff does at least two things: we also add some instrumentation, which probably can stand on its own (correct me if I'm wrong).

@karol-bisztyga you can request changes even if it's just for the clarification. Also, when you think someone should be a blocking reviewer, you should add them.

This revision now requires changes to proceed.Apr 26 2022, 11:15 AM

Splitting diff up, addressing feedback

In D3853#107224, @palys-swm wrote:

This diff is rather big - is there a way to split it somehow? It also looks like the diff does at least two things: we also add some instrumentation, which probably can stand on its own (correct me if I'm wrong).

@karol-bisztyga you can request changes even if it's just for the clarification. Also, when you think someone should be a blocking reviewer, you should add them.

Yeah, the tracing instrumentation should be in its own diff. I'm moving the get_pake_registration method to a separate diff. cargo emits warnings if code is unused, so I was trying to avoid that, but it's not a big deal.

services/identity/src/database.rs
5 ↗(On Diff #11904)

Yeah, DynamoDb is a trait implemented by DynamoDbClient, but the trait impl is only available if we import it. We need this implementation to call get_item()

15 ↗(On Diff #11904)

Yeah it's just a constructor. We can name it anything, new is just the norm

25–26 ↗(On Diff #11904)

AttributeValue represents the data for an attribute. userID is a string so we set the s field to the user_id String and then set the rest to their defaults (None)

32 ↗(On Diff #11904)

correct

33 ↗(On Diff #11904)

correct

38 ↗(On Diff #11904)

I'm checking if the item field, which is an Option<HashMap<String, AttributeValue>>, is the Some variant, and then assigning the HashMap to a variable named item so I can use it on line 40.

40 ↗(On Diff #11904)

Yeah, fair enough. I'll make it bytes or something

jim requested changes to this revision.May 5 2022, 8:30 AM
jim added inline comments.
services/identity/src/database.rs
18 ↗(On Diff #12231)

Don't love this being hardcoded, just hardcode it in main.rs and pass to new. No need for a Default.

services/identity/src/service.rs
21 ↗(On Diff #12231)

Why is this pub?

This revision now requires changes to proceed.May 5 2022, 8:30 AM
services/identity/src/database.rs
18 ↗(On Diff #12231)

ack

services/identity/src/service.rs
21 ↗(On Diff #12231)

hmm yeah neither the client nor config should be pub

tomek added a reviewer: ashoat.

Adding @ashoat as we're including a new library

This revision is now accepted and ready to land.May 9 2022, 9:27 AM
This revision was automatically updated to reflect the committed changes.