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.



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

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

Instance Method Details

#handle_envelope(envelope) ⇒ Object



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

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



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

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

#stop_listening(world) ⇒ Object



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

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



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

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