-
Notifications
You must be signed in to change notification settings - Fork 30.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
stream: mutable highwatermark #33346
Closed
0807Jpatel
wants to merge
9
commits into
nodejs:master
from
0807Jpatel:feat/mutable-highwatermark-objectmode
Closed
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
cf72487
feat(stream): added mutable highwatermark and object mode
0807Jpatel 134c204
fix(readme): added REPLACEME in place of version
0807Jpatel 8ab362b
fix: remove debug statements from writable stream
0807Jpatel 5ca4f8c
chore: removed mutable objectMode and highWaterMark uses setter
0807Jpatel ef07cf6
chore: removed useless function declaration and bigFile.txt
0807Jpatel e0e232f
chore: updated doc to merge getter and setter
0807Jpatel 04c4145
chore: highwatermark getter throws error in _read and _write
0807Jpatel cf28052
fix: removed unused highwatermark flags from writable stream
0807Jpatel 0b7b1ea
chore: updated debug statement
0807Jpatel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -540,13 +540,13 @@ Is set to `true` immediately before the [`'finish'`][] event is emitted. | |
|
||
##### `writable.writableHighWaterMark` | ||
<!-- YAML | ||
added: v9.3.0 | ||
added: REPLACEME | ||
--> | ||
|
||
* {number} | ||
|
||
Return the value of `highWaterMark` passed when constructing this | ||
`Writable`. | ||
Get or set the value of `highWaterMark` for a given `Writable` stream. Should | ||
not update `writableHighWaterMark` from [`stream.write`][stream-write] | ||
|
||
##### `writable.writableLength` | ||
<!-- YAML | ||
|
@@ -1183,13 +1183,13 @@ in the [Stream Three States][] section. | |
|
||
##### `readable.readableHighWaterMark` | ||
<!-- YAML | ||
added: v9.3.0 | ||
added: REPLACEME | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ditto here |
||
--> | ||
|
||
* {number} | ||
|
||
Returns the value of `highWaterMark` passed when constructing this | ||
`Readable`. | ||
Get or set the value of `highWaterMark` for a given `Readable` stream. Should | ||
not update `readableHighWaterMark` from [`stream.read()`][stream-read]. | ||
|
||
##### `readable.readableLength` | ||
<!-- YAML | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
'use strict'; | ||
|
||
const common = require('../common'); | ||
const assert = require('assert'); | ||
const stream = require('stream'); | ||
|
||
const rs = new stream.Readable({ | ||
read: function() { | ||
this.readableHighWaterMark = 200; | ||
this.push(null); | ||
} | ||
}); | ||
|
||
const ws = stream.Writable({ write() {} }); | ||
|
||
rs.on('error', common.mustCall((err) => { | ||
assert.strictEqual(err.code, 'ERR_STREAM_UPDATING_HIGHWATERMARK_IN_READ'); | ||
assert.strictEqual(err.message, 'Cannot update highwatermark while reading'); | ||
})); | ||
rs.on('end', common.mustNotCall()); | ||
|
||
rs.pipe(ws); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
'use strict'; | ||
|
||
const common = require('../common'); | ||
const assert = require('assert'); | ||
const stream = require('stream'); | ||
|
||
const currHighWaterMark = 20; | ||
let pushes = 0; | ||
const rs = new stream.Readable({ | ||
read: common.mustCall(function() { | ||
(pushes++ < 100) ? this.push(Buffer.alloc(1024)) : this.push(null); | ||
}, 101) | ||
}); | ||
|
||
const ws = stream.Writable({ | ||
write: common.mustCall(function(data, enc, cb) { | ||
setImmediate(cb); | ||
}, 100) | ||
}); | ||
|
||
assert.strictEqual(rs.readableHighWaterMark, 16384); // default HWM | ||
rs.readableHighWaterMark = currHighWaterMark; | ||
assert.strictEqual(rs.readableHighWaterMark, currHighWaterMark); | ||
|
||
rs.pipe(ws); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
'use strict'; | ||
|
||
const common = require('../common'); | ||
const assert = require('assert'); | ||
const stream = require('stream'); | ||
|
||
const rs = new stream.Readable({ | ||
read: function() { | ||
this.push(Buffer.alloc(1024)); | ||
this.push(null); | ||
} | ||
}); | ||
|
||
const ws = stream.Writable({ write() { | ||
this.writableHighWaterMark = 20; | ||
} }); | ||
|
||
ws.on('error', common.mustCall((err) => { | ||
assert.strictEqual(err.code, 'ERR_STREAM_UPDATING_HIGHWATERMARK_IN_WRITE'); | ||
assert.strictEqual(err.message, 'Cannot update highwatermark while writing'); | ||
})); | ||
ws.on('end', common.mustNotCall()); | ||
|
||
rs.pipe(ws); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
'use strict'; | ||
|
||
const common = require('../common'); | ||
const assert = require('assert'); | ||
const stream = require('stream'); | ||
|
||
let pushes = 0; | ||
const rs = new stream.Readable({ | ||
read: common.mustCall(function() { | ||
pushes++ < 100 ? this.push(Buffer.alloc(1024)) : this.push(null); | ||
}, 101) | ||
}); | ||
|
||
const currHighWaterMark = 0; | ||
const ws = stream.Writable({ | ||
write: common.mustCall(function(_data, _enc, cb) { | ||
setImmediate(cb); | ||
}, 100) | ||
}); | ||
|
||
assert.strictEqual(ws.writableHighWaterMark, 16384); // default HWM | ||
ws.writableHighWaterMark = currHighWaterMark; | ||
assert.strictEqual(ws.writableHighWaterMark, currHighWaterMark); | ||
|
||
rs.pipe(ws); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This shouldn't be changed, instead add an additional metadata entry that mentions the setter ability.