This is an alternative site for discovering Elm packages. You may be looking for the official Elm package site instead.
Rate-limited queues for arbitrary data types
version 1.0.0
license BSD3
native-modules False
elm-version 0.18.0 <= v < 0.19.0
Tag 1.0.0
Committed At 2017-03-09 04:43:42 UTC
elm-lang/html 2.0.0 <= v < 3.0.0 2.0.0
elm-lang/core 5.1.1 <= v < 6.0.0 5.1.1



Rate-Limited Queues in Elm

GitHub issues GitHub pull requests

Rate-limited queues for arbitrary data types

elm-ratequeue provides rate-limited queues for arbitrary data types. Currently the primary use-case for this is to release batched HTTP requests at regular intervals to avoid hitting rate limit caps from third-party APIs.


elm-package install bitrage-io/elm-ratequeue


import Dict exposing (Dict)
import RateQueue exposing (RateQueue)
import Time

-- Create a new queue
emptyQueue : RateQueue String
emptyQueue = Time.second

-- Add some items to the queue
queueWithItems : RateQueue String
queueWithItems =
    RateQueue.enqueue ["a", "b", "c"] emptyQueue

-- Release something from the queue
queueAndReleasedItem : ( RateQueue String, Maybe String )
queueAndReleasedItem =
    RateQueue.release 0 queueWithItems

-- Add some items to a queue in a dictionary
queueDict : Dict String (RateQueue String)
queueDict =
    RateQueue.enqueueDict Time.second "queue-id" ["a", "b", "c"] Dict.empty

-- Release items from all queues in a dictionary
queueDictAndReleasedItems : (Dict String (RateQueue String), List String)
queueDictAndReleasedItems =
    RateQueue.releaseDict 0 queueDict


Feel free to open an issue or submit a pull-request!