module Concurrent::Actor::Behaviour
Actors have modular architecture, which is achieved by combining a light core with chain of behaviours. Each message or internal event propagates through the chain allowing the behaviours react based on their responsibility.
-
{Behaviour::Linking}:
> {include:Actor::Behaviour::Linking}
-
{Behaviour::Awaits}:
> {include:Actor::Behaviour::Awaits}
-
{Behaviour::Pausing}:
> {include:Actor::Behaviour::Pausing}
-
{Behaviour::Supervising}:
> {include:Actor::Behaviour::Supervising}
-
{Behaviour::Supervising}:
> {include:Actor::Behaviour::Supervising}
-
{Behaviour::ExecutesContext}:
> {include:Actor::Behaviour::ExecutesContext}
-
{Behaviour::ErrorsOnUnknownMessage}:
> {include:Actor::Behaviour::ErrorsOnUnknownMessage}
-
{Behaviour::Termination}:
> {include:Actor::Behaviour::Termination}
-
{Behaviour::RemovesChild}:
> {include:Actor::Behaviour::RemovesChild}
If needed new behaviours can be added, or old one removed to get required behaviour.
-
{Context} uses {include:Actor::Behaviour.basic_behaviour_definition}
-
{RestartingContext} uses {include:Actor::Behaviour.restarting_behaviour_definition}
Constants
- MESSAGE_PROCESSED
Public Class Methods
@see '' its source code
# File lib/concurrent/actor/behaviour.rb, line 105 def self.base(on_error) [[SetResults, on_error], # has to be before Termination to be able to remove children from terminated actor RemovesChild, Termination] end
Array of behaviours and their construction parameters.
[[Behaviour::SetResults, :terminate!], [Behaviour::RemovesChild], [Behaviour::Termination], [Behaviour::Linking], [Behaviour::Awaits], [Behaviour::ExecutesContext], [Behaviour::ErrorsOnUnknownMessage]]
@see '' its source code
# File lib/concurrent/actor/behaviour.rb, line 77 def self.basic_behaviour_definition [*base(:terminate!), *linking, *user_messages] end
@see '' its source code
# File lib/concurrent/actor/behaviour.rb, line 113 def self.linking [Linking] end
Array of behaviours and their construction parameters.
[[Behaviour::SetResults, :pause!], [Behaviour::RemovesChild], [Behaviour::Termination], [Behaviour::Linking], [Behaviour::Pausing], [Behaviour::Supervising, :reset!, :one_for_one], [Behaviour::Awaits], [Behaviour::ExecutesContext], [Behaviour::ErrorsOnUnknownMessage]]
@see '' its source code
# File lib/concurrent/actor/behaviour.rb, line 96 def self.restarting_behaviour_definition(handle = :reset!, strategy = :one_for_one) [*base(:pause!), *linking, *supervised, *supervising(handle, strategy), *user_messages] end
@see '' its source code
# File lib/concurrent/actor/behaviour.rb, line 118 def self.supervised [Pausing] end
@see '' its source code
# File lib/concurrent/actor/behaviour.rb, line 123 def self.supervising(handle = :reset!, strategy = :one_for_one) [[Behaviour::Supervising, handle, strategy]] end
@see '' its source code
# File lib/concurrent/actor/behaviour.rb, line 128 def self.user_messages [Awaits, ExecutesContext, ErrorsOnUnknownMessage] end