serfx 0.0.6 → 0.0.7
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.
- checksums.yaml +4 -4
- data/lib/serfx/utils/async_job.rb +11 -4
- data/lib/serfx/version.rb +1 -1
- data/lib/serfx.rb +5 -1
- data/spec/serfx/client_spec.rb +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 192f63ff3c81b7514e291a9ddd7e4061c3ec97a3
|
4
|
+
data.tar.gz: 9a4dfc3ca65be460ba0097338c1c57f5fce3bd89
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e98cf655dbb65a787eafecdd57c222d1a802bafe5d4aafaf2779283e630b26c629a0c6db88f62e46363fbdceeb01c4759793a2566c1a1725dd21416614129f75
|
7
|
+
data.tar.gz: 5a5b41cdd7c275ae11f30b32533c5dbcc808d07afeca4e71bfe69b895222539567f0c6c50df24837e7d4de4bfee2129c898304a3569dec54459c763dde02f2c7
|
@@ -91,7 +91,7 @@ module Serfx
|
|
91
91
|
def kill(sig = 'KILL')
|
92
92
|
if running?
|
93
93
|
begin
|
94
|
-
Process.kill(sig,
|
94
|
+
Process.kill(sig, stateinfo['pid'].to_i)
|
95
95
|
'success'
|
96
96
|
rescue Exception
|
97
97
|
'failed'
|
@@ -101,7 +101,7 @@ module Serfx
|
|
101
101
|
end
|
102
102
|
end
|
103
103
|
|
104
|
-
# obtain current state information about the task
|
104
|
+
# obtain current state information about the task as json
|
105
105
|
#
|
106
106
|
# @return [String] JSON string representing current state of the task
|
107
107
|
def state_info
|
@@ -112,11 +112,18 @@ module Serfx
|
|
112
112
|
end
|
113
113
|
end
|
114
114
|
|
115
|
+
# obtain current state information about the task as hash
|
116
|
+
#
|
117
|
+
# @return [Hash] JSON string representing current state of the task
|
118
|
+
def stateinfo
|
119
|
+
JSON.parse(state_info)
|
120
|
+
end
|
121
|
+
|
115
122
|
# delete the statefile of a finished task
|
116
123
|
#
|
117
124
|
# @return [String] 'success' if the task is reaped, 'failed' otherwise
|
118
125
|
def reap
|
119
|
-
if
|
126
|
+
if stateinfo['status'] == 'finished'
|
120
127
|
File.unlink(state_file)
|
121
128
|
'success'
|
122
129
|
else
|
@@ -174,7 +181,7 @@ module Serfx
|
|
174
181
|
# @return [TrueClass, FalseClass] true if the task running, else false
|
175
182
|
def running?
|
176
183
|
if exists?
|
177
|
-
File.exist?(File.join('/proc',
|
184
|
+
File.exist?(File.join('/proc', stateinfo['pid'].to_s))
|
178
185
|
else
|
179
186
|
false
|
180
187
|
end
|
data/lib/serfx/version.rb
CHANGED
data/lib/serfx.rb
CHANGED
@@ -15,15 +15,19 @@ module Serfx
|
|
15
15
|
# * host => Serf host's rpc bind address (127.0.0.1 by default)
|
16
16
|
# * port => Serf host's rpc port (7373 by default)
|
17
17
|
# * authkey => Encryption key for RPC communiction
|
18
|
+
#
|
19
|
+
# @return value of the block evaluation of nil
|
18
20
|
def self.connect(opts = {})
|
19
21
|
conn = Serfx::Connection.new(opts)
|
20
22
|
conn.handshake
|
21
23
|
conn.auth if opts.key?(:authkey)
|
24
|
+
res = nil
|
22
25
|
if block_given?
|
23
|
-
yield conn
|
26
|
+
res = yield conn
|
24
27
|
conn.close unless conn.closed?
|
25
28
|
else
|
26
29
|
conn
|
27
30
|
end
|
31
|
+
res
|
28
32
|
end
|
29
33
|
end
|
data/spec/serfx/client_spec.rb
CHANGED
@@ -88,7 +88,7 @@ describe Serfx do
|
|
88
88
|
response = @conn.members_filtered('group' => 'odd')
|
89
89
|
expect(response.header.error).to be_empty
|
90
90
|
tags = response.body['Members'].map { |x|x['Tags']['group'] }
|
91
|
-
expect(tags.all? { |t| t == 'odd' }).to
|
91
|
+
expect(tags.all? { |t| t == 'odd' }).to be(true)
|
92
92
|
end
|
93
93
|
|
94
94
|
it '#tags' do
|
@@ -110,7 +110,7 @@ describe Serfx do
|
|
110
110
|
t.kill
|
111
111
|
expect(data['Name']).to eq('test')
|
112
112
|
expect(data['Payload']).to eq('whoa')
|
113
|
-
expect(data['Coalesce']).to
|
113
|
+
expect(data['Coalesce']).to be(true)
|
114
114
|
expect(data['Event']).to eq('user')
|
115
115
|
end
|
116
116
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: serfx
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rnjib Dey
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-07-
|
11
|
+
date: 2014-07-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: msgpack
|