Sha256: c4ff6dc1ca1e34baf6669aa97c1b0cd4e0102b298805e9cc62ad9d0edad01009

Contents?: true

Size: 1.41 KB

Versions: 24

Compression:

Stored size: 1.41 KB

Contents

module Concurrent
  module Actor
    module Behaviour

      # 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).
      # @note TODO missing example
      # @note this will change in next version to support supervision trees better
      class Supervising < Abstract
        def initialize(core, subsequent, core_options, handle, strategy)
          super core, subsequent, core_options
          @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

        def on_envelope(envelope)
          case envelope.message
          when Exception, :paused
            receivers = if @strategy == :one_for_all
                          children
                        else
                          [envelope.sender]
                        end
            receivers.each { |ch| ch << @handle }
          else
            pass envelope
          end
        end
      end
    end
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

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