Module: Karafka::Pro::Processing::PeriodicJob::Consumer
- Defined in:
- lib/karafka/pro/processing/periodic_job/consumer.rb
Overview
Consumer extra methods useful only when periodic jobs are in use
Class Method Summary collapse
-
.included(consumer_singleton_class) ⇒ Object
Defines an empty ‘#tick` method if not present.
Instance Method Summary collapse
-
#on_before_schedule_tick ⇒ Object
Runs the on-schedule tick periodic operations This method is an alias but is part of the naming convention used for other flows, this is why we do not reference the ‘handle_before_schedule_tick` directly.
-
#on_tick ⇒ Object
Used by the executor to trigger consumer tick.
Class Method Details
.included(consumer_singleton_class) ⇒ Object
Defines an empty ‘#tick` method if not present
We define it that way due to our injection strategy flow.
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/karafka/pro/processing/periodic_job/consumer.rb', line 45 def included(consumer_singleton_class) # Do not define empty tick method on consumer if it already exists # We only define it when it does not exist to have empty periodic ticking # # We need to check both cases (public and private) since user is not expected to # have this method public return if consumer_singleton_class.method_defined?(:tick) return if consumer_singleton_class.private_instance_methods.include?(:tick) # Create empty ticking method consumer_singleton_class.class_eval do def tick end end end |
Instance Method Details
#on_before_schedule_tick ⇒ Object
Runs the on-schedule tick periodic operations This method is an alias but is part of the naming convention used for other flows, this is why we do not reference the ‘handle_before_schedule_tick` directly
65 66 67 |
# File 'lib/karafka/pro/processing/periodic_job/consumer.rb', line 65 def on_before_schedule_tick handle_before_schedule_tick end |
#on_tick ⇒ Object
Used by the executor to trigger consumer tick
71 72 73 74 75 76 77 78 79 80 |
# File 'lib/karafka/pro/processing/periodic_job/consumer.rb', line 71 def on_tick handle_tick rescue => e Karafka.monitor.instrument( "error.occurred", error: e, caller: self, type: "consumer.tick.error" ) end |