canvas_sync 0.19.0.beta8 → 0.19.0.beta9

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: 016fb182ae3234080415fdcd2283d6d05b40cc77c5ed36cfb3345c42b17d39b3
4
- data.tar.gz: 3d485ca044b6f377aee719156206e6ca6a59ce2ff489c9b4d84ba713c7500ca8
3
+ metadata.gz: f1552d94643db48ef054d304102ffe1afcad0a7d149ace187a5b10f0d9e35c8b
4
+ data.tar.gz: e9d91a46ade6380bbd48a4c51dd540a8df65de64228107c400f4567ec13e64d0
5
5
  SHA512:
6
- metadata.gz: 5bff1ac3d68f5b01aed96f19cc66d61af8d23db671b14bc354397b8217fc30a103a63aa7c200771b15b756a784423ab2f92eeac598a1939938ced433a7eb11af
7
- data.tar.gz: 5b38641379b39c8d3f85b01d6e06c1771a6ceb85e13d8878baa4b0ab1ae3a3f7e091776a5e77245b516f85c49f9c7c5cd56b4f570d936eb1bc3aae38b28b3055
6
+ metadata.gz: 9904cb4fab07d92c2c0bbc64b308197b28a4652064e1d6992955f393f2b8a55e9f7f22b01dbb02f6de94df97f1743a52eb2d08c9a8e55a60e8606f234dc6c7d7
7
+ data.tar.gz: f80dfe46eb813956444932d943fd3236cd384205b359f42138553dd92441bc887c959b392d848e056f23d59a957d52394e93b5a2c63092fae225778d46118ecd
@@ -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.hincrby(redis_key, "_active_count", 0)
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
- redis.hdel("#{redis_key}-active", status.bid)
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)
@@ -1,3 +1,3 @@
1
1
  module CanvasSync
2
- VERSION = "0.19.0.beta8".freeze
2
+ VERSION = "0.19.0.beta9".freeze
3
3
  end
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.beta8
4
+ version: 0.19.0.beta9
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-07 00:00:00.000000000 Z
11
+ date: 2024-03-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails