Skip to content
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

Disable highwater/lowwater feature #19

Open
timmolendijk opened this issue Jun 1, 2021 · 3 comments
Open

Disable highwater/lowwater feature #19

timmolendijk opened this issue Jun 1, 2021 · 3 comments

Comments

@timmolendijk
Copy link

timmolendijk commented Jun 1, 2021

I'm trying to use the library without setting any restrictions on buffer size (because if I set restrictions I will have to deal with buffers elsewhere in my code).

I've tried to read the source code (since the docs don't really mention this scenario) and it has left me with a few questions:

  • By default a high water mark of 100 items is set, but does this have any real consequences other than a console warning? I noticed that an isPaused flag is set, but then nothing is truly paused as new events will still be pushed to queue(?)

  • What is the recommended approach for disabling the back pressure (including console warning) altogether? I've tried setting highWaterMark to undefined but this won't override the default parameter value of 100. I figure I could implement highWater with an empty function, but that feels a bit hacky.

Thanks for your work on this project and I hope you will find some time help me out a little bit. Cheers!

@timmolendijk
Copy link
Author

timmolendijk commented Jun 1, 2021

Looked into this once more and I am drawing the following preliminary conclusions:

  • highWaterMark and lowWaterMark settings do not impact behavior other than that they determine when the highWater and lowWater callbacks will be called, plus a console warning.
  • isPause flag merely exists to prevent repeat calls to those callbacks (plus the console warning).
  • Not using this feature and disabling the console warning can be done by either defining an noop highWater callback or setting highWaterMark to Infinity.

Do these make any sense?

@rolftimmermans
Copy link
Owner

I think you're right. In order to deal with high water marks the stream needs to be paused, otherwise the event queue will still fill, potentially until your system memory is exhausted. The documentation section about backpressure should give some context, but of course improvements or further clarifications are welcome: https://github.com/rolftimmermans/event-iterator#backpressure

I do believe it should be possible to disable the warning by setting highWaterMark to undefined? If that does not work I'd consider it a bug. Infinity should work too.

@timmolendijk
Copy link
Author

I do believe it should be possible to disable the warning by setting highWaterMark to undefined? If that does not work I'd consider it a bug. Infinity should work too.

It is a consequence of how JavaScript works:

function getKwargValue({ kwarg = 'value' } = {}) {
  return kwarg;
}

getKwargValue() // => 'value'
getKwargValue({ kwarg: undefined }) // => 'value'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants