delayed_job_active_record 4.1.0 → 4.1.1

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
  SHA1:
3
- metadata.gz: ef929cbdb8454d37f3c65c7c1ef5c35af9c58bda
4
- data.tar.gz: 3e07fc038e9b3f5070f82db76567998b6a78dbc9
3
+ metadata.gz: 3fd97d1444b2e5cbf2bfa22b304cde221619558d
4
+ data.tar.gz: 000b0e8eedbd1c0d2f470288d03f3349bf72f2d8
5
5
  SHA512:
6
- metadata.gz: 02ba4660e00fb9fd21fc324c7796c545a894954dd2d08f6fb733f508187afbee91768c86d1cb0f8792bcac61345041c30dcd741c94b9f140621cb96a83db375e
7
- data.tar.gz: e94cc064175c69d4b09751c0fcb4d05390ec5e3a6fbaae090c4afc7641a8a76cbc52ab2434dbac24eff55216adb9728d2b3d1d96f1b68d2d41e9c36c3a66cac9
6
+ metadata.gz: 689515b8aa68f2395b5f5d3ab31f0b2fb8098bb8cdc8f3f93eb1cbcd93db84d6cb78db67e43e1b6fe93f999bd3a9d61aecf3138ec17a0bac6439c9600a387ec6
7
+ data.tar.gz: 2488595100525ad2b22c1112dd6a90e37507e47342e6fdb936d5ba465662dac49e0092b91d1a03bf6feb7facfaf1624161456ae682d1733943231b6c8848c14f
data/README.md CHANGED
@@ -1,3 +1,8 @@
1
+ **If you're viewing this at https://github.com/collectiveidea/delayed_job_active_record,
2
+ you're reading the documentation for the master branch.
3
+ [View documentation for the latest release
4
+ (4.1.0).](https://github.com/collectiveidea/delayed_job_active_record/tree/v4.1.0)**
5
+
1
6
  # DelayedJob ActiveRecord Backend
2
7
 
3
8
  [![Gem Version](https://badge.fury.io/rb/delayed_job_active_record.png)](https://rubygems.org/gems/delayed_job_active_record)
@@ -20,6 +25,12 @@ delayed_job table.
20
25
  rails g delayed_job:active_record
21
26
  rake db:migrate
22
27
 
28
+ ## Problems locking jobs
29
+
30
+ You can try using the legacy locking code. It is usually slower but works better for certain people.
31
+
32
+ Delayed::Backend::ActiveRecord.configuration.reserve_sql_strategy = :default_sql
33
+
23
34
  ## Upgrading from 2.x to 3.0.0
24
35
 
25
36
  If you're upgrading from Delayed Job 2.x, run the upgrade generator to create a
@@ -1,5 +1,5 @@
1
1
  Gem::Specification.new do |spec|
2
- spec.add_dependency "activerecord", [">= 3.0", "< 5"]
2
+ spec.add_dependency "activerecord", [">= 3.0", "< 5.1"]
3
3
  spec.add_dependency "delayed_job", [">= 3.0", "< 5"]
4
4
  spec.authors = ["Brian Ryckbost", "Matt Griffin", "Erik Michaels-Ober"]
5
5
  spec.description = "ActiveRecord backend for Delayed::Job, originally authored by Tobias Lütke"
@@ -10,5 +10,5 @@ Gem::Specification.new do |spec|
10
10
  spec.name = "delayed_job_active_record"
11
11
  spec.require_paths = ["lib"]
12
12
  spec.summary = "ActiveRecord backend for DelayedJob"
13
- spec.version = "4.1.0"
13
+ spec.version = "4.1.1"
14
14
  end
@@ -2,6 +2,27 @@ require "active_record/version"
2
2
  module Delayed
3
3
  module Backend
4
4
  module ActiveRecord
5
+ class Configuration
6
+ attr_reader :reserve_sql_strategy
7
+
8
+ def initialize
9
+ self.reserve_sql_strategy = :optimized_sql
10
+ end
11
+
12
+ def reserve_sql_strategy=(val)
13
+ raise ArgumentError, "allowed values are :optimized_sql or :default_sql" unless val == :optimized_sql || val == :default_sql
14
+ @reserve_sql_strategy = val
15
+ end
16
+ end
17
+
18
+ def self.configuration
19
+ @configuration ||= Configuration.new
20
+ end
21
+
22
+ def self.configure
23
+ yield(configuration)
24
+ end
25
+
5
26
  # A job object that is persisted to the database.
6
27
  # Contains the work object as a YAML field.
7
28
  class Job < ::ActiveRecord::Base
@@ -54,7 +75,18 @@ module Delayed
54
75
  end
55
76
 
56
77
  def self.reserve_with_scope(ready_scope, worker, now)
78
+ case Delayed::Backend::ActiveRecord.configuration.reserve_sql_strategy
57
79
  # Optimizations for faster lookups on some common databases
80
+ when :optimized_sql
81
+ reserve_with_scope_using_optimized_sql(ready_scope, worker, now)
82
+ # Slower but in some cases more unproblematic strategy to lookup records
83
+ # See https://github.com/collectiveidea/delayed_job_active_record/pull/89 for more details.
84
+ when :default_sql
85
+ reserve_with_scope_using_default_sql(ready_scope, worker, now)
86
+ end
87
+ end
88
+
89
+ def self.reserve_with_scope_using_optimized_sql(ready_scope, worker, now)
58
90
  case connection.adapter_name
59
91
  when "PostgreSQL"
60
92
  # Custom SQL required for PostgreSQL because postgres does not support UPDATE...LIMIT
@@ -91,6 +123,7 @@ module Delayed
91
123
  return nil if count == 0
92
124
  # MSSQL JDBC doesn't support OUTPUT INSERTED.* for returning a result set, so query locked row
93
125
  where(locked_at: now, locked_by: worker.name, failed_at: nil).first
126
+ # Fallback for unknown / other DBMS
94
127
  else
95
128
  reserve_with_scope_using_default_sql(ready_scope, worker, now)
96
129
  end
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.0
4
+ version: 4.1.1
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: 2015-09-24 00:00:00.000000000 Z
13
+ date: 2016-05-16 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: '5'
24
+ version: '5.1'
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: '5'
34
+ version: '5.1'
35
35
  - !ruby/object:Gem::Dependency
36
36
  name: delayed_job
37
37
  requirement: !ruby/object:Gem::Requirement
@@ -93,7 +93,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
93
93
  version: '0'
94
94
  requirements: []
95
95
  rubyforge_project:
96
- rubygems_version: 2.4.8
96
+ rubygems_version: 2.5.1
97
97
  signing_key:
98
98
  specification_version: 4
99
99
  summary: ActiveRecord backend for DelayedJob