Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Treatment parts

http/upload::parts


Parameters

↳ var retries: u32 = 5

Inputs

⇥ parts: Stream<Vec<byte>>
⇥ requests: Stream<PreparedRequest> (http/client::PreparedRequest)
⇥ tag_header: Block<string>

Outputs

↦ completed: Block<void>
↦ error: Block<string>
↦ failed: Block<void>
↦ finished: Block<void>
↦ tags: Stream<string>


Upload parts, each to its prepared request.

Each part received through parts, such as cut gives, is sent with the request received through requests in the same position, such as one presigned for that part number, with its length. The value of the header named tag_header in each answer, such as etag for object storage, is given through tags, in the order of the parts, to complete the upload.

A part refused with 5xx, 429 or 408, or whose connection fails, is sent again up to retries times, waiting longer each time: it is kept until it is uploaded. Memory holds that part, and those given but not taken yet.

Once parts ends and every part is uploaded, completed is emitted. If a part is refused otherwise, retries are exhausted, an answer has no tag_header, or a part has no request, failed is emitted and error contains the reason, with the status and the <Code> of XML error bodies, never the URL. finished is emitted in every case.

Requests are made as given, without the headers of any HttpClient.

graph LR
     T("parts()")
     P["… [🟦 🟦] [🟦 🟦 🟦]"] -->|parts| T
     R["… 🟨 🟨"] -->|requests| T
     H["〈etag〉"] -->|tag_header| T

     T -->|tags| O["… 🟪 🟪"]
     T -->|completed| C["〈🟩〉"]

     style P fill:#ffffff,stroke:#ffffff
     style R fill:#ffffff,stroke:#ffffff
     style H fill:#ffffff,stroke:#ffffff
     style O fill:#ffffff,stroke:#ffffff
     style C fill:#ffffff,stroke:#ffffff