Class: Delayed::Plugins::Reporting::Context
- Inherits:
-
Object
- Object
- Delayed::Plugins::Reporting::Context
- Defined in:
- lib/delayed-plugins-reporting/context.rb
Instance Attribute Summary collapse
-
#listener ⇒ Object
readonly
Returns the value of attribute listener.
Class Method Summary collapse
Instance Method Summary collapse
- #after_failure(worker, job) ⇒ Object
- #before_perform(worker, job) ⇒ Object
-
#initialize(listener:) ⇒ Context
constructor
A new instance of Context.
Constructor Details
#initialize(listener:) ⇒ Context
Returns a new instance of Context.
8 9 10 |
# File 'lib/delayed-plugins-reporting/context.rb', line 8 def initialize(listener:) @listener = listener end |
Instance Attribute Details
#listener ⇒ Object (readonly)
Returns the value of attribute listener.
6 7 8 |
# File 'lib/delayed-plugins-reporting/context.rb', line 6 def listener @listener end |
Class Method Details
.create(reporter: {}, formatter: {}, listener: {}) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/delayed-plugins-reporting/context.rb', line 26 def create(reporter: {}, formatter: {}, listener: {}) = formatter.dup = listener.dup = reporter.dup formatter_class = .delete(:class) || PrettyJsonJobFormatter listener_class = .delete(:class) || JobListener reporter_class = .delete(:class) || NullReporter new( listener: listener_class.new( reporter: reporter_class.new( formatter: formatter_class.new( ** ), ** ), ** ) ) end |
Instance Method Details
#after_failure(worker, job) ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/delayed-plugins-reporting/context.rb', line 12 def after_failure(worker, job) max_attempts = worker.max_attempts(job) if max_attempts > 1 && job.attempts == max_attempts listener.max_attempts_exceeded(job) end end |
#before_perform(worker, job) ⇒ Object
20 21 22 23 |
# File 'lib/delayed-plugins-reporting/context.rb', line 20 def before_perform(worker, job) return if job.attempts.zero? listener.job_retried(job) end |