delayed_job_active_record 4.1.4 → 4.1.5

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: 34b98bb9055f3859d08f79f718c41a32010f49af901dc106a71d09599096b2ac
4
- data.tar.gz: 917eaf5a7b4e2752a69dcaffa1e24d63d6b258cbfe54c53c8a5014d7c1f02b8e
3
+ metadata.gz: 1799d6d0f6301b5285da09c332bfe6abeb6cfb60b410a29e93f94a99aa0313b7
4
+ data.tar.gz: a1b0adfed07a2a7f47603390156688e193aed7bcc187184c9812b72e182fb859
5
5
  SHA512:
6
- metadata.gz: ad865a5de93e631550580611f794f34847707770bb7c8dbb64dcaa92d9ef36b4168dc618daedb770c9b69fbdd55fff920bc47c0267ca695a568dfeda00a16b34
7
- data.tar.gz: f1c84d310f8ccfd17879bd368d3434c764c26341f1fb4035a5f1141ae647773268c1ce2c6e1daee2635e0bcfd73019cc6c220807d38bed8a3ca9618ba5c3de53
6
+ metadata.gz: c17b88c4d64f8698405c1cf9918b887baecbd2366d42a71d4d02879227d339aba4de0ba3419fc3a4cc0272b193769709efb86fd95f251a08afa4e9c00d07ac58
7
+ data.tar.gz: 9d8bc65f7e959d71264c8d46d2cff8c2409a975755be9c5a9f0387d033bf1054d76c20e56a0dd685f7556b9cde282dd7c76818f733c9ad9e28fc9e7cbaa67da1
data/README.md CHANGED
@@ -1,12 +1,12 @@
1
1
  **If you're viewing this at https://github.com/collectiveidea/delayed_job_active_record,
2
2
  you're reading the documentation for the master branch.
3
3
  [View documentation for the latest release
4
- (4.1.4).](https://github.com/collectiveidea/delayed_job_active_record/tree/v4.1.4)**
4
+ (4.1.5).](https://github.com/collectiveidea/delayed_job_active_record/tree/v4.1.5)**
5
5
 
6
6
  # DelayedJob ActiveRecord Backend
7
7
 
8
8
  [![Gem Version](https://img.shields.io/gem/v/delayed_job_active_record.svg)](https://rubygems.org/gems/delayed_job_active_record)
9
- [![Build Status](https://img.shields.io/travis/collectiveidea/delayed_job_active_record.svg)](https://travis-ci.org/collectiveidea/delayed_job_active_record)
9
+ ![CI](https://github.com/collectiveidea/delayed_job_active_record/workflows/CI/badge.svg)
10
10
  [![Coverage Status](https://img.shields.io/coveralls/collectiveidea/delayed_job_active_record.svg)](https://coveralls.io/r/collectiveidea/delayed_job_active_record)
11
11
 
12
12
  ## Installation
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  Gem::Specification.new do |spec|
4
- spec.add_dependency "activerecord", [">= 3.0", "< 6.1"]
4
+ spec.add_dependency "activerecord", [">= 3.0", "< 6.2"]
5
5
  spec.add_dependency "delayed_job", [">= 3.0", "< 5"]
6
6
  spec.authors = ["Brian Ryckbost", "Matt Griffin", "Erik Michaels-Ober"]
7
7
  spec.description = "ActiveRecord backend for Delayed::Job, originally authored by Tobias Lütke"
@@ -12,5 +12,5 @@ Gem::Specification.new do |spec|
12
12
  spec.name = "delayed_job_active_record"
13
13
  spec.require_paths = ["lib"]
14
14
  spec.summary = "ActiveRecord backend for DelayedJob"
15
- spec.version = "4.1.4"
15
+ spec.version = "4.1.5"
16
16
  end
@@ -54,7 +54,7 @@ module Delayed
54
54
 
55
55
  def self.ready_to_run(worker_name, max_run_time)
56
56
  where(
57
- "(run_at <= ? AND (locked_at IS NULL OR locked_at < ?) OR locked_by = ?) AND failed_at IS NULL",
57
+ "((run_at <= ? AND (locked_at IS NULL OR locked_at < ?)) OR locked_by = ?) AND failed_at IS NULL",
58
58
  db_time_now,
59
59
  db_time_now - max_run_time,
60
60
  worker_name
@@ -112,8 +112,11 @@ module Delayed
112
112
  end
113
113
 
114
114
  def self.reserve_with_scope_using_default_sql(ready_scope, worker, now)
115
- # This is our old fashion, tried and true, but slower lookup
116
- ready_scope.limit(worker.read_ahead).detect do |job|
115
+ # This is our old fashion, tried and true, but possibly slower lookup
116
+ # Instead of reading the entire job record for our detect loop, we select only the id,
117
+ # and only read the full job record after we've successfully locked the job.
118
+ # This can have a noticable impact on large read_ahead configurations and large payload jobs.
119
+ ready_scope.limit(worker.read_ahead).select(:id).detect do |job|
117
120
  count = ready_scope.where(id: job.id).update_all(locked_at: now, locked_by: worker.name)
118
121
  count == 1 && job.reload
119
122
  end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Delayed
4
+ module Backend
5
+ module ActiveRecord
6
+ class Railtie < ::Rails::Railtie
7
+ config.after_initialize do
8
+ require "delayed/backend/active_record"
9
+ Delayed::Worker.backend = :active_record
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end
@@ -1,7 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "active_record"
4
3
  require "delayed_job"
5
- require "delayed/backend/active_record"
6
4
 
7
- Delayed::Worker.backend = :active_record
5
+ if defined?(Rails::Railtie)
6
+ require "delayed/backend/active_record/railtie"
7
+ else
8
+ require "active_record"
9
+ require "delayed/backend/active_record"
10
+
11
+ Delayed::Worker.backend = :active_record
12
+ end
@@ -1,6 +1,6 @@
1
1
  class CreateDelayedJobs < ActiveRecord::Migration<%= migration_version %>
2
2
  def self.up
3
- create_table :delayed_jobs, force: true do |table|
3
+ create_table :delayed_jobs do |table|
4
4
  table.integer :priority, default: 0, null: false # Allows some jobs to jump to the front of the queue
5
5
  table.integer :attempts, default: 0, null: false # Provides for retries, but still fail eventually.
6
6
  table.text :handler, null: false # YAML-encoded string of the object that will do work
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: delayed_job_active_record
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.1.4
4
+ version: 4.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Ryckbost
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2019-08-20 00:00:00.000000000 Z
13
+ date: 2020-12-09 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activerecord
@@ -21,7 +21,7 @@ dependencies:
21
21
  version: '3.0'
22
22
  - - "<"
23
23
  - !ruby/object:Gem::Version
24
- version: '6.1'
24
+ version: '6.2'
25
25
  type: :runtime
26
26
  prerelease: false
27
27
  version_requirements: !ruby/object:Gem::Requirement
@@ -31,7 +31,7 @@ dependencies:
31
31
  version: '3.0'
32
32
  - - "<"
33
33
  - !ruby/object:Gem::Version
34
- version: '6.1'
34
+ version: '6.2'
35
35
  - !ruby/object:Gem::Dependency
36
36
  name: delayed_job
37
37
  requirement: !ruby/object:Gem::Requirement
@@ -67,6 +67,7 @@ files:
67
67
  - README.md
68
68
  - delayed_job_active_record.gemspec
69
69
  - lib/delayed/backend/active_record.rb
70
+ - lib/delayed/backend/active_record/railtie.rb
70
71
  - lib/delayed_job_active_record.rb
71
72
  - lib/generators/delayed_job/active_record_generator.rb
72
73
  - lib/generators/delayed_job/next_migration_version.rb