123456789_123456789_123456789_123456789_123456789_

Class: Concurrent::Actor::Behaviour::Supervising

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/supervising.rb

Overview

Note:

TODO missing example

Note:

this will change in next version to support supervision trees better

Handles supervised actors. Handle configures what to do with failed child: :terminate!, :resume!, :reset!, or :restart!. Strategy sets :one_for_one (restarts just failed actor) or :one_for_all (restarts all child actors).

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, handle, strategy) ⇒ Supervising

[ GitHub ]

  
# File 'lib/concurrent-ruby-edge/concurrent/actor/behaviour/supervising.rb', line 12

def initialize(core, subsequent, core_options, handle, strategy)
  super core, subsequent, core_options
  @handle   = Match! handle, :terminate!, :resume!, :reset!, :restart!
  @strategy = case @handle
              when :terminate!
                Match! strategy, nil
              when :resume!
                Match! strategy, :one_for_one
              when :reset!, :restart!
                Match! strategy, :one_for_one, :one_for_all
              end
end

Instance Method Details

#on_envelope(envelope)

[ GitHub ]

  
# File 'lib/concurrent-ruby-edge/concurrent/actor/behaviour/supervising.rb', line 25

def on_envelope(envelope)
  case envelope.message
  when Exception, :paused
    receivers = if @strategy == :one_for_all
                  children
                else
                  [envelope.sender]
                end
    receivers.each { |ch| ch << @handle }
  else
    pass envelope
  end
end