Class: TransactionalOutbox::Relay::WorkerSet::Worker

Inherits:
Object
  • Object
show all
Defined in:
lib/transactional_outbox/relay/worker_set/worker.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#dbObject (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

#producerObject (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

#queueObject (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

#runObject



16
17
18
# File 'lib/transactional_outbox/relay/worker_set/worker.rb', line 16

def run
  @thread = spawn_thread
end

#shutdownObject



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

Returns:

  • (Boolean)


26
# File 'lib/transactional_outbox/relay/worker_set/worker.rb', line 26

def shutting_down? = !thread.nil? && !!thread[:shutdown]

#stopped?Boolean

Returns:

  • (Boolean)


27
# File 'lib/transactional_outbox/relay/worker_set/worker.rb', line 27

def stopped? = !thread.nil? && !!thread[:stopped]