-
Notifications
You must be signed in to change notification settings - Fork 38.5k
Support for registering handlers in RSocketRequester.Builder #23170
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
Comments
I'm working on this right now.
Annotated handlers cannot be typed (they're like MVC controllers). In #23135 we're discussing the possibility to introduce a functional variant for RSocket handlers. In this case they would have a proper type, and we would probably need to configure them on the builder as well. Is there a way to design annotated handlers being configured on the requester, without clashing with potential future plans for the functional variant? |
The method could be called |
This commit introduced a package tangle by referencing We should reconsider the way to solve this issue, as this circular dependency when/if we try to introduce the function handlers variants here. Functional handlers will be typed so it will be even more obvious. |
One idea would be to create a ClientResponderBuilder responderBuilder =
RSocketMessageHandler.clientResponderBuilder(new ClientHandler())
.routeMatcher(routeMatcher)
.build();
RSocketRequester.builder()
.responder(responderBuilder)
.rsocketStrategies(rsocketStrategies)
.connectTcp("localhost", server.address().getPort()) This is slightly less convenient but more flexible and also breaks the package cycle if |
Prior to this commit, the `RSocketRequester.Builder` would allow to configure directly annotated handlers for processing server requests. This lead to a package tangle where the `o.s.messaging.rsocket` would use classes from `o.s.messaging.rsocket.annotation.support` package. This commit introduces the `ClientResponder` interface for configuring a responder on the client requester. This is compatible with future changes with a parallel implementation of a functional variant for RSocket handlers. Closes spring-projectsgh-23170
@rstoyanchev I've got a slightly different proposal for this: bclozel@f6b879d The |
It's true RSocket doesn't provide an interface for a "client acceptor" which is actually a misnomer since on the client side it's merely a callback before the connection is even established. I'm going to rename the Next to that the proposed Back to the original idea, I think the main goal is to allow creating an So perhaps a |
I gave another attempt at this and I'm still not convinced for the following reasons:
|
The new interface supersedes ClientResponderFactory and is more general, for any RSocketFactory customization. DefaultClientResponderFactory implements the new interface and is renamed to AnnotationClientResponderConfigurer. See gh-23170
Currently client-side handling involves registering an acceptor, for example like so, which is likely an RSocketMessageHandler bean with manually registered handlers.
Arguably in this case there isn't much reason for applications to be aware of the
RSocketMessageHandler
nor to have it as a bean, so we should offer an option to register such client-side handlers directly withRSocketRequester.Builder
, which would internally create theRSocketMessageHandler
and configure it as an acceptor in theRSocketFactory
.In the Javadoc we should make it clear that registering handlers is a shortcut for creating an
RSocketMessageHandler
and configuring it as an acceptor. That latter still remains an option for more advanced cases and that should be made clear.The text was updated successfully, but these errors were encountered: