linnik / roundrobin

This is rather small collection of round robin utilites

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Build Status PyPI install versions

roundrobin

This is rather small collection of round robin utilities

>>> import roundrobin
>>> get_roundrobin = roundrobin.basic(["A", "B", "C"])
>>> ''.join([get_roundrobin() for _ in range(7)])
'ABCABCA'
>>> # weighted round-robin balancing algorithm as seen in LVS
>>> get_weighted = roundrobin.weighted([("A", 5), ("B", 1), ("C", 1)])
>>> ''.join([get_weighted() for _ in range(7)])
'AAAAABC'
>>> # smooth weighted round-robin balancing algorithm as seen in Nginx
>>> get_weighted_smooth = roundrobin.smooth([("A", 5), ("B", 1), ("C", 1)])
>>> ''.join([get_weighted_smooth() for _ in range(7)])
'AABACAA'

About

This is rather small collection of round robin utilites

License:MIT License


Languages

Language:Python 100.0%