Class: Trident::Pool
- Inherits:
-
Object
- Object
- Trident::Pool
- Includes:
- GemLogger::LoggerSupport, Utils
- Defined in:
- lib/trident/pool.rb
Instance Attribute Summary collapse
-
#handler ⇒ Object
readonly
Returns the value of attribute handler.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#size ⇒ Object
readonly
Returns the value of attribute size.
-
#workers ⇒ Object
readonly
Returns the value of attribute workers.
Instance Method Summary collapse
-
#initialize(name, handler, size, options = {}) ⇒ Pool
constructor
A new instance of Pool.
- #start ⇒ Object
- #stop(action = 'stop_gracefully') ⇒ Object
- #update ⇒ Object
- #wait ⇒ Object
Methods included from Utils
Constructor Details
#initialize(name, handler, size, options = {}) ⇒ Pool
Returns a new instance of Pool.
8 9 10 11 12 13 14 |
# File 'lib/trident/pool.rb', line 8 def initialize(name, handler, size, ={}) @name = name @handler = handler @size = size @options = || {} @workers = Set.new end |
Instance Attribute Details
#handler ⇒ Object (readonly)
Returns the value of attribute handler.
6 7 8 |
# File 'lib/trident/pool.rb', line 6 def handler @handler end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
6 7 8 |
# File 'lib/trident/pool.rb', line 6 def name @name end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
6 7 8 |
# File 'lib/trident/pool.rb', line 6 def @options end |
#size ⇒ Object (readonly)
Returns the value of attribute size.
6 7 8 |
# File 'lib/trident/pool.rb', line 6 def size @size end |
#workers ⇒ Object (readonly)
Returns the value of attribute workers.
6 7 8 |
# File 'lib/trident/pool.rb', line 6 def workers @workers end |
Instance Method Details
#start ⇒ Object
16 17 18 19 20 |
# File 'lib/trident/pool.rb', line 16 def start logger.info "<pool-#{name}> Starting pool" maintain_worker_count('stop_gracefully') logger.info "<pool-#{name}> Pool started with #{workers.size} workers" end |
#stop(action = 'stop_gracefully') ⇒ Object
22 23 24 25 26 27 |
# File 'lib/trident/pool.rb', line 22 def stop(action='stop_gracefully') logger.info "<pool-#{name}> Stopping pool" @size = 0 maintain_worker_count(action) logger.info "<pool-#{name}> Pool stopped" end |
#update ⇒ Object
35 36 37 38 39 |
# File 'lib/trident/pool.rb', line 35 def update logger.info "<pool-#{name}> Updating pool" maintain_worker_count('stop_gracefully') logger.info "<pool-#{name}> Pool up to date" end |
#wait ⇒ Object
29 30 31 32 33 |
# File 'lib/trident/pool.rb', line 29 def wait logger.info "<pool-#{name}> Waiting for pool" cleanup_dead_workers(true) logger.info "<pool-#{name}> Wait complete" end |