-
Type:
Improvement
-
Resolution: Fixed
-
Priority:
Minor - P4
-
Affects Version/s: None
-
Component/s: None
Use Case
As a developer
I want a correct Writable stream imlpementation for GridFSBucketWriteStream
So that the stream adheres to Node.js standards.
User Impact
Corrects the writable stream implementation
Dependencies
- None
Unknowns
- Effect on TypeScript types
Acceptance Criteria
- Remove override of the write method in favour of _write
- Use destroy instead of manually emitting the end events.
Implementation Requirements
- See the streams spike doc for additional context
Node.js streams are meant to be implemented via the _ (underscore) prefixed methods, the non-prefixed methods provide a consistent API regardless of underlying stream (generally allowing any stream to be chained to another).
We currently have an implementation of write and end, as well as manual emits for FINISH, CLOSE, and DRAIN events. Remove all emits
We should change our write to _write, our end to _final, and remove emitting finish, error, and close events.
The helpers for write (doWrite) and end (writeRemnant) will always be given a callback now, that must always be invoked, changing callback optionality and carefully following the helpers early return cases will correct that.
Our write/end methods ensured indexes were created prior to beginning their respective operations. We can use _construct to make sure indexes are made before _write/_final are entered.
We should not invoke callbacks synchronously. Consider refactoring to async/await
Remove boolean return values from all helpers. (except for isAborted)
The finish and drain event is supposed to not receive any arguments however we emit, the file document. We should store the fileDocument as a class property when upload is complete.
Testing Requirements
- Add unit tests for the stream implementation
Documentation Requirements
- Release notes
Follow Up Requirements
- None