donkey 0.1.0

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.
@@ -0,0 +1,50 @@
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 rpc call" do
27
+ ASS.actor("spec") do
28
+ def foo(i)
29
+ i
30
+ end
31
+ end
32
+ c = ASS.client
33
+ c.call("spec",:foo,1).wait.should == 1
34
+ end
35
+
36
+ it "should do cast" do
37
+ q = Queue.new
38
+ ASS.actor("spec") do
39
+ define_method(:foo) do |i|
40
+ q << i
41
+ i
42
+ end
43
+ end
44
+ c = ASS.client
45
+ c.cast("spec",:foo,1)
46
+ q.pop.should == 1
47
+ end
48
+ end
49
+
50
+
@@ -0,0 +1,73 @@
1
+ require 'rubygems'
2
+ require "lib/ass"
3
+ require "spec"
4
+ require 'thread'
5
+
6
+ require 'eventmachine'
7
+ EM.threadpool_size = 1
8
+
9
+ describe "RPC" do
10
+ before do
11
+ q = Queue.new
12
+ @server = nil
13
+ @thread = Thread.new {ASS.start(:logging => false) {
14
+ q << :ready
15
+ }}
16
+ @thread.abort_on_exception = true
17
+ q.pop.should == :ready
18
+ end
19
+
20
+ after do
21
+ ASS.stop
22
+ @thread.join
23
+ end
24
+
25
+ it "should make synchronized call" do
26
+ ASS.actor("spec") {
27
+ def foo(i)
28
+ i
29
+ end
30
+ }
31
+ rpc = ASS.rpc
32
+ futures = 100.times.map { |i| rpc.call("spec",:foo,i) }
33
+ rspec_thread = Thread.current
34
+ futures.each_with_index { |f,i|
35
+ f.should be_an(ASS::RPC::Future)
36
+ f.wait(5) {
37
+ raise "timeout"
38
+ }.should == i
39
+ f.done?.should == true
40
+ f.timeout?.should == false
41
+ }
42
+ end
43
+
44
+ it "should timeout call" do
45
+ ASS.actor("spec") {
46
+ def foo(i)
47
+ discard
48
+ end
49
+ }
50
+ rpc = ASS.rpc
51
+ rpc.call("spec",:foo,1).wait(1) { :timeout }.should == :timeout
52
+ end
53
+
54
+ it "should make call information available to waited future" do
55
+ ASS.actor("spec") {
56
+ def foo(i)
57
+ i
58
+ end
59
+ }
60
+ rpc = ASS.rpc
61
+ futures = 10.times.map { |i| rpc.call("spec",:foo,i,{},i) }
62
+ futures.each_with_index { |f,i|
63
+ f.wait(5) {
64
+ raise "timeout"
65
+ }
66
+ f.header.should be_a(MQ::Header)
67
+ f.method.should == :foo
68
+ f.meta.should == i
69
+ f.data.should == i
70
+ }
71
+ end
72
+
73
+ end
@@ -0,0 +1,7 @@
1
+ require 'test_helper'
2
+
3
+ class AssTest < Test::Unit::TestCase
4
+ should "probably rename this file and start testing for real" do
5
+ flunk "hey buddy, you should probably rename this file and start testing for real"
6
+ end
7
+ end
@@ -0,0 +1,10 @@
1
+ require 'rubygems'
2
+ require 'test/unit'
3
+ require 'shoulda'
4
+
5
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
6
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
7
+ require 'ass'
8
+
9
+ class Test::Unit::TestCase
10
+ end
metadata ADDED
@@ -0,0 +1,85 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: donkey
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-11-30 00:00:00 -08: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
+ - LICENSE
36
+ - README.textile
37
+ - Rakefile
38
+ - VERSION.yml
39
+ - lib/ass.rb
40
+ - lib/ass/actor.rb
41
+ - lib/ass/amqp.rb
42
+ - lib/ass/callback_factory.rb
43
+ - lib/ass/client.rb
44
+ - lib/ass/peeper.rb
45
+ - lib/ass/rpc.rb
46
+ - lib/ass/serializers.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/donkey
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/ass_spec.rb
81
+ - spec/client_spec.rb
82
+ - spec/actor_spec.rb
83
+ - spec/rpc_spec.rb
84
+ - test/ass_test.rb
85
+ - test/test_helper.rb