Class: Plumbing::Actor::Threaded::Message

Inherits:
Object
  • Object
show all
Defined in:
lib/plumbing/actor/threaded.rb

Instance Method Summary collapse

Instance Method Details

#callObject



57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/plumbing/actor/threaded.rb', line 57

def call
  args = Plumbing::Actor.transporter.unmarshal(*packed_args)
  params = Plumbing::Actor.transporter.unmarshal(packed_params)
  Plumbing.config.logger.debug { "---> #{target.class}##{message_name}(#{args.first.inspect}, #{params.first.inspect}, &#{!unsafe_block.nil?})\n#{Thread.current.name}" }
  value = target.send message_name, *args, **params.first, &unsafe_block
  Plumbing.config.logger.debug { "===> #{target.class}##{message_name} => #{value}\n#{Thread.current.name}" }

  result.put Plumbing::Actor.transporter.marshal(value)
rescue => ex
  Plumbing.config.logger.debug { "!!!! #{target.class}##{message_name} => #{ex}\n#{Thread.current.name}" }
  result.put ex
end

#valueObject



70
71
72
73
74
# File 'lib/plumbing/actor/threaded.rb', line 70

def value
  value = Plumbing::Actor.transporter.unmarshal(*result.take(Plumbing.config.timeout)).first
  raise value if value.is_a? Exception
  value
end