roundRobin: A simple round-robin data type

[ concurrency, library, mit ] [ Propose Tags ]

This package provide a simple data type wrap a round-robin table. so you can select resources(host, connection...) using round-robin fashion.


[Skip to Readme]

Modules

[Index]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 0.1.0.0, 0.1.0.1, 0.1.1.0, 0.1.2.0
Dependencies base (>=4.6 && <5.0) [details]
License MIT
Author winterland1989
Maintainer winterland1989@gmail.com
Category Concurrency
Source repo head: git clone https://github.com/winterland1989/roundRobin.git
Uploaded by winterland at 2016-05-23T02:37:40Z
Distributions NixOS:0.1.2.0
Reverse Dependencies 1 direct, 0 indirect [details]
Downloads 2656 total (15 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2016-05-23 [all 1 reports]

Readme for roundRobin-0.1.0.0

[back to package description]

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

import qualified Date.RoundRobin as RR
import qualified Network.HTTP.Client as HTTP

main :: 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
        ...