delayed_job-active_job 1.0.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 73a9d8e3e9c660ca02a3912662159c63885f34fee8a5b979443022a6ef6e8c64
4
- data.tar.gz: 3c7dc284a05854437c0a870b497327561e7c3e6d5d1e2f74e735585d07713418
3
+ metadata.gz: e3317716ec9921e5a12cb006308a17d10b0b2e6e1d9bac8efe76d88a4a1fbed2
4
+ data.tar.gz: 85264227d8d76686f6a3c710c3b25ba1d3994113552fcf6122bbf404a8ea45d1
5
5
  SHA512:
6
- metadata.gz: b20d80faf8e3bc9ba422c8079c1f7bae1183aeaca711820999c42ae293c205390ad0624dfc5aefa830876dbe3ec1d4f6d8f115dbe5764a324669f8e64075e061
7
- data.tar.gz: b5726d299fbd037909bc3e14093f6d369f5f3dfd705e127a4e64da7384737b282a9071bc24e131e116e02b82797547c6f38d10de6a7fa526bd8c5e1b506401e1
6
+ metadata.gz: 4a20e2438aa1884332230ea31d1ce037d48b02aad06511064763a8cf085191e3bacd5b887557785ad9b907441fcd089f664f0c736efb36bb7e504ea7403dbb99
7
+ data.tar.gz: 4f543211de1e67f546234d21a6d647f861529e0674f90c77119c362fc47522d49a026cd75e89c70e83a69849f98e458285dbaeef5593d4d4788e2d42e9ac1eea
data/README.md CHANGED
@@ -8,15 +8,16 @@ The Delayed Job adapter will be [removed from Rails soon](https://github.com/rai
8
8
 
9
9
  If you are using a version of Rails that includes a Delayed Job adapter, using this gem will replace Rails' version with this gem's.
10
10
 
11
- This gem implements some new features beyond what the Rails adapter did:
11
+ This gem implements some new features beyond what the Rails adapter did. See [features](#features) for instructions.
12
12
 
13
13
  - Support for [`perform_all_later`](https://github.com/rails/rails/pull/46603).
14
- - You can set `run_at` directly on a job instance.
14
+ - You can set `run_at` when bulk enqueueing.
15
15
  - You can persist extra attributes on a job by writing to `job_attributes`.
16
16
 
17
17
  ---
18
18
 
19
19
  - [Quick start](#quick-start)
20
+ - [Features](#features)
20
21
  - [Support](#support)
21
22
  - [License](#license)
22
23
  - [Contribution guide](#contribution-guide)
@@ -34,6 +35,44 @@ Configure the Active Job backend. [See the Rails docs for more information](http
34
35
  config.active_job.queue_adapter = :delayed_job
35
36
  ```
36
37
 
38
+ ## Features
39
+
40
+ This gem supports all the base functionality of any Active Job adapter. So anything in https://guides.rubyonrails.org/active_job_basics.html should work. If it doesn't please log an issue.
41
+
42
+ ### `perform_all_later`
43
+
44
+ ```ruby
45
+ ActiveJob.perform_all_later([HelloJob.new("Jamie"), HelloJob.new("John"), HelloJob.new("Alex")])
46
+ ```
47
+
48
+ Under the hood, this uses `Delayed::Job.insert_all` to insert all the jobs into the database using a single SQL query.
49
+
50
+ ### Set `run_at` when bulk enqueueing
51
+
52
+ ```ruby
53
+ job = HelloJob.new("Alex")
54
+ job.run_at = 1.hour.from_now
55
+ ActiveJob.perform_all_later([job])
56
+ ```
57
+
58
+ This is the equivalent to `HelloJob.set(wait: 1.hour).perform_later("Alex")`.
59
+
60
+ ### Extra attributes via `job_attributes`
61
+
62
+ ```ruby
63
+ job = HelloJob.new("Alex")
64
+ job.job_attributes = { metadata: "foo" }
65
+ job.enqueue
66
+ ```
67
+
68
+ ```ruby
69
+ job = HelloJob.new("Alex")
70
+ job.job_attributes = { metadata: "foo" }
71
+ ActiveJob.perform_all_later([job])
72
+ ```
73
+
74
+ These examples would write `"foo"` into the `metadata` column on the `delayed_jobs` table. This works with any type of column, not just strings.
75
+
37
76
  ## Support
38
77
 
39
78
  If you want to report a bug, or have ideas, feedback or questions about the gem, [let me know via GitHub issues](https://github.com/TandaHQ/delayed_job-active_job/issues/new) and I will do my best to provide a helpful answer. Happy hacking!
@@ -2,6 +2,6 @@
2
2
 
3
3
  module DelayedJob
4
4
  module ActiveJob
5
- VERSION = "1.0.0"
5
+ VERSION = "1.1.0"
6
6
  end
7
7
  end
@@ -21,7 +21,7 @@ module ActiveJob
21
21
  # Rails.application.config.active_job.queue_adapter = :delayed_job
22
22
  class DelayedJobAdapter < ActiveJob::QueueAdapters::AbstractAdapter
23
23
  def enqueue(job)
24
- delayed_job = Delayed::Job.enqueue(
24
+ delayed_job = Delayed::Worker.backend.enqueue(
25
25
  JobWrapper.new(job.serialize),
26
26
  queue: job.queue_name,
27
27
  priority: job.priority,
@@ -33,7 +33,7 @@ module ActiveJob
33
33
  end
34
34
 
35
35
  def enqueue_at(job, timestamp)
36
- delayed_job = Delayed::Job.enqueue(
36
+ delayed_job = Delayed::Worker.backend.enqueue(
37
37
  JobWrapper.new(job.serialize),
38
38
  queue: job.queue_name,
39
39
  priority: job.priority,
@@ -50,10 +50,10 @@ module ActiveJob
50
50
  JobWrapper.new(job.serialize),
51
51
  queue: job.queue_name,
52
52
  priority: job.priority,
53
- run_at: job.run_at,
53
+ run_at: job.run_at || Delayed::Worker.backend.db_time_now,
54
54
  **job.job_attributes
55
55
  ).prepare
56
- job_to_enqueue = Delayed::Job.new(options)
56
+ job_to_enqueue = Delayed::Worker.backend.new(options)
57
57
  if Delayed::Worker.delay_job?(job_to_enqueue)
58
58
  job_to_enqueue.attributes.except("id", "created_at", "updated_at")
59
59
  else
@@ -61,7 +61,8 @@ module ActiveJob
61
61
  nil
62
62
  end
63
63
  end
64
- Delayed::Job.insert_all(wrapped_jobs)
64
+ enqueued_jobs = Delayed::Worker.backend.insert_all(wrapped_jobs)
65
+ enqueued_jobs.count
65
66
  end
66
67
 
67
68
  class JobWrapper # :nodoc:
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: delayed_job-active_job
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-04-01 00:00:00.000000000 Z
11
+ date: 2025-04-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activejob