Class: Celluloid::SupervisionGroup

### Home Classes Methods

### In Files

- lib/celluloid/supervision_group.rb

### Parent

Object

### Namespace

- CLASS Celluloid::SupervisionGroup::Member

### Methods

- ::blocks
- ::new
- ::pool
- ::run
- ::run!
- ::supervise
- #[]
- #actors
- #add
- #pool
- #restart_actor
- #supervise
- #supervise_as

### Included Modules

- Celluloid

### Class/Module Index

Quicksearch

- Celluloid
- Celluloid::AbortError
- Celluloid::AbstractProxy
- Celluloid::Actor
- Celluloid::Actor::Sleeper
- Celluloid::ActorProxy
- Celluloid::ActorSystem
- Celluloid::AsyncCall
- Celluloid::AsyncProxy
- Celluloid::BlockCall
- Celluloid::BlockProxy
- Celluloid::BlockResponse
- Celluloid::CPUCounter
- Celluloid::Call
- Celluloid::CallChain
- Celluloid::Cell
- Celluloid::Cell::ExitHandler
- Celluloid::CellProxy
- Celluloid::ClassMethods
- Celluloid::Condition
- Celluloid::Condition::Waiter
- Celluloid::ConditionError
- Celluloid::DeadTaskError
- Celluloid::ErrorResponse
- Celluloid::EventedMailbox
- Celluloid::ExitEvent
- Celluloid::FSM
- Celluloid::FSM::ClassMethods
- Celluloid::FSM::State
- Celluloid::FSM::UnattachedError
- Celluloid::FiberStackError
- Celluloid::Future
- Celluloid::Future::Result
- Celluloid::FutureProxy
- Celluloid::Handler
- Celluloid::Handlers
- Celluloid::Incident
- Celluloid::IncidentLogger
- Celluloid::IncidentLogger::Severity
- Celluloid::IncidentReporter
- Celluloid::IncidentReporter::Formatter
- Celluloid::InstanceMethods
- Celluloid::InternalPool
- Celluloid::LinkingRequest
- Celluloid::LinkingResponse
- Celluloid::Links
- Celluloid::LogEvent
- Celluloid::Logger
- Celluloid::Logger::WithBacktrace
- Celluloid::Mailbox
- Celluloid::MailboxDead
- Celluloid::MailboxShutdown
- Celluloid::Method
- Celluloid::NamingRequest
- Celluloid::NotTaskError
- Celluloid::Notifications
- Celluloid::Notifications::Fanout
- Celluloid::Notifications::Subscriber
- Celluloid::PoolManager
- Celluloid::Probe
- Celluloid::Properties
- Celluloid::Receiver
- Celluloid::Receivers
- Celluloid::Registry
- Celluloid::Response
- Celluloid::ResumableError
- Celluloid::RingBuffer
- Celluloid::SignalConditionRequest
- Celluloid::Signals
- Celluloid::StackDump
- Celluloid::StackDump::ActorState
- Celluloid::StackDump::CellState
- Celluloid::StackDump::DisplayBacktrace
- Celluloid::StackDump::TaskState
- Celluloid::StackDump::ThreadState
- Celluloid::SuccessResponse
- Celluloid::SupervisionGroup
- Celluloid::SupervisionGroup::Member
- Celluloid::Supervisor
- Celluloid::SyncCall
- Celluloid::SyncProxy
- Celluloid::SystemEvent
- Celluloid::Task
- Celluloid::Task::TerminatedError
- Celluloid::Task::TimeoutError
- Celluloid::TaskFiber
- Celluloid::TaskSet
- Celluloid::TaskThread
- Celluloid::TerminationRequest
- Celluloid::Thread
- Celluloid::ThreadHandle
- Celluloid::UUID
- org
- org::jruby
- org::jruby::ext
- org::jruby::ext::fiber
- org::jruby::ext::fiber::ThreadFiber
- Bar
- Baz
- Blocker
- ExampleActorClass
- ExampleCrash
- ExampleMailbox
- ExampleProxy
- ExampleTask
- Fiber
- Foo
- MockActor
- Object
- Thread

No matching classes.

# Celluloid::SupervisionGroup

Supervise collections of actors as a group

### Public Class Methods

blocks() click to toggle source

Actors or sub-applications to be supervised

    # File lib/celluloid/supervision_group.rb, line 10
    def blocks
      @blocks ||= []
    end

new(registry = nil) click to toggle source

Start the group

    # File lib/celluloid/supervision_group.rb, line 62
    def initialize(registry = nil)
      @members = []
      @registry = registry || Celluloid.actor_system.registry

      yield current_actor if block_given?
    end

pool(klass, options = {}) click to toggle source

Register a pool of actors to be launched on group startup Available options are:

- as: register this application in the Celluloid::Actor[] directory

- args: start the actor pool with the given arguments

    # File lib/celluloid/supervision_group.rb, line 52
    def pool(klass, options = {})
      blocks << lambda do |group|
        group.pool klass, options
      end
    end

run(registry = nil) click to toggle source

Run the application in the foreground with a simple watchdog

    # File lib/celluloid/supervision_group.rb, line 25
    def run(registry = nil)
      loop do
        supervisor = run!(registry)

        # Take five, toplevel supervisor
        sleep 5 while supervisor.alive?

        Logger.error "!!! Celluloid::SupervisionGroup #{self} crashed. Restarting..."
      end
    end

run!(registry = nil) click to toggle source

Start this application (and watch it with a supervisor)

    # File lib/celluloid/supervision_group.rb, line 15
    def run!(registry = nil)
      group = new(registry) do |_group|
        blocks.each do |block|
          block.call(_group)
        end
      end
      group
    end

supervise(klass, options = {}) click to toggle source

Register an actor class or a sub-group to be launched and supervised Available options are:

- as: register this application in the Celluloid::Actor[] directory

- args: start the actor with the given arguments

    # File lib/celluloid/supervision_group.rb, line 41
    def supervise(klass, options = {})
      blocks << lambda do |group|
        group.add klass, options
      end
    end

### Public Instance Methods

[](actor_name) click to toggle source

    # File lib/celluloid/supervision_group.rb, line 94
    def [](actor_name)
      @registry[actor_name]
    end

actors() click to toggle source

    # File lib/celluloid/supervision_group.rb, line 90
    def actors
      @members.map(&:actor)
    end

add(klass, options) click to toggle source

    # File lib/celluloid/supervision_group.rb, line 84
    def add(klass, options)
      member = Member.new(@registry, klass, options)
      @members << member
      member.actor
    end

pool(klass, options = {}) click to toggle source

    # File lib/celluloid/supervision_group.rb, line 79
    def pool(klass, options = {})
      options[:method] = 'pool_link'
      add(klass, options)
    end

restart_actor(actor, reason) click to toggle source

Restart a crashed actor

    # File lib/celluloid/supervision_group.rb, line 99
    def restart_actor(actor, reason)
      member = @members.find do |_member|
        _member.actor == actor
      end
      raise "a group member went missing. This shouldn't be!" unless member

      if reason
        member.restart
      else
        member.cleanup
        @members.delete(member)
      end
    end

supervise(klass, *args, &block) click to toggle source

    # File lib/celluloid/supervision_group.rb, line 71
    def supervise(klass, *args, &block)
      add(klass, :args => args, :block => block)
    end

supervise_as(name, klass, *args, &block) click to toggle source

    # File lib/celluloid/supervision_group.rb, line 75
    def supervise_as(name, klass, *args, &block)
      add(klass, :args => args, :block => block, :as => name)
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.