spring-framework icon indicating copy to clipboard operation
spring-framework copied to clipboard

RSocket Functional route & Kotlin DSL

Open linux-china opened this issue 6 years ago • 2 comments

Now functional route is useful feature for Spring WebFlux and SpringMVC, and it's possible to add this feature for RSocket? Functional route is very convenient with functional style, especially for Kotlin, and all are functions and messages/events.

    @Bean
    public RouterFunction locateRoutes() {
        return RouterFunctions
                .route(RPC("findId"), payload -> Mono.just(DefaultPayload.create("hello")))
                .andRoute(FIRE("notifyLogin"), payload -> Mono.empty())
                .andRoute(STREAM("accounts"), payload -> Flux.empty());
    }

Two hard things: MessageMapping and payload data serialization. I like following style, and it's very useful sometimes.

    @MessageMapping("users.{user}.info")
    Mono<ChatUserInfo> getUserInfo(@DestinationVariable String user, Body body) {
        // ...
    }

linux-china avatar Jun 13 '19 16:06 linux-china