lib/announcer/publishers/async_resque_publisher.rb
##
# The suprvisor created in the initializer will restart the PublisherWorker
# but there can be a short period of time when the actor returned by
# Celluloid::Actor[...] is dead. To avoid that we sleep for a millisecond
# to give it time to create a new worker thread.  We try three times before
# giving up.
#
# This should ensure that it's unlikely for a dead worker to be returned.
# However, if a dead worker is returned, then async calls will silently
# fail, allowing normal execution. This makes firing events best-effort.
The suprvisor created in the initializer will restart the PublisherWorker
but there can be a short period of time when the actor returned by
Celluloid::Actor[...] is dead. To avoid that we sleep for a millisecond
to give it time to create a new worker thread.  We try three times before
giving up.

This should ensure that it's unlikely for a dead worker to be returned.
However, if a dead worker is returned, then async calls will silently
fail, allowing normal execution. This makes firing events best-effort.
The suprvisor created in the initializer will restart the PublisherWorker but there can be a short period of time when the actor returned by Celluloid :: Actor [ ... ] is dead . To avoid that we sleep for a millisecond to give it time to create a new worker thread . We try three times before giving up . This should ensure that it ' s unlikely for a dead worker to be returned . However if a dead worker is returned then async calls will silently fail allowing normal execution . This makes firing events best - effort .
def worker
        w = Celluloid::Actor[worker_id] || PublisherWorker.supervise(
          args: [self],
          as: worker_id
        ).send(worker_id)
        3.times {
          if w.dead?
            sleep(0.001)
            w = Celluloid::Actor[worker_id]
          else
            break
          end
        }
        w
      end
def worker w = Celluloid :: Actor [ worker_id ] || PublisherWorker . supervise ( args : [ self ] , as : worker_id ) . send ( worker_id ) 3 . times { if w . dead? sleep ( 0.001 ) w = Celluloid :: Actor [ worker_id ] else break end } w end
The suprvisor created in the initializer will restart the PublisherWorker
but there can be a short period of time when the actor returned by
Celluloid::Actor[...] is dead.
The suprvisor created in the initializer will restart the PublisherWorker but there can be a short period of time when the actor returned by Celluloid :: Actor [ ... ] is dead .
# Retrieve the PublisherWorker or start the supervisor.