Class: Magent::ActorChannel

Inherits:
GenericChannel show all
Defined in:
lib/magent/actor_channel.rb

Instance Attribute Summary

Attributes inherited from GenericChannel

#name

Instance Method Summary collapse

Methods inherited from GenericChannel

#collection, #dequeue, #enqueue, #initialize, #message_count, #next_message, #queue_count

Methods included from Failure

#enqueue_error, #error_collection, #error_count, #errors, #failed, #remove_error, #retry_error

Constructor Details

This class inherits a constructor from Magent::GenericChannel

Instance Method Details

#on_shutdownObject



28
29
30
31
32
# File 'lib/magent/actor_channel.rb', line 28

def on_shutdown
  if @method
    self.enqueue(@method, @payload)
  end
end

#process!(message) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/magent/actor_channel.rb', line 7

def process!(message)
  @actor = Magent.current_actor

  @method, @payload = message
  return false if @method.nil?

  sucess = @actor._run_tasks

  $stderr.puts "#{@actor.class}##{@method}(#{@payload.inspect})"
  if @actor.class.can_handle?(@method)
    @actor.send(@method, @payload)
    return true
  else
    $stderr.puts "Unknown action: #{@method} (payload=#{@payload.inspect})"
  end

  @method, @payload = nil

  sucess
end

#push(message, args) ⇒ Object



3
4
5
# File 'lib/magent/actor_channel.rb', line 3

def push(message, args)
  enqueue([message, args])
end