Class: Trident::Pool

Inherits:
Object
  • Object
show all
Includes:
GemLogger::LoggerSupport, Utils
Defined in:
lib/trident/pool.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Utils

#procline

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, options={})
  @name = name
  @handler = handler
  @size = size
  @options = options || {}
  @workers = Set.new
end

Instance Attribute Details

#handlerObject (readonly)

Returns the value of attribute handler.



6
7
8
# File 'lib/trident/pool.rb', line 6

def handler
  @handler
end

#nameObject (readonly)

Returns the value of attribute name.



6
7
8
# File 'lib/trident/pool.rb', line 6

def name
  @name
end

#optionsObject (readonly)

Returns the value of attribute options.



6
7
8
# File 'lib/trident/pool.rb', line 6

def options
  @options
end

#sizeObject (readonly)

Returns the value of attribute size.



6
7
8
# File 'lib/trident/pool.rb', line 6

def size
  @size
end

#workersObject (readonly)

Returns the value of attribute workers.



6
7
8
# File 'lib/trident/pool.rb', line 6

def workers
  @workers
end

Instance Method Details

#startObject



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

#updateObject



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

#waitObject



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