Skip to content

Conversation

@robertroeser
Copy link
Member

Optimize request channel to let you peak at the first item in the stream #569

…uestChannel

Signed-off-by: Robert Roeser <rroeserr@gmail.com>
@robertroeser robertroeser force-pushed the requestChannelImprovements branch from 43d44ee to 48acae8 Compare January 28, 2019 09:18
import reactor.core.publisher.Flux;

/**
* Extends the {@link RSocket} that allows an implementor to peek at the first request payload of a channel.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* Extends the {@link RSocket} that allows an implementor to peek at the first request payload of a channel.
* Extends the {@link RSocket} that allows an implementer to peek at the first request payload of a channel.

*/
public interface RequestHandler extends RSocket {
/**
* Implement this method to peak at the first payload of the incoming request stream
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe clarify that peak means that payloads still includes the peaked payload.

Signed-off-by: Robert Roeser <rroeserr@gmail.com>
private final DuplexConnection connection;
private final RSocket requestHandler;
private final RequestHandler optimizedRequestHandler;
private final boolean hasOptimizedRequestHandler;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need for an extra boolean property, just checking optimizedRequestHandler != null should be fine

if (requestHandler instanceof RequestHandler) {
this.optimizedRequestHandler = (RequestHandler) requestHandler;
this.hasOptimizedRequestHandler = true;
this.requestHandler = null;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would keep the requestHandler assigned anyway for consistency.

Signed-off-by: Robert Roeser <rroeserr@gmail.com>
@robertroeser robertroeser force-pushed the requestChannelImprovements branch from 4d69ee2 to 92a4d1d Compare January 30, 2019 00:00
Signed-off-by: Robert Roeser <rroeserr@gmail.com>
@robertroeser robertroeser force-pushed the requestChannelImprovements branch from 6eaef08 to f2a73a8 Compare January 31, 2019 01:32
@robertroeser robertroeser merged commit 21c39bd into 1.0.x Jan 31, 2019
robertroeser added a commit that referenced this pull request Feb 8, 2019
* optimize request channel to let you peak at the first item in the requestChannel

Signed-off-by: Robert Roeser <rroeserr@gmail.com>

* updated javadoc

Signed-off-by: Robert Roeser <rroeserr@gmail.com>

* updates

Signed-off-by: Robert Roeser <rroeserr@gmail.com>

* call requestChannelWith 2 arguments

Signed-off-by: Robert Roeser <rroeserr@gmail.com>
Signed-off-by: Robert Roeser <rroeserr@gmail.com>
robertroeser added a commit that referenced this pull request Feb 12, 2019
* Adds specific requestChannel(Payload, Publisher<Payload>)  (#572)

* optimize request channel to let you peak at the first item in the requestChannel

Signed-off-by: Robert Roeser <rroeserr@gmail.com>

* updated javadoc

Signed-off-by: Robert Roeser <rroeserr@gmail.com>

* updates

Signed-off-by: Robert Roeser <rroeserr@gmail.com>

* call requestChannelWith 2 arguments

Signed-off-by: Robert Roeser <rroeserr@gmail.com>
Signed-off-by: Robert Roeser <rroeserr@gmail.com>

* first pass at refactoring to idomatic ByteBuf flyweights

Signed-off-by: Robert Roeser <rroeserr@gmail.com>

* fixing tests

Signed-off-by: Robert Roeser <rroeserr@gmail.com>

* fixed some more tests

Signed-off-by: Robert Roeser <rroeserr@gmail.com>

* fix frame flyweights

Signed-off-by: Robert Roeser <rroeserr@gmail.com>

* testing

Signed-off-by: Robert Roeser <rroeserr@gmail.com>

* accept ByteBufAllocator in a constructors and renames FrameDecoder to PayloadDecoder

Signed-off-by: Robert Roeser <rroeserr@gmail.com>

* javadoc

Signed-off-by: Robert Roeser <rroeserr@gmail.com>

* first pass at refactoring to idomatic ByteBuf flyweights

Signed-off-by: Robert Roeser <rroeserr@gmail.com>

* fixing tests

Signed-off-by: Robert Roeser <rroeserr@gmail.com>

* fixed some more tests

Signed-off-by: Robert Roeser <rroeserr@gmail.com>

* testing

Signed-off-by: Robert Roeser <rroeserr@gmail.com>

* fix frame flyweights

Signed-off-by: Robert Roeser <rroeserr@gmail.com>

* accept ByteBufAllocator in a constructors and renames FrameDecoder to PayloadDecoder

Signed-off-by: Robert Roeser <rroeserr@gmail.com>

* javadoc

Signed-off-by: Robert Roeser <rroeserr@gmail.com>

* setup frame flyweight: allow null metadata

restore micrometer RSocket test

Signed-off-by: Maksym Ostroverkhov <m.ostroverkhov@gmail.com>

* apply fixes from review

release ByteBufs in tests

Signed-off-by: Maksym Ostroverkhov <m.ostroverkhov@gmail.com>
@nebhale nebhale deleted the requestChannelImprovements branch February 20, 2019 18:18
@rstoyanchev
Copy link
Contributor

rstoyanchev commented Feb 25, 2019

Not sure if this is expected or not but I tried using the ResponderRSocket interface and ran into UnsupportedOperationException because of an RSocketProxy interceptor that is only aware of the RSocket interface. In my case it was an easy fix but I can imagine a case where the interceptor is not mine to change, plus it means my ResponderRSocket is fragile and could break.

Perhaps there needs to be an ResponderRSocketProxy and that should be expected for a receiving side interceptor?

mostroverkhov pushed a commit to mostroverkhov/rsocket-java that referenced this pull request Feb 27, 2019
* Adds specific requestChannel(Payload, Publisher<Payload>)  (rsocket#572)

* optimize request channel to let you peak at the first item in the requestChannel

Signed-off-by: Robert Roeser <rroeserr@gmail.com>

* updated javadoc

Signed-off-by: Robert Roeser <rroeserr@gmail.com>

* updates

Signed-off-by: Robert Roeser <rroeserr@gmail.com>

* call requestChannelWith 2 arguments

Signed-off-by: Robert Roeser <rroeserr@gmail.com>
Signed-off-by: Robert Roeser <rroeserr@gmail.com>

* first pass at refactoring to idomatic ByteBuf flyweights

Signed-off-by: Robert Roeser <rroeserr@gmail.com>

* fixing tests

Signed-off-by: Robert Roeser <rroeserr@gmail.com>

* fixed some more tests

Signed-off-by: Robert Roeser <rroeserr@gmail.com>

* fix frame flyweights

Signed-off-by: Robert Roeser <rroeserr@gmail.com>

* testing

Signed-off-by: Robert Roeser <rroeserr@gmail.com>

* accept ByteBufAllocator in a constructors and renames FrameDecoder to PayloadDecoder

Signed-off-by: Robert Roeser <rroeserr@gmail.com>

* javadoc

Signed-off-by: Robert Roeser <rroeserr@gmail.com>

* first pass at refactoring to idomatic ByteBuf flyweights

Signed-off-by: Robert Roeser <rroeserr@gmail.com>

* fixing tests

Signed-off-by: Robert Roeser <rroeserr@gmail.com>

* fixed some more tests

Signed-off-by: Robert Roeser <rroeserr@gmail.com>

* testing

Signed-off-by: Robert Roeser <rroeserr@gmail.com>

* fix frame flyweights

Signed-off-by: Robert Roeser <rroeserr@gmail.com>

* accept ByteBufAllocator in a constructors and renames FrameDecoder to PayloadDecoder

Signed-off-by: Robert Roeser <rroeserr@gmail.com>

* javadoc

Signed-off-by: Robert Roeser <rroeserr@gmail.com>

* setup frame flyweight: allow null metadata

restore micrometer RSocket test

Signed-off-by: Maksym Ostroverkhov <m.ostroverkhov@gmail.com>

* apply fixes from review

release ByteBufs in tests

Signed-off-by: Maksym Ostroverkhov <m.ostroverkhov@gmail.com>
Signed-off-by: Maksym Ostroverkhov <m.ostroverkhov@gmail.com>
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.

6 participants