123456789_123456789_123456789_123456789_123456789_

Class: Concurrent::Actor::Behaviour::SetResults

Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
self, Abstract
Instance Chain:
Inherits: Concurrent::Actor::Behaviour::Abstract
Defined in: lib/concurrent-ruby-edge/concurrent/actor/behaviour/sets_results.rb

Overview

Collects returning value and sets the ResolvableFuture in the Actor::Envelope or error on failure.

Constant Summary

Concern::Logging - Included

SEV_LABEL

Class Method Summary

Instance Attribute Summary

Instance Method Summary

Abstract - Inherited

#broadcast

broadcasts event to all behaviours and context.

#on_envelope

override to add extra behaviour.

#on_event

override to add extra behaviour.

#pass, #reject_envelope

Actor::InternalDelegations - Included

Concern::Logging - Included

#log

Logs through Concurrent.global_logger, it can be overridden by setting @logger.

Actor::PublicDelegations - Included

Actor::TypeCheck - Included

Constructor Details

.new(core, subsequent, core_options, error_strategy) ⇒ SetResults

[ GitHub ]

  
# File 'lib/concurrent-ruby-edge/concurrent/actor/behaviour/sets_results.rb', line 10

def initialize(core, subsequent, core_options, error_strategy)
  super core, subsequent, core_options
  @error_strategy = Match! error_strategy, :just_log, :terminate!, :pause!
end

Instance Attribute Details

#error_strategy (readonly)

[ GitHub ]

  
# File 'lib/concurrent-ruby-edge/concurrent/actor/behaviour/sets_results.rb', line 8

attr_reader :error_strategy

Instance Method Details

#on_envelope(envelope)

[ GitHub ]

  
# File 'lib/concurrent-ruby-edge/concurrent/actor/behaviour/sets_results.rb', line 15

def on_envelope(envelope)
  result = pass envelope
  if result != MESSAGE_PROCESSED && !envelope.future.nil?
    envelope.future.fulfill result
    log(DEBUG) { "finished processing of #{envelope.message.inspect}"}
  end
  nil
rescue => error
  log ERROR, error
  case error_strategy
  when :terminate!
    terminate!
  when :pause!
    behaviour!(Pausing).pause!(error)
  when :just_log
    # nothing
  else
    raise
  end
  envelope.future.reject error unless envelope.future.nil?
end