https://github.com/linux-china/rsocket-deno-service
RSocket Deno integration
https://github.com/linux-china/rsocket-deno-service
deno rsocket
Last synced: 9 months ago
JSON representation
RSocket Deno integration
- Host: GitHub
- URL: https://github.com/linux-china/rsocket-deno-service
- Owner: linux-china
- Created: 2020-06-10T20:09:10.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2020-06-10T20:13:30.000Z (about 6 years ago)
- Last Synced: 2025-05-14T07:17:07.439Z (about 1 year ago)
- Topics: deno, rsocket
- Language: Java
- Size: 8.79 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Spring Boot RSocket Service for Deno
====================================
# Example usage
* RSocket settings for application.properties :
```properties
spring.rsocket.server.mapping-path=/rsocket
spring.rsocket.server.transport=websocket
```
* RSocket service controller:
```java
@Controller
@MessageMapping("UserService")
public class UserServiceController {
@MessageMapping("findById")
public Mono findById(Integer id) {
return Mono.just(new User(1, "linux_china"));
}
}
```
* Deno client
```typescript
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;
findAllUsers(type: number): Publisher
}
const rsocket = await RSocketConnector.create().connect("ws://127.0.0.1:8080/rsocket");
const userService = buildServiceStub(rsocket, "UserService")
let user = await userService.findById(1);
```
* Deno test
```
$ deno test --allow-net deno_client.ts
```
# References
* Deno RSocket: https://deno.land/x/rsocket
* Deno: https://deno.land/
* Spring RSocket: https://docs.spring.io/spring/docs/5.2.7.RELEASE/spring-framework-reference/web-reactive.html#rsocket