postqueue 0.5.2 → 0.5.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/postqueue/cli/options_parser.rb +17 -4
- data/lib/postqueue/cli/stats.rb +10 -2
- data/lib/postqueue/cli.rb +1 -1
- data/lib/postqueue/default_queue.rb +1 -1
- data/lib/postqueue/queue/processing.rb +1 -0
- data/lib/postqueue/queue.rb +1 -1
- data/lib/postqueue/version.rb +1 -1
- data/spec/postqueue/enqueue_spec.rb +4 -4
- data/spec/postqueue/process_mode_spec.rb +2 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ad176bce5f7bba7fda654b053e5fa32acd41abdd
|
4
|
+
data.tar.gz: 646743647918dbc637ea6e740f4015b3ef942f82
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ffd319be64f642202f294c85b7c2d89d310b4d42dc4654cbb6d3d4d2bf65ffcd57ab80a6aa9aa328062a7243ca5d2696d03e120993b46db1f49a578c65a124e2
|
7
|
+
data.tar.gz: 587ab795e8b9e239f8e126d6325418dca8d9014999c1da4d696ddbc19115074497be3d5ee00fd457ca2dac234f7a2ff21801be154457c5b03f34428c14466ce1
|
@@ -16,7 +16,11 @@ module Postqueue
|
|
16
16
|
def parse_args
|
17
17
|
require "optparse"
|
18
18
|
options = OpenStruct.new
|
19
|
-
options.sub_command = argv.shift ||
|
19
|
+
options.sub_command = argv.shift || "stats"
|
20
|
+
|
21
|
+
unless %w(stats peek enqueue run process).include?(options.sub_command)
|
22
|
+
usage!
|
23
|
+
end
|
20
24
|
|
21
25
|
case options.sub_command
|
22
26
|
when "enqueue"
|
@@ -32,13 +36,22 @@ module Postqueue
|
|
32
36
|
argv.shift || usage!
|
33
37
|
end
|
34
38
|
|
35
|
-
def usage
|
39
|
+
def usage
|
36
40
|
STDERR.puts <<-USAGE
|
37
|
-
|
41
|
+
This is postqueue #{Postqueue::VERSION}. Usage examples:
|
42
|
+
|
43
|
+
postqueue [ stats ]
|
44
|
+
postqueue peek
|
38
45
|
postqueue enqueue op entity_id,entity_id,entity_id
|
39
46
|
postqueue run
|
47
|
+
postqueue help
|
40
48
|
postqueue process
|
41
|
-
|
49
|
+
|
50
|
+
USAGE
|
51
|
+
end
|
52
|
+
|
53
|
+
def usage!
|
54
|
+
usage
|
42
55
|
exit 1
|
43
56
|
end
|
44
57
|
end
|
data/lib/postqueue/cli/stats.rb
CHANGED
@@ -10,14 +10,22 @@ module Postqueue
|
|
10
10
|
sql = <<-SQL
|
11
11
|
SELECT op,
|
12
12
|
COUNT(*) AS count,
|
13
|
+
failed_attempts,
|
14
|
+
CASE
|
15
|
+
WHEN failed_attempts >= 5 THEN 'FAILED'
|
16
|
+
WHEN failed_attempts > 0 THEN 'RETRY'
|
17
|
+
WHEN next_run_at < now() THEN 'READY'
|
18
|
+
ELSE 'WAIT'
|
19
|
+
END AS status,
|
13
20
|
MIN(now() - created_at) AS min_age,
|
14
21
|
MAX(now() - created_at) AS max_age,
|
15
22
|
AVG(now() - created_at) AS avg_age
|
16
|
-
FROM #{Postqueue.item_class.table_name}
|
23
|
+
FROM #{Postqueue.item_class.table_name}
|
24
|
+
GROUP BY op, failed_attempts, status
|
17
25
|
SQL
|
18
26
|
|
19
27
|
recs = Postqueue.item_class.find_by_sql(sql)
|
20
|
-
tp recs, :op, :count, :avg_age, :min_age, :max_age
|
28
|
+
tp recs, :status, :op, :failed_attempts, :count, :avg_age, :min_age, :max_age
|
21
29
|
end
|
22
30
|
|
23
31
|
def peek(_options)
|
data/lib/postqueue/cli.rb
CHANGED
@@ -12,7 +12,7 @@ module Postqueue
|
|
12
12
|
extend SingleForwardable
|
13
13
|
|
14
14
|
def_delegators :default_queue, :enqueue
|
15
|
-
def_delegators :default_queue, :item_class, :batch_sizes, :on
|
15
|
+
def_delegators :default_queue, :item_class, :batch_sizes, :on, :on_exception
|
16
16
|
def_delegators :default_queue, :process, :process_one
|
17
17
|
def_delegators :default_queue, :processing
|
18
18
|
def_delegators :default_queue, :run, :run!
|
data/lib/postqueue/queue.rb
CHANGED
@@ -38,7 +38,7 @@ module Postqueue
|
|
38
38
|
end
|
39
39
|
|
40
40
|
on "fail" do |_op, entity_ids|
|
41
|
-
raise
|
41
|
+
raise "Postqueue test failure, w/entity_ids: #{entity_ids.inspect}"
|
42
42
|
end
|
43
43
|
|
44
44
|
on :missing_handler do |op, entity_ids|
|
data/lib/postqueue/version.rb
CHANGED
@@ -16,13 +16,13 @@ describe "enqueuing" do
|
|
16
16
|
end
|
17
17
|
|
18
18
|
it "enqueues arrays" do
|
19
|
-
queue.enqueue op: "myop", entity_id: [13,14,15]
|
20
|
-
expect(items.pluck(:entity_id)).to eq([12,13,14,15])
|
19
|
+
queue.enqueue op: "myop", entity_id: [13, 14, 15]
|
20
|
+
expect(items.pluck(:entity_id)).to eq([12, 13, 14, 15])
|
21
21
|
end
|
22
22
|
|
23
23
|
it "enqueues sets" do
|
24
|
-
queue.enqueue op: "myop", entity_id: Set.new([13,14,15])
|
25
|
-
expect(items.pluck(:entity_id)).to eq([12,13,14,15])
|
24
|
+
queue.enqueue op: "myop", entity_id: Set.new([13, 14, 15])
|
25
|
+
expect(items.pluck(:entity_id)).to eq([12, 13, 14, 15])
|
26
26
|
end
|
27
27
|
|
28
28
|
it "sets defaults" do
|
@@ -44,9 +44,9 @@ describe "process mode" do
|
|
44
44
|
end
|
45
45
|
|
46
46
|
it "raises an error for invalid ops" do
|
47
|
-
expect
|
47
|
+
expect do
|
48
48
|
queue.enqueue op: "invalid", entity_id: 12
|
49
|
-
|
49
|
+
end.to raise_error(Postqueue::MissingHandler)
|
50
50
|
end
|
51
51
|
end
|
52
52
|
end
|