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
Class Method Summary
Abstract
- Inherited
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
#behaviour | see Core#behaviour |
#behaviour! | see Core#behaviour! |
#children, #context, #dead_letter_routing, | |
#log | delegates to core.log. |
#redirect, #terminate! |
Concern::Logging
- Included
#log | Logs through Concurrent.global_logger, it can be overridden by setting @logger. |
Actor::PublicDelegations
- Included
#actor_class | Alias for PublicDelegations#context_class. |
#context_class, #executor, #name, #parent, #path, | |
#ref | Alias for PublicDelegations#reference. |
#reference |
Actor::TypeCheck
- Included
Constructor Details
.new(core, subsequent, core_options, handle, strategy) ⇒ Supervising
# File 'lib/concurrent-ruby-edge/concurrent/actor/behaviour/supervising.rb', line 12
def initialize(core, subsequent, , handle, strategy) super core, subsequent, @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. when Exception, :paused receivers = if @strategy == :one_for_all children else [envelope.sender] end receivers.each { |ch| ch << @handle } else pass envelope end end