Class: Balancir::Distributor

Inherits:
Object
  • Object
show all
Defined in:
lib/balancir/distributor.rb

Overview

Accepts requests and distributes them between connectors.

Instance Method Summary collapse

Constructor Details

#initializeDistributor

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