33 lines
895 B
Haskell
33 lines
895 B
Haskell
|
|
module Main where
|
||
|
|
|
||
|
|
import MiniSeqQueues.Queue
|
||
|
|
( Retry (Retry)
|
||
|
|
, enqueueRetry
|
||
|
|
, renderBatch
|
||
|
|
, renderQueue
|
||
|
|
, sampleQueue
|
||
|
|
, takeBatch
|
||
|
|
)
|
||
|
|
import System.Environment (getArgs)
|
||
|
|
import System.Exit (die)
|
||
|
|
|
||
|
|
main :: IO ()
|
||
|
|
main = do
|
||
|
|
args <- getArgs
|
||
|
|
batchSize <-
|
||
|
|
case args of
|
||
|
|
[] -> pure 2
|
||
|
|
[rawBatchSize] ->
|
||
|
|
case reads rawBatchSize of
|
||
|
|
[(parsedBatchSize, "")]
|
||
|
|
| parsedBatchSize > 0 -> pure parsedBatchSize
|
||
|
|
| otherwise -> die "batch size must be greater than zero"
|
||
|
|
_ -> die ("invalid batch size: " ++ rawBatchSize)
|
||
|
|
_ -> die "expected either no arguments or: <batch-size>"
|
||
|
|
|
||
|
|
let queueWithNewRetry = enqueueRetry sampleQueue (Retry "auth" 1)
|
||
|
|
(nextBatch, remainingQueue) = takeBatch batchSize queueWithNewRetry
|
||
|
|
|
||
|
|
putStrLn ("batch: " ++ renderBatch nextBatch)
|
||
|
|
putStrLn ("remaining: " ++ renderQueue remainingQueue)
|