allq 0.1.6 → 0.1.8
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/allq/actions/base.rb +2 -1
- data/lib/allq/actions/release.rb +5 -3
- data/lib/allq/client.rb +2 -2
- data/lib/allq/job.rb +18 -8
- data/lib/allq/version.rb +1 -1
- 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: 7ca70c2e8febb6c7327bfedca67668ffb0adb108
|
4
|
+
data.tar.gz: 699caf855839a14e96850622445c44732edfd72b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9287fb36db6b421c2f6230372f802251b5e705882601a9bcfca191fb9f79fc828a4c34ff928f1ccc776be8a63de4013e7b445911311f9b07bffae32348b17b61
|
7
|
+
data.tar.gz: 13828baf5392b74ee1d2e928fd0001788b925da672a26df27b7a6e75282faf2ec4d71640d56925801b725563f98b7ee9a9e990be92d8400446d782b347f24e2e
|
data/lib/allq/actions/base.rb
CHANGED
@@ -40,7 +40,8 @@ class AllQ
|
|
40
40
|
job = Job.new(job_id)
|
41
41
|
# -- Optional fields
|
42
42
|
job.body = job_info["body"] if job_info["body"]
|
43
|
-
job.
|
43
|
+
job.expireds = job_info["expireds"] if job_info["expireds"]
|
44
|
+
job.releases = job_info["releases"] if job_info["releases"]
|
44
45
|
return job
|
45
46
|
end
|
46
47
|
|
data/lib/allq/actions/release.rb
CHANGED
@@ -3,7 +3,8 @@ class AllQ
|
|
3
3
|
|
4
4
|
def snd(data)
|
5
5
|
job_id = data[:job_id]
|
6
|
-
|
6
|
+
delay = data[:delay] || 0
|
7
|
+
send_data = base_send(job_id, delay)
|
7
8
|
response = send_hash_as_json(send_data)
|
8
9
|
result = rcv(response)
|
9
10
|
return result["release"] && result["release"]["job_id"]
|
@@ -14,11 +15,12 @@ class AllQ
|
|
14
15
|
JSON.parse(data)
|
15
16
|
end
|
16
17
|
|
17
|
-
def base_send(job_id)
|
18
|
+
def base_send(job_id, delay)
|
18
19
|
{
|
19
20
|
'action' => 'release',
|
20
21
|
'params' => {
|
21
|
-
'job_id' => job_id
|
22
|
+
'job_id' => job_id,
|
23
|
+
'delay' => delay
|
22
24
|
}
|
23
25
|
}
|
24
26
|
end
|
data/lib/allq/client.rb
CHANGED
@@ -87,9 +87,9 @@ class AllQ
|
|
87
87
|
@stats_action.snd(nil)
|
88
88
|
end
|
89
89
|
|
90
|
-
def release(job)
|
90
|
+
def release(job, delay)
|
91
91
|
raise "Can't 'release' a Job that is nil." unless job
|
92
|
-
@release_action.snd(job_id: job.id)
|
92
|
+
@release_action.snd(job_id: job.id, delay: delay)
|
93
93
|
end
|
94
94
|
|
95
95
|
|
data/lib/allq/job.rb
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
class AllQ
|
2
2
|
|
3
3
|
class Job
|
4
|
-
attr_accessor :id, :body, :
|
5
|
-
def initialize(id, tube = nil, body = nil,
|
4
|
+
attr_accessor :id, :body, :expireds, :releases
|
5
|
+
def initialize(id, tube = nil, body = nil, expireds = nil, releases = nil)
|
6
6
|
@body = body
|
7
7
|
@id = id
|
8
8
|
@tube = tube
|
9
|
-
@
|
9
|
+
@expireds = expireds
|
10
|
+
@releases = releases
|
10
11
|
end
|
11
12
|
|
12
13
|
def to_hash
|
@@ -14,7 +15,8 @@ class AllQ
|
|
14
15
|
'job_id' => @id,
|
15
16
|
'body' => @body,
|
16
17
|
'tube' => @tube,
|
17
|
-
'
|
18
|
+
'expireds' => @expireds,
|
19
|
+
'releases' => @releases
|
18
20
|
}
|
19
21
|
end
|
20
22
|
|
@@ -30,8 +32,8 @@ class AllQ
|
|
30
32
|
AllQ::Client.instance.touch(self)
|
31
33
|
end
|
32
34
|
|
33
|
-
def release
|
34
|
-
AllQ::Client.instance.release(self)
|
35
|
+
def release(delay = 0)
|
36
|
+
AllQ::Client.instance.release(self, delay)
|
35
37
|
end
|
36
38
|
|
37
39
|
def bury
|
@@ -50,13 +52,21 @@ class AllQ
|
|
50
52
|
to_json.to_json
|
51
53
|
end
|
52
54
|
|
55
|
+
def stats
|
56
|
+
{
|
57
|
+
"releases" => @releases,
|
58
|
+
"expireds" => @expireds
|
59
|
+
}
|
60
|
+
end
|
61
|
+
|
53
62
|
def self.new_from_hash(hash)
|
54
63
|
begin
|
55
64
|
id = hash.fetch('job_id')
|
56
65
|
body = hash.fetch('body')
|
57
66
|
tube = hash.fetch('tube')
|
58
|
-
|
59
|
-
|
67
|
+
expireds = hash.fetch('expireds')
|
68
|
+
releases = hash.fetch('releases')
|
69
|
+
job = Job.new(id, tube, body, expireds, releases)
|
60
70
|
return job
|
61
71
|
rescue => ex
|
62
72
|
puts "Server value: #{hash}"
|
data/lib/allq/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: allq
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jason
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-04-
|
11
|
+
date: 2018-04-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|