Class: TransactionalOutbox::Relay::WorkerSet::Worker
- Inherits:
-
Object
- Object
- TransactionalOutbox::Relay::WorkerSet::Worker
- Defined in:
- lib/transactional_outbox/relay/worker_set/worker.rb
Instance Attribute Summary collapse
-
#db ⇒ Object
readonly
Returns the value of attribute db.
-
#producer ⇒ Object
readonly
Returns the value of attribute producer.
-
#queue ⇒ Object
readonly
Returns the value of attribute queue.
Instance Method Summary collapse
-
#initialize(queue) ⇒ Worker
constructor
A new instance of Worker.
- #run ⇒ Object
- #shutdown ⇒ Object
- #shutting_down? ⇒ Boolean
- #stopped? ⇒ Boolean
Constructor Details
#initialize(queue) ⇒ Worker
Returns a new instance of Worker.
11 12 13 14 |
# File 'lib/transactional_outbox/relay/worker_set/worker.rb', line 11 def initialize(queue) @queue = queue @producer = TransactionalOutbox::Producer.new end |
Instance Attribute Details
#db ⇒ Object (readonly)
Returns the value of attribute db.
9 10 11 |
# File 'lib/transactional_outbox/relay/worker_set/worker.rb', line 9 def db @db end |
#producer ⇒ Object (readonly)
Returns the value of attribute producer.
9 10 11 |
# File 'lib/transactional_outbox/relay/worker_set/worker.rb', line 9 def producer @producer end |
#queue ⇒ Object (readonly)
Returns the value of attribute queue.
9 10 11 |
# File 'lib/transactional_outbox/relay/worker_set/worker.rb', line 9 def queue @queue end |
Instance Method Details
#run ⇒ Object
16 17 18 |
# File 'lib/transactional_outbox/relay/worker_set/worker.rb', line 16 def run @thread = spawn_thread end |
#shutdown ⇒ Object
20 21 22 23 24 |
# File 'lib/transactional_outbox/relay/worker_set/worker.rb', line 20 def shutdown return true if thread[:stopped] thread[:shutdown] = true end |
#shutting_down? ⇒ Boolean
26 |
# File 'lib/transactional_outbox/relay/worker_set/worker.rb', line 26 def shutting_down? = !thread.nil? && !!thread[:shutdown] |
#stopped? ⇒ Boolean
27 |
# File 'lib/transactional_outbox/relay/worker_set/worker.rb', line 27 def stopped? = !thread.nil? && !!thread[:stopped] |