Skip to content

Support Next/Complete payloads#148

Open
echistyakov wants to merge 1 commit intorsocket:masterfrom
echistyakov:support-next-complete-payloads
Open

Support Next/Complete payloads#148
echistyakov wants to merge 1 commit intorsocket:masterfrom
echistyakov:support-next-complete-payloads

Conversation

@echistyakov
Copy link
Contributor

Support sending a payload with both Next and Complete flags.

Motivation:

Currently - it's impossible to send a payload with both Next and Complete flags when using RequestChannel subscriber.
OnNext callback sends the payload with Next flag, and OnComplete payload sends an empty payload with a Complete flag.
But that's two separate payloads, not one.

Setting both Next and Complete flags on the final payload is totally valid (as per RSocket spec).

And some implementations (such as Thrift RSocket in C++) in fact require the ability to set both Next and Complete flags on a payload for certain use cases:
https://github.com/facebook/fbthrift/blob/8679ad11edc2a79afa602a55ac4839c524ca36e0/thrift/lib/cpp2/transport/rocket/client/RocketClient.cpp#L699-L700

Modifications:

Add a FinalPayload wrapper and some simple logic to allow the user to send a payload with both Next and Complete flags.
The behavior is equivalent to calling OnNext and OnComplete, but only one payload is sent.

Result:

The modification allows for interoperability of rsocket-go with other rsocket implementations and removed the limitation on Next/Complete flags being set on a payload.

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

Successfully merging this pull request may close these issues.

1 participant