em-nodes 0.5.1 → 0.5.27
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +9 -0
- data/lib/em-nodes/client.rb +4 -0
- data/lib/em-nodes/client/task.rb +8 -3
- data/lib/em-nodes/version.rb +1 -1
- data/spec/base_spec.rb +3 -2
- data/spec/simple2_spec.rb +1 -1
- data/spec/spec_helper.rb +3 -0
- data/spec/waiter_spec.rb +2 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 15f186e1f26c19bcc23b349732640afc79b9bb86
|
4
|
+
data.tar.gz: 3a9c86de3c9dd34df08b5c8eb2ad90876cf609b5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d76be1f7c858e4d0fc15da1b680ffacd0ab989df17b39cc86d98c1a3a08ca1d2872dfe6ffeefe36f9c243445305099dfa92f92f9bb753d23bcd1d415e3f26410
|
7
|
+
data.tar.gz: bfe232231ed284e231f19df0d5412f7c8bdf8b51c2069cbebd96cb96ce8e83b46d421ed21dd22bd6c33edb5e8d0fc58f58dc99e8a18bc8cab7112c08cfde1c9c
|
data/.travis.yml
ADDED
data/lib/em-nodes/client.rb
CHANGED
data/lib/em-nodes/client/task.rb
CHANGED
@@ -1,5 +1,10 @@
|
|
1
1
|
class EM::Nodes::Client
|
2
2
|
module TaskFeature
|
3
|
+
def initialize(*args)
|
4
|
+
super(*args)
|
5
|
+
@mutex = Mutex.new
|
6
|
+
@tasks_hash = {}
|
7
|
+
end
|
3
8
|
|
4
9
|
def on_task(task_id, data)
|
5
10
|
# redefine me
|
@@ -7,19 +12,19 @@ class EM::Nodes::Client
|
|
7
12
|
end
|
8
13
|
|
9
14
|
def tasks
|
10
|
-
@
|
15
|
+
@tasks_hash.values
|
11
16
|
end
|
12
17
|
|
13
18
|
def send_task_result(task_id, result)
|
14
19
|
send_task_result_internal(task_id, result)
|
15
|
-
|
20
|
+
@mutex.synchronize { @tasks_hash.delete(task_id) }
|
16
21
|
end
|
17
22
|
|
18
23
|
private
|
19
24
|
|
20
25
|
def on_task_internal(task_id, data)
|
21
26
|
obj = on_task(task_id, data)
|
22
|
-
|
27
|
+
@mutex.synchronize { @tasks_hash[task_id] = obj }
|
23
28
|
end
|
24
29
|
end
|
25
30
|
end
|
data/lib/em-nodes/version.rb
CHANGED
data/spec/base_spec.rb
CHANGED
@@ -31,8 +31,9 @@ end
|
|
31
31
|
describe "Base spec" do
|
32
32
|
it "base callbacks should work" do
|
33
33
|
EM.run do
|
34
|
-
|
35
|
-
$
|
34
|
+
host, port = (RUBY_PLATFORM =~ /java/) ? ['127.0.0.1', 19999] : ['/tmp/emn_server0.sock']
|
35
|
+
$server0 = Server0.start(host, port)
|
36
|
+
$client0 = Client0.connect(host, port)
|
36
37
|
|
37
38
|
EM.next_tick do
|
38
39
|
$client0.bla.should == 1
|
data/spec/simple2_spec.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
data/spec/waiter_spec.rb
CHANGED
@@ -45,11 +45,12 @@ describe "write task object, to prevent GC" do
|
|
45
45
|
EM.add_timer(0.5) do
|
46
46
|
$server5_results.should be_empty
|
47
47
|
$client5.tasks.size.should == 10
|
48
|
-
$client5.tasks.
|
48
|
+
$client5.tasks.map(&:time).compact.size.should == 10
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
52
52
|
$server5_results.size.should == 10
|
53
53
|
$client5.tasks.size.should == 0
|
54
|
+
$client5.tasks.is_a?(Array).should == true
|
54
55
|
end
|
55
56
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: em-nodes
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.27
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- "'Konstantin Makarchev'"
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-06-
|
11
|
+
date: 2015-06-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: eventmachine
|
@@ -76,6 +76,7 @@ extra_rdoc_files: []
|
|
76
76
|
files:
|
77
77
|
- ".gitignore"
|
78
78
|
- ".rspec"
|
79
|
+
- ".travis.yml"
|
79
80
|
- Gemfile
|
80
81
|
- LICENSE.txt
|
81
82
|
- README.md
|
@@ -139,7 +140,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
139
140
|
version: '0'
|
140
141
|
requirements: []
|
141
142
|
rubyforge_project:
|
142
|
-
rubygems_version: 2.
|
143
|
+
rubygems_version: 2.4.7
|
143
144
|
signing_key:
|
144
145
|
specification_version: 4
|
145
146
|
summary: Simple abstraction on top of EventMachine for easy create clients, servers,
|