batch: Simplify queuing up data and processing it in batch.

[ bsd3, data, library ] [ Propose Tags ] [ Report a vulnerability ]

Simplify queuing up data and processing it in batch.


[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
Change log ChangeLog.md
Dependencies async (>=2.0), base (>=4.7 && <5), lifted-async (>=0.9), lifted-base (>=0.2.3), monad-control (>=1.0), mtl (>=2.2), stm (>=2.4), timespan (>=0.3), transformers-base (>=0.4) [details]
License BSD-3-Clause
Copyright 2017 Alexander Thiemann <mail@athiemann.net>
Author Alexander Thiemann
Maintainer mail@athiemann.net
Category Data
Home page https://github.com/agrafix/batch#readme
Bug tracker https://github.com/agrafix/batch/issues
Source repo head: git clone https://github.com/agrafix/batch
Uploaded by AlexanderThiemann at 2018-01-27T08:49:14Z
Distributions NixOS:0.1.0.0
Reverse Dependencies 1 direct, 0 indirect [details]
Downloads 995 total (6 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2018-01-27 [all 1 reports]

Readme for batch-0.1.0.0

[back to package description]

batch

CircleCI

Simplify queuing up data and processing it in batch.

import Control.Batch
import Control.Concurrent.STM
import Control.Monad

example :: IO ()
example =
  do outVar <- atomically $ newTVar []
     let cfg =
             Batch
             { b_runEveryItems = Just 5
             , b_runAfterTimeout = Nothing
             , b_maxQueueLength = Nothing
             , b_runBatch =
                     \x -> atomically $ modifyTVar' outVar (++x)
             }
     withBatchRunner cfg $ \hdl ->
         do replicateM_ 5 $ bh_enqueue hdl True
            out <-
                atomically $
                do x <- readTVar outVar
                   when (length x /= 5) retry
                   pure x
            out `shouldBe` [True, True, True, True, True]