sidekiq-history 0.0.7 → 0.0.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/README.md +4 -0
- data/lib/sidekiq/history/middleware.rb +30 -2
- data/lib/sidekiq/history/version.rb +1 -1
- data/lib/sidekiq/history.rb +7 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a5fc1bfef2bd8600e4c92b2c95e96f6af3868958
|
4
|
+
data.tar.gz: e637f50b96a6fb1069ee608ddc1f874bf6261602
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 544c08be81d7a1bfc2d77b1cb055a59fb7426a9e9bbe9f82e2d60c74fa837112db1ac7fd87a1ccee80fb8b2afeff4315ef4446eb704588b68aac974d452569a2
|
7
|
+
data.tar.gz: 64024757374fb345d3fa4686fd2a28efb8593fb7521e507ed75d766f64e1c17050a4ce92c084346a8c19185b7f8c6b34782755002981b10e1f5025c2a15c03c6
|
data/README.md
CHANGED
@@ -20,6 +20,10 @@ Or install it yourself as:
|
|
20
20
|
|
21
21
|
Nothing left to do. Mount sidekiq, and go to the web interface. You'll see a shiny new History tab!
|
22
22
|
|
23
|
+
By default it will keep history on the last 1000 jobs. To change that set `Sidekiq::History::Middleware::MAX_COUNT = 10000`. Be careful because the data is persisted in Redis Sorted Set and it WILL take up RAM. Max possible value is 4294967295 per Redis limit.
|
24
|
+
|
25
|
+
If you want to only record history for specific jobs you can set `Sidekiq::History::Middleware::EXCLUDE_JOBS = ['OneJob']` (do not record for specified jobs) and `Sidekiq::History::Middleware::INCLUDE_JOBS = ['AnotherJob']` (record ONLY jobs specified). INCLUDE will take precedence so if you set it to blank array nothing will be recorded.
|
26
|
+
|
23
27
|
## Screenshot
|
24
28
|
|
25
29
|

|
@@ -9,6 +9,7 @@ module Sidekiq
|
|
9
9
|
|
10
10
|
def call(worker, msg, queue)
|
11
11
|
self.msg = msg
|
12
|
+
job_class = msg['args'][0]['job_class']
|
12
13
|
|
13
14
|
data = {
|
14
15
|
started_at: Time.now.utc,
|
@@ -26,12 +27,16 @@ module Sidekiq
|
|
26
27
|
conn.del(LIST_KEY)
|
27
28
|
list.each do |entry|
|
28
29
|
migrated_data = JSON.parse(entry)
|
29
|
-
|
30
|
+
if record_history(job_class) == true
|
31
|
+
conn.zadd(LIST_KEY, data[:started_at].to_f, Sidekiq.dump_json(migrated_data))
|
32
|
+
end
|
30
33
|
end
|
31
34
|
end
|
32
35
|
|
33
36
|
# regular storage of history
|
34
|
-
|
37
|
+
if record_history(job_class) == true
|
38
|
+
conn.zadd(LIST_KEY, data[:started_at].to_f, Sidekiq.dump_json(data))
|
39
|
+
end
|
35
40
|
unless Sidekiq.history_max_count == false
|
36
41
|
conn.zremrangebyrank(LIST_KEY, 0, -(Sidekiq.history_max_count + 1))
|
37
42
|
end
|
@@ -39,6 +44,29 @@ module Sidekiq
|
|
39
44
|
|
40
45
|
yield
|
41
46
|
end
|
47
|
+
|
48
|
+
private
|
49
|
+
|
50
|
+
# check if this job should be recorded
|
51
|
+
def record_history job_class
|
52
|
+
# first check inclusion
|
53
|
+
if defined? INCLUDE_JOBS
|
54
|
+
if INCLUDE_JOBS.include? job_class
|
55
|
+
return true
|
56
|
+
else
|
57
|
+
return false
|
58
|
+
end
|
59
|
+
elsif defined? EXCLUDE_JOBS
|
60
|
+
if EXCLUDE_JOBS.include? job_class
|
61
|
+
return false
|
62
|
+
else
|
63
|
+
return true
|
64
|
+
end
|
65
|
+
else
|
66
|
+
return true
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
42
70
|
end
|
43
71
|
end
|
44
72
|
end
|
data/lib/sidekiq/history.rb
CHANGED
@@ -9,7 +9,13 @@ module Sidekiq
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def self.history_max_count
|
12
|
-
|
12
|
+
# => use default 1000 unless specified in config. Max is 4294967295 per Redis Sorted Set limit
|
13
|
+
if defined? MAX_COUNT
|
14
|
+
hmc = [MAX_COUNT, 4294967295].min
|
15
|
+
else
|
16
|
+
hmc = 1000
|
17
|
+
end
|
18
|
+
return hmc if @history_max_count.nil?
|
13
19
|
@history_max_count
|
14
20
|
end
|
15
21
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sidekiq-history
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Russ Smith
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-04-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sidekiq
|
@@ -135,7 +135,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
135
135
|
version: '0'
|
136
136
|
requirements: []
|
137
137
|
rubyforge_project:
|
138
|
-
rubygems_version: 2.5.
|
138
|
+
rubygems_version: 2.5.2
|
139
139
|
signing_key:
|
140
140
|
specification_version: 4
|
141
141
|
summary: History for sidekiq jobs.
|