async-job-adapter-active_job 0.20.0 → 0.21.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/context/production-deployment.md +12 -2
- data/context/queue-configuration.md +18 -0
- data/lib/async/job/adapter/active_job/environment.rb +6 -0
- data/lib/async/job/adapter/active_job/service.rb +9 -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: c511212f8812f17482be72b895a5a8bb1448cceb7be848be1c03e32c1b7a4c77
|
|
4
|
+
data.tar.gz: eaa270226a7a42a0de5f1a46dd088e43f2e43638574ea40a6550cb1b63faa900
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d6b8ce9d35e14fffc33065016159afd0e3dcd2ca76a977c04b75e5eb99039452576fe5c14404a6c93daf92e680b33b16c1d904e2ebbe09923daff33397c71e0b
|
|
7
|
+
data.tar.gz: 18e5902aaf6ae3df933126083fc61f2bb1390d84dd36fe08012f6a30838a52bcce29199960c6d840b2d87b761c0702bd15ee208d677d61c1606506c868f17a5c
|
checksums.yaml.gz.sig
CHANGED
|
Binary file
|
|
@@ -31,14 +31,22 @@ Replace the built-in `default` queue definition in `config/initializers/async_jo
|
|
|
31
31
|
```ruby
|
|
32
32
|
require "async/job/processor/redis"
|
|
33
33
|
|
|
34
|
+
redis_endpoint = Async::Redis::Endpoint.parse(ENV.fetch("REDIS_URL"))
|
|
35
|
+
|
|
34
36
|
Rails.application.configure do
|
|
35
37
|
config.async_job.define_queue "default" do
|
|
36
|
-
dequeue Async::Job::Processor::Redis
|
|
38
|
+
dequeue Async::Job::Processor::Redis, endpoint: redis_endpoint
|
|
37
39
|
end
|
|
38
40
|
end
|
|
39
41
|
```
|
|
40
42
|
|
|
41
|
-
|
|
43
|
+
Set `REDIS_URL` in both the Rails and worker process environments. It may use the `redis://` or `rediss://` scheme and include credentials, a port, and a database number:
|
|
44
|
+
|
|
45
|
+
```shell
|
|
46
|
+
$ REDIS_URL=redis://redis.example.com:6379/0 bundle exec async-job-adapter-active_job-server
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Without an explicit endpoint, the processor connects to `redis://localhost:6379`. With one logical queue, the default `async-job` prefix is sufficient. Configure distinct, stable prefixes when multiple queue definitions share a Redis endpoint.
|
|
42
50
|
|
|
43
51
|
## Starting Workers
|
|
44
52
|
|
|
@@ -50,6 +58,8 @@ $ RAILS_ENV=production bundle exec async-job-adapter-active_job-server
|
|
|
50
58
|
|
|
51
59
|
The server loads the Rails environment and starts every defined queue. The service container supervises worker instances and reports their readiness.
|
|
52
60
|
|
|
61
|
+
By default, `config/environment.rb` is preloaded in the parent process before worker processes are forked. This avoids loading application dependencies for the first time after a fork and allows workers to share preloaded application code.
|
|
62
|
+
|
|
53
63
|
If the command cannot run from the application root, set `RAILS_ROOT` explicitly:
|
|
54
64
|
|
|
55
65
|
```shell
|
|
@@ -36,6 +36,24 @@ end
|
|
|
36
36
|
|
|
37
37
|
Processors can accept positional and keyword arguments after the processor class.
|
|
38
38
|
|
|
39
|
+
## Redis Endpoints
|
|
40
|
+
|
|
41
|
+
Without an explicit `endpoint`, the Redis processor connects to `redis://localhost:6379`. Pass an ruby:`Async::Redis::Endpoint` when Redis runs on another host, requires credentials, uses a different database, or accepts TLS connections:
|
|
42
|
+
|
|
43
|
+
```ruby
|
|
44
|
+
redis_endpoint = Async::Redis::Endpoint.parse(ENV.fetch("REDIS_URL"))
|
|
45
|
+
|
|
46
|
+
Rails.application.configure do
|
|
47
|
+
config.async_job.define_queue "default" do
|
|
48
|
+
dequeue Async::Job::Processor::Redis, endpoint: redis_endpoint
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
`REDIS_URL` may use either the `redis://` or `rediss://` scheme and can include credentials, a port, and a database number, for example `redis://username:password@redis.example.com:6379/1`. Keep credentials in the environment rather than writing them into the initializer.
|
|
54
|
+
|
|
55
|
+
The bundled worker loads the Rails environment, so Rails and worker processes use the same queue definition. Ensure `REDIS_URL` is present and identical in both process environments.
|
|
56
|
+
|
|
39
57
|
## Redis Prefixes
|
|
40
58
|
|
|
41
59
|
Without an explicit `prefix`, every Redis processor uses `async-job`. Queue definition names do not alter that default, so two definitions using the same Redis endpoint and prefix operate on the same underlying queue.
|
|
@@ -22,6 +22,12 @@ module Async
|
|
|
22
22
|
ENV.fetch("RAILS_ROOT", Dir.pwd)
|
|
23
23
|
end
|
|
24
24
|
|
|
25
|
+
# The paths to preload before worker processes are forked.
|
|
26
|
+
# @returns [Array(String)]
|
|
27
|
+
def preload
|
|
28
|
+
["config/environment"]
|
|
29
|
+
end
|
|
30
|
+
|
|
25
31
|
# Get the default dispatcher instance.
|
|
26
32
|
# @returns [Object] The dispatcher from the Railtie.
|
|
27
33
|
def dispatcher
|
|
@@ -15,6 +15,15 @@ module Async
|
|
|
15
15
|
module ActiveJob
|
|
16
16
|
# A job server that can be run as a service.
|
|
17
17
|
class Service < Async::Service::Generic
|
|
18
|
+
# Preload the application before worker processes are forked.
|
|
19
|
+
def start
|
|
20
|
+
Array(@evaluator.preload).each do |path|
|
|
21
|
+
require File.expand_path(path, @evaluator.root)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
super
|
|
25
|
+
end
|
|
26
|
+
|
|
18
27
|
# Load the Rails environment and start the job server.
|
|
19
28
|
def setup(container)
|
|
20
29
|
container_options = @evaluator.container_options
|
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.21.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Samuel Williams
|
|
@@ -129,7 +129,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
129
129
|
- !ruby/object:Gem::Version
|
|
130
130
|
version: '0'
|
|
131
131
|
requirements: []
|
|
132
|
-
rubygems_version: 4.0.
|
|
132
|
+
rubygems_version: 4.0.16
|
|
133
133
|
specification_version: 4
|
|
134
134
|
summary: A asynchronous job queue for Ruby on Rails.
|
|
135
135
|
test_files: []
|
metadata.gz.sig
CHANGED
|
Binary file
|