Skip to content

Latest commit

 

History

History
98 lines (71 loc) · 1.8 KB

README.md

File metadata and controls

98 lines (71 loc) · 1.8 KB

rsocket-rb

Ruby implementation of RSocket

Installation

Add this line to your application's Gemfile:

gem 'rsocket-rb'

And then execute:

$ bundle

Or install it yourself as:

$ gem install rsocket-rb

How to use?

  • RSocket Server with Sinatra style
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
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

  • TCP
  • Websocket: em-websocket

Duplex Socket

  • MetadataPush
  • RequestFNF
  • RequestResponse
  • RequestStream
  • RequestChannel
Others
  • Composite Metadata
  • TCK Test
  • Timeout support
  • Resume
  • Keepalive
  • Fragmentation
  • Cancel
  • Error
  • Flow Control: RequestN
  • Flow Control: Lease
  • Load Balance

References