Class: Trident::PoolHandler

Inherits:
Object
  • Object
show all
Defined in:
lib/trident/pool_handler.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, worker_class_name, environment, signal_mappings, options = {}) ⇒ PoolHandler

Returns a new instance of PoolHandler.



6
7
8
9
10
11
12
# File 'lib/trident/pool_handler.rb', line 6

def initialize(name, worker_class_name, environment, signal_mappings, options={})
  @name = name
  @worker_class_name = worker_class_name
  @environment = environment
  @signal_mappings = signal_mappings
  @options = options || {}
end

Instance Attribute Details

#environmentObject (readonly)

Returns the value of attribute environment.



4
5
6
# File 'lib/trident/pool_handler.rb', line 4

def environment
  @environment
end

#nameObject (readonly)

Returns the value of attribute name.



4
5
6
# File 'lib/trident/pool_handler.rb', line 4

def name
  @name
end

#optionsObject (readonly)

Returns the value of attribute options.



4
5
6
# File 'lib/trident/pool_handler.rb', line 4

def options
  @options
end

#signal_mappingsObject (readonly)

Returns the value of attribute signal_mappings.



4
5
6
# File 'lib/trident/pool_handler.rb', line 4

def signal_mappings
  @signal_mappings
end

#worker_class_nameObject (readonly)

Returns the value of attribute worker_class_name.



4
5
6
# File 'lib/trident/pool_handler.rb', line 4

def worker_class_name
  @worker_class_name
end

Instance Method Details

#loadObject



14
15
16
# File 'lib/trident/pool_handler.rb', line 14

def load
  eval environment if environment
end

#signal_for(action) ⇒ Object



26
27
28
# File 'lib/trident/pool_handler.rb', line 26

def signal_for(action)
  signal_mappings[action] || signal_mappings['default'] || "SIGTERM"
end

#start(opts = {}) ⇒ Object



22
23
24
# File 'lib/trident/pool_handler.rb', line 22

def start(opts={})
  worker_class.new(self.options.merge(opts)).start
end

#worker_classObject



18
19
20
# File 'lib/trident/pool_handler.rb', line 18

def worker_class
  self.class.const_get(worker_class_name)
end