Module: Concurrent::Actor::Behaviour
- Defined in:
- lib/concurrent/actor/behaviour.rb,
lib/concurrent/actor/behaviour/awaits.rb,
lib/concurrent/actor/behaviour/buffer.rb,
lib/concurrent/actor/behaviour/linking.rb,
lib/concurrent/actor/behaviour/pausing.rb,
lib/concurrent/actor/behaviour/abstract.rb,
lib/concurrent/actor/behaviour/supervised.rb,
lib/concurrent/actor/behaviour/supervising.rb,
lib/concurrent/actor/behaviour/termination.rb,
lib/concurrent/actor/behaviour/sets_results.rb,
lib/concurrent/actor/behaviour/removes_child.rb,
lib/concurrent/actor/behaviour/executes_context.rb,
lib/concurrent/actor/behaviour/terminates_children.rb,
lib/concurrent/actor/behaviour/errors_on_unknown_message.rb
Overview
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. listing few as an example:
-
> Links the actor to other actors and sends actor’s events to them, like: ‘:terminated`, `:paused`, errors, etc TODO example
-
> Handles ‘:await` messages. Which allows to wait on Actor to process all previously send messages.
See Behaviour‘s namespace fo other behaviours. If needed new behaviours can be added, or old one removed to get required behaviour.
Defined Under Namespace
Classes: Abstract, Awaits, Buffer, ErrorsOnUnknownMessage, ExecutesContext, Linking, Pausing, RemovesChild, SetResults, Supervised, Supervising, TerminatesChildren, Termination
Constant Summary collapse
- MESSAGE_PROCESSED =
Object.new
Class Method Summary collapse
- .base ⇒ Object
- .basic_behaviour_definition ⇒ Object
- .restarting_behaviour_definition ⇒ Object
- .supervised ⇒ Object
- .user_messages(on_error) ⇒ Object
Class Method Details
.base ⇒ Object
47 48 49 50 51 52 53 54 |
# File 'lib/concurrent/actor/behaviour.rb', line 47 def self.base [[SetResults, [:terminate!]], # has to be before Termination to be able to remove children form terminated actor [RemovesChild, []], [Termination, []], [TerminatesChildren, []], [Linking, []]] end |
.basic_behaviour_definition ⇒ Object
35 36 37 38 |
# File 'lib/concurrent/actor/behaviour.rb', line 35 def self.basic_behaviour_definition [*base, *(:terminate!)] end |
.restarting_behaviour_definition ⇒ Object
40 41 42 43 44 45 |
# File 'lib/concurrent/actor/behaviour.rb', line 40 def self.restarting_behaviour_definition [*base, *supervised, [Behaviour::Supervising, [:reset!, :one_for_one]], *(:pause!)] end |
.supervised ⇒ Object
56 57 58 59 |
# File 'lib/concurrent/actor/behaviour.rb', line 56 def self.supervised [[Supervised, []], [Pausing, []]] end |
.user_messages(on_error) ⇒ Object
61 62 63 64 65 66 67 |
# File 'lib/concurrent/actor/behaviour.rb', line 61 def self.(on_error) [[Buffer, []], [SetResults, [on_error]], [Awaits, []], [ExecutesContext, []], [ErrorsOnUnknownMessage, []]] end |