{"id":18559009,"url":"https://github.com/linux-china/rsocket-deno","last_synced_at":"2025-09-07T01:03:52.475Z","repository":{"id":46141268,"uuid":"267200868","full_name":"linux-china/rsocket-deno","owner":"linux-china","description":"🦕RSocket Deno module","archived":false,"fork":false,"pushed_at":"2021-07-04T08:06:45.000Z","size":178,"stargazers_count":11,"open_issues_count":1,"forks_count":4,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-02T02:51:15.691Z","etag":null,"topics":["deno","rsocket"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/linux-china.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-05-27T02:25:30.000Z","updated_at":"2023-06-09T05:21:58.000Z","dependencies_parsed_at":"2022-08-29T21:32:51.922Z","dependency_job_id":null,"html_url":"https://github.com/linux-china/rsocket-deno","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/linux-china%2Frsocket-deno","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/linux-china%2Frsocket-deno/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/linux-china%2Frsocket-deno/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/linux-china%2Frsocket-deno/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/linux-china","download_url":"https://codeload.github.com/linux-china/rsocket-deno/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248140799,"owners_count":21054353,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["deno","rsocket"],"created_at":"2024-11-06T21:41:50.336Z","updated_at":"2025-04-10T01:33:07.292Z","avatar_url":"https://github.com/linux-china.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"RSocket Deno module\n===================\n\n🦕Deno library to create/consume async RSocket services.\n\n# What is RSocket?\n\nRSocket is a binary protocol for use on byte stream transports such as TCP and WebSocket.\nIt enables the following symmetric interaction models via async message passing over a single connection:\n\n* request/response (stream of 1)\n* request/stream (finite stream of many)\n* fire-and-forget (no response)\n* channel (bi-directional streams)\n\nYes, RSocket is designed for async/reactive communication between services.\n\n# How to use?\n\nNow RSocket Deno is under active development, please execute following command to make sure all code are updated to last version.\n\n```\ndeno run --reload https://deno.land/x/rsocket/mod.ts\n```\n\n### Start RSocket Server with Deno\n\n```\n$ deno run --allow-net https://deno.land/x/rsocket/rsocket_server.ts\n```\n\nand RSocket server side code as following:\n\n```typescript\nimport {\n    RSocketServer,\n    forRequestResponse,\n    Payload\n} from \"https://deno.land/x/rsocket/mod.ts\"\n\nawait RSocketServer.create(forRequestResponse(\n    async (payload: Payload): Promise\u003cPayload\u003e =\u003e {\n        console.log(`Received: ${payload.getDataUtf8()} `)\n        return Payload.fromText(\"Hello, this is Deno Server!\", \"\");\n    })\n).bind(\"tcp://0.0.0.0:42252\");\n\nconsole.log(\"RSocket Server started on 0.0.0.0:42252\")\n\n```\n\n### Start RSocket requester to test async RPC call\n\n```\n$ deno run --allow-net https://deno.land/x/rsocket/rsocket_client.ts\n```\n\nand RSocket client side code as following:\n\n```typescript\nimport {\n    RSocketConnector,\n    Payload\n} from \"https://deno.land/x/rsocket/mod.ts\"\n\nconst rsocket = await RSocketConnector.create().connect(\"tcp://127.0.0.1:42252\");\n\nconst result = await rsocket.requestResponse(Payload.fromText(\"Hello, I'm requester!\", \"\"));\nconsole.log(result.getDataUtf8());\n```\n\n\n# Service router and stub\n\n#### Service route for RSocket server side\n\n```typescript\nimport {\n    RSocketServer,\n    RSocket,\n    ConnectionSetupPayload,\n    RSocketRouteHandler\n} from \"https://deno.land/x/rsocket/mod.ts\"\n\n//RSocket Service\nclass UserService {\n\n    async findNickById(id: number): Promise\u003cstring\u003e {\n        return \"DenoServer\";\n    }\n}\n\nconst server = await RSocketServer.create({\n    accept(setup: ConnectionSetupPayload, sendingSocket: RSocket) {\n        return RSocketRouteHandler.fromHandler(\"com.example.UserService\", new UserService());\n    }\n}).bind(\"tcp://127.0.0.1:42252\");\n```\n\n### Service stub for requester side\n\n```typescript\nimport {RSocketConnector, buildServiceStub} from \"https://deno.land/x/rsocket/mod.ts\"\n\nconst rsocket = await RSocketConnector.create().connect(\"tcp://127.0.0.1:42252\");\n\ninterface UserService {\n    findNickById(id: number): Promise\u003cstring\u003e;\n}\n\nconst userService = buildServiceStub\u003cUserService\u003e(rsocket, \"com.example.UserService\")\n\nlet nick = await userService.findNickById(1);\nconsole.log(nick)\n\n```\n\n# WebSocket support\n\nJust use \"ws://127.0.0.0:42252\" format.\n\n# Interoperate with Spring Boot RSocket\n\n* Deno Spring Boot integration: https://github.com/linux-china/rsocket-deno-service\n* springRSocket_test.ts: https://deno.land/x/rsocket/tests/requester/springRSocket_test.ts\n\n# Reactive streams interoperation with RxJS\n\nReactive Streams supplies interoperation with RxJS, such as Publisher to Observable or Observable to Publisher.\n\n```typescript\n// @deno-types=\"https://deno.land/x/types/rxjs/v6.5.5/rxjs.d.ts\"\nimport {Observable, range, of} from \"https://cdn.pika.dev/rxjs@6.5.5\";\n// @deno-types=\"https://deno.land/x/types/rxjs/v6.5.5/operators.d.ts\"\nimport operators from 'https://dev.jspm.io/rxjs@6.5.5/operators';\nconst {map, filter} = operators;\n\nimport { publisherToObservable, observableToPublisher } from \"https://deno.land/x/rsocket/reactivestreams/rxjs.ts\"\n```\n\nor you can use https://deno.land/x/rxjs\n\n```typescript\nimport {Observable} from \"https://deno.land/x/rxjs/mod.ts\";\nimport {map, last} from \"https://deno.land/x/rxjs/src/operators/index.ts\";\n```\n\n# TODO\n\n#### RSocket\n\n- Operations\n  - [x] REQUEST_FNF\n  - [x] REQUEST_RESPONSE\n  - [x] REQUEST_STREAM\n  - [x] REQUEST_CHANNEL\n  - [x] METADATA_PUSH\n- More Operations\n  - [x] Error\n  - [ ] Cancel\n  - [x] Keepalive\n- QoS\n  - [ ] RequestN\n  - [ ] Lease\n- Transport\n  - [x] TCP\n  - [x] Websocket\n- High Level APIs\n  - [x] Client\n  - [x] Server\n- Misc\n  - [x] RxJS\n\n# References\n\n* RSocket: https://rsocket.io/\n* Deno: https://deno.land/\n* RSocket-JS: https://github.com/rsocket/rsocket-js\n* RxJS: https://github.com/ReactiveX/rxjs\n* rxjs-for-await: https://github.com/benlesh/rxjs-for-await\n* IxJS: Interactive Extensions for JavaScript https://github.com/ReactiveX/IxJS\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flinux-china%2Frsocket-deno","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flinux-china%2Frsocket-deno","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flinux-china%2Frsocket-deno/lists"}