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