good_job 4.1.0 → 4.2.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.
Files changed (69) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +71 -0
  3. data/README.md +10 -10
  4. data/app/charts/good_job/performance_index_chart.rb +1 -1
  5. data/app/charts/good_job/performance_show_chart.rb +1 -1
  6. data/app/controllers/good_job/application_controller.rb +1 -1
  7. data/app/controllers/good_job/batches_controller.rb +6 -0
  8. data/app/controllers/good_job/frontends_controller.rb +6 -2
  9. data/app/controllers/good_job/performance_controller.rb +1 -1
  10. data/app/frontend/good_job/icons.svg +79 -0
  11. data/app/frontend/good_job/style.css +5 -0
  12. data/app/helpers/good_job/icons_helper.rb +8 -5
  13. data/app/models/concerns/good_job/advisory_lockable.rb +17 -7
  14. data/app/models/concerns/good_job/error_events.rb +2 -2
  15. data/app/models/concerns/good_job/reportable.rb +8 -12
  16. data/app/models/good_job/batch.rb +31 -9
  17. data/app/models/good_job/batch_record.rb +19 -20
  18. data/app/models/good_job/discrete_execution.rb +6 -59
  19. data/app/models/good_job/execution.rb +59 -4
  20. data/app/models/good_job/execution_result.rb +6 -6
  21. data/app/models/good_job/job.rb +543 -12
  22. data/app/models/good_job/process.rb +14 -3
  23. data/app/views/good_job/batches/_jobs.erb +1 -1
  24. data/app/views/good_job/batches/_table.erb +7 -1
  25. data/app/views/good_job/batches/show.html.erb +8 -0
  26. data/app/views/good_job/jobs/index.html.erb +1 -1
  27. data/app/views/layouts/good_job/application.html.erb +7 -7
  28. data/config/brakeman.ignore +75 -0
  29. data/config/locales/de.yml +54 -49
  30. data/config/locales/en.yml +5 -0
  31. data/config/locales/es.yml +19 -14
  32. data/config/locales/fr.yml +5 -0
  33. data/config/locales/it.yml +5 -0
  34. data/config/locales/ja.yml +10 -5
  35. data/config/locales/ko.yml +9 -4
  36. data/config/locales/nl.yml +5 -0
  37. data/config/locales/pt-BR.yml +5 -0
  38. data/config/locales/ru.yml +5 -0
  39. data/config/locales/tr.yml +5 -0
  40. data/config/locales/uk.yml +6 -1
  41. data/config/routes.rb +8 -4
  42. data/lib/good_job/active_job_extensions/concurrency.rb +109 -98
  43. data/lib/good_job/adapter/inline_buffer.rb +73 -0
  44. data/lib/good_job/adapter.rb +59 -53
  45. data/lib/good_job/capsule_tracker.rb +2 -2
  46. data/lib/good_job/configuration.rb +13 -12
  47. data/lib/good_job/cron_manager.rb +1 -3
  48. data/lib/good_job/current_thread.rb +4 -4
  49. data/lib/good_job/notifier/process_heartbeat.rb +3 -2
  50. data/lib/good_job/version.rb +1 -1
  51. data/lib/good_job.rb +6 -5
  52. metadata +6 -20
  53. data/app/models/good_job/base_execution.rb +0 -605
  54. data/app/views/good_job/shared/icons/_arrow_clockwise.html.erb +0 -5
  55. data/app/views/good_job/shared/icons/_check.html.erb +0 -5
  56. data/app/views/good_job/shared/icons/_circle_half.html.erb +0 -4
  57. data/app/views/good_job/shared/icons/_clock.html.erb +0 -5
  58. data/app/views/good_job/shared/icons/_dash_circle.html.erb +0 -5
  59. data/app/views/good_job/shared/icons/_dots.html.erb +0 -3
  60. data/app/views/good_job/shared/icons/_eject.html.erb +0 -4
  61. data/app/views/good_job/shared/icons/_exclamation.html.erb +0 -5
  62. data/app/views/good_job/shared/icons/_globe.html.erb +0 -3
  63. data/app/views/good_job/shared/icons/_info.html.erb +0 -4
  64. data/app/views/good_job/shared/icons/_moon_stars_fill.html.erb +0 -5
  65. data/app/views/good_job/shared/icons/_pause.html.erb +0 -4
  66. data/app/views/good_job/shared/icons/_play.html.erb +0 -4
  67. data/app/views/good_job/shared/icons/_skip_forward.html.erb +0 -4
  68. data/app/views/good_job/shared/icons/_stop.html.erb +0 -4
  69. data/app/views/good_job/shared/icons/_sun_fill.html.erb +0 -4
@@ -1,63 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module GoodJob # :nodoc:
4
- class DiscreteExecution < BaseRecord
5
- include ErrorEvents
6
-
7
- self.table_name = 'good_job_executions'
8
- self.implicit_order_column = 'created_at'
9
-
10
- belongs_to :job, class_name: 'GoodJob::Job', foreign_key: 'active_job_id', primary_key: 'active_job_id', inverse_of: :discrete_executions, optional: true
11
-
12
- scope :finished, -> { where.not(finished_at: nil) }
13
-
14
- alias_attribute :performed_at, :created_at
15
-
16
- # TODO: Remove when support for Rails 6.1 is dropped
17
- attribute :duration, :interval if ActiveJob.version.canonical_segments.take(2) == [6, 1]
18
-
19
- def number
20
- serialized_params.fetch('executions', 0) + 1
21
- end
22
-
23
- # Time between when this job was expected to run and when it started running
24
- def queue_latency
25
- created_at - scheduled_at
26
- end
27
-
28
- # Monotonic time between when this job started and finished
29
- def runtime_latency
30
- duration
31
- end
32
-
33
- def last_status_at
34
- finished_at || created_at
35
- end
36
-
37
- def status
38
- if finished_at.present?
39
- if error.present? && job.finished_at.present?
40
- :discarded
41
- elsif error.present?
42
- :retried
43
- else
44
- :succeeded
45
- end
46
- else
47
- :running
48
- end
49
- end
50
-
51
- def display_serialized_params
52
- serialized_params.merge({
53
- _good_job_execution: attributes.except('serialized_params'),
54
- })
55
- end
56
-
57
- def filtered_error_backtrace
58
- Rails.backtrace_cleaner.clean(error_backtrace || [])
59
- end
3
+ module GoodJob
4
+ # Deprecated, use +Execution+ instead.
5
+ class DiscreteExecution < Execution
60
6
  end
61
- end
62
7
 
63
- ActiveSupport.run_load_hooks(:good_job_execution, GoodJob::DiscreteExecution)
8
+ include ActiveSupport::Deprecation::DeprecatedConstantAccessor
9
+ deprecate_constant :DiscreteExecution, 'Execution', deprecator: GoodJob.deprecator
10
+ end
@@ -1,8 +1,63 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module GoodJob
4
- # Created at the time a Job begins executing.
5
- # Behavior from +DiscreteExecution+ will be merged into this class.
6
- class Execution < DiscreteExecution
3
+ module GoodJob # :nodoc:
4
+ class Execution < BaseRecord
5
+ include ErrorEvents
6
+
7
+ self.table_name = 'good_job_executions'
8
+ self.implicit_order_column = 'created_at'
9
+
10
+ belongs_to :job, class_name: 'GoodJob::Job', foreign_key: 'active_job_id', primary_key: 'id', inverse_of: :executions, optional: true
11
+
12
+ scope :finished, -> { where.not(finished_at: nil) }
13
+
14
+ alias_attribute :performed_at, :created_at
15
+
16
+ # TODO: Remove when support for Rails 6.1 is dropped
17
+ attribute :duration, :interval if ActiveJob.version.canonical_segments.take(2) == [6, 1]
18
+
19
+ def number
20
+ serialized_params.fetch('executions', 0) + 1
21
+ end
22
+
23
+ # Time between when this job was expected to run and when it started running
24
+ def queue_latency
25
+ created_at - scheduled_at
26
+ end
27
+
28
+ # Monotonic time between when this job started and finished
29
+ def runtime_latency
30
+ duration
31
+ end
32
+
33
+ def last_status_at
34
+ finished_at || created_at
35
+ end
36
+
37
+ def status
38
+ if finished_at.present?
39
+ if error.present? && job.finished_at.present?
40
+ :discarded
41
+ elsif error.present?
42
+ :retried
43
+ else
44
+ :succeeded
45
+ end
46
+ else
47
+ :running
48
+ end
49
+ end
50
+
51
+ def display_serialized_params
52
+ serialized_params.merge({
53
+ _good_job_execution: attributes.except('serialized_params'),
54
+ })
55
+ end
56
+
57
+ def filtered_error_backtrace
58
+ Rails.backtrace_cleaner.clean(error_backtrace || [])
59
+ end
7
60
  end
8
61
  end
62
+
63
+ ActiveSupport.run_load_hooks(:good_job_execution, GoodJob::Execution)
@@ -13,22 +13,22 @@ module GoodJob
13
13
  attr_reader :error_event
14
14
  # @return [Boolean, nil]
15
15
  attr_reader :unexecutable
16
- # @return [GoodJob::Execution, nil]
17
- attr_reader :retried
16
+ # @return [GoodJob::Job, nil]
17
+ attr_reader :retried_job
18
18
 
19
19
  # @param value [Object, nil]
20
20
  # @param handled_error [Exception, nil]
21
21
  # @param unhandled_error [Exception, nil]
22
22
  # @param error_event [String, nil]
23
23
  # @param unexecutable [Boolean, nil]
24
- # @param retried [Boolean, nil]
25
- def initialize(value:, handled_error: nil, unhandled_error: nil, error_event: nil, unexecutable: nil, retried: nil)
24
+ # @param retried_job [GoodJob::Job, nil]
25
+ def initialize(value:, handled_error: nil, unhandled_error: nil, error_event: nil, unexecutable: nil, retried_job: nil)
26
26
  @value = value
27
27
  @handled_error = handled_error
28
28
  @unhandled_error = unhandled_error
29
29
  @error_event = error_event
30
30
  @unexecutable = unexecutable
31
- @retried = retried
31
+ @retried_job = retried_job
32
32
  end
33
33
 
34
34
  # @return [Boolean]
@@ -38,7 +38,7 @@ module GoodJob
38
38
 
39
39
  # @return [Boolean]
40
40
  def retried?
41
- retried.present?
41
+ retried_job.present?
42
42
  end
43
43
  end
44
44
  end