canvas_sync 0.19.0.beta8 → 0.19.0.beta10
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3cd64554a1f451160b874e8901b7275a25b6f9c526d687a29e531abff9f0b285
|
4
|
+
data.tar.gz: 9cac31449a633b4c3513088abf00b0274b0ce794e54f72742d65802bf2bb5a8c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a479a1705e765b3e338c7aed688728436fbeedd82809218bcbd288775e9a2175c62d5294dc2a206fdb77a7945f0223be723b74e9ec6800635841124e42149c22
|
7
|
+
data.tar.gz: 96bef245b0ba1a4de671dfc1d49a184d35bd03fea62efad44dbaac1bdcff345cabd19b1f12147f1d334b967641ce72e9c66704e0709f55b5f2378475d39d9d86
|
@@ -493,12 +493,8 @@ module CanvasSync
|
|
493
493
|
|
494
494
|
def pipelined(*args, &block)
|
495
495
|
Batch.redis do |r|
|
496
|
-
|
497
|
-
|
498
|
-
block.call(r)
|
499
|
-
end
|
500
|
-
else
|
501
|
-
r.pipelined(*args, &block)
|
496
|
+
r.pipelined(*args) do |r2|
|
497
|
+
block.call(r2 || r)
|
502
498
|
end
|
503
499
|
end
|
504
500
|
end
|
@@ -90,7 +90,7 @@ module CanvasSync
|
|
90
90
|
|
91
91
|
activec, pactivec, pendingc, clean_when_empty, keep_open = redis.multi do |r|
|
92
92
|
r.hlen("#{redis_key}-active")
|
93
|
-
r.
|
93
|
+
r.hget(redis_key, "_active_count")
|
94
94
|
pending_count(r)
|
95
95
|
r.hget(redis_key, 'clean_when_empty')
|
96
96
|
r.hget(redis_key, 'keep_open')
|
@@ -98,7 +98,7 @@ module CanvasSync
|
|
98
98
|
|
99
99
|
return if keep_open == 'true' || clean_when_empty == 'false'
|
100
100
|
|
101
|
-
if activec <= 0 && pactivec <= 0 && pendingc <= 0
|
101
|
+
if activec <= 0 && (pactivec.try(:to_i) || 0) <= 0 && pendingc <= 0
|
102
102
|
cleanup_redis
|
103
103
|
end
|
104
104
|
end
|
@@ -125,9 +125,7 @@ module CanvasSync
|
|
125
125
|
end
|
126
126
|
|
127
127
|
def job_checked_in(status, options)
|
128
|
-
|
129
|
-
redis.hincrby(redis_key, "complete_count", 1)
|
130
|
-
active_count = refill_allotment
|
128
|
+
active_count = refill_allotment(status.bid)
|
131
129
|
cleanup_if_empty unless active_count > 0
|
132
130
|
end
|
133
131
|
|
@@ -150,8 +148,8 @@ module CanvasSync
|
|
150
148
|
"POOLID-#{pid}"
|
151
149
|
end
|
152
150
|
|
153
|
-
def refill_allotment
|
154
|
-
active_count, job_descs = POOL_REFILL.call(redis, [redis_key, "#{redis_key}-jobs", "#{redis_key}-active"], [])
|
151
|
+
def refill_allotment(checkin_bid = nil)
|
152
|
+
active_count, job_descs = POOL_REFILL.call(redis, [redis_key, "#{redis_key}-jobs", "#{redis_key}-active"], [checkin_bid || ""])
|
155
153
|
return active_count if active_count < 0
|
156
154
|
|
157
155
|
pending_job_descs = job_descs.dup
|
@@ -220,27 +218,6 @@ module CanvasSync
|
|
220
218
|
end
|
221
219
|
end
|
222
220
|
|
223
|
-
# @deprecated
|
224
|
-
def pop_job_from_pool
|
225
|
-
jobs_key = "#{redis_key}-jobs"
|
226
|
-
order = self.order || 'fifo'
|
227
|
-
|
228
|
-
job_json = case order.to_sym
|
229
|
-
when :fifo
|
230
|
-
redis.lpop(jobs_key)
|
231
|
-
when :lifo
|
232
|
-
redis.rpop(jobs_key)
|
233
|
-
when :random
|
234
|
-
redis.spop(jobs_key)
|
235
|
-
when :priority
|
236
|
-
redis.zpopmax(jobs_key)&.[](0)
|
237
|
-
end
|
238
|
-
|
239
|
-
return nil unless job_json.present?
|
240
|
-
|
241
|
-
::ActiveJob::Arguments.deserialize(JSON.parse(job_json))[0]&.symbolize_keys
|
242
|
-
end
|
243
|
-
|
244
221
|
def self.redis(&blk)
|
245
222
|
Batch.redis &blk
|
246
223
|
end
|
@@ -3,10 +3,17 @@ local poolkey = KEYS[1]
|
|
3
3
|
local qkey = KEYS[2]
|
4
4
|
local activekey = KEYS[3]
|
5
5
|
|
6
|
+
local checkin_item = ARGV[1]
|
7
|
+
|
6
8
|
if redis.call('EXISTS', poolkey) == 0 then
|
7
9
|
return { -1, {} } -- pool doesn't exist
|
8
10
|
end
|
9
11
|
|
12
|
+
if checkin_item ~= "" then
|
13
|
+
redis.call("HDEL", activekey, checkin_item)
|
14
|
+
redis.call("HINCRBY", poolkey, "complete_count", 1)
|
15
|
+
end
|
16
|
+
|
10
17
|
local pool_type = redis.call('HGET', poolkey, "order")
|
11
18
|
local allotment = tonumber(redis.call("HGET", poolkey, "concurrency"))
|
12
19
|
local active = redis.call("HLEN", activekey) + (redis.call("HGET", poolkey, "_active_count") or 0)
|
data/lib/canvas_sync/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: canvas_sync
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.19.0.
|
4
|
+
version: 0.19.0.beta10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Instructure CustomDev
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-03-
|
11
|
+
date: 2024-03-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|