canvas_sync 0.17.0.beta6 → 0.17.0.beta7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/canvas_sync/job_batches/batch.rb +43 -35
- data/lib/canvas_sync/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 92aceb45ca42ac3cedcb449ea12ee0c04f437239ccc7375995f56939216ea473
|
4
|
+
data.tar.gz: 37b66818e5ba35d6b0d159ef817cbaf3c8bf66b8194e21c85876f2fdebaa30a0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 22b6826841d14ef7c9bbde34ba0d17484183a8f48247167b08b4332ced3b2b8e5bff7d2d4ea6e6e8246ea720efd79998b46768c973303094839104804c827e26
|
7
|
+
data.tar.gz: da90ec118b97081ce4f54de372e288d0033f76d91e1401ef1bcf70d7a62d589a0e08df18a83030da4e2f0b14bffe51cc33b3b97c198ec7f70f58874b118c2fd2
|
@@ -118,7 +118,7 @@ module CanvasSync
|
|
118
118
|
@initialized = true
|
119
119
|
end
|
120
120
|
|
121
|
-
@ready_to_queue = []
|
121
|
+
job_queue = @ready_to_queue = []
|
122
122
|
|
123
123
|
puts "Beginning Batch #{@bidkey}"
|
124
124
|
|
@@ -127,33 +127,20 @@ module CanvasSync
|
|
127
127
|
Thread.current[:batch] = self
|
128
128
|
yield
|
129
129
|
ensure
|
130
|
+
@ready_to_queue = nil
|
131
|
+
append_jobs(job_queue)
|
130
132
|
Thread.current[:batch] = parent
|
131
133
|
end
|
132
134
|
|
133
|
-
|
134
|
-
r.multi do
|
135
|
-
if parent_bid
|
136
|
-
r.hincrby("BID-#{parent_bid}", "children", 1)
|
137
|
-
r.hincrby("BID-#{parent_bid}", "total", @ready_to_queue.size)
|
138
|
-
r.expire("BID-#{parent_bid}", BID_EXPIRE_TTL)
|
139
|
-
end
|
140
|
-
|
141
|
-
r.hincrby(@bidkey, "pending", @ready_to_queue.size)
|
142
|
-
r.hincrby(@bidkey, "total", @ready_to_queue.size)
|
143
|
-
r.expire(@bidkey, BID_EXPIRE_TTL)
|
144
|
-
|
145
|
-
if @ready_to_queue.size > 0
|
146
|
-
r.sadd(@bidkey + "-jids", @ready_to_queue)
|
147
|
-
r.expire(@bidkey + "-jids", BID_EXPIRE_TTL)
|
148
|
-
end
|
149
|
-
end
|
150
|
-
end
|
151
|
-
|
152
|
-
@ready_to_queue
|
135
|
+
job_queue
|
153
136
|
end
|
154
137
|
|
155
138
|
def increment_job_queue(jid)
|
156
|
-
@ready_to_queue
|
139
|
+
if @ready_to_queue
|
140
|
+
@ready_to_queue << jid
|
141
|
+
else
|
142
|
+
append_jobs([jid])
|
143
|
+
end
|
157
144
|
end
|
158
145
|
|
159
146
|
def invalidate_all
|
@@ -216,6 +203,27 @@ module CanvasSync
|
|
216
203
|
@pending_attrs = {}
|
217
204
|
end
|
218
205
|
|
206
|
+
def append_jobs(jids)
|
207
|
+
redis do |r|
|
208
|
+
r.multi do
|
209
|
+
if parent_bid
|
210
|
+
r.hincrby("BID-#{parent_bid}", "children", 1)
|
211
|
+
r.hincrby("BID-#{parent_bid}", "total", jids.size)
|
212
|
+
r.expire("BID-#{parent_bid}", BID_EXPIRE_TTL)
|
213
|
+
end
|
214
|
+
|
215
|
+
r.hincrby(@bidkey, "pending", jids.size)
|
216
|
+
r.hincrby(@bidkey, "total", jids.size)
|
217
|
+
r.expire(@bidkey, BID_EXPIRE_TTL)
|
218
|
+
|
219
|
+
if jids.size > 0
|
220
|
+
r.sadd(@bidkey + "-jids", jids)
|
221
|
+
r.expire(@bidkey + "-jids", BID_EXPIRE_TTL)
|
222
|
+
end
|
223
|
+
end
|
224
|
+
end
|
225
|
+
end
|
226
|
+
|
219
227
|
class << self
|
220
228
|
def process_failed_job(bid, jid)
|
221
229
|
_, pending, failed, children, complete, parent_bid = redis do |r|
|
@@ -361,19 +369,19 @@ module CanvasSync
|
|
361
369
|
|
362
370
|
def cleanup_redis(bid)
|
363
371
|
logger.debug {"Cleaning redis of batch #{bid}"}
|
364
|
-
redis do |r|
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
end
|
372
|
+
# redis do |r|
|
373
|
+
# r.del(
|
374
|
+
# "BID-#{bid}",
|
375
|
+
# "BID-#{bid}-callbacks-complete",
|
376
|
+
# "BID-#{bid}-callbacks-success",
|
377
|
+
# "BID-#{bid}-failed",
|
378
|
+
|
379
|
+
# "BID-#{bid}-batches-success",
|
380
|
+
# "BID-#{bid}-batches-complete",
|
381
|
+
# "BID-#{bid}-batches-failed",
|
382
|
+
# "BID-#{bid}-jids",
|
383
|
+
# )
|
384
|
+
# end
|
377
385
|
end
|
378
386
|
|
379
387
|
def redis(*args, &blk)
|
data/lib/canvas_sync/version.rb
CHANGED