class Celluloid::Probe
Constants
- EVENTS_BUFFER
- NOTIFICATIONS_TOPIC_BASE
Public Class Methods
actor_created(actor)
click to toggle source
# File lib/celluloid/probe.rb, line 23 def actor_created(actor) trigger_event(:actor_created, actor) end
actor_died(actor)
click to toggle source
# File lib/celluloid/probe.rb, line 31 def actor_died(actor) trigger_event(:actor_died, actor) end
actor_named(actor)
click to toggle source
# File lib/celluloid/probe.rb, line 27 def actor_named(actor) trigger_event(:actor_named, actor) end
actors_linked(a, b)
click to toggle source
# File lib/celluloid/probe.rb, line 35 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 60 def initialize async.process_queue 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
run_without_supervision()
click to toggle source
# File lib/celluloid/probe.rb, line 19 def run_without_supervision Actor[:probe_actor] = Celluloid::Probe.new end
Private Class Methods
find_actor(obj)
click to toggle source
# File lib/celluloid/probe.rb, line 51 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 43 def trigger_event(name, *args) return unless $CELLULOID_MONITORING EVENTS_BUFFER << [name, args] probe_actor = Actor[:probe_actor] probe_actor.async.process_queue if probe_actor end
Public Instance Methods
dispatch_event(cmd, args)
click to toggle source
# File lib/celluloid/probe.rb, line 71 def dispatch_event(cmd, args) publish(NOTIFICATIONS_TOPIC_BASE % cmd, args) end
process_queue()
click to toggle source
# File lib/celluloid/probe.rb, line 64 def process_queue until EVENTS_BUFFER.empty? event = EVENTS_BUFFER.pop dispatch_event(*event) end end