Page MenuHomePhabricator

[services][blob] Add methods to manage the blob table
ClosedPublic

Authored by bartek on Nov 20 2022, 11:46 PM.
Tags
None
Referenced Files
F1668285: D5693.diff
Fri, Apr 26, 6:20 PM
Unknown Object (File)
Wed, Apr 3, 4:28 AM
Unknown Object (File)
Wed, Apr 3, 4:28 AM
Unknown Object (File)
Wed, Apr 3, 4:28 AM
Unknown Object (File)
Wed, Apr 3, 4:28 AM
Unknown Object (File)
Wed, Apr 3, 4:27 AM
Unknown Object (File)
Wed, Apr 3, 4:18 AM
Unknown Object (File)
Mar 13 2024, 6:44 PM
Subscribers

Details

Summary

Implemented methods for managing the blob-service-blob table. They will be needed in subsequent diffs.

This is mostly the same approach as in Identity Service, except I use anyhow to handle errors for now, for the sake of simplicity. Proper error handling is going to be introduced later.

Link to the C++ counterpart

Part of ENG-2300

Test Plan

Called these locally and ensured that entities are properly inserted/read/removed from database.

Diff Detail

Repository
rCOMM Comm
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

bartek held this revision as a draft.
services/blob/src/database.rs
52 ↗(On Diff #18627)

Currently, I store it as an int64 timestamp to keep it compatible with the old C++ implementation.

I have prepared a possible commit which implements this field as chrono::DateTime, while still storing it as a timestamp string in the database.

But maybe it would be a better idea to drop backwards compatibility and use to_rfc3339() as it is done in Identity service?

156–164 ↗(On Diff #18627)

This helper function is copy-pasted from the Identity service (except temporarily using anyhow for error handling)

It would be a good idea to move some common code to a Rust library shared across services, the same way we have it for C++ code (the services/lib/src dir).

I can create a Linear task for this unless it has already been created.

services/blob/src/database.rs
156–164 ↗(On Diff #18627)

I haven't found a task for this so I created one: https://linear.app/comm/issue/ENG-2311/shared-rust-code-across-services

services/blob/src/database.rs
52 ↗(On Diff #18627)

Did you intentionally leave this diff in Draft state? Just want to make sure it isn't stuck here for some other (possibly CI-related?) reason

bartek published this revision for review.Nov 22 2022, 1:54 AM
services/blob/src/database.rs
52 ↗(On Diff #18627)

The only reason to keep backwards compatibility is to make testing easier for you. We haven't introduced any usages of this service in production, so we should be okay breaking backwards compatibility if you are okay with it.

varun requested changes to this revision.Nov 22 2022, 10:09 AM
varun added inline comments.
services/blob/src/database.rs
52 ↗(On Diff #18627)

+1 what Ashoat said, and I think using rfc3339 is good for consistency

156–164 ↗(On Diff #18627)

Do we have a task for creating new Error types and moving away from Anyhow?

This revision now requires changes to proceed.Nov 22 2022, 10:09 AM
bartek edited the summary of this revision. (Show Details)
  • Rebase
  • Use RFC 3339 for created datetime
services/blob/src/database.rs
156–164 ↗(On Diff #18627)

Do we have a task for creating new Error types and moving away from Anyhow?

Do you mean moving away from Anyhow only in Blob service or in general? If the former, then I created ENG-2307, but for the latter case I haven't found any.

tomek added inline comments.
services/blob/src/database.rs
166 ↗(On Diff #18806)

Shouldn't we somehow specify the format from which we're parsing?

varun added inline comments.
services/blob/src/database.rs
166 ↗(On Diff #18806)

The format is implied, actually, but a comment might be helpful
https://docs.rs/chrono/latest/chrono/struct.DateTime.html#impl-FromStr-for-DateTime%3CUtc%3E

156–164 ↗(On Diff #18627)

I meant for the former. Thanks for creating that task!

This revision is now accepted and ready to land.Nov 28 2022, 11:04 PM
  • Rebase
  • Added comment about parsing RFC3339 as suggested