async-job-adapter-active_job 0.13.0 → 0.14.1
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 +5 -2
- data/bin/async-job-adapter-active_job-server +1 -6
- data/lib/active_job/queue_adapters/async_job_adapter.rb +8 -2
- data/lib/async/job/adapter/active_job/dispatcher.rb +8 -1
- data/lib/async/job/adapter/active_job/environment.rb +14 -2
- data/lib/async/job/adapter/active_job/service.rb +21 -2
- data/lib/async/job/adapter/active_job/thread_local_dispatcher.rb +5 -0
- data/lib/async/job/adapter/active_job/version.rb +1 -1
- data.tar.gz.sig +0 -0
- metadata +2 -2
- 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: ea1f70c52b6ac8fef768e6f873af46fc7d41f0fcaf2135821a85a6585289b3e5
|
4
|
+
data.tar.gz: 10961b83ada11d421f0c253f54c342323e87961a8f5718326a17323aaf7d004b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c1624087283cb466494db419e184a624826b072db17782e7b69a650f4acce0ef11a4f072645b1304580f5ea4febf50f1dad3c0a632ca5c9d956241f3d905f7f1
|
7
|
+
data.tar.gz: a890ddfc103218be83e6eb954c619e21bb1991c5c16e7a58b1c061d9c19013c3c181bd75a5c453af2c6a0b6a62cffbadfd54ab1b96aede5406aa64e9e7ca7cc0
|
checksums.yaml.gz.sig
CHANGED
@@ -1,2 +1,5 @@
|
|
1
|
-
|
2
|
-
�Z�
|
1
|
+
P̮��NFOAoP(��%_O���B)0���?S�
|
2
|
+
����q���1�k�^��Ҷ�D�H�ޔ#�ɄԷ���?Z�%����y�r�z��M�kz�Fb����w�/�M��lc��7�zE���)
|
3
|
+
Z)�AJ
|
4
|
+
9,��j��k� \҂�\�&L�3��<&=���/�љ�̷>� �z�|)�h� �m:����#u��Ay>���
|
5
|
+
#u54n�M�*�n`�.N��3�giu�?��'����B���"����|����]����q��b2U3��eb��KAu-�.pLV_O9�5v��koxo�|�SJ�Lj�[F
|
@@ -7,13 +7,8 @@ require 'async/service/controller'
|
|
7
7
|
require 'async/job/adapter/active_job/environment'
|
8
8
|
|
9
9
|
configuration = Async::Service::Configuration.build do
|
10
|
-
service "async-job-server" do
|
10
|
+
service "async-job-adapter-active_job-server" do
|
11
11
|
include Async::Job::Adapter::ActiveJob::Environment
|
12
|
-
|
13
|
-
root {ENV.fetch('RAILS_ROOT', Dir.pwd)}
|
14
|
-
|
15
|
-
# If you have multiple queues, you may want to run a separate server for each queue.
|
16
|
-
queue_name ENV.fetch('ASYNC_JOB_ADAPTER_ACTIVE_JOB_QUEUE_NAME', 'default')
|
17
12
|
end
|
18
13
|
end
|
19
14
|
|
@@ -5,6 +5,8 @@
|
|
5
5
|
|
6
6
|
require 'active_job/queue_adapters/abstract_adapter'
|
7
7
|
|
8
|
+
require 'kernel/sync'
|
9
|
+
|
8
10
|
module ActiveJob
|
9
11
|
module QueueAdapters
|
10
12
|
class AsyncJobAdapter < AbstractAdapter
|
@@ -14,12 +16,16 @@ module ActiveJob
|
|
14
16
|
|
15
17
|
# Enqueue a job for processing.
|
16
18
|
def enqueue(job)
|
17
|
-
|
19
|
+
Sync do
|
20
|
+
@dispatcher.call(job)
|
21
|
+
end
|
18
22
|
end
|
19
23
|
|
20
24
|
# Enqueue a job for processing at a specific time.
|
21
25
|
def enqueue_at(job, timestamp)
|
22
|
-
|
26
|
+
Sync do
|
27
|
+
@dispatcher.call(job)
|
28
|
+
end
|
23
29
|
end
|
24
30
|
end
|
25
31
|
end
|
@@ -17,7 +17,7 @@ module Async
|
|
17
17
|
# Prepare the dispacher with the given definitions and aliases.
|
18
18
|
# @parameter definitions [Hash(String, Proc)] The definitions to use constructing queues.
|
19
19
|
# @parameter aliases [Hash(String, Proc)] The aliases for the definitions.
|
20
|
-
def initialize(definitions, aliases = {})
|
20
|
+
def initialize(definitions = {}, aliases = {})
|
21
21
|
@definitions = definitions
|
22
22
|
@aliases = aliases
|
23
23
|
|
@@ -30,6 +30,9 @@ module Async
|
|
30
30
|
# @attribute [Hash(String, String)] The aliases for the definitions.
|
31
31
|
attr :aliases
|
32
32
|
|
33
|
+
# @attribute [Hash(String, Queue)] The queues that have been constructed.
|
34
|
+
attr :queues
|
35
|
+
|
33
36
|
# Look up a queue by name, constructing it if necessary using the given definition.
|
34
37
|
# @parameter name [String] The name of the queue.
|
35
38
|
def [](name)
|
@@ -50,6 +53,10 @@ module Async
|
|
50
53
|
self[name].server.start
|
51
54
|
end
|
52
55
|
|
56
|
+
def keys
|
57
|
+
@definitions.keys
|
58
|
+
end
|
59
|
+
|
53
60
|
private def build(definition)
|
54
61
|
builder = Builder.new(Executor::DEFAULT)
|
55
62
|
|
@@ -16,9 +16,21 @@ module Async
|
|
16
16
|
Service
|
17
17
|
end
|
18
18
|
|
19
|
+
def root
|
20
|
+
ENV.fetch('RAILS_ROOT', Dir.pwd)
|
21
|
+
end
|
22
|
+
|
23
|
+
def dispatcher
|
24
|
+
Railtie.dispatcher
|
25
|
+
end
|
26
|
+
|
19
27
|
# The name of the queue to use.
|
20
|
-
def
|
21
|
-
|
28
|
+
def queue_names
|
29
|
+
if queue_names = ENV['ASYNC_JOB_ADAPTER_ACTIVE_JOB_QUEUE_NAMES']
|
30
|
+
queue_names.split(',')
|
31
|
+
else
|
32
|
+
dispatcher.keys
|
33
|
+
end
|
22
34
|
end
|
23
35
|
end
|
24
36
|
end
|
@@ -4,6 +4,8 @@
|
|
4
4
|
# Copyright, 2024, by Samuel Williams.
|
5
5
|
|
6
6
|
require 'async/service/generic'
|
7
|
+
require 'console/event/failure'
|
8
|
+
require 'async/barrier'
|
7
9
|
|
8
10
|
module Async
|
9
11
|
module Job
|
@@ -15,12 +17,29 @@ module Async
|
|
15
17
|
def setup(container)
|
16
18
|
container.run(name: self.name, restart: true) do |instance|
|
17
19
|
evaluator = @environment.evaluator
|
20
|
+
|
18
21
|
require File.expand_path('config/environment', evaluator.root)
|
19
22
|
|
23
|
+
dispatcher = evaluator.dispatcher
|
24
|
+
|
20
25
|
instance.ready!
|
21
26
|
|
22
|
-
Sync do
|
23
|
-
|
27
|
+
Sync do |task|
|
28
|
+
barrier = Async::Barrier.new
|
29
|
+
|
30
|
+
# Start all the named queues:
|
31
|
+
evaluator.queue_names.each do |queue_name|
|
32
|
+
barrier.async do
|
33
|
+
Console.debug(self, "Starting queue...", queue_name: queue_name)
|
34
|
+
dispatcher.start(queue_name)
|
35
|
+
rescue => error
|
36
|
+
Console::Event::Failure.for(error).emit(self, "Queue failed!")
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
barrier.wait
|
41
|
+
ensure
|
42
|
+
barrier.stop
|
24
43
|
end
|
25
44
|
end
|
26
45
|
end
|
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
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.14.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
@@ -37,7 +37,7 @@ cert_chain:
|
|
37
37
|
Q2K9NVun/S785AP05vKkXZEFYxqG6EW012U4oLcFl5MySFajYXRYbuUpH6AY+HP8
|
38
38
|
voD0MPg1DssDLKwXyt1eKD/+Fq0bFWhwVM/1XiAXL7lyYUyOq24KHgQ2Csg=
|
39
39
|
-----END CERTIFICATE-----
|
40
|
-
date: 2024-08-
|
40
|
+
date: 2024-08-14 00:00:00.000000000 Z
|
41
41
|
dependencies:
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
43
|
name: async-job
|
metadata.gz.sig
CHANGED
Binary file
|