arpie 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/README +7 -4
- data/Rakefile +1 -1
- data/lib/arpie.rb +1 -0
- data/lib/arpie/client.rb +6 -5
- data/lib/arpie/protocol.rb +300 -207
- data/lib/arpie/proxy.rb +29 -18
- data/lib/arpie/server.rb +4 -4
- data/lib/arpie/xmlrpc.rb +108 -0
- data/spec/client_server_spec.rb +107 -0
- data/spec/protocol_merge_and_split_spec.rb +47 -0
- data/spec/protocol_spec.rb +152 -0
- data/spec/spec_helper.rb +58 -0
- data/tools/benchmark.rb +3 -2
- data/tools/protocol_benchmark.rb +11 -14
- metadata +10 -5
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
|
3
|
+
Thread.abort_on_exception = true
|
4
|
+
|
5
|
+
unless Object.const_defined?('Arpie')
|
6
|
+
$:.unshift(File.join(File.dirname(__FILE__), "../lib/"))
|
7
|
+
require 'arpie'
|
8
|
+
end
|
9
|
+
|
10
|
+
describe "IO Mockup", :shared => true do
|
11
|
+
before do
|
12
|
+
@r, @w = IO.pipe
|
13
|
+
end
|
14
|
+
|
15
|
+
def chain_write *m
|
16
|
+
m.each {|mm|
|
17
|
+
@chain.write_message(@w, mm)
|
18
|
+
}
|
19
|
+
@w.close
|
20
|
+
end
|
21
|
+
|
22
|
+
def chain_read
|
23
|
+
@chain.read_message(@r)
|
24
|
+
end
|
25
|
+
|
26
|
+
def chain_r_w *m
|
27
|
+
chain_write *m
|
28
|
+
chain_read
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
describe "ProtocolChainSetup", :shared => true do
|
33
|
+
it_should_behave_like "IO Mockup"
|
34
|
+
|
35
|
+
before do
|
36
|
+
@chain = Arpie::ProtocolChain.new(* subject.map {|x| x.new })
|
37
|
+
@testdata_a = "xa"
|
38
|
+
@testdata_b = "xb"
|
39
|
+
end
|
40
|
+
|
41
|
+
# Make sure that no stray buffer contents remain.
|
42
|
+
after do
|
43
|
+
@chain.buffer.size.should == 0
|
44
|
+
@chain.messages.size.should == 0
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
describe "RPCProtocolChainSetup", :shared => true do
|
49
|
+
it_should_behave_like "IO Mockup"
|
50
|
+
|
51
|
+
before do
|
52
|
+
@client = Arpie::ProtocolChain.new(* subject[0].map {|x| x.new })
|
53
|
+
@server = Arpie::ProtocolChain.new(* subject[1].map {|x| x.new })
|
54
|
+
@testdata_a = "xa"
|
55
|
+
@testdata_b = "xb"
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
data/tools/benchmark.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
require 'socket'
|
3
|
+
$:.unshift(File.join(File.dirname(__FILE__), "../lib/"))
|
3
4
|
require 'arpie'
|
4
5
|
require 'benchmark'
|
5
6
|
require 'drb'
|
@@ -16,14 +17,14 @@ include Arpie
|
|
16
17
|
|
17
18
|
server = TCPServer.new(51210)
|
18
19
|
|
19
|
-
endpoint = ProxyServer.new MarshalProtocol.new
|
20
|
+
endpoint = ProxyServer.new MarshalProtocol.new, SizedProtocol.new
|
20
21
|
endpoint.handle Wrap.new
|
21
22
|
|
22
23
|
endpoint.accept do
|
23
24
|
server.accept
|
24
25
|
end
|
25
26
|
|
26
|
-
$proxy = ProxyClient.new MarshalProtocol.new
|
27
|
+
$proxy = ProxyClient.new MarshalProtocol.new, SizedProtocol.new
|
27
28
|
$proxy.connect(true) do
|
28
29
|
TCPSocket.new("127.0.0.1", 51210)
|
29
30
|
end
|
data/tools/protocol_benchmark.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'rubygems'
|
2
|
+
$:.unshift(File.join(File.dirname(__FILE__), "../lib/"))
|
2
3
|
require 'socket'
|
3
4
|
require 'arpie'
|
4
5
|
require 'benchmark'
|
@@ -8,20 +9,16 @@ include Arpie
|
|
8
9
|
# Data test size.
|
9
10
|
DATA_SIZE = 512
|
10
11
|
|
11
|
-
rpc_call =
|
12
|
+
rpc_call = RPCall.new('ns.', 'meth', [1, 2, 3, 4])
|
12
13
|
$test_data = "a" * DATA_SIZE
|
13
14
|
$test_data.freeze
|
14
15
|
|
15
16
|
# Protocols to test:
|
16
|
-
PROTOCOLS =
|
17
|
-
|
18
|
-
SizedProtocol
|
19
|
-
|
20
|
-
|
21
|
-
YAMLProtocol => $test_data,
|
22
|
-
# XMLRPCProtocol => [rpc_call, :server],
|
23
|
-
# HTTPXMLRPCProtocol => [rpc_call, :client],
|
24
|
-
}
|
17
|
+
PROTOCOLS = [
|
18
|
+
[SizedProtocol.new],
|
19
|
+
[MarshalProtocol.new, SizedProtocol.new],
|
20
|
+
[YAMLProtocol.new]
|
21
|
+
]
|
25
22
|
|
26
23
|
ITERATIONS = 1000
|
27
24
|
|
@@ -30,14 +27,14 @@ $stderr.puts "Testing protocols with a data size of #{DATA_SIZE}, #{ITERATIONS}
|
|
30
27
|
|
31
28
|
Benchmark.bm {|b|
|
32
29
|
r, w = IO.pipe
|
33
|
-
PROTOCOLS.each {|p
|
30
|
+
PROTOCOLS.each {|p|
|
34
31
|
a ||= []
|
35
|
-
proto =
|
32
|
+
proto = ProtocolChain.new *p
|
36
33
|
r, w = IO.pipe
|
37
34
|
|
38
|
-
b.report("%-30s" % p.to_s) {
|
35
|
+
b.report("%-30s\n" % p.map{|x| x.class.to_s}.inspect) {
|
39
36
|
ITERATIONS.times do
|
40
|
-
proto.write_message(w,
|
37
|
+
proto.write_message(w, $test_data)
|
41
38
|
proto.read_message(r)
|
42
39
|
end
|
43
40
|
}
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: arpie
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bernhard Stoeckner
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-02-
|
12
|
+
date: 2009-02-16 00:00:00 +01:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -35,14 +35,19 @@ files:
|
|
35
35
|
- COPYING
|
36
36
|
- README
|
37
37
|
- Rakefile
|
38
|
-
- spec/spec.opts
|
39
38
|
- spec/rcov.opts
|
40
|
-
-
|
39
|
+
- spec/protocol_merge_and_split_spec.rb
|
40
|
+
- spec/spec_helper.rb
|
41
|
+
- spec/protocol_spec.rb
|
42
|
+
- spec/spec.opts
|
43
|
+
- spec/client_server_spec.rb
|
41
44
|
- lib/arpie
|
45
|
+
- lib/arpie/proxy.rb
|
46
|
+
- lib/arpie/xmlrpc.rb
|
42
47
|
- lib/arpie/client.rb
|
43
48
|
- lib/arpie/protocol.rb
|
44
|
-
- lib/arpie/proxy.rb
|
45
49
|
- lib/arpie/server.rb
|
50
|
+
- lib/arpie.rb
|
46
51
|
- tools/benchmark.rb
|
47
52
|
- tools/protocol_benchmark.rb
|
48
53
|
has_rdoc: true
|