async-job-adapter-active_job 0.14.1 → 0.15.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 +4 -4
- checksums.yaml.gz.sig +0 -0
- data/bin/async-job-adapter-active_job-server +3 -3
- data/lib/active_job/queue_adapters/async_job_adapter.rb +12 -2
- data/lib/async/job/adapter/active_job/dispatcher.rb +7 -3
- data/lib/async/job/adapter/active_job/environment.rb +8 -4
- data/lib/async/job/adapter/active_job/executor.rb +11 -5
- data/lib/async/job/adapter/active_job/railtie.rb +4 -3
- data/lib/async/job/adapter/active_job/service.rb +6 -4
- data/lib/async/job/adapter/active_job/thread_local_dispatcher.rb +8 -1
- data/lib/async/job/adapter/active_job/version.rb +1 -1
- data/lib/async/job/adapter/active_job.rb +13 -0
- data/license.md +1 -0
- data/readme.md +55 -1
- data/releases.md +86 -0
- data.tar.gz.sig +0 -0
- metadata +6 -9
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 754e798963465a3af74167d1fed826c57f37dd843bb5e0150ab4109e940c3658
|
4
|
+
data.tar.gz: e8d8dd967ce0f5f444f1fffa3091a7081c87678b33c8607e8ffb111057d7b51f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 335a1ede4d6f09e76f11ec86abb87481e5e64ab7fd100fd2614ee7e828a5a5bce1687aab08d919c559769181346e7b7f0fa230866a6a7a1f2bb073c97004953e
|
7
|
+
data.tar.gz: dc681b9ed7b5ec17af74784b3404d92e6f60d5d9a9d0afb5c0a87c8eb0b9be08ae40f5561009989fcad6e862715a568a65eae3828d4092510552cee4e8fed519
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
@@ -1,10 +1,10 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
|
-
require
|
5
|
-
require
|
4
|
+
require "async/service/configuration"
|
5
|
+
require "async/service/controller"
|
6
6
|
|
7
|
-
require
|
7
|
+
require "async/job/adapter/active_job/environment"
|
8
8
|
|
9
9
|
configuration = Async::Service::Configuration.build do
|
10
10
|
service "async-job-adapter-active_job-server" do
|
@@ -3,18 +3,24 @@
|
|
3
3
|
# Released under the MIT License.
|
4
4
|
# Copyright, 2024, by Samuel Williams.
|
5
5
|
|
6
|
-
require
|
6
|
+
require "active_job/queue_adapters/abstract_adapter"
|
7
7
|
|
8
|
-
require
|
8
|
+
require "kernel/sync"
|
9
9
|
|
10
|
+
# @namespace
|
10
11
|
module ActiveJob
|
12
|
+
# @namespace
|
11
13
|
module QueueAdapters
|
14
|
+
# ActiveJob adapter for async-job, providing asynchronous job processing capabilities.
|
12
15
|
class AsyncJobAdapter < AbstractAdapter
|
16
|
+
# Initialize the adapter with a dispatcher.
|
17
|
+
# @parameter dispatcher [Object] The job dispatcher, defaults to the Railtie dispatcher.
|
13
18
|
def initialize(dispatcher = ::Async::Job::Adapter::ActiveJob::Railtie.dispatcher)
|
14
19
|
@dispatcher = dispatcher
|
15
20
|
end
|
16
21
|
|
17
22
|
# Enqueue a job for processing.
|
23
|
+
# @parameter job [ActiveJob::Base] The job to enqueue.
|
18
24
|
def enqueue(job)
|
19
25
|
Sync do
|
20
26
|
@dispatcher.call(job)
|
@@ -22,7 +28,11 @@ module ActiveJob
|
|
22
28
|
end
|
23
29
|
|
24
30
|
# Enqueue a job for processing at a specific time.
|
31
|
+
# @parameter job [ActiveJob::Base] The job to enqueue.
|
32
|
+
# @parameter timestamp [Time] The time at which to enqueue the job.
|
25
33
|
def enqueue_at(job, timestamp)
|
34
|
+
job.scheduled_at = timestamp
|
35
|
+
|
26
36
|
Sync do
|
27
37
|
@dispatcher.call(job)
|
28
38
|
end
|
@@ -3,10 +3,10 @@
|
|
3
3
|
# Released under the MIT License.
|
4
4
|
# Copyright, 2024, by Samuel Williams.
|
5
5
|
|
6
|
-
require_relative
|
6
|
+
require_relative "executor"
|
7
7
|
|
8
|
-
require
|
9
|
-
require
|
8
|
+
require "async/job"
|
9
|
+
require "async/job/builder"
|
10
10
|
|
11
11
|
module Async
|
12
12
|
module Job
|
@@ -42,6 +42,8 @@ module Async
|
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
45
|
+
# Dispatch a job to the appropriate queue.
|
46
|
+
# @parameter job [ActiveJob::Base] The job to dispatch.
|
45
47
|
def call(job)
|
46
48
|
name = @aliases.fetch(job.queue_name, job.queue_name)
|
47
49
|
|
@@ -53,6 +55,8 @@ module Async
|
|
53
55
|
self[name].server.start
|
54
56
|
end
|
55
57
|
|
58
|
+
# Get the names of all available queue definitions.
|
59
|
+
# @returns [Array<String>] The queue definition names.
|
56
60
|
def keys
|
57
61
|
@definitions.keys
|
58
62
|
end
|
@@ -3,7 +3,7 @@
|
|
3
3
|
# Released under the MIT License.
|
4
4
|
# Copyright, 2024, by Samuel Williams.
|
5
5
|
|
6
|
-
require_relative
|
6
|
+
require_relative "service"
|
7
7
|
|
8
8
|
module Async
|
9
9
|
module Job
|
@@ -16,18 +16,22 @@ module Async
|
|
16
16
|
Service
|
17
17
|
end
|
18
18
|
|
19
|
+
# The rails root.
|
20
|
+
# @return [String]
|
19
21
|
def root
|
20
|
-
ENV.fetch(
|
22
|
+
ENV.fetch("RAILS_ROOT", Dir.pwd)
|
21
23
|
end
|
22
24
|
|
25
|
+
# Get the default dispatcher instance.
|
26
|
+
# @returns [Object] The dispatcher from the Railtie.
|
23
27
|
def dispatcher
|
24
28
|
Railtie.dispatcher
|
25
29
|
end
|
26
30
|
|
27
31
|
# The name of the queue to use.
|
28
32
|
def queue_names
|
29
|
-
if queue_names = ENV[
|
30
|
-
queue_names.split(
|
33
|
+
if queue_names = ENV["ASYNC_JOB_ADAPTER_ACTIVE_JOB_QUEUE_NAMES"]
|
34
|
+
queue_names.split(",")
|
31
35
|
else
|
32
36
|
dispatcher.keys
|
33
37
|
end
|
@@ -3,13 +3,13 @@
|
|
3
3
|
# Released under the MIT License.
|
4
4
|
# Copyright, 2024, by Samuel Williams.
|
5
5
|
|
6
|
-
require
|
6
|
+
require "json"
|
7
7
|
|
8
|
-
require
|
9
|
-
require
|
8
|
+
require "console"
|
9
|
+
require "console/event/failure"
|
10
10
|
|
11
|
-
require
|
12
|
-
require
|
11
|
+
require "active_job"
|
12
|
+
require "active_job/base"
|
13
13
|
|
14
14
|
module Async
|
15
15
|
module Job
|
@@ -17,10 +17,14 @@ module Async
|
|
17
17
|
module ActiveJob
|
18
18
|
# An executor for processing jobs using `ActiveJob`.
|
19
19
|
class Executor
|
20
|
+
# Initialize the executor with an optional delegate.
|
21
|
+
# @parameter delegate [Object] An optional delegate object for handling lifecycle methods.
|
20
22
|
def initialize(delegate = nil)
|
21
23
|
@delegate = delegate
|
22
24
|
end
|
23
25
|
|
26
|
+
# Execute a job with the given data.
|
27
|
+
# @parameter job_data [Hash] Serialized job data from ActiveJob.
|
24
28
|
def execute(job_data)
|
25
29
|
::ActiveJob::Callbacks.run_callbacks(:execute) do
|
26
30
|
job = ::ActiveJob::Base.deserialize(job_data)
|
@@ -46,10 +50,12 @@ module Async
|
|
46
50
|
@delegate&.call(job)
|
47
51
|
end
|
48
52
|
|
53
|
+
# Start the delegate if present.
|
49
54
|
def start
|
50
55
|
@delegate&.start
|
51
56
|
end
|
52
57
|
|
58
|
+
# Stop the delegate if present.
|
53
59
|
def stop
|
54
60
|
@delegate&.stop
|
55
61
|
end
|
@@ -3,10 +3,10 @@
|
|
3
3
|
# Released under the MIT License.
|
4
4
|
# Copyright, 2024, by Samuel Williams.
|
5
5
|
|
6
|
-
require
|
7
|
-
require
|
6
|
+
require "async/job"
|
7
|
+
require "async/job/processor/inline"
|
8
8
|
|
9
|
-
require_relative
|
9
|
+
require_relative "thread_local_dispatcher"
|
10
10
|
|
11
11
|
module Async
|
12
12
|
module Job
|
@@ -19,6 +19,7 @@ module Async
|
|
19
19
|
dequeue Processor::Inline
|
20
20
|
end
|
21
21
|
|
22
|
+
# Initialize the railtie with default queue configuration.
|
22
23
|
def initialize
|
23
24
|
@definitions = {"default" => DEFAULT_QUEUE_DEFINITION}
|
24
25
|
@aliases = {}
|
@@ -3,9 +3,11 @@
|
|
3
3
|
# Released under the MIT License.
|
4
4
|
# Copyright, 2024, by Samuel Williams.
|
5
5
|
|
6
|
-
require
|
7
|
-
require
|
8
|
-
|
6
|
+
require "async/service/generic"
|
7
|
+
require "console/event/failure"
|
8
|
+
|
9
|
+
require "async"
|
10
|
+
require "async/barrier"
|
9
11
|
|
10
12
|
module Async
|
11
13
|
module Job
|
@@ -18,7 +20,7 @@ module Async
|
|
18
20
|
container.run(name: self.name, restart: true) do |instance|
|
19
21
|
evaluator = @environment.evaluator
|
20
22
|
|
21
|
-
require File.expand_path(
|
23
|
+
require File.expand_path("config/environment", evaluator.root)
|
22
24
|
|
23
25
|
dispatcher = evaluator.dispatcher
|
24
26
|
|
@@ -3,7 +3,7 @@
|
|
3
3
|
# Released under the MIT License.
|
4
4
|
# Copyright, 2024, by Samuel Williams.
|
5
5
|
|
6
|
-
require_relative
|
6
|
+
require_relative "dispatcher"
|
7
7
|
|
8
8
|
Thread.attr_accessor :async_job_adapter_active_job_dispatcher
|
9
9
|
|
@@ -13,6 +13,9 @@ module Async
|
|
13
13
|
module ActiveJob
|
14
14
|
# Used for dispatching jobs to a thread-local queue to avoid thread-safety issues.
|
15
15
|
class ThreadLocalDispatcher
|
16
|
+
# Initialize with queue definitions and aliases.
|
17
|
+
# @parameter definitions [Hash] The queue definitions.
|
18
|
+
# @parameter aliases [Hash] The queue aliases.
|
16
19
|
def initialize(definitions, aliases)
|
17
20
|
@definitions = definitions
|
18
21
|
@aliases = aliases
|
@@ -31,10 +34,14 @@ module Async
|
|
31
34
|
Thread.current.async_job_adapter_active_job_dispatcher ||= Dispatcher.new(@definitions, @aliases)
|
32
35
|
end
|
33
36
|
|
37
|
+
# Get a queue by name.
|
38
|
+
# @parameter name [String] The queue name.
|
34
39
|
def [](name)
|
35
40
|
dispatcher[name]
|
36
41
|
end
|
37
42
|
|
43
|
+
# Dispatch a job using the thread-local dispatcher.
|
44
|
+
# @parameter job [ActiveJob::Base] The job to dispatch.
|
38
45
|
def call(job)
|
39
46
|
dispatcher.call(job)
|
40
47
|
end
|
@@ -10,3 +10,16 @@ if defined?(Rails::Railtie)
|
|
10
10
|
require_relative "active_job/railtie"
|
11
11
|
require "active_job/queue_adapters/async_job_adapter"
|
12
12
|
end
|
13
|
+
|
14
|
+
# @namespace
|
15
|
+
module Async
|
16
|
+
# @namespace
|
17
|
+
module Job
|
18
|
+
# @namespace
|
19
|
+
module Adapter
|
20
|
+
# @namespace
|
21
|
+
module ActiveJob
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
data/license.md
CHANGED
data/readme.md
CHANGED
@@ -8,7 +8,61 @@ Provides an adapter for ActiveJob on top of `Async::Job`.
|
|
8
8
|
|
9
9
|
Please see the [project documentation](https://socketry.github.io/async-job-adapter-active_job/) for more details.
|
10
10
|
|
11
|
-
- [Getting Started](https://socketry.github.io/async-job-adapter-active_job/guides/getting-started/index) - This guide explains how to get started with the `async-job-active_job
|
11
|
+
- [Getting Started](https://socketry.github.io/async-job-adapter-active_job/guides/getting-started/index) - This guide explains how to get started with the `async-job-adapter-active_job` gem.
|
12
|
+
|
13
|
+
## Releases
|
14
|
+
|
15
|
+
Please see the [project releases](https://socketry.github.io/async-job-adapter-active_job/releases/index) for all releases.
|
16
|
+
|
17
|
+
### v0.15.0
|
18
|
+
|
19
|
+
- Fix handling of scheduled jobs with proper `scheduled_at` assignment.
|
20
|
+
- 100% documentation coverage.
|
21
|
+
- 100% test coverage.
|
22
|
+
- Modernize code formatting and structure.
|
23
|
+
- Fix typo in gem name (\#7).
|
24
|
+
|
25
|
+
### v0.14.1
|
26
|
+
|
27
|
+
- Ensure the adapter wraps enqueue operations with `Sync` (\#10).
|
28
|
+
|
29
|
+
### v0.14.0
|
30
|
+
|
31
|
+
- Support for running multiple queues.
|
32
|
+
- Minor documentation fixes.
|
33
|
+
|
34
|
+
### v0.13.0
|
35
|
+
|
36
|
+
- Add support for `:async_job` queue adapter name.
|
37
|
+
- Require `active_job` in the executor.
|
38
|
+
- Updated logging examples and documentation.
|
39
|
+
- Remove `thread-local` gem dependency.
|
40
|
+
- Improve error handling - don't log failures as ActiveJob already handles this.
|
41
|
+
|
42
|
+
### v0.12.1
|
43
|
+
|
44
|
+
- Force string names for queue identifiers, fixes \#5.
|
45
|
+
|
46
|
+
### v0.12.0
|
47
|
+
|
48
|
+
- Improved error handling - let ActiveJob handle retry logic.
|
49
|
+
|
50
|
+
### v0.11.0
|
51
|
+
|
52
|
+
- Prefer `define_queue` and `alias_queue` methods for queue configuration.
|
53
|
+
|
54
|
+
### v0.10.0
|
55
|
+
|
56
|
+
- Rename "pipeline" concept to "queue" for consistency.
|
57
|
+
|
58
|
+
### v0.9.0
|
59
|
+
|
60
|
+
- Update interface to suit upstream async-job changes.
|
61
|
+
|
62
|
+
### v0.8.0
|
63
|
+
|
64
|
+
- Add `#start`/`#stop` delegators for better lifecycle management.
|
65
|
+
- Performance improvements with benchmarking.
|
12
66
|
|
13
67
|
## Contributing
|
14
68
|
|
data/releases.md
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
# Releases
|
2
|
+
|
3
|
+
## v0.15.0
|
4
|
+
|
5
|
+
- Fix handling of scheduled jobs with proper `scheduled_at` assignment.
|
6
|
+
- 100% documentation coverage.
|
7
|
+
- 100% test coverage.
|
8
|
+
- Modernize code formatting and structure.
|
9
|
+
- Fix typo in gem name (\#7).
|
10
|
+
|
11
|
+
## v0.14.1
|
12
|
+
|
13
|
+
- Ensure the adapter wraps enqueue operations with `Sync` (\#10).
|
14
|
+
|
15
|
+
## v0.14.0
|
16
|
+
|
17
|
+
- Support for running multiple queues.
|
18
|
+
- Minor documentation fixes.
|
19
|
+
|
20
|
+
## v0.13.0
|
21
|
+
|
22
|
+
- Add support for `:async_job` queue adapter name.
|
23
|
+
- Require `active_job` in the executor.
|
24
|
+
- Updated logging examples and documentation.
|
25
|
+
- Remove `thread-local` gem dependency.
|
26
|
+
- Improve error handling - don't log failures as ActiveJob already handles this.
|
27
|
+
|
28
|
+
## v0.12.1
|
29
|
+
|
30
|
+
- Force string names for queue identifiers, fixes \#5.
|
31
|
+
|
32
|
+
## v0.12.0
|
33
|
+
|
34
|
+
- Improved error handling - let ActiveJob handle retry logic.
|
35
|
+
|
36
|
+
## v0.11.0
|
37
|
+
|
38
|
+
- Prefer `define_queue` and `alias_queue` methods for queue configuration.
|
39
|
+
|
40
|
+
## v0.10.0
|
41
|
+
|
42
|
+
- Rename "pipeline" concept to "queue" for consistency.
|
43
|
+
|
44
|
+
## v0.9.0
|
45
|
+
|
46
|
+
- Update interface to suit upstream async-job changes.
|
47
|
+
|
48
|
+
## v0.8.0
|
49
|
+
|
50
|
+
- Add `#start`/`#stop` delegators for better lifecycle management.
|
51
|
+
- Performance improvements with benchmarking.
|
52
|
+
|
53
|
+
## v0.7.0
|
54
|
+
|
55
|
+
- Major modernization of the gem structure.
|
56
|
+
- Improved documentation generation.
|
57
|
+
- Drop Ruby 3.0 support.
|
58
|
+
- Fix server binary and add default server configuration.
|
59
|
+
|
60
|
+
## v0.6.0
|
61
|
+
|
62
|
+
- Update dependency on `async-service`.
|
63
|
+
- Add explicit `Environment` class for better configuration.
|
64
|
+
|
65
|
+
## v0.5.0
|
66
|
+
|
67
|
+
- Move builder pattern to `async-job` library.
|
68
|
+
- Significantly improved test coverage.
|
69
|
+
|
70
|
+
## v0.4.0
|
71
|
+
|
72
|
+
- Add Redis workflow support.
|
73
|
+
|
74
|
+
## v0.3.0
|
75
|
+
|
76
|
+
- Introduce builder pattern for constructing adapters and queues.
|
77
|
+
- Support for multiple queues.
|
78
|
+
|
79
|
+
## v0.2.0
|
80
|
+
|
81
|
+
- Add support for basic configuration.
|
82
|
+
- Initial test suite.
|
83
|
+
|
84
|
+
## v0.1.0
|
85
|
+
|
86
|
+
- Initial extraction of ActiveJob adapter code from `async-job`.
|
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: async-job-adapter-active_job
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.15.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
8
|
-
|
8
|
+
- Trevor Turk
|
9
9
|
bindir: bin
|
10
10
|
cert_chain:
|
11
11
|
- |
|
@@ -37,7 +37,7 @@ cert_chain:
|
|
37
37
|
Q2K9NVun/S785AP05vKkXZEFYxqG6EW012U4oLcFl5MySFajYXRYbuUpH6AY+HP8
|
38
38
|
voD0MPg1DssDLKwXyt1eKD/+Fq0bFWhwVM/1XiAXL7lyYUyOq24KHgQ2Csg=
|
39
39
|
-----END CERTIFICATE-----
|
40
|
-
date:
|
40
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
41
41
|
dependencies:
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
43
|
name: async-job
|
@@ -67,8 +67,6 @@ dependencies:
|
|
67
67
|
- - "~>"
|
68
68
|
- !ruby/object:Gem::Version
|
69
69
|
version: '0.12'
|
70
|
-
description:
|
71
|
-
email:
|
72
70
|
executables:
|
73
71
|
- async-job-adapter-active_job-server
|
74
72
|
extensions: []
|
@@ -86,13 +84,13 @@ files:
|
|
86
84
|
- lib/async/job/adapter/active_job/version.rb
|
87
85
|
- license.md
|
88
86
|
- readme.md
|
87
|
+
- releases.md
|
89
88
|
homepage: https://github.com/socketry/async-job-adapter-active_job
|
90
89
|
licenses:
|
91
90
|
- MIT
|
92
91
|
metadata:
|
93
92
|
documentation_uri: https://socketry.github.io/async-job-adapter-active_job/
|
94
93
|
source_code_uri: https://github.com/socketry/async-job-adapter-active_job.git
|
95
|
-
post_install_message:
|
96
94
|
rdoc_options: []
|
97
95
|
require_paths:
|
98
96
|
- lib
|
@@ -100,15 +98,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
100
98
|
requirements:
|
101
99
|
- - ">="
|
102
100
|
- !ruby/object:Gem::Version
|
103
|
-
version: '3.
|
101
|
+
version: '3.2'
|
104
102
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
105
103
|
requirements:
|
106
104
|
- - ">="
|
107
105
|
- !ruby/object:Gem::Version
|
108
106
|
version: '0'
|
109
107
|
requirements: []
|
110
|
-
rubygems_version: 3.
|
111
|
-
signing_key:
|
108
|
+
rubygems_version: 3.6.7
|
112
109
|
specification_version: 4
|
113
110
|
summary: A asynchronous job queue for Ruby on Rails.
|
114
111
|
test_files: []
|
metadata.gz.sig
CHANGED
Binary file
|