Class: Hystrix::CommandExecutorPool
- Inherits:
-
Object
- Object
- Hystrix::CommandExecutorPool
- Defined in:
- lib/hystrix/executor_pool.rb
Instance Attribute Summary collapse
-
#circuit_supervisor ⇒ Object
Returns the value of attribute circuit_supervisor.
-
#executors ⇒ Object
Returns the value of attribute executors.
-
#lock ⇒ Object
Returns the value of attribute lock.
-
#name ⇒ Object
Returns the value of attribute name.
-
#size ⇒ Object
Returns the value of attribute size.
Instance Method Summary collapse
-
#initialize(name, size) ⇒ CommandExecutorPool
constructor
A new instance of CommandExecutorPool.
- #shutdown ⇒ Object
- #take ⇒ Object
Constructor Details
#initialize(name, size) ⇒ CommandExecutorPool
Returns a new instance of CommandExecutorPool.
34 35 36 37 38 39 40 41 42 43 |
# File 'lib/hystrix/executor_pool.rb', line 34 def initialize(name, size) self.name = name self.size = size self.executors = [] self.lock = Mutex.new self.circuit_supervisor = Circuit.supervise size.times do self.executors << CommandExecutor.new end end |
Instance Attribute Details
#circuit_supervisor ⇒ Object
Returns the value of attribute circuit_supervisor.
32 33 34 |
# File 'lib/hystrix/executor_pool.rb', line 32 def circuit_supervisor @circuit_supervisor end |
#executors ⇒ Object
Returns the value of attribute executors.
31 32 33 |
# File 'lib/hystrix/executor_pool.rb', line 31 def executors @executors end |
#lock ⇒ Object
Returns the value of attribute lock.
31 32 33 |
# File 'lib/hystrix/executor_pool.rb', line 31 def lock @lock end |
#name ⇒ Object
Returns the value of attribute name.
30 31 32 |
# File 'lib/hystrix/executor_pool.rb', line 30 def name @name end |
#size ⇒ Object
Returns the value of attribute size.
30 31 32 |
# File 'lib/hystrix/executor_pool.rb', line 30 def size @size end |
Instance Method Details
#shutdown ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/hystrix/executor_pool.rb', line 58 def shutdown lock.synchronize do until executors.size == 0 do for i in (0...executors.size) unless executors[i].locked? executors[i] = nil end end executors.compact! sleep 0.1 end end end |
#take ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/hystrix/executor_pool.rb', line 45 def take lock.synchronize do for executor in self.executors unless executor.locked? executor.lock return executor end end end raise ExecutorPoolFullError.new("Unable to get executor from #{self.name} pool.") end |