https://github.com/rsocket/rsocket-rb
https://github.com/rsocket/rsocket-rb
eventmachine ruby
Last synced: 11 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/rsocket/rsocket-rb
- Owner: rsocket
- License: apache-2.0
- Created: 2019-04-10T17:54:42.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2021-07-21T16:43:37.000Z (over 4 years ago)
- Last Synced: 2024-05-09T09:55:30.851Z (almost 2 years ago)
- Topics: eventmachine, ruby
- Language: Ruby
- Size: 64.5 KB
- Stars: 8
- Watchers: 5
- Forks: 5
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
rsocket-rb
===================
Ruby implementation of [RSocket](http://rsocket.io)
# Installation
Add this line to your application's Gemfile:
```ruby
gem 'rsocket-rb'
```
And then execute:
$ bundle
Or install it yourself as:
$ gem install rsocket-rb
# How to use?
* RSocket Server with Sinatra style
```ruby
require 'rsocket/server_bootstrap'
require 'rsocket/payload'
require 'rx'
set :schema, 'tcp'
set :port, 42252
# @param payload [RSocket::Payload]
#@return [Rx::Observable]
def request_response(payload)
puts "request/response called"
Rx::Observable.just(payload_of("data", "metadata"))
end
```
* RSocket Client
```ruby
require 'rubygems'
require 'eventmachine'
require 'rsocket/requester'
require 'rsocket/payload'
require 'rx'
EventMachine.run {
#rsocket = EventMachine.connect '127.0.0.1', 1235, AppRequester
rsocket = RSocket.connect("tcp://127.0.0.1:42252")
rsocket.request_response(payload_of("request", "response"))
.subscribe(Rx::Observer.configure do |observer|
observer.on_next { |payload| puts payload.data_utf8 }
observer.on_completed { puts "completed" }
observer.on_error { |error| puts error }
end)
}
```
# Todo
#### Transport
- [x] TCP
- [ ] Websocket: em-websocket
#### Duplex Socket
- [x] MetadataPush
- [x] RequestFNF
- [x] RequestResponse
- [x] RequestStream
- [x] RequestChannel
##### Others
- [x] Composite Metadata
- [ ] TCK Test
- [x] Timeout support
- [ ] Resume
- [x] Keepalive
- [ ] Fragmentation
- [ ] Cancel
- [x] Error
- [ ] Flow Control: RequestN
- [ ] Flow Control: Lease
- [x] Load Balance
# References
* RSocket Home: http://rsocket.io/
* EventMachine: fast, simple event-processing library for Ruby programs https://github.com/eventmachine/eventmachine
* RxRuby: https://github.com/ReactiveX/RxRuby