Page MenuHomePhabricator

[services][identity] helper function to create primary key for DynamoDB
ClosedPublic

Authored by varun on May 12 2022, 8:06 AM.
Tags
None
Referenced Files
Unknown Object (File)
Tue, Nov 19, 6:00 PM
Unknown Object (File)
Tue, Nov 19, 5:29 PM
Unknown Object (File)
Fri, Nov 15, 11:33 PM
Unknown Object (File)
Thu, Nov 7, 3:21 PM
Unknown Object (File)
Tue, Nov 5, 7:19 PM
Unknown Object (File)
Oct 21 2024, 6:35 PM
Unknown Object (File)
Oct 14 2024, 8:53 AM
Unknown Object (File)
Oct 14 2024, 2:03 AM

Details

Summary

This function takes a partition key and optional sort key and returns a primary key for the DynamoDB client.

Depends on D3920

Test Plan

Unit tested

Diff Detail

Repository
rCOMM Comm
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

varun requested review of this revision.May 12 2022, 8:11 AM

Looks ok, but wouldn't it be better to add tests separately? I mean, in a different file or something?

services/identity/src/database.rs
47–48 ↗(On Diff #12578)

is it really a good practice to put tests right next to the functionality itself? Where does this come from?

This revision now requires changes to proceed.May 16 2022, 12:45 AM
varun requested review of this revision.May 16 2022, 8:14 AM

Replied inline

services/identity/src/database.rs
47–48 ↗(On Diff #12578)

by convention, unit tests go in the same file as the function they are testing. https://doc.rust-lang.org/book/ch11-03-test-organization.html#unit-tests

integration tests, on the other hand, should go in a separate tests directory.

karol added inline comments.
services/identity/src/database.rs
47–48 ↗(On Diff #12578)

Interesting! Thanks for clarifying!

jim requested changes to this revision.May 17 2022, 8:11 AM
jim added inline comments.
services/identity/src/database.rs
23 ↗(On Diff #12578)

If these are in an unordered HashMap, how will DynamoDB know which is the partition key and which is the sort key?

This revision now requires changes to proceed.May 17 2022, 8:11 AM

I think this would be better as two functions create_simple_primary_key(partition_key) and create_composite_primary_key(partition_key, sort_key). Terminology from https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/HowItWorks.CoreComponents.html#HowItWorks.CoreComponents.PrimaryKey.

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

Sorry, ignore this, I misunderstood what this does

This revision is now accepted and ready to land.May 19 2022, 7:21 AM