Page MenuHomePhabricator

[blob-service] Implement download logic with new db
ClosedPublic

Authored by bartek on Jul 9 2023, 2:05 PM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, Jun 27, 5:07 AM
Unknown Object (File)
Tue, Jun 25, 11:20 AM
Unknown Object (File)
Tue, Jun 25, 3:35 AM
Unknown Object (File)
Tue, Jun 25, 3:35 AM
Unknown Object (File)
Tue, Jun 25, 3:35 AM
Unknown Object (File)
Tue, Jun 25, 3:35 AM
Unknown Object (File)
Tue, Jun 25, 3:34 AM
Unknown Object (File)
Tue, Jun 25, 3:25 AM
Subscribers

Details

Summary

Part of ENG-4269.

Most of this code is copy-pasted from http::handlers::blob::get_blob_handler

Decided to create a separate download object, similar to "upload sessions" we already have. The reasoning for this is that we typically have the following workflow:

  1. Get the download object metadata (size etc.)
  2. Set download params (range, format, streaming options)
  3. Stream the data to the client

Depends on D8453.

Test Plan

Tested later in the stack

Diff Detail

Repository
rCOMM Comm
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

bartek held this revision as a draft.
bartek edited the test plan for this revision. (Show Details)
bartek edited the summary of this revision. (Show Details)
bartek published this revision for review.Jul 10 2023, 12:43 AM

rust LGTM, would like for someone else to take a look

services/blob/src/service.rs
78 ↗(On Diff #28510)

nit: metadata

121 ↗(On Diff #28510)

Any reason for not using non-inclusive range? Seems like it would simplify the code a bit

154 ↗(On Diff #28510)

I think this might skip the last byte in some cases (e.g. when chunk_size == 1 or when offset is equal to the byte one before last), but I could be mistaken

patryk added inline comments.
services/blob/src/service.rs
121 ↗(On Diff #28510)

Maybe it's because HTTP Range header is inclusive too, but might be another reason.

154 ↗(On Diff #28510)

Good catch! It skips last byte when (last_byte - first_byte) % chunk_size == 0. Changing condition to offset <= last_byte should solve the problem.

This revision now requires changes to proceed.Jul 17 2023, 11:48 PM
services/blob/src/service.rs
121 ↗(On Diff #28510)

No opinion on this. Inclusive ranges seemed just more natural and re-used existing code. I can change to non-inclusive

154 ↗(On Diff #28510)

Yeah, good catch. But it means that previous code was also wrong (this part was copy-pasted) - see D8458

Fixed invalid range handling. Used exclusive ranges.

LGTM, just fix this nit.

services/blob/src/service.rs
78 ↗(On Diff #28913)

nit metadta

This revision now requires changes to proceed.Jul 21 2023, 3:06 AM
This revision is now accepted and ready to land.Jul 21 2023, 3:21 AM