Sha256: e1f41536a1d47b222860c7c0bce4c7b6ea1aa4bfcb94c3f049bb9f7f99423d5c
Contents?: true
Size: 1.48 KB
Versions: 3
Compression:
Stored size: 1.48 KB
Contents
require 'concurrent/concern/logging' require 'concurrent/actor/type_check' require 'concurrent/actor/internal_delegations' module Concurrent module Actor module Behaviour class Abstract include TypeCheck include InternalDelegations attr_reader :core, :subsequent def initialize(core, subsequent, core_options) @core = Type! core, Core @subsequent = Type! subsequent, Abstract, NilClass end # override to add extra behaviour # @note super needs to be called not to break the chain def on_envelope(envelope) pass envelope end # @param [Envelope] envelope to pass to {#subsequent} behaviour def pass(envelope) subsequent.on_envelope envelope end # override to add extra behaviour # @note super needs to be called not to break the chain def on_event(public, event) subsequent.on_event public, event if subsequent end # broadcasts event to all behaviours and context # @see #on_event # @see AbstractContext#on_event def broadcast(public, event) core.broadcast(public, event) end def reject_envelope(envelope) envelope.reject! ActorTerminated.new(reference) dead_letter_routing << envelope unless envelope.future log(DEBUG) { "rejected #{envelope.message} from #{envelope.sender_path}"} end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems