msgpack-rpc-over-http 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,9 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in msgpack-rpc-over-http.gemspec
4
+ gemspec
5
+
6
+ group :test do
7
+ gem 'test-unit', '~> 2.5.2'
8
+ gem 'thin'
9
+ end
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Narihiro Nakamura
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,97 @@
1
+ # MessagePack-RPC over HTTP (Ruby)
2
+
3
+ This library provides [MessagePack-RPC](https://github.com/msgpack/msgpack-rpc) via HTTP as XML-RPC.
4
+ The original MessagePack-RPC Server in Ruby is not good in some cases.
5
+ It doesn't scale. It's incompatible with Thread. There is no decent termination...
6
+
7
+ We alreadly have various high perfomance HTTP servers.
8
+ We can use these in MessagePack-RPC over HTTP.
9
+
10
+ **CAUTION**
11
+
12
+ There is no compatibility with other implementation of normal MessagePack-RPC (not over HTTP).
13
+ So you can not connect a normal RPC client to a RPC server over HTTP.
14
+
15
+ ## Usage
16
+
17
+ **Server**
18
+
19
+ confir.ru:
20
+ ```ruby
21
+ require 'msgpack-rpc-over-http'
22
+ class MyHandler
23
+ def add(x,y) return x+y end
24
+ end
25
+
26
+ run MessagePack::RPCOverHTTP::Server.app(MyHandler.new)
27
+ ```
28
+
29
+ rackup:
30
+ ```zsh
31
+ % rackup config.ru -s thin
32
+ >> Thin web server (v1.5.0 codename Knife)
33
+ >> Maximum connections set to 1024
34
+ >> Listening on 0.0.0.0:9292, CTRL+C to stop
35
+ ```
36
+
37
+ **Client**
38
+
39
+ client.rb:
40
+ ```ruby
41
+ require 'msgpack-rpc-over-http'
42
+ c = MessagePack::RPCOverHTTP::Client.new("http://0.0.0.0:9292/")
43
+ result = c.call(:add, 1, 2) #=> 3
44
+ ```
45
+
46
+ ## Extended futures
47
+
48
+ Support streaming response via Chunked Transfer-Encoding.
49
+
50
+ ```ruby
51
+ # server side
52
+ class Handler
53
+ include MessagePack::RPCOverHTTP::Server::Streamer
54
+ def log
55
+ return stream do
56
+ File.open('/var/log/syslog') do |f|
57
+ while line = f.gets.chomp
58
+ # write a chunked data
59
+ chunk(line)
60
+ end
61
+ end
62
+ end
63
+ end
64
+ end
65
+
66
+ # client
67
+ client = MessagePack::RPCOverHTTP::Client.new("http://0.0.0.0:80/")
68
+ client.stream do |line|
69
+ p line # => "Nov 3 ..."
70
+ end
71
+ ```
72
+
73
+ ## Installation
74
+
75
+ Add this line to your application's Gemfile:
76
+
77
+ gem 'msgpack-rpc-over-http'
78
+
79
+ And then execute:
80
+
81
+ $ bundle
82
+
83
+ Or install it yourself as:
84
+
85
+ $ gem install msgpack-rpc-over-http
86
+
87
+ ## Usage
88
+
89
+ TODO: Write usage instructions here
90
+
91
+ ## Contributing
92
+
93
+ 1. Fork it
94
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
95
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
96
+ 4. Push to the branch (`git push origin my-new-feature`)
97
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
@@ -0,0 +1,111 @@
1
+ require 'celluloid'
2
+ require 'httpclient'
3
+ require 'forwardable'
4
+
5
+ module MessagePack
6
+ module RPCOverHTTP
7
+
8
+ # Cliet for MessagePack-RPC over HTTP.
9
+ class Client
10
+ extend Forwardable
11
+
12
+ HEADER = {"Content-Type" => 'text/plain'}
13
+
14
+ def initialize(url, options={})
15
+ @url = url
16
+ @client = HTTPClient.new
17
+ @reqtable = {}
18
+ @seqid = 0
19
+ end
20
+
21
+ def_delegators(:@client,
22
+ :connect_timeout, :send_timeout, :receive_timeout)
23
+
24
+ # call-seq:
25
+ # call(symbol, *args) -> result of remote method
26
+ #
27
+ # Calls remote method.
28
+ # This method is same as call_async(method, *args).value
29
+ def call(method, *args)
30
+ return send_request(method, args)
31
+ end
32
+
33
+ # call-seq:
34
+ # call_async(symbol, *args) -> Celluloid::Future
35
+ #
36
+ # Calls remote method asynchronously.
37
+ # This method is non-blocking and returns Future.
38
+ def call_async(method, *args)
39
+ return Celluloid::Future.new{ send_request(method, args) }
40
+ end
41
+
42
+ # call-seq:
43
+ # callback(symbol, *args) {|res, err| } -> Celluloid::Future
44
+ #
45
+ # Calls remote method asynchronously.
46
+ # The callback method is called with Future when the result is reached.
47
+ # `err' is assigned a instance of RemoteError or child if res is nil.
48
+ def callback(method, *args, &block)
49
+ return Celluloid::Future.new do
50
+ begin
51
+ block.call(send_request(method, args))
52
+ rescue RemoteError => ex
53
+ block.call(nil, ex)
54
+ end
55
+ end
56
+ end
57
+
58
+ # call-seq:
59
+ # stream(symbol, *args) {|chunk| }
60
+ #
61
+ # Calls remote method with streaming.
62
+ # Remote method have to return a chunked response.
63
+ def stream(method, *args, &block)
64
+ data = create_request_body(method, args)
65
+ @client.post_content(@url, :body => data, :header => HEADER) do |chunk|
66
+ begin
67
+ block.call(get_result(chunk))
68
+ rescue RemoteError => ex
69
+ block.call(nil, ex)
70
+ end
71
+ end
72
+ end
73
+
74
+ # call-seq:
75
+ # stream_async(symbol, *args) {|chunk| } -> Celluloid::Future
76
+ #
77
+ # Calls remote method asynchronously with streaming.
78
+ def stream_async(method, *args, &block)
79
+ return Celluloid::Future.new do
80
+ stream(method, *args, &block)
81
+ end
82
+ end
83
+
84
+ private
85
+ def send_request(method, param)
86
+ data = create_request_body(method, param)
87
+ body = @client.post_content(@url, :body => data, :header => HEADER)
88
+ return get_result(body)
89
+ end
90
+
91
+ def create_request_body(method, param)
92
+ method = method.to_s
93
+ msgid = @seqid
94
+ @seqid += 1
95
+ @seqid = 0 if @seqid >= (1 << 31)
96
+ data = [REQUEST, msgid, method, param].to_msgpack
97
+ end
98
+
99
+ def get_result(body)
100
+ type, msgid, err, res = MessagePack.unpack(body)
101
+ raise "Unknown message type #{type}" if type != RESPONSE
102
+
103
+ if err.nil?
104
+ return res
105
+ else
106
+ raise RemoteError.create(err, res)
107
+ end
108
+ end
109
+ end
110
+ end
111
+ end
@@ -0,0 +1,44 @@
1
+ module MessagePack
2
+
3
+ ##
4
+ ## MessagePack-RPCOverHTTP Exception
5
+ ##
6
+ #
7
+ # RemoteError
8
+ # |
9
+ # +-- RuntimeError
10
+ # |
11
+ # +-- (user-defined errors)
12
+ #
13
+ module RPCOverHTTP
14
+ class RemoteError < StandardError
15
+ def initialize(code, *data)
16
+ @code = code.to_s
17
+ @data = data
18
+ super(@data.shift || @code)
19
+ end
20
+
21
+ attr_reader :code
22
+ attr_reader :data
23
+
24
+ def self.create(code, data)
25
+ error_class = constantize(code)
26
+ if error_class < RemoteError
27
+ error_class.new(code, *data)
28
+ else
29
+ self.new(code, *data)
30
+ end
31
+ end
32
+
33
+ private
34
+ def self.constantize(name)
35
+ return name.split("::").inject(Object) do |memo, i|
36
+ memo.const_get(i)
37
+ end
38
+ end
39
+ end
40
+
41
+ class RuntimeError < RemoteError
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,24 @@
1
+ module MessagePack
2
+ module RPCOverHTTP
3
+ class Server
4
+
5
+ # Dispatcher of user-defined handler.
6
+ class Dispatcher
7
+ def initialize(handler, accept=handler.public_methods)
8
+ @handler = handler
9
+ @accept = accept
10
+ end
11
+
12
+ def call(env)
13
+ method = env['msgpack-rpc.method']
14
+ params = env['msgpack-rpc.params']
15
+ unless @accept.include?(method)
16
+ raise NoMethodError, "method `#{method}' is not accepted"
17
+ end
18
+
19
+ return @handler.send(method, *params)
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,69 @@
1
+ module MessagePack
2
+ module RPCOverHTTP
3
+ class Server
4
+
5
+ # Rack Middleware that unpacks a serialized string in a HTTP
6
+ # request.
7
+ class RequestUnpacker
8
+ def initialize(app)
9
+ @app = app
10
+ end
11
+
12
+ def call(env)
13
+ req = Rack::Request.new(env)
14
+ if (error = check_request(req))
15
+ return error
16
+ end
17
+
18
+ unpack(env, req.body.read)
19
+ return @app.call(env)
20
+ end
21
+
22
+ private
23
+ def check_request(req)
24
+ if req.request_method != "POST"
25
+ return [
26
+ 405, # Method Not Allowed
27
+ {'Content-Type' => 'text/plain'},
28
+ ["Only POST is allowed"]
29
+ ]
30
+ end
31
+
32
+ if req.media_type != "text/plain"
33
+ return [
34
+ 400, # Bad Request
35
+ {'Content-Type' => 'text/plain'},
36
+ ["Only text/plain is allowed #{req.content_type}"]
37
+ ]
38
+ end
39
+
40
+ if req.content_length.to_i <= 0
41
+ return [
42
+ 411, # Length Required
43
+ {'Content-Type' => 'text/plain'},
44
+ ["Missing Content-Length"]
45
+ ]
46
+ end
47
+
48
+ return nil
49
+ end
50
+
51
+ def unpack(env, body)
52
+ msg = MessagePack.unpack(body)
53
+ env['msgpack-rpc.type'] = msg[0]
54
+ case msg[0]
55
+ when REQUEST
56
+ env['msgpack-rpc.msgid'] = msg[1]
57
+ env['msgpack-rpc.method'] = msg[2].to_sym
58
+ env['msgpack-rpc.params'] = msg[3]
59
+ when NOTIFY
60
+ env['msgpack-rpc.method'] = msg[1].to_sym
61
+ env['msgpack-rpc.params'] = msg[2]
62
+ else
63
+ raise "unknown message type #{msg[0]}"
64
+ end
65
+ end
66
+ end
67
+ end
68
+ end
69
+ end
@@ -0,0 +1,41 @@
1
+ module MessagePack
2
+ module RPCOverHTTP
3
+ class Server
4
+
5
+ # Rack Middleware that packs a result of a handler method and
6
+ # create a HTTP Responce.
7
+ class ResponsePacker
8
+ def initialize(dispatcher)
9
+ @dispatcher = dispatcher
10
+ end
11
+
12
+ def call(env)
13
+ res = Rack::Response.new
14
+ res["Content-type"] = "text/plain"
15
+ msgid = env['msgpack-rpc.msgid']
16
+
17
+ body = @dispatcher.call(env)
18
+ if body.is_a?(Streamer::Body)
19
+ body.msgid = msgid
20
+ res.body = body
21
+ return [res.status.to_i, res.header, body]
22
+ else
23
+ res.write self.class.pack(msgid, nil, body)
24
+ return res.finish
25
+ end
26
+ rescue RPCOverHTTP::RemoteError => ex
27
+ res.write self.class.pack(msgid, ex.class.name, ex.message)
28
+ return res.finish
29
+ rescue ::RuntimeError => ex
30
+ res.write(self.class.pack(
31
+ msgid, RPCOverHTTP::RuntimeError.name, ex.message))
32
+ return res.finish
33
+ end
34
+
35
+ def self.pack(msgid, error, result)
36
+ return MessagePack.pack([RESPONSE, msgid, error, result])
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,67 @@
1
+ require 'fiber'
2
+
3
+ module MessagePack
4
+ module RPCOverHTTP
5
+ class Server
6
+
7
+ # Support streaming
8
+ module Streamer
9
+ class Body
10
+ attr_accessor :msgid
11
+
12
+ def initialize(&proc)
13
+ @proc = proc
14
+ end
15
+
16
+ def each(&block)
17
+ @proc.call(msgid, block)
18
+ return self
19
+ end
20
+ end
21
+
22
+ # call-seq:
23
+ # stream(&writer) -> streamable body
24
+ #
25
+ # Returns a Body object that responds to each.
26
+ # Chunks of body are created with calling chunk() in given block.
27
+ #
28
+ # def passwd
29
+ # return stream do
30
+ # File.open('/etc/passwd') do |file|
31
+ # while line = file.gets
32
+ # chunk(file.gets)
33
+ # end
34
+ # end
35
+ # end
36
+ # end
37
+ def stream(&writer)
38
+ fi = Fiber.new do
39
+ writer.call
40
+ end
41
+
42
+ Body.new do |msgid, sender|
43
+ begin
44
+ while true
45
+ chunk = fi.resume
46
+ break unless fi.alive?
47
+ sender.call(ResponsePacker.pack(msgid, nil, chunk))
48
+ end
49
+ rescue RemoteError => ex
50
+ sender.call(ResponsePacker.pack(msgid, ex.class.name, nil))
51
+ rescue ::RuntimeError => ex
52
+ sender.call(ResponsePacker.pack(msgid, RuntimeError.name, nil))
53
+ end
54
+ end
55
+ end
56
+
57
+ # call-seq:
58
+ # chunk(obj)
59
+ #
60
+ # Send a object as chunked data in block of stream().
61
+ def chunk(obj)
62
+ Fiber.yield(obj)
63
+ end
64
+ end
65
+ end
66
+ end
67
+ end
@@ -0,0 +1,25 @@
1
+ require 'rack'
2
+ require 'rack/builder'
3
+ require_relative 'server/dispatcher'
4
+ require_relative 'server/request_unpacker'
5
+ require_relative 'server/response_packer'
6
+ require_relative 'server/streamer'
7
+
8
+ module MessagePack
9
+ module RPCOverHTTP
10
+ class Server
11
+
12
+ # Retruns the application for MessagePack-RPC.
13
+ # It's create with Rack::Builder
14
+ def self.app(handler)
15
+ return Rack::Builder.app do
16
+ use Rack::Chunked
17
+ use RequestUnpacker
18
+ use ResponsePacker
19
+ use Dispatcher
20
+ run handler
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,5 @@
1
+ module MessagePack
2
+ module RPCOverHTTP
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,16 @@
1
+ require 'msgpack'
2
+ require_relative "msgpack/rpc_over_http/version"
3
+ require_relative "msgpack/rpc_over_http/error"
4
+ require_relative "msgpack/rpc_over_http/server"
5
+ require_relative "msgpack/rpc_over_http/client"
6
+
7
+ module MessagePack
8
+ module RPCOverHTTP
9
+ REQUEST = 0 # [0, msgid, method, param]
10
+ RESPONSE = 1 # [1, msgid, error, result]
11
+ NOTIFY = 2 # [2, method, param]
12
+
13
+ NO_METHOD_ERROR = 0x01;
14
+ ARGUMENT_ERROR = 0x02;
15
+ end
16
+ end
@@ -0,0 +1,22 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/msgpack/rpc_over_http/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["Narihiro Nakamura"]
6
+ gem.email = ["authornari@gmail.com"]
7
+ gem.description = %q{This library provides MessagePack-RPC via HTTP}
8
+ gem.summary = %q{This library provides MessagePack-RPC via HTTP}
9
+ gem.homepage = "https://github.com/authorNari/msgpack-rpc-over-http"
10
+
11
+ gem.files = `git ls-files`.split($\)
12
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
13
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
14
+ gem.name = "msgpack-rpc-over-http"
15
+ gem.require_paths = ["lib"]
16
+ gem.version = MessagePack::RPCOverHTTP::VERSION
17
+
18
+ gem.add_development_dependency "rack", "~> 1.4.1"
19
+ gem.add_development_dependency "msgpack", "~> 0.4.7"
20
+ gem.add_development_dependency "celluloid", "~> 0.12.3"
21
+ gem.add_development_dependency "httpclient", "~> 2.3.0.1"
22
+ end
data/test/helper.rb ADDED
@@ -0,0 +1,49 @@
1
+ require 'net/http'
2
+ require 'timeout'
3
+
4
+ class MockHandler
5
+ include MessagePack::RPCOverHTTP::Server::Streamer
6
+
7
+ class Error < MessagePack::RPCOverHTTP::RemoteError
8
+ end
9
+
10
+ def test(*args)
11
+ return args
12
+ end
13
+
14
+ def stream_normal(*args)
15
+ return stream { args.each{|arg| chunk(arg) } }
16
+ end
17
+
18
+ def stream_error(*args)
19
+ return stream do
20
+ args.each{|arg| chunk(arg) }
21
+ raise "Error"
22
+ end
23
+ end
24
+
25
+ def error
26
+ raise "Something Error"
27
+ end
28
+
29
+ def user_defined_error
30
+ raise Error, "Something Error"
31
+ end
32
+ end
33
+
34
+ def sleep_until_http_server_is_started(host, port)
35
+ timeout(30) do
36
+ while stopped_test_app_server?(host, port)
37
+ sleep 1
38
+ end
39
+ end
40
+ end
41
+
42
+ def stopped_test_app_server?(host, port)
43
+ begin
44
+ Net::HTTP.get(host, '/', port)
45
+ return false
46
+ rescue => ex
47
+ return true
48
+ end
49
+ end
@@ -0,0 +1,8 @@
1
+ #\ -s thin
2
+ $LOAD_PATH.unshift(File.expand_path("./../lib", File.dirname(__FILE__)))
3
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
4
+
5
+ require 'msgpack-rpc-over-http'
6
+ require 'helper'
7
+
8
+ run MessagePack::RPCOverHTTP::Server.app(MockHandler.new)
data/test/run-test.rb ADDED
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/env ruby
2
+ base_dir = File.expand_path(File.dirname(__FILE__))
3
+ top_dir = File.expand_path("..", base_dir)
4
+ $LOAD_PATH.unshift(File.join(top_dir, "lib"))
5
+ $LOAD_PATH.unshift(File.join(top_dir, "test"))
6
+
7
+ require "bundler"
8
+ Bundler.require(:default, :test)
9
+ require "test/unit"
10
+
11
+ require "msgpack-rpc-over-http"
12
+ require "helper"
13
+
14
+ test_file = "./test/test_*.rb"
15
+ Dir.glob(test_file) do |file|
16
+ require file
17
+ end
18
+
@@ -0,0 +1,83 @@
1
+ module MessagePack::RPCOverHTTP
2
+ class TestClient < Test::Unit::TestCase
3
+ def self.unused_port
4
+ s = TCPServer.open(0)
5
+ port = s.addr[1]
6
+ s.close
7
+ port
8
+ end
9
+
10
+ @@server_port = unused_port
11
+ @@is_stopped_test_app_server = true
12
+
13
+ def setup
14
+ @client = Client.new("http://0.0.0.0:#{@@server_port}/")
15
+ if @@is_stopped_test_app_server
16
+ pid = fork {
17
+ Rack::Server.start(config: "test/mock_server.ru", Port: @@server_port)
18
+ exit 0
19
+ }
20
+ at_exit do
21
+ Process.kill(:INT, pid)
22
+ Process.waitpid(pid)
23
+ end
24
+ sleep_until_http_server_is_started("0.0.0.0", @@server_port)
25
+ @@is_stopped_test_app_server = false
26
+ end
27
+ end
28
+
29
+ def test_call
30
+ assert_equal ["a", "b"], @client.call(:test, "a", "b")
31
+ assert_raise(MessagePack::RPCOverHTTP::RuntimeError) do
32
+ @client.call(:error)
33
+ end
34
+ assert_raise(MockHandler::Error) do
35
+ @client.call(:user_defined_error)
36
+ end
37
+ end
38
+
39
+ def test_call_async
40
+ future = @client.call_async(:test, "a", "b")
41
+ assert_equal ["a", "b"], future.value
42
+ assert_raise(MessagePack::RPCOverHTTP::RuntimeError) do
43
+ future = @client.call(:error)
44
+ future.value
45
+ end
46
+ end
47
+
48
+ def test_callback
49
+ future = @client.callback(:test, "a", "b") do |res|
50
+ assert_equal ["a", "b"], res
51
+ end
52
+ future.value
53
+ future = @client.callback(:error) do |res, err|
54
+ assert_kind_of MessagePack::RPCOverHTTP::RuntimeError, err
55
+ end
56
+ future.value
57
+ end
58
+
59
+ def test_stream
60
+ expect = ["a", "b"]
61
+ @client.stream(:stream_normal, "a", "b") do |res|
62
+ assert_equal expect.shift, res
63
+ end
64
+
65
+ expect = ["a", "b"]
66
+ @client.stream(:stream_error) do |res, err|
67
+ if res
68
+ assert_equal expect.shift, res
69
+ else
70
+ assert_kind_of MessagePack::RPCOverHTTP::RuntimeError, err
71
+ end
72
+ end
73
+ end
74
+
75
+ def test_stream_async
76
+ expect = ["a", "b"]
77
+ future = @client.stream_async(:stream_normal, "a", "b") do |res|
78
+ assert_equal expect.shift, res
79
+ end
80
+ future.value
81
+ end
82
+ end
83
+ end
metadata ADDED
@@ -0,0 +1,132 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: msgpack-rpc-over-http
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Narihiro Nakamura
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-11-03 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rack
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 1.4.1
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: 1.4.1
30
+ - !ruby/object:Gem::Dependency
31
+ name: msgpack
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ~>
36
+ - !ruby/object:Gem::Version
37
+ version: 0.4.7
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: 0.4.7
46
+ - !ruby/object:Gem::Dependency
47
+ name: celluloid
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ~>
52
+ - !ruby/object:Gem::Version
53
+ version: 0.12.3
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: 0.12.3
62
+ - !ruby/object:Gem::Dependency
63
+ name: httpclient
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ~>
68
+ - !ruby/object:Gem::Version
69
+ version: 2.3.0.1
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ~>
76
+ - !ruby/object:Gem::Version
77
+ version: 2.3.0.1
78
+ description: This library provides MessagePack-RPC via HTTP
79
+ email:
80
+ - authornari@gmail.com
81
+ executables: []
82
+ extensions: []
83
+ extra_rdoc_files: []
84
+ files:
85
+ - .gitignore
86
+ - Gemfile
87
+ - LICENSE
88
+ - README.md
89
+ - Rakefile
90
+ - lib/msgpack-rpc-over-http.rb
91
+ - lib/msgpack/rpc_over_http/client.rb
92
+ - lib/msgpack/rpc_over_http/error.rb
93
+ - lib/msgpack/rpc_over_http/server.rb
94
+ - lib/msgpack/rpc_over_http/server/dispatcher.rb
95
+ - lib/msgpack/rpc_over_http/server/request_unpacker.rb
96
+ - lib/msgpack/rpc_over_http/server/response_packer.rb
97
+ - lib/msgpack/rpc_over_http/server/streamer.rb
98
+ - lib/msgpack/rpc_over_http/version.rb
99
+ - msgpack-rpc-over-http.gemspec
100
+ - test/helper.rb
101
+ - test/mock_server.ru
102
+ - test/run-test.rb
103
+ - test/test_client.rb
104
+ homepage: https://github.com/authorNari/msgpack-rpc-over-http
105
+ licenses: []
106
+ post_install_message:
107
+ rdoc_options: []
108
+ require_paths:
109
+ - lib
110
+ required_ruby_version: !ruby/object:Gem::Requirement
111
+ none: false
112
+ requirements:
113
+ - - ! '>='
114
+ - !ruby/object:Gem::Version
115
+ version: '0'
116
+ required_rubygems_version: !ruby/object:Gem::Requirement
117
+ none: false
118
+ requirements:
119
+ - - ! '>='
120
+ - !ruby/object:Gem::Version
121
+ version: '0'
122
+ requirements: []
123
+ rubyforge_project:
124
+ rubygems_version: 1.8.24
125
+ signing_key:
126
+ specification_version: 3
127
+ summary: This library provides MessagePack-RPC via HTTP
128
+ test_files:
129
+ - test/helper.rb
130
+ - test/mock_server.ru
131
+ - test/run-test.rb
132
+ - test/test_client.rb