Class: Celluloid::Probe

Inherits:
Object
  • Object
show all
Includes:
Celluloid, Notifications
Defined in:
lib/celluloid/probe.rb

Constant Summary collapse

NOTIFICATIONS_TOPIC_BASE =
'celluloid.events.%s'
INITIAL_EVENTS =
Queue.new

Constants included from Celluloid

BARE_OBJECT_WARNING_MESSAGE, DeadActorError, Error, LINKING_TIMEOUT, NotActorError, OWNER_IVAR, TIMER_QUANTUM, TimeoutError, VERSION

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Notifications

notifier, #publish, #subscribe, #unsubscribe

Methods included from Celluloid

#abort, actor?, #after, #async, boot, #call_chain_id, cores, #current_actor, #defer, detect_recursion, #every, exception_handler, #exclusive, #exclusive?, #future, included, init, #link, #linked_to?, #links, mailbox, #monitor, #monitoring?, #receive, register_shutdown, running?, shutdown, #signal, #sleep, stack_dump, start, suspend, #tasks, #terminate, #timeout, #unlink, #unmonitor, uuid, version, #wait

Constructor Details

#initializeProbe


58
59
60
# File 'lib/celluloid/probe.rb', line 58

def initialize
  async.first_run
end

Class Method Details

.actor_created(actor) ⇒ Object


19
20
21
# File 'lib/celluloid/probe.rb', line 19

def actor_created(actor)
  trigger_event(:actor_created, actor)
end

.actor_died(actor) ⇒ Object


27
28
29
# File 'lib/celluloid/probe.rb', line 27

def actor_died(actor)
  trigger_event(:actor_died, actor)
end

.actor_named(actor) ⇒ Object


23
24
25
# File 'lib/celluloid/probe.rb', line 23

def actor_named(actor)
  trigger_event(:actor_named, actor)
end

.actors_linked(a, b) ⇒ Object


31
32
33
34
35
# File 'lib/celluloid/probe.rb', line 31

def actors_linked(a, b)
  a = find_actor(a)
  b = find_actor(b)
  trigger_event(:actors_linked, a, b)
end

.runObject


14
15
16
17
# File 'lib/celluloid/probe.rb', line 14

def run  # spawn the actor if not found

  supervise_as(:probe_actor) unless Actor[:probe_actor] && Actor[:probe_actor].alive?
end

Instance Method Details

#dispatch_event(cmd, args) ⇒ Object


69
70
71
# File 'lib/celluloid/probe.rb', line 69

def dispatch_event(cmd, args)
  publish(NOTIFICATIONS_TOPIC_BASE % cmd, args)
end

#first_runObject


62
63
64
65
66
67
# File 'lib/celluloid/probe.rb', line 62

def first_run
  until INITIAL_EVENTS.size == 0
    event = INITIAL_EVENTS.pop
    dispatch_event(*event)
  end
end