Skip to content

Add RSocketInboundGateway; refactoring #2923

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

Merged
merged 5 commits into from
May 10, 2019

Conversation

artembilan
Copy link
Member

  • Extract an AbstractRSocketConnector for common client and server connectors logic
  • Introduce an IntegrationRSocketAcceptor and IntegrationRSocket for the
    mapping and handling logic of RSockets and messages in between
  • Introduce an IntegrationRSocketEndpoint marker interface for Inbound Gateway mappings
  • Add RSocketInboundGateway implementation, which is called from the
    IntegrationRSocketAcceptor by the IntegrationRSocketEndpoint mapping
  • Add RSocketConnectedEvent to emit when the client is connected to the server.
    It does not make sense in Spring Integration to delegate such a logic into the
    RSocketInboundGateway

@artembilan artembilan changed the title Add RSocketInboundGateway; refactoring [DO NOT MERGE YET] Add RSocketInboundGateway; refactoring May 8, 2019
@artembilan
Copy link
Member Author

This is not fully ready yet.

At least tests are needed to cover an introduced functionality.

The server inbound side and docs might be deferred into a separate PR...

Right now I just want to share what I have so far to gather any possible feedback.

Thanks

Copy link
Contributor

@garyrussell garyrussell left a comment

Choose a reason for hiding this comment

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

A few comments from first review pass.

int refCount = refCount(dataBuffer);
return Mono
.defer(() -> {
this.applicationEventPublisher.publishEvent(
Copy link
Contributor

Choose a reason for hiding this comment

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

null check or no-op implementation needed.

Copy link
Contributor

Choose a reason for hiding this comment

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

See comment at caller.

@Override
public Mono<RSocket> accept(ConnectionSetupPayload setupPayload, RSocket sendingRSocket) {
IntegrationRSocket rsocket = createRSocket(sendingRSocket);
rsocket.setApplicationEventPublisher(this.applicationEventPublisher);
Copy link
Contributor

Choose a reason for hiding this comment

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

null check or no-op default implementation.

@artembilan artembilan force-pushed the RSocketInboundGateway branch from 3001d03 to ecee757 Compare May 9, 2019 22:58
@artembilan artembilan requested a review from garyrussell May 9, 2019 22:58
@artembilan
Copy link
Member Author

Pushed some further implements and implementation.
See commit comment for details.

Thanks

@artembilan artembilan changed the title [DO NOT MERGE YET] Add RSocketInboundGateway; refactoring Add RSocketInboundGateway; refactoring May 9, 2019
Copy link
Contributor

@garyrussell garyrussell left a comment

Choose a reason for hiding this comment

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

Just one issue from this pass.

public String toString() {
return "RSocketConnectedEvent{" +
"destination='" + this.destination + '\'' +
", data=" + Arrays.toString(this.data.asByteBuffer().array()) +
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think rendering a byte[] as a bunch of ints is useful, maybe omit this (or just include the length, perhaps).

@artembilan
Copy link
Member Author

OK. Now I think it is very close for merging.

Pay attention, please, how @Transformer looks in the RSocketInboundGatewayIntegrationTests.CommonConfig. It is nice to have it without subscription - everything is done by the RSocket protocol.

@@ -67,7 +65,7 @@ public RSocketRequester getRequester() {
public String toString() {
return "RSocketConnectedEvent{" +
"destination='" + this.destination + '\'' +
", data=" + Arrays.toString(this.data.asByteBuffer().array()) +
", data length=" + this.data.asByteBuffer().array().length +
Copy link
Contributor

Choose a reason for hiding this comment

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

This still seems to be a lot of overhead in a toString().

Why do we need this DataBuffer in the event?

* Extract an `AbstractRSocketConnector` for common client and server connectors logic
* Introduce an `IntegrationRSocketAcceptor` and `IntegrationRSocket` for the
mapping and handling logic of RSockets and messages in between
* Introduce an `IntegrationRSocketEndpoint` marker interface for Inbound Gateway mappings
* Add `RSocketInboundGateway` implementation, which is called from the
`IntegrationRSocketAcceptor` by the `IntegrationRSocketEndpoint` mapping
* Add `RSocketConnectedEvent` to emit when the client is connected to the server.
It does not make sense in Spring Integration to delegate such a logic into the
`RSocketInboundGateway`
container for connected `RSocketRequester`s from clients
* Extract `accept(ConnectionSetupPayload setupPayload, RSocket sendingRSocket)`
server logic into an internal `ServerRSocketAcceptor` extension for the
`IntegrationRSocketAcceptor`
* Address PR comments:
 - `RSocketConnectedEvent.toString()`
 - `ApplicationEventPublisherAware` into the `ServerRSocketConnector`
 - Log RSocket connection if no `this.applicationEventPublisher`
* Remove `handleConnectionSetupPayload()` from the `IntegrationRSocket`
since it is not delegated to the target handler
* Provide reasonable default `RSocketStrategies` for the
`AbstractRSocketConnector` and `RSocketInboundGateway`
* Add initial `RSocketInboundGatewayIntegrationTests`
* Always `payload.retain()` when we convert `Payload` to `DataBuffer`
* Fix `IntegrationRSocketAcceptor.detectEndpoints()` stream logic
to really iterate over all the `IntegrationRSocketEndpoint` beans
* Fix test to use an explicit `ClientConfig` class for the
`@SpringJUnitConfig`: looks like JUnit 5 is OK to scan for `package
protected` classes as well
* Add request/reply tests into the `RSocketInboundGatewayIntegrationTests`
for both server and client sides
@artembilan artembilan force-pushed the RSocketInboundGateway branch from 149f43d to 18e1d59 Compare May 10, 2019 17:42
@garyrussell garyrussell merged commit 36e7041 into spring-projects:master May 10, 2019
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.

2 participants