Class: Dynflow::Connectors::Direct::Core

Inherits:
Actor
  • Object
show all
Defined in:
lib/dynflow/connectors/direct.rb

Instance Method Summary collapse

Methods inherited from Actor

#behaviour_definition, #finish_termination, #start_termination, #terminating?

Methods included from MethodicActor

#on_message

Methods included from Actor::LogWithFullBacktrace

#log

Constructor Details

#initialize(connector) ⇒ Core

Returns a new instance of Core.



7
8
9
10
11
# File 'lib/dynflow/connectors/direct.rb', line 7

def initialize(connector)
  @connector = connector
  @worlds = {}
  @executor_round_robin = RoundRobin.new
end

Instance Method Details

#handle_envelope(envelope) ⇒ Object



28
29
30
31
32
33
34
# File 'lib/dynflow/connectors/direct.rb', line 28

def handle_envelope(envelope)
  if world = find_receiver(envelope)
    @connector.receive(world, envelope)
  else
    log(Logger::ERROR, "Receiver for envelope #{envelope} not found")
  end
end

#start_listening(world) ⇒ Object



13
14
15
16
# File 'lib/dynflow/connectors/direct.rb', line 13

def start_listening(world)
  @worlds[world.id] = world
  @executor_round_robin.add(world) if world.executor
end

#stop_listening(world) ⇒ Object



22
23
24
25
26
# File 'lib/dynflow/connectors/direct.rb', line 22

def stop_listening(world)
  @worlds.delete(world.id)
  @executor_round_robin.delete(world) if world.executor
  reference.tell(:terminate!) if @worlds.empty?
end

#stop_receiving_new_work(world) ⇒ Object



18
19
20
# File 'lib/dynflow/connectors/direct.rb', line 18

def stop_receiving_new_work(world)
  @executor_round_robin.delete(world)
end