Class: Carnivore::Supervisor

Inherits:
Celluloid::SupervisionGroup
  • Object
show all
Defined in:
lib/carnivore/supervisor.rb

Instance Attribute Summary (collapse)

Class Method Summary (collapse)

Instance Method Summary (collapse)

Instance Attribute Details

- (Celluloid::Registry) registry (readonly)

Returns:

  • (Celluloid::Registry)


64
65
66
# File 'lib/carnivore/supervisor.rb', line 64

def registry
  @registry
end

Class Method Details

+ (Carinvore::Supervisor) build!

Build a new supervisor

Returns:

  • (Carinvore::Supervisor)


12
13
14
15
# File 'lib/carnivore/supervisor.rb', line 12

def build!
  _, s = create!
  supervisor(s)
end

+ (Array<[Celluloid::Registry, Carnivore::Supervisor]>) create!

Create a new supervisor

Returns:



20
21
22
23
# File 'lib/carnivore/supervisor.rb', line 20

def create!
  registry = Celluloid::Registry.new
  [registry, run!(registry)]
end

+ (Celluloid::Registry, NilClass) registry

Get the registry of the default supervisor

Returns:

  • (Celluloid::Registry, NilClass)


39
40
41
42
43
# File 'lib/carnivore/supervisor.rb', line 39

def registry
  if(supervisor)
    supervisor.registry
  end
end

+ (Carnivore::Supervisor) supervisor(sup = nil)

Get/set the default supervisor

Parameters:

Returns:



29
30
31
32
33
34
# File 'lib/carnivore/supervisor.rb', line 29

def supervisor(sup=nil)
  if(sup)
    Celluloid::Actor[:carnivore_supervisor] = sup
  end
  Celluloid::Actor[:carnivore_supervisor]
end

+ (TrueClass) terminate!

Destroy the registered default supervisor

Returns:

  • (TrueClass)


48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/carnivore/supervisor.rb', line 48

def terminate!
  if(supervisor)
    begin
      supervisor.terminate
    rescue Celluloid::DeadActorError => e
      Celluloid::Logger.warn "Default supervisor is already in dead state (#{e.class}: #{e})"
    end
    @supervisor = nil
    @registry = nil
  end
  true
end

Instance Method Details

- (Celluloid::Actor, NilClass) [](k)

Fetch actor from registry

Parameters:

  • k (String, Symbol)

    identifier

Returns:

  • (Celluloid::Actor, NilClass)


70
71
72
# File 'lib/carnivore/supervisor.rb', line 70

def [](k)
  registry[k]
end