Project

roundrobin

0.01
No commit activity in last 3 years
No release in over 3 years
Just ask for the next item of a specified array. It will be persisted to a Redis DB
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 1.3.5
~> 10.0
>= 0

Runtime

>= 0
 Project Readme

RoundRobin

Build Status

Add a Round-Robin based process to your flow.

Installation

Add this line to your application's Gemfile:

gem 'roundrobin'

And then execute:

$ bundle

Or install it yourself as:

$ gem install roundrobin

Usage

Initialize your Round-Robin instance

>> rr = Roundrobin.new

or

>> rr = Roundrobin.new("redis://:p4ssw0rd@10.0.1.1:6380/15")

Now you can ask for the next item (in a Round-Robin logic)

>> rr.next(%w(foo bar))
=> "foo"
>> rr.next(%w(foo bar))
=> "bar"
>> rr.next(%w(foo bar))
=> "foo"

>> candidates = [{name: 'John', email: 'john@example.com'}, {name: 'Sara', email: 'sara@example.com'}])
>> rr.next(candidates)
=> {name: 'John', email: 'john@example.com'}
>> rr.next(candidates)
=> {name: 'Sara', email: 'sara@example.com'}
>> rr.next(candidates)
=> {name: 'John', email: 'john@example.com'}

All the data will be persisted to your DB, so you can restart your server, or do this in multiple threads and the results will be the same: you will be using the Round Robin algorith.

Development

$ cd roundrobin
$ gem build roundrobin.gemspec
$ gem install ./roundrobin-XXX.gem

Contributing

  1. Fork it ( https://github.com/archdaily/roundrobin/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request