whatwg / streams

Streams Standard
https://streams.spec.whatwg.org/
Other
1.35k stars 160 forks source link

Define valid queuing strategy #427

Open domenic opened 8 years ago

domenic commented 8 years ago

As an author- and other-spec-facing requirement, we should define valid queuing strategies. I think the requirements are:

neovov commented 7 years ago

A related question: Why does a queuing strategy get an object as argument and not simply a value (new CountQueingStrategy({ highWaterMark: 42 }) against new CountQueingStrategy(42))?

Also, I think the constructor should raise a TypeError if given a bad highWaterMark value.

I think highWaterMark should be updatable since it might be useful for an AdaptiveQueuingStrategy.

domenic commented 7 years ago

Can highWaterMark be 0? (what could be the use cases?)

Yes. For example, for a writable stream, this would apply backpressure whenever there is a write pending.

Can highWaterMark be a float?

Sure.

A related question: Why does a queuing strategy get an object as argument and not simply a value

This allows better future extensibility and explicitness in the code. It's a bit of a judgment call, but that's where we ended up.

Also, I think the constructor should raise a TypeError if given a bad highWaterMark value.

I think it's OK since it's validated at stream construction time. It's nice that the queueing strategy classes are just dumb value holders, IMO. It's their consumers who have notions of how they should act.

I think highWaterMark should be updatable since it might be useful for an AdaptiveQueuingStrategy.

This is actually impossible now due to how we copy the properties in the constructor :-/.

ricea commented 7 years ago
tyoshino commented 7 years ago

Regarding highWaterMark, I think we could instead explore making [[strategyHWM]] adjustable.