sqeduler 0.3.2 → 0.3.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGES.md +4 -0
- data/lib/sqeduler/lock_maintainer.rb +1 -1
- data/lib/sqeduler/version.rb +1 -1
- data/spec/lock_maintainer_spec.rb +15 -10
- 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: 285c8e84ead9c7c09c993c9dd758dde10dd1e9f1
|
4
|
+
data.tar.gz: 3fa620e267de5111437ed61a7993ea9e6ce9f248
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 18bed5ddc6ea2b8f34a5dd5817c49c9841912307a0dfe4e864dfae796e561a4e5e571132a20f4344ac8c049164795aa601b76dfe81232486c6801137d5a65825
|
7
|
+
data.tar.gz: 1fcfd239f05867d25212d83ba47c0fb28794d28799ffed3b7c4dafecca225af13c48373f321ad536424b1f73b45d69ed2609764bf9020b8f438ec5385c7e0558
|
data/CHANGES.md
CHANGED
@@ -39,7 +39,7 @@ module Sqeduler
|
|
39
39
|
def synchronize
|
40
40
|
now = Time.now.to_i
|
41
41
|
|
42
|
-
Service.redis_pool do |redis|
|
42
|
+
Service.redis_pool.with do |redis|
|
43
43
|
redis.pipelined do
|
44
44
|
workers.each do |_worker, _tid, args|
|
45
45
|
# No sense in pinging if it's not been running long enough to matter
|
data/lib/sqeduler/version.rb
CHANGED
@@ -58,6 +58,8 @@ RSpec.describe Sqeduler::LockMaintainer do
|
|
58
58
|
|
59
59
|
run.join(1)
|
60
60
|
run.terminate
|
61
|
+
|
62
|
+
expect(instance.send(:redis_lock).locked?).to eq(false)
|
61
63
|
end
|
62
64
|
|
63
65
|
it "doesn't die on errors" do
|
@@ -67,6 +69,16 @@ RSpec.describe Sqeduler::LockMaintainer do
|
|
67
69
|
expect(run.status).to_not be_falsy
|
68
70
|
run.terminate
|
69
71
|
end
|
72
|
+
|
73
|
+
it "obeys the exclusive lock" do
|
74
|
+
lock = Sqeduler::RedisLock.new("sqeduler-lock-maintainer", :expiration => 60, :timeout => 0)
|
75
|
+
lock.lock
|
76
|
+
|
77
|
+
expect(instance).to_not receive(:synchronize)
|
78
|
+
|
79
|
+
run.join(1)
|
80
|
+
run.terminate
|
81
|
+
end
|
70
82
|
end
|
71
83
|
|
72
84
|
context "#synchronize" do
|
@@ -121,13 +133,13 @@ RSpec.describe Sqeduler::LockMaintainer do
|
|
121
133
|
end
|
122
134
|
|
123
135
|
context "when outside the run threshold" do
|
124
|
-
let(:run_at) { Time.now - described_class::RUN_INTERVAL - 5 }
|
136
|
+
let(:run_at) { (Time.now - described_class::RUN_INTERVAL - 5).to_i }
|
125
137
|
|
126
138
|
let(:lock_key) { SyncExclusiveWorker.sync_lock_key(job_args) }
|
127
139
|
|
128
140
|
it "refresh the lock" do
|
129
141
|
SyncExclusiveWorker.new.perform(job_args) do
|
130
|
-
Sqeduler::Service.redis_pool do |redis|
|
142
|
+
Sqeduler::Service.redis_pool.with do |redis|
|
131
143
|
# Change the lock timing to make sure ours works
|
132
144
|
redis.expire(lock_key, 10)
|
133
145
|
expect(redis.ttl(lock_key)).to eq(10)
|
@@ -141,17 +153,10 @@ RSpec.describe Sqeduler::LockMaintainer do
|
|
141
153
|
end
|
142
154
|
|
143
155
|
# Shouldn't be around once the job finished
|
144
|
-
Sqeduler::Service.redis_pool do |redis|
|
156
|
+
Sqeduler::Service.redis_pool.with do |redis|
|
145
157
|
expect(redis.exists(lock_key)).to eq(false)
|
146
158
|
end
|
147
159
|
end
|
148
|
-
|
149
|
-
it "obeys the exclusive lock" do
|
150
|
-
instance.send(:redis_lock).send(:take_lock)
|
151
|
-
expect(instance).to_not receive(:str_to_class)
|
152
|
-
|
153
|
-
sync
|
154
|
-
end
|
155
160
|
end
|
156
161
|
end
|
157
162
|
|
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.3
|
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-03-
|
11
|
+
date: 2016-03-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sidekiq
|