class Celluloid::Probe

Constants

INITIAL_EVENTS
NOTIFICATIONS_TOPIC_BASE

Public Class Methods

actor_created(actor) click to toggle source
# File lib/celluloid/probe.rb, line 19
def actor_created(actor)
  trigger_event(:actor_created, actor)
end
actor_died(actor) click to toggle source
# File lib/celluloid/probe.rb, line 27
def actor_died(actor)
  trigger_event(:actor_died, actor)
end
actor_named(actor) click to toggle source
# File lib/celluloid/probe.rb, line 23
def actor_named(actor)
  trigger_event(:actor_named, actor)
end
actors_linked(a, b) click to toggle source
# 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
new() click to toggle source
# File lib/celluloid/probe.rb, line 58
def initialize
  async.first_run
end
run() click to toggle source
# 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

Private Class Methods

find_actor(obj) click to toggle source
# File lib/celluloid/probe.rb, line 49
def find_actor(obj)
  if obj.__send__(:class) == Actor
    obj
  elsif owner = obj.instance_variable_get(OWNER_IVAR)
    owner
  end
end
trigger_event(name, *args) click to toggle source
# File lib/celluloid/probe.rb, line 39
def trigger_event(name, *args)
  return unless $CELLULOID_MONITORING
  probe_actor = Actor[:probe_actor]
  if probe_actor
    probe_actor.async.dispatch_event(name, args)
  else
    INITIAL_EVENTS << [name, args]
  end
end

Public Instance Methods

dispatch_event(cmd, args) click to toggle source
# File lib/celluloid/probe.rb, line 69
def dispatch_event(cmd, args)
  publish(NOTIFICATIONS_TOPIC_BASE % cmd, args)
end
first_run() click to toggle source
# File lib/celluloid/probe.rb, line 62
def first_run
  until INITIAL_EVENTS.size == 0
    event = INITIAL_EVENTS.pop
    dispatch_event(*event)
  end
end