good_job 2.0.1 → 2.0.2

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: 917d4630bb8be8ea639b3516e8c4fc5465c5dfd52e0ea361259cf68d58bafe90
4
- data.tar.gz: 867861782ccd6cc20934162c3ca7c2c76ed09407d9e9a7d00ee4d33f9de120cf
3
+ metadata.gz: 11a59540e5e10acc24b9010cb14dc8cbce2f43e8c2f1fe886b6fcf0895a978f2
4
+ data.tar.gz: 6fea5677587740d390f6eaa3dc903cee7c26a8576f14dd91f85f8886637d634b
5
5
  SHA512:
6
- metadata.gz: a45d3b4eb52724ef8faf8d86c74f7051500aa33b3a98c0482bfc1568df95b444088e9ead34820606abf8f2389f3dc6b8ca51f84e6c07421b861a5f49dd825e38
7
- data.tar.gz: 11790854220ca578a92f8b3e4a37fe5cc2d23205cd41e4cb55acfe3e7db5547b091ea4d542b3c466aa12cc59da35903d1566cbf3911cae9c153b8ec1a547e293
6
+ metadata.gz: '087af5fa1eaf81eff5078b5e3303e202aa73ea022d7018d60f01c6abb5a808a9442278e87490f846475c626bb5b5dd320537d68c16697ca54e9f30147f5b9225'
7
+ data.tar.gz: d19960b918937484e0f37eb0456fc3352dc2f4394fab4b0477bde7dedab789f2ce63c48b4971e38d2ff3a5d8725f1761afd425426ad384766f34cf549c35009e
data/CHANGELOG.md CHANGED
@@ -1,19 +1,41 @@
1
1
  # Changelog
2
2
 
3
+ ## [v2.0.2](https://github.com/bensheldon/good_job/tree/v2.0.2) (2021-08-27)
4
+
5
+ [Full Changelog](https://github.com/bensheldon/good_job/compare/v1.99.1...v2.0.2)
6
+
7
+ **Closed issues:**
8
+
9
+ - Migrations generator assumes migrations are in db/migrate [\#352](https://github.com/bensheldon/good_job/issues/352)
10
+
11
+ **Merged pull requests:**
12
+
13
+ - v2.0: Generators support multiple databases: `--database` option, `migrations_paths`, custom `GoodJob.active_record_parent_class` [\#354](https://github.com/bensheldon/good_job/pull/354) ([bensheldon](https://github.com/bensheldon))
14
+ - README style/typo fixes: "web server" and possessive "Rails'" [\#350](https://github.com/bensheldon/good_job/pull/350) ([aried3r](https://github.com/aried3r))
15
+ - Add examples of setting config.good\_job.queues [\#349](https://github.com/bensheldon/good_job/pull/349) ([zachmargolis](https://github.com/zachmargolis))
16
+
17
+ ## [v1.99.1](https://github.com/bensheldon/good_job/tree/v1.99.1) (2021-08-27)
18
+
19
+ [Full Changelog](https://github.com/bensheldon/good_job/compare/v2.0.1...v1.99.1)
20
+
21
+ **Closed issues:**
22
+
23
+ - Does Good job support delay method? [\#344](https://github.com/bensheldon/good_job/issues/344)
24
+
3
25
  ## [v2.0.1](https://github.com/bensheldon/good_job/tree/v2.0.1) (2021-08-24)
4
26
 
5
27
  [Full Changelog](https://github.com/bensheldon/good_job/compare/v2.0.0...v2.0.1)
6
28
 
29
+ **Implemented enhancements:**
30
+
31
+ - Suppress backtrace of ConcurrencyExceededError [\#348](https://github.com/bensheldon/good_job/pull/348) ([reczy](https://github.com/reczy))
32
+
7
33
  **Closed issues:**
8
34
 
9
35
  - Is there any value in seeing a backtrace for ConcurrencyExceededError? [\#347](https://github.com/bensheldon/good_job/issues/347)
10
36
  - Release GoodJob 2.0 [\#307](https://github.com/bensheldon/good_job/issues/307)
11
37
  - Unhandled ActiveJob errors should trigger GoodJob.on\_thread\_error [\#247](https://github.com/bensheldon/good_job/issues/247)
12
38
 
13
- **Merged pull requests:**
14
-
15
- - Suppress backtrace of ConcurrencyExceededError [\#348](https://github.com/bensheldon/good_job/pull/348) ([reczy](https://github.com/reczy))
16
-
17
39
  ## [v2.0.0](https://github.com/bensheldon/good_job/tree/v2.0.0) (2021-08-24)
18
40
 
19
41
  [Full Changelog](https://github.com/bensheldon/good_job/compare/v1.99.0...v2.0.0)
data/README.md CHANGED
@@ -86,6 +86,13 @@ For more of the story of GoodJob, read the [introductory blog post](https://isla
86
86
  $ bin/rails db:migrate
87
87
  ```
88
88
 
89
+ Optional: If using Rails' multiple databases with the `migrations_paths` configuration option, use the `--database` option:
90
+
91
+ ```bash
92
+ bin/rails g good_job:install --database animals
93
+ bin/rails db:migrate:animals
94
+ ```
95
+
89
96
  1. Configure the ActiveJob adapter:
90
97
 
91
98
  ```ruby
@@ -128,7 +135,7 @@ For more of the story of GoodJob, read the [introductory blog post](https://isla
128
135
  $ GOOD_JOB_EXECUTION_MODE=async rails server
129
136
  ```
130
137
 
131
- Additional configuration is likely necessary, see the reference below for f configuration.
138
+ Additional configuration is likely necessary, see the reference below for configuration.
132
139
 
133
140
  ## Compatibility
134
141
 
@@ -219,6 +226,7 @@ config.good_job.poll_interval = 30 # seconds
219
226
  config.good_job.shutdown_timeout = 25 # seconds
220
227
  config.good_job.enable_cron = true
221
228
  config.good_job.cron = { example: { cron: '0 * * * *', class: 'ExampleJob' } }
229
+ config.good_job.queues = '*'
222
230
 
223
231
  # ...or all at once.
224
232
  config.good_job = {
@@ -233,6 +241,7 @@ config.good_job = {
233
241
  class: 'ExampleJob'
234
242
  },
235
243
  },
244
+ queues: '*',
236
245
  }
237
246
  ```
238
247
 
@@ -241,7 +250,7 @@ Available configuration options are:
241
250
  - `execution_mode` (symbol) specifies how and where jobs should be executed. You can also set this with the environment variable `GOOD_JOB_EXECUTION_MODE`. It can be any one of:
242
251
  - `:inline` executes jobs immediately in whatever process queued them (usually the web server process). This should only be used in test and development environments.
243
252
  - `:external` causes the adapter to enqueue jobs, but not execute them. When using this option (the default for production environments), you’ll need to use the command-line tool to actually execute your jobs.
244
- - `:async` (or `:async_server`) executes jobs in separate threads within the Rails webserver process (`bundle exec rails server`). It can be more economical for small workloads because you don’t need a separate machine or environment for running your jobs, but if your web server is under heavy load or your jobs require a lot of resources, you should choose `:external` instead. When not in the Rails webserver, jobs will execute in `:external` mode to ensure jobs are not executed within `rails console`, `rails db:migrate`, `rails assets:prepare`, etc.
253
+ - `:async` (or `:async_server`) executes jobs in separate threads within the Rails web server process (`bundle exec rails server`). It can be more economical for small workloads because you don’t need a separate machine or environment for running your jobs, but if your web server is under heavy load or your jobs require a lot of resources, you should choose `:external` instead. When not in the Rails web server, jobs will execute in `:external` mode to ensure jobs are not executed within `rails console`, `rails db:migrate`, `rails assets:prepare`, etc.
245
254
  - `:async_all` executes jobs in separate threads in _any_ Rails process.
246
255
  - `max_threads` (integer) sets the maximum number of threads to use when `execution_mode` is set to `:async`. You can also set this with the environment variable `GOOD_JOB_MAX_THREADS`.
247
256
  - `queues` (string) determines which queues to execute jobs from when `execution_mode` is set to `:async`. See the description of `good_job start` for more details on the format of this string. You can also set this with the environment variable `GOOD_JOB_QUEUES`.
@@ -387,7 +396,7 @@ config.good_job.enable_cron = ENV['DYNO'] == 'worker.1' # or `true` or via $GOOD
387
396
 
388
397
  # Configure cron with a hash that has a unique key for each recurring job
389
398
  config.good_job.cron = {
390
- # Every 15 minutes, enqueue `ExampleJob.set(priority: -10).perform_later(52, name: "Alice")`
399
+ # Every 15 minutes, enqueue `ExampleJob.set(priority: -10).perform_later(42, name: "Alice")`
391
400
  frequent_task: { # each recurring job must have a unique key
392
401
  cron: "*/15 * * * *", # cron-style scheduling format by fugit gem
393
402
  class: "ExampleJob", # reference the Job class with a string
@@ -419,6 +428,12 @@ To perform upgrades to the GoodJob database tables:
419
428
  bin/rails g good_job:update
420
429
  ```
421
430
 
431
+ Optional: If using Rails' multiple databases with the `migrations_paths` configuration option, use the `--database` option:
432
+
433
+ ```bash
434
+ $ bin/rails g good_job:update --database animals
435
+ ```
436
+
422
437
  1. Run the database migration locally
423
438
 
424
439
  ```bash
@@ -599,7 +614,7 @@ Keep in mind, queue operations and management is an advanced discipline. This st
599
614
 
600
615
  ### Database connections
601
616
 
602
- Each GoodJob execution thread requires its own database connection that is automatically checked out from Rails’s connection pool. _Allowing GoodJob to create more threads than available database connections can lead to timeouts and is not recommended._ For example:
617
+ Each GoodJob execution thread requires its own database connection that is automatically checked out from Rails’ connection pool. _Allowing GoodJob to create more threads than available database connections can lead to timeouts and is not recommended._ For example:
603
618
 
604
619
  ```yaml
605
620
  # config/database.yml
@@ -608,7 +623,7 @@ pool: <%= [ENV.fetch("RAILS_MAX_THREADS", 5).to_i, ENV.fetch("GOOD_JOB_MAX_THREA
608
623
 
609
624
  ### Execute jobs async / in-process
610
625
 
611
- GoodJob can execute jobs "async" in the same process as the webserver (e.g. `bin/rail s`). GoodJob's async execution mode offers benefits of economy by not requiring a separate job worker process, but with the tradeoff of increased complexity. Async mode can be configured in two ways:
626
+ GoodJob can execute jobs "async" in the same process as the web server (e.g. `bin/rails s`). GoodJob's async execution mode offers benefits of economy by not requiring a separate job worker process, but with the tradeoff of increased complexity. Async mode can be configured in two ways:
612
627
 
613
628
  - Via Rails configuration:
614
629
 
@@ -642,7 +657,7 @@ Depending on your application configuration, you may need to take additional ste
642
657
  pool: <%= ENV.fetch("RAILS_MAX_THREADS", 5).to_i + ENV.fetch("GOOD_JOB_MAX_THREADS", 4).to_i %>
643
658
  ```
644
659
 
645
- - When running Puma with workers (`WEB_CONCURRENCY > 0`) or another process-forking webserver, GoodJob's threadpool schedulers should be stopped before forking, restarted after fork, and cleanly shut down on exit. Stopping GoodJob's scheduler pre-fork is recommended to ensure that GoodJob does not continue executing jobs in the parent/controller process. For example, with Puma:
660
+ - When running Puma with workers (`WEB_CONCURRENCY > 0`) or another process-forking web server, GoodJob's threadpool schedulers should be stopped before forking, restarted after fork, and cleanly shut down on exit. Stopping GoodJob's scheduler pre-fork is recommended to ensure that GoodJob does not continue executing jobs in the parent/controller process. For example, with Puma:
646
661
 
647
662
  ```ruby
648
663
  # config/puma.rb
@@ -1,23 +1,23 @@
1
1
  # frozen_string_literal: true
2
2
  require 'rails/generators'
3
3
  require 'rails/generators/active_record'
4
+
4
5
  module GoodJob
5
6
  #
6
7
  # Rails generator used for setting up GoodJob in a Rails application.
7
8
  # Run it with +bin/rails g good_job:install+ in your console.
8
9
  #
9
10
  class InstallGenerator < Rails::Generators::Base
10
- include Rails::Generators::Migration
11
+ include ActiveRecord::Generators::Migration
11
12
 
12
- class << self
13
- delegate :next_migration_number, to: ActiveRecord::Generators::Base
14
- end
13
+ TEMPLATES = File.join(File.dirname(__FILE__), "templates/install")
14
+ source_paths << TEMPLATES
15
15
 
16
- source_paths << File.join(File.dirname(__FILE__), "templates/install")
16
+ class_option :database, type: :string, aliases: %i(--db), desc: "The database for your migration. By default, the current environment's primary database is used."
17
17
 
18
18
  # Generates monolithic migration file that contains all database changes.
19
19
  def create_migration_file
20
- migration_template 'migrations/create_good_jobs.rb.erb', 'db/migrate/create_good_jobs.rb'
20
+ migration_template 'migrations/create_good_jobs.rb.erb', File.join(db_migrate_path, "create_good_jobs.rb")
21
21
  end
22
22
  end
23
23
  end
@@ -8,22 +8,20 @@ module GoodJob
8
8
  # Run it with +bin/rails g good_job:update+ in your console.
9
9
  #
10
10
  class UpdateGenerator < Rails::Generators::Base
11
- include Rails::Generators::Migration
12
-
13
- class << self
14
- delegate :next_migration_number, to: ActiveRecord::Generators::Base
15
- end
11
+ include ActiveRecord::Generators::Migration
16
12
 
17
13
  TEMPLATES = File.join(File.dirname(__FILE__), "templates/update")
18
14
  source_paths << TEMPLATES
19
15
 
16
+ class_option :database, type: :string, aliases: %i(--db), desc: "The database for your migration. By default, the current environment's primary database is used."
17
+
20
18
  # Generates incremental migration files unless they already exist.
21
19
  # All migrations should be idempotent e.g. +add_index+ is guarded with +if_index_exists?+
22
20
  def update_migration_files
23
21
  migration_templates = Dir.children(File.join(TEMPLATES, 'migrations')).sort
24
22
  migration_templates.each do |template_file|
25
23
  destination_file = template_file.match(/^\d*_(.*\.rb)/)[1] # 01_create_good_jobs.rb.erb => create_good_jobs.rb
26
- migration_template "migrations/#{template_file}", "db/migrate/#{destination_file}", skip: true
24
+ migration_template "migrations/#{template_file}", File.join(db_migrate_path, destination_file), skip: true
27
25
  end
28
26
  end
29
27
  end
@@ -8,8 +8,8 @@ module GoodJob
8
8
  #
9
9
  # - +:inline+ executes jobs immediately in whatever process queued them (usually the web server process). This should only be used in test and development environments.
10
10
  # - +:external+ causes the adapter to enqueue jobs, but not execute them. When using this option (the default for production environments), you'll need to use the command-line tool to actually execute your jobs.
11
- # - +:async+ (or +:async_server+) executes jobs in separate threads within the Rails webserver process (`bundle exec rails server`). It can be more economical for small workloads because you don't need a separate machine or environment for running your jobs, but if your web server is under heavy load or your jobs require a lot of resources, you should choose +:external+ instead.
12
- # When not in the Rails webserver, jobs will execute in +:external+ mode to ensure jobs are not executed within `rails console`, `rails db:migrate`, `rails assets:prepare`, etc.
11
+ # - +:async+ (or +:async_server+) executes jobs in separate threads within the Rails web server process (`bundle exec rails server`). It can be more economical for small workloads because you don't need a separate machine or environment for running your jobs, but if your web server is under heavy load or your jobs require a lot of resources, you should choose +:external+ instead.
12
+ # When not in the Rails web server, jobs will execute in +:external+ mode to ensure jobs are not executed within `rails console`, `rails db:migrate`, `rails assets:prepare`, etc.
13
13
  # - +:async_all+ executes jobs in any Rails process.
14
14
  #
15
15
  # The default value depends on the Rails environment:
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
  module GoodJob
3
3
  # GoodJob gem version.
4
- VERSION = '2.0.1'
4
+ VERSION = '2.0.2'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: good_job
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.1
4
+ version: 2.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Sheldon
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-08-24 00:00:00.000000000 Z
11
+ date: 2021-08-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activejob