Class: Balancir::Distributor
- Inherits:
-
Object
- Object
- Balancir::Distributor
- Defined in:
- lib/balancir/distributor.rb
Overview
Accepts requests and distributes them between connectors.
Instance Method Summary collapse
- #add_connector(connector, weight) ⇒ Object
- #get(path) ⇒ Object
-
#initialize ⇒ Distributor
constructor
A new instance of Distributor.
Constructor Details
#initialize ⇒ Distributor
Returns a new instance of Distributor.
5 6 7 |
# File 'lib/balancir/distributor.rb', line 5 def initialize @connectors = [] end |
Instance Method Details
#add_connector(connector, weight) ⇒ Object
9 10 11 |
# File 'lib/balancir/distributor.rb', line 9 def add_connector(connector, weight) @connectors << connector end |
#get(path) ⇒ Object
13 14 15 16 17 18 |
# File 'lib/balancir/distributor.rb', line 13 def get(path) response = @connectors.first.get(path) if (500..599).include? response.status @connectors.first.record_error end end |