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".freeze
EVENTS_BUFFER =
Queue.new

Constants included from Celluloid

BARE_OBJECT_WARNING_MESSAGE, LINKING_TIMEOUT, OWNER_IVAR, 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?, public_registry, publish, #receive, register_shutdown, running?, shutdown, #signal, #sleep, stack_dump, stack_summary, start, supervise, suspend, #tasks, #terminate, #timeout, #unlink, #unmonitor, uuid, version, #wait

Constructor Details

#initializeProbe

Returns a new instance of Probe.



66
67
68
# File 'lib/celluloid/probe.rb', line 66

def initialize
  async.process_queue
end

Class Method Details

.actor_created(actor) ⇒ Object



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

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

.actor_died(actor) ⇒ Object



34
35
36
# File 'lib/celluloid/probe.rb', line 34

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

.actor_named(actor) ⇒ Object



30
31
32
# File 'lib/celluloid/probe.rb', line 30

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

.actors_linked(a, b) ⇒ Object



38
39
40
41
42
# File 'lib/celluloid/probe.rb', line 38

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

.runObject



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

def run
  # spawn the actor if not found
  supervise_as(:probe_actor) unless Actor[:probe_actor] && Actor[:probe_actor].alive?
end

.run_without_supervisionObject



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

def run_without_supervision
  Actor[:probe_actor] = Celluloid::Probe.new
end

Instance Method Details

#dispatch_event(cmd, args) ⇒ Object



77
78
79
# File 'lib/celluloid/probe.rb', line 77

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

#process_queueObject



70
71
72
73
74
75
# File 'lib/celluloid/probe.rb', line 70

def process_queue
  until EVENTS_BUFFER.empty?
    event = EVENTS_BUFFER.pop
    dispatch_event(*event)
  end
end