Class: Wye::Distributor::Sticky
- Inherits:
-
Object
- Object
- Wye::Distributor::Sticky
- Defined in:
- lib/wye/distributor/sticky.rb
Instance Method Summary collapse
-
#initialize(values) ⇒ Sticky
constructor
A new instance of Sticky.
- #next(id) ⇒ Object
Constructor Details
#initialize(values) ⇒ Sticky
Returns a new instance of Sticky.
6 7 8 |
# File 'lib/wye/distributor/sticky.rb', line 6 def initialize(values) @values = values end |
Instance Method Details
#next(id) ⇒ Object
10 11 12 |
# File 'lib/wye/distributor/sticky.rb', line 10 def next(id) (mod = @values.length) > 0 ? @values[Zlib.crc32(id.to_s) % mod] : nil end |