Class: Fluent::PluginHelper::ServiceDiscovery::RoundRobinBalancer
- Inherits:
-
Object
- Object
- Fluent::PluginHelper::ServiceDiscovery::RoundRobinBalancer
- Defined in:
- lib/fluent/plugin_helper/service_discovery/round_robin_balancer.rb
Instance Method Summary collapse
-
#initialize ⇒ RoundRobinBalancer
constructor
A new instance of RoundRobinBalancer.
- #rebalance(services) ⇒ Object
- #select_service {|s| ... } ⇒ Object
Constructor Details
#initialize ⇒ RoundRobinBalancer
Returns a new instance of RoundRobinBalancer.
21 22 23 24 |
# File 'lib/fluent/plugin_helper/service_discovery/round_robin_balancer.rb', line 21 def initialize @services = [] @mutex = Mutex.new end |
Instance Method Details
#rebalance(services) ⇒ Object
26 27 28 29 30 |
# File 'lib/fluent/plugin_helper/service_discovery/round_robin_balancer.rb', line 26 def rebalance(services) @mutex.synchronize do @services = services end end |
#select_service {|s| ... } ⇒ Object
32 33 34 35 36 37 38 39 |
# File 'lib/fluent/plugin_helper/service_discovery/round_robin_balancer.rb', line 32 def select_service s = @mutex.synchronize do s = @services.shift @services.push(s) s end yield(s) end |