Skip to content

Commit

Permalink
Support asynchronous read-file function (aka read-from-stream) (#321)
Browse files Browse the repository at this point in the history
Support async function for readFileFn

Since implementing a good concurrency-handler may be painful we provide a promise-based read-locking one so that asyncReadFileFn is safe to use out-of-the-box.

Given that streams-read are often unable to correctly/exactly compute their final amount of bytes to upload, the number of chunks may also be off. We handle this in a safe way via FlowChunk.readBytes:
- if read using an async function
- and the last chunk read less bytes than usual (including 0)
- and the current chunk read no byte
- assume that this chunk is in fact superfluous and simulate its completion.

Previous discussion on:
* #42
* #318
(In the long-term Flow.js may have to support the concept of "approximate chunk number")
  • Loading branch information
drzraf authored Dec 31, 2020
1 parent 25709e7 commit f7e6d77
Show file tree
Hide file tree
Showing 6 changed files with 3,178 additions and 77 deletions.
Loading

0 comments on commit f7e6d77

Please sign in to comment.