sqeduler 0.3.1 → 0.3.2
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/CHANGES.md +5 -0
- data/lib/sqeduler/lock_maintainer.rb +14 -6
- data/lib/sqeduler/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: abf3832836e43f9513299831abcce9bc67551ed1
|
4
|
+
data.tar.gz: eee3fc43d7e4d7aa106e7ff244f8029932feda94
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e984434cc1cd0c5fbe44f34b85a1fa75d520d2de2e635a0ba3e848ad195dcc6015e0cf00495e2cc41fe30fdfcb3988cbf2e7aac7a5c24d547f6c6a95dc3d998d
|
7
|
+
data.tar.gz: c5cc39b2699fb6da450f3c8dd32c4da5eadd11775820b3420af024d1376598ca51f09a4fae376b60ef6761cb75fe3323a411ecebfcf7ef0a51b4df7cf582e9a8
|
data/CHANGES.md
CHANGED
@@ -17,9 +17,16 @@ module Sqeduler
|
|
17
17
|
@maintainer_thread ||= Thread.new do
|
18
18
|
loop do
|
19
19
|
begin
|
20
|
-
|
20
|
+
if redis_lock.lock
|
21
|
+
begin
|
22
|
+
synchronize
|
23
|
+
ensure
|
24
|
+
redis_lock.unlock
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
21
28
|
rescue => ex
|
22
|
-
Service.logger.error "[
|
29
|
+
Service.logger.error "[#{self.class}] #{ex.class}, #{ex.message}"
|
23
30
|
end
|
24
31
|
|
25
32
|
sleep RUN_INTERVAL + rand(RUN_JITTER)
|
@@ -30,10 +37,6 @@ module Sqeduler
|
|
30
37
|
private
|
31
38
|
|
32
39
|
def synchronize
|
33
|
-
# Not great, but finding our identity in Sidekiq is a pain, and we already have locks in Sqeduler.
|
34
|
-
# Easier to just try and grab a lock each time and whichever server wins gets to do it.
|
35
|
-
return unless redis_lock.send(:take_lock)
|
36
|
-
|
37
40
|
now = Time.now.to_i
|
38
41
|
|
39
42
|
Service.redis_pool do |redis|
|
@@ -51,6 +54,9 @@ module Sqeduler
|
|
51
54
|
# We don't have to worry about atomic operations or anything like that.
|
52
55
|
# If the job finishes in the interim and deletes the key nothing will happen.
|
53
56
|
redis.expire(lock_key, klass.synchronize_jobs_expiration)
|
57
|
+
|
58
|
+
Service.logger.debug "[#{self.class}] Refreshing lock on '#{lock_key}" \
|
59
|
+
"to #{klass.synchronize_jobs_expiration} seconds"
|
54
60
|
end
|
55
61
|
end
|
56
62
|
end
|
@@ -64,10 +70,12 @@ module Sqeduler
|
|
64
70
|
if klass.respond_to?(:synchronize_jobs_mode)
|
65
71
|
# We only care about exclusive jobs that are long running
|
66
72
|
if klass.synchronize_jobs_mode == :one_at_a_time && klass.synchronize_jobs_expiration >= RUN_INTERVAL
|
73
|
+
Service.logger.debug "[#{self.class}] Adding #{class_name} to the whitelist of classes that have locks"
|
67
74
|
return @class_with_locks[class_name] = klass
|
68
75
|
end
|
69
76
|
end
|
70
77
|
|
78
|
+
Service.logger.debug "[#{self.class}] Adding #{class_name} to the blacklist of classes that have locks"
|
71
79
|
@class_with_locks[class_name] = false
|
72
80
|
end
|
73
81
|
|
data/lib/sqeduler/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sqeduler
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jared Jenkins
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-03-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sidekiq
|