Update specification with supporting of unbounded mode for request(n) #325
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.
Update specification with supporting of unbounded mode for request(n) to overcome absence of Magic Number from Reactive Streams specification
Motivation:
In Reactive Streams specification, and in Project Reactor (implementation of spec), there is possibility to make stream
unbounded
by using magic number (2^63-1 (java.lang.Long.MAX_VALUE)) when calling request(n) on subscription.But in RSocket there is no this magic number, as it uses 4 bytes instead of 8.
So
rsocket-java
, emulatesunbounded
mode by sending Int.MAX_VALUE instead or magic number if it appears.And also current implementation can go into an
unbounded
mode when during stream lifetime, SUM of all request(n) for stream is more than Int.MAX_VALUE. After stream becomesunbounded
, there will be no more REQUEST_N frames sent there.The problem is, that, if implementation don't do the same thing (because this behavior isn't specified in specification), those Int.MAX_VALUE credits can be exhausted in relatively small period of time in real use case: 12-15 hours, as found by @marcelja.
Modifications:
Adding
U
bit to REQUEST_N, REQUEST_STREAM and REQUEST_CHANNEL frames to enableunbounded
mode and make it possible to better interop with Reactive Streams specification.Result:
Implementation SHOULD handle such bit, and make it possible to request
unbounded
stream.F.e. in
rsocket-java
there should be mapping when usingrequest(n)
where n is of Long type (so magic number is available) to use unbounded mode if Long.MAX_VALUE appears.