Sha256: 74fa95e53125756c6e54aca504cad5fad5b4da63d8957d52278cb896f4bc5d6f

Contents?: true

Size: 1.39 KB

Versions: 16

Compression:

Stored size: 1.39 KB

Contents

require 'concurrent/concern/logging'

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

16 entries across 16 versions & 1 rubygems

Version Path
concurrent-ruby-edge-0.6.0 lib/concurrent-ruby-edge/concurrent/actor/behaviour/abstract.rb
concurrent-ruby-edge-0.6.0.pre1 lib/concurrent-ruby-edge/concurrent/actor/behaviour/abstract.rb
concurrent-ruby-edge-0.5.0 lib-edge/concurrent/actor/behaviour/abstract.rb
concurrent-ruby-edge-0.4.1 lib-edge/concurrent/actor/behaviour/abstract.rb
concurrent-ruby-edge-0.4.0.pre2 lib-edge/concurrent/actor/behaviour/abstract.rb
concurrent-ruby-edge-0.4.0.pre1 lib-edge/concurrent/actor/behaviour/abstract.rb
concurrent-ruby-edge-0.2.4 lib/concurrent/actor/behaviour/abstract.rb
concurrent-ruby-edge-0.3.1 lib/concurrent/actor/behaviour/abstract.rb
concurrent-ruby-edge-0.3.0 lib/concurrent/actor/behaviour/abstract.rb
concurrent-ruby-edge-0.2.3 lib/concurrent/actor/behaviour/abstract.rb
concurrent-ruby-edge-0.2.3.pre3 lib/concurrent/actor/behaviour/abstract.rb
concurrent-ruby-edge-0.2.2 lib/concurrent/actor/behaviour/abstract.rb
concurrent-ruby-edge-0.2.1 lib/concurrent/actor/behaviour/abstract.rb
concurrent-ruby-edge-0.2.0 lib/concurrent/actor/behaviour/abstract.rb
concurrent-ruby-edge-0.2.0.pre5 lib/concurrent/actor/behaviour/abstract.rb
concurrent-ruby-edge-0.1.2 lib/concurrent/actor/behaviour/abstract.rb