Class: RightSupport::Net::LB::RoundRobin

Inherits:
Object
  • Object
show all
Defined in:
lib/right_support/net/lb/round_robin.rb

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ RoundRobin

Returns a new instance of RoundRobin.



26
27
28
29
# File 'lib/right_support/net/lb/round_robin.rb', line 26

def initialize(options ={})
  @endpoints = []
  @counter = rand(0xffff)
end

Instance Method Details

#bad(endpoint, t0, t1) ⇒ Object



44
45
46
# File 'lib/right_support/net/lb/round_robin.rb', line 44

def bad(endpoint, t0, t1)
  #no-op; round robin does not care about failures
end

#good(endpoint, t0, t1) ⇒ Object



40
41
42
# File 'lib/right_support/net/lb/round_robin.rb', line 40

def good(endpoint, t0, t1)
  #no-op; round robin does not care about failures
end

#health_check(endpoint) ⇒ Object



48
49
50
51
# File 'lib/right_support/net/lb/round_robin.rb', line 48

def health_check(endpoint)
  #no-op; round robin does not perform health checks
  true
end

#nextObject



35
36
37
38
# File 'lib/right_support/net/lb/round_robin.rb', line 35

def next
  @counter += 1
  [ @endpoints[@counter % @endpoints.size], false ] unless @endpoints.empty?
end

#set_endpoints(endpoints) ⇒ Object



31
32
33
# File 'lib/right_support/net/lb/round_robin.rb', line 31

def set_endpoints(endpoints)
  @endpoints = endpoints
end