Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/winterland1989/roundrobin
A simple round-robin data type
https://github.com/winterland1989/roundrobin
Last synced: 29 days ago
JSON representation
A simple round-robin data type
- Host: GitHub
- URL: https://github.com/winterland1989/roundrobin
- Owner: winterland1989
- License: mit
- Created: 2016-05-20T16:15:12.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2016-08-07T03:36:44.000Z (over 8 years ago)
- Last Synced: 2024-10-28T00:33:03.510Z (3 months ago)
- Language: Haskell
- Size: 6.84 KB
- Stars: 4
- Watchers: 4
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[![Hackage](https://img.shields.io/hackage/v/roundRobin.svg?style=flat)](http://hackage.haskell.org/package/roundRobin)
[![Travis-CI](https://travis-ci.org/winterland1989/roundRobin.svg)](https://travis-ci.org/winterland1989/roundRobin)# A simple round-robin data type
This package provide a simple data type wrap a round-robin table. so you can select resources(host, connection...) using round-robin fashion.
## Example
```haskell
import qualified Date.RoundRobin as RR
import qualified Network.HTTP.Client as HTTPmain :: IO ()
main = do
reqs <- mapM HTTP.parseUrl ["http://foo.com", "http://bar.com", "http://qux.com"]
proxyTable <- RR.newRoundRobin reqs
manager <- HTTP.newManager HTTP.defaultManagerSettings...
-- maybe now you're inside a server service(a forked thread)
-- use select to choose a request in round-robin fashion
req <- RR.select proxyTable
res <- HTTP.httpLbs req manager
...
```