Class: Dionysus::Producer::Outbox::Runner
- Inherits:
-
Object
- Object
- Dionysus::Producer::Outbox::Runner
- Defined in:
- lib/dionysus/producer/outbox/runner.rb
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
Instance Method Summary collapse
-
#initialize(config: Dionysus::Producer.configuration, logger: Dionysus.logger) ⇒ Runner
constructor
A new instance of Runner.
- #start ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize(config: Dionysus::Producer.configuration, logger: Dionysus.logger) ⇒ Runner
Returns a new instance of Runner.
7 8 9 10 11 12 13 |
# File 'lib/dionysus/producer/outbox/runner.rb', line 7 def initialize(config: Dionysus::Producer.configuration, logger: Dionysus.logger) @id = SecureRandom.uuid @logger = logger logger.("Dionysus::Producer::Outbox::Runners #{id}") if logger.respond_to?(:push_tags) @config = config end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
4 5 6 |
# File 'lib/dionysus/producer/outbox/runner.rb', line 4 def id @id end |
Instance Method Details
#start ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/dionysus/producer/outbox/runner.rb', line 15 def start log("started") instrument("outbox_producer.started") @should_stop = false ensure_database_connection! loop do if @should_stop instrument("outbox_producer.shutting_down") log("shutting down") break end process_topics instrument("outbox_producer.heartbeat") sleep outbox_worker_sleep_seconds end rescue => e error_handler.capture_exception(e) log("error: #{e} #{e.}") instrument("outbox_producer.error", error: e, error_message: e.) raise e end |
#stop ⇒ Object
37 38 39 40 41 |
# File 'lib/dionysus/producer/outbox/runner.rb', line 37 def stop log("Outbox worker stopping") instrument("outbox_producer.stopped") @should_stop = true end |