Class: Trident::PoolHandler
- Inherits:
-
Object
- Object
- Trident::PoolHandler
- Defined in:
- lib/trident/pool_handler.rb
Instance Attribute Summary collapse
-
#environment ⇒ Object
readonly
Returns the value of attribute environment.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#signal_mappings ⇒ Object
readonly
Returns the value of attribute signal_mappings.
-
#worker_class_name ⇒ Object
readonly
Returns the value of attribute worker_class_name.
Instance Method Summary collapse
-
#initialize(name, worker_class_name, environment, signal_mappings, options = {}) ⇒ PoolHandler
constructor
A new instance of PoolHandler.
- #load ⇒ Object
- #signal_for(action) ⇒ Object
- #start(opts = {}) ⇒ Object
- #worker_class ⇒ Object
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, ={}) @name = name @worker_class_name = worker_class_name @environment = environment @signal_mappings = signal_mappings @options = || {} end |
Instance Attribute Details
#environment ⇒ Object (readonly)
Returns the value of attribute environment.
4 5 6 |
# File 'lib/trident/pool_handler.rb', line 4 def environment @environment end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
4 5 6 |
# File 'lib/trident/pool_handler.rb', line 4 def name @name end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
4 5 6 |
# File 'lib/trident/pool_handler.rb', line 4 def @options end |
#signal_mappings ⇒ Object (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_name ⇒ Object (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
#load ⇒ Object
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..merge(opts)).start end |
#worker_class ⇒ Object
18 19 20 |
# File 'lib/trident/pool_handler.rb', line 18 def worker_class self.class.const_get(worker_class_name) end |