inst-jobs 3.1.5 → 3.1.6

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: 5adf88a85cf490a4fee0b3e8b5234be47b0f70034f6a89489ace8a132c74886d
4
- data.tar.gz: '07836a394917c38fcb1cba64a9a1988f3c949bb7e147247f759da8f860382a7f'
3
+ metadata.gz: e33f94a9740d7ecb8c90f2473450468397ac1c3df195a5c7a957ea7d10861cb1
4
+ data.tar.gz: '0820afd8c1ffde55f0c1ff8ef31ca37e020e8cfe7ae8068aca476473ee4ea5e3'
5
5
  SHA512:
6
- metadata.gz: 8fc62248de29a57be2044a0949299ac26475df434c4906f0786293bb07b3a7bf63fb1c2b79c3e230e992825984e76417eb9ad221a46bac5c78b92d305c2db638
7
- data.tar.gz: 44a04dcfd05ecad3345bd9da25909711912edaaf16e9f6a502859765319de33e0a59ac840571b5f5e543b76ce40b43550ab9a750e56753c60c29886002894201
6
+ metadata.gz: 10d3bd5fb8193811f144aa094f2d81e1366efe9d476ec5f9b3386637e1f59b8d0c362fed2208f3f5e6f771def087bed5eeb7a04057b098c3ee8d441562d5efe7
7
+ data.tar.gz: d7d8f75f6e4d75b23003a018694dc17973e05a88e0408687deaf64c20cb81174ef65ad1b852aa5e1bed9141f590d107ce694a793229ca23db0180600ab58a602
@@ -320,6 +320,24 @@ module Delayed
320
320
  scope.order(Arel.sql("COUNT(tag) DESC")).count.map { |t, c| { tag: t, count: c } }
321
321
  end
322
322
 
323
+ # given a scope of non-stranded queued jobs, apply a temporary strand to throttle their execution
324
+ # returns [job_count, new_strand]
325
+ # (this is designed for use in a Rails console or the Canvas Jobs interface)
326
+ def self.apply_temp_strand!(job_scope, max_concurrent: 1)
327
+ if job_scope.where("strand IS NOT NULL OR singleton IS NOT NULL").exists?
328
+ raise ArgumentError, "can't apply strand to already stranded jobs"
329
+ end
330
+
331
+ job_count = 0
332
+ new_strand = "tmp_strand_#{SecureRandom.alphanumeric(16)}"
333
+ ::Delayed::Job.transaction do
334
+ job_count = job_scope.update_all(strand: new_strand, max_concurrent: max_concurrent, next_in_strand: false)
335
+ ::Delayed::Job.where(strand: new_strand).order(:id).limit(max_concurrent).update_all(next_in_strand: true)
336
+ end
337
+
338
+ [job_count, new_strand]
339
+ end
340
+
323
341
  def self.maybe_silence_periodic_log(&block)
324
342
  if Settings.silence_periodic_log
325
343
  ::ActiveRecord::Base.logger.silence(&block)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Delayed
4
- VERSION = "3.1.5"
4
+ VERSION = "3.1.6"
5
5
  end
metadata CHANGED
@@ -1,16 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: inst-jobs
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.5
4
+ version: 3.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cody Cutrer
8
8
  - Ethan Vizitei
9
9
  - Jacob Burroughs
10
- autorequire:
10
+ autorequire:
11
11
  bindir: exe
12
12
  cert_chain: []
13
- date: 2022-07-07 00:00:00.000000000 Z
13
+ date: 2022-10-25 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activerecord
@@ -192,14 +192,14 @@ dependencies:
192
192
  requirements:
193
193
  - - "~>"
194
194
  - !ruby/object:Gem::Version
195
- version: 2.5.1
195
+ version: 2.6.3
196
196
  type: :development
197
197
  prerelease: false
198
198
  version_requirements: !ruby/object:Gem::Requirement
199
199
  requirements:
200
200
  - - "~>"
201
201
  - !ruby/object:Gem::Version
202
- version: 2.5.1
202
+ version: 2.6.3
203
203
  - !ruby/object:Gem::Dependency
204
204
  name: pg
205
205
  requirement: !ruby/object:Gem::Requirement
@@ -410,7 +410,7 @@ dependencies:
410
410
  - - ">="
411
411
  - !ruby/object:Gem::Version
412
412
  version: '0'
413
- description:
413
+ description:
414
414
  email:
415
415
  - cody@instructure.com
416
416
  - evizitei@instructure.com
@@ -504,7 +504,7 @@ homepage: https://github.com/instructure/inst-jobs
504
504
  licenses: []
505
505
  metadata:
506
506
  rubygems_mfa_required: 'true'
507
- post_install_message:
507
+ post_install_message:
508
508
  rdoc_options: []
509
509
  require_paths:
510
510
  - lib
@@ -520,7 +520,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
520
520
  version: '0'
521
521
  requirements: []
522
522
  rubygems_version: 3.1.6
523
- signing_key:
523
+ signing_key:
524
524
  specification_version: 4
525
525
  summary: Instructure-maintained fork of delayed_job
526
526
  test_files: []