Page MenuHomePhabricator

[Identity] Use references of DatabaseClient
ClosedPublic

Authored by jon on Mar 1 2023, 8:50 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, Apr 14, 9:20 PM
Unknown Object (File)
Sun, Apr 14, 9:20 PM
Unknown Object (File)
Sun, Apr 14, 9:20 PM
Unknown Object (File)
Sun, Apr 14, 9:20 PM
Unknown Object (File)
Sun, Apr 14, 9:16 PM
Unknown Object (File)
Feb 27 2024, 10:51 PM
Unknown Object (File)
Feb 27 2024, 10:51 PM
Unknown Object (File)
Feb 27 2024, 10:51 PM
Subscribers

Details

Summary

DatabaseClient is essentially an instance factory, we
don't need to be taking ownership of it on every function call;
thus forcing a .clone() on the caller.

Test Plan

This will be tested more thoroughly in a later diff, however,
the changes should just reduce the number of deep copies we do
of the "instance factory".

cd services/identity
cargo build

Diff Detail

Repository
rCOMM Comm
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

jon retitled this revision from Use references of DatabaseClient to [Identity] Use references of DatabaseClient.Mar 1 2023, 8:54 PM
varun requested changes to this revision.Mar 2 2023, 11:19 AM

DatabaseClient essentially just wraps the AWS DynamoDB client in an Arc. I'm not sure why we need to avoid cloning

This revision now requires changes to proceed.Mar 2 2023, 11:19 AM

We don't need 15 difference copies of the Arc wrapping; just when we cross a thread boundary like tokio::spawn.

I'm not sure why we need to avoid cloning

For similar reasons to preferring &str over String::clone(), because you don't need to copy.

i think cloning here is pretty inexpensive since we're just incrementing the atomic reference count, but you're right, we should avoid it altogether when possible

This revision is now accepted and ready to land.Mar 2 2023, 1:35 PM

Rebase on top of latest master