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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 438122b9f40ef9fd97ebe48bb50ff7a015a4dcd4837f6d9cd70cfb2dfba86a70
4
- data.tar.gz: 19308266ced3a1fe91990d4b865aeb68cbdd5b82c1f99e4f62de068c0e0f97f2
3
+ metadata.gz: c511212f8812f17482be72b895a5a8bb1448cceb7be848be1c03e32c1b7a4c77
4
+ data.tar.gz: eaa270226a7a42a0de5f1a46dd088e43f2e43638574ea40a6550cb1b63faa900
5
5
  SHA512:
6
- metadata.gz: 64ec94d3dd9421049c342ab7702cb2f9ed4ae38859f76ba5a41d9f09bb1cc0a459f43d5229969a10a58e800e98ae0d68e065a8e65ab06d63e75694bccf13cfd7
7
- data.tar.gz: 26733df41fe820a33a31dddae659610ee11a7d709f2b3fcbff4d0319e850c6b46ac676cfa4d8566cc0ffbf5aa10a6c0fdacc418836d70f1e6fdf036206329d55
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
- The processor connects to Redis on its local default endpoint unless another endpoint is provided. With one logical queue, the default `async-job` prefix is sufficient. Configure distinct, stable prefixes when multiple queue definitions share a Redis endpoint.
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
@@ -7,7 +7,7 @@ module Async
7
7
  module Job
8
8
  module Adapter
9
9
  module ActiveJob
10
- VERSION = "0.20.0"
10
+ VERSION = "0.21.0"
11
11
  end
12
12
  end
13
13
  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.20.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.10
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