Skip to content

linux-china/rsocket-deno-service

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Spring Boot RSocket Service for Deno

Example usage

  • RSocket settings for application.properties :
spring.rsocket.server.mapping-path=/rsocket
spring.rsocket.server.transport=websocket
  • RSocket service controller:
@Controller
@MessageMapping("UserService")
public class UserServiceController {

    @MessageMapping("findById")
    public Mono<User> findById(Integer id) {
        return Mono.just(new User(1, "linux_china"));
    }
}
  • Deno client
import {buildServiceStub, RSocketConnector} from "https://deno.land/x/rsocket/mod.ts"
import {Publisher, publisherToAsyncIterator} from "https://deno.land/x/rsocket/reactivestreams/mod.ts";

type User = {
    id: number,
    nick: string
}

interface UserService {
    findById(id: number): Promise<User>;

    findAllUsers(type: number): Publisher<User>
}

const rsocket = await RSocketConnector.create().connect("ws://127.0.0.1:8080/rsocket");

const userService = buildServiceStub<UserService>(rsocket, "UserService")

let user = await userService.findById(1);
  • Deno test
$ deno test --allow-net deno_client.ts

References

About

RSocket Deno integration

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published