jamesgolick-ASS 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/ASS.gemspec +62 -0
- data/LICENSE +20 -0
- data/README.textile +162 -0
- data/Rakefile +57 -0
- data/VERSION.yml +4 -0
- data/lib/ass.rb +107 -0
- data/lib/ass/actor.rb +50 -0
- data/lib/ass/amqp.rb +19 -0
- data/lib/ass/callback_factory.rb +95 -0
- data/lib/ass/client.rb +19 -0
- data/lib/ass/peeper.rb +38 -0
- data/lib/ass/rpc.rb +180 -0
- data/lib/ass/server.rb +171 -0
- data/lib/ass/topic.rb +25 -0
- data/spec/actor_spec.rb +84 -0
- data/spec/ass_spec.rb +291 -0
- data/spec/client_spec.rb +50 -0
- data/spec/rpc_spec.rb +74 -0
- data/test/ass_test.rb +7 -0
- data/test/test_helper.rb +10 -0
- metadata +85 -0
data/spec/rpc_spec.rb
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require "lib/ass"
|
3
|
+
require "spec"
|
4
|
+
require 'rant/spec'
|
5
|
+
require 'thread'
|
6
|
+
|
7
|
+
require 'eventmachine'
|
8
|
+
EM.threadpool_size = 1
|
9
|
+
|
10
|
+
describe "RPC" do
|
11
|
+
before do
|
12
|
+
q = Queue.new
|
13
|
+
@server = nil
|
14
|
+
@thread = Thread.new {ASS.start(:logging => false) {
|
15
|
+
q << :ready
|
16
|
+
}}
|
17
|
+
@thread.abort_on_exception = true
|
18
|
+
q.pop.should == :ready
|
19
|
+
end
|
20
|
+
|
21
|
+
after do
|
22
|
+
ASS.stop
|
23
|
+
@thread.join
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should make synchronized call" do
|
27
|
+
ASS.actor("spec") {
|
28
|
+
def foo(i)
|
29
|
+
i
|
30
|
+
end
|
31
|
+
}
|
32
|
+
rpc = ASS.rpc
|
33
|
+
futures = 100.times.map { |i| rpc.call("spec",:foo,i) }
|
34
|
+
rspec_thread = Thread.current
|
35
|
+
futures.each_with_index { |f,i|
|
36
|
+
f.should be_an(ASS::RPC::Future)
|
37
|
+
f.wait(5) {
|
38
|
+
raise "timeout"
|
39
|
+
}.should == i
|
40
|
+
f.done?.should == true
|
41
|
+
f.timeout?.should == false
|
42
|
+
}
|
43
|
+
end
|
44
|
+
|
45
|
+
it "should timeout call" do
|
46
|
+
ASS.actor("spec") {
|
47
|
+
def foo(i)
|
48
|
+
discard
|
49
|
+
end
|
50
|
+
}
|
51
|
+
rpc = ASS.rpc
|
52
|
+
rpc.call("spec",:foo,1).wait(1) { :timeout }.should == :timeout
|
53
|
+
end
|
54
|
+
|
55
|
+
it "should make call information available to waited future" do
|
56
|
+
ASS.actor("spec") {
|
57
|
+
def foo(i)
|
58
|
+
i
|
59
|
+
end
|
60
|
+
}
|
61
|
+
rpc = ASS.rpc
|
62
|
+
futures = 10.times.map { |i| rpc.call("spec",:foo,i,{},i) }
|
63
|
+
futures.each_with_index { |f,i|
|
64
|
+
f.wait(5) {
|
65
|
+
raise "timeout"
|
66
|
+
}
|
67
|
+
f.header.should be_a(MQ::Header)
|
68
|
+
f.method.should == :foo
|
69
|
+
f.meta.should == i
|
70
|
+
f.data.should == i
|
71
|
+
}
|
72
|
+
end
|
73
|
+
|
74
|
+
end
|
data/test/ass_test.rb
ADDED
data/test/test_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,85 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: jamesgolick-ASS
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Howard Yeh
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-10-30 00:00:00 -07:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: amqp
|
17
|
+
type: :runtime
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: "0"
|
24
|
+
version:
|
25
|
+
description:
|
26
|
+
email: hayeah@gmail.com
|
27
|
+
executables: []
|
28
|
+
|
29
|
+
extensions: []
|
30
|
+
|
31
|
+
extra_rdoc_files:
|
32
|
+
- LICENSE
|
33
|
+
- README.textile
|
34
|
+
files:
|
35
|
+
- ASS.gemspec
|
36
|
+
- LICENSE
|
37
|
+
- README.textile
|
38
|
+
- Rakefile
|
39
|
+
- VERSION.yml
|
40
|
+
- lib/ass.rb
|
41
|
+
- lib/ass/actor.rb
|
42
|
+
- lib/ass/amqp.rb
|
43
|
+
- lib/ass/callback_factory.rb
|
44
|
+
- lib/ass/client.rb
|
45
|
+
- lib/ass/peeper.rb
|
46
|
+
- lib/ass/rpc.rb
|
47
|
+
- lib/ass/server.rb
|
48
|
+
- lib/ass/topic.rb
|
49
|
+
- test/ass_test.rb
|
50
|
+
- test/test_helper.rb
|
51
|
+
has_rdoc: true
|
52
|
+
homepage: http://github.com/hayeah/ass
|
53
|
+
licenses: []
|
54
|
+
|
55
|
+
post_install_message:
|
56
|
+
rdoc_options:
|
57
|
+
- --charset=UTF-8
|
58
|
+
require_paths:
|
59
|
+
- lib
|
60
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
61
|
+
requirements:
|
62
|
+
- - ">="
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: "0"
|
65
|
+
version:
|
66
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
67
|
+
requirements:
|
68
|
+
- - ">="
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: "0"
|
71
|
+
version:
|
72
|
+
requirements: []
|
73
|
+
|
74
|
+
rubyforge_project:
|
75
|
+
rubygems_version: 1.3.5
|
76
|
+
signing_key:
|
77
|
+
specification_version: 3
|
78
|
+
summary: Asynchronous Service Stages for Distributed Services
|
79
|
+
test_files:
|
80
|
+
- spec/actor_spec.rb
|
81
|
+
- spec/ass_spec.rb
|
82
|
+
- spec/client_spec.rb
|
83
|
+
- spec/rpc_spec.rb
|
84
|
+
- test/ass_test.rb
|
85
|
+
- test/test_helper.rb
|