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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 00bad4ee593106421544ae0ec2e99c8d5376c48450ce924774f00bc936130bee
4
- data.tar.gz: 21341abba869bf4c375b5d7fa00d5c165b6901fc38bcbe76c1bff9873ef2437d
3
+ metadata.gz: 92aceb45ca42ac3cedcb449ea12ee0c04f437239ccc7375995f56939216ea473
4
+ data.tar.gz: 37b66818e5ba35d6b0d159ef817cbaf3c8bf66b8194e21c85876f2fdebaa30a0
5
5
  SHA512:
6
- metadata.gz: e9def679518392df1a99842b1afa51b0804718ebc7c5b8d652001c5b4fa07463171cb14ba187c092b78c4abf6cc127184fa2ba752a473b14e0330cdd0ff8182c
7
- data.tar.gz: d4e0b07807371ab31c55527aeee07ef756708bd2acccd0de4467f8bc15473e70de0a552caa704b4cb805b06aa98edb6cc49a80c67a5b51b3a029056e736236ce
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
- redis do |r|
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 << jid
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
- r.del(
366
- "BID-#{bid}",
367
- "BID-#{bid}-callbacks-complete",
368
- "BID-#{bid}-callbacks-success",
369
- "BID-#{bid}-failed",
370
-
371
- "BID-#{bid}-batches-success",
372
- "BID-#{bid}-batches-complete",
373
- "BID-#{bid}-batches-failed",
374
- "BID-#{bid}-jids",
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)
@@ -1,3 +1,3 @@
1
1
  module CanvasSync
2
- VERSION = "0.17.0.beta6".freeze
2
+ VERSION = "0.17.0.beta7".freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: canvas_sync
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.17.0.beta6
4
+ version: 0.17.0.beta7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nate Collings