haskell-throttle-0.1.0.0: A simple throttling library, which drops messages from same group.
Copyright(c) CNRS 2024-Present
LicenseAGPL + CECILL v3
Maintainerteam@gargantext.org
Stabilityexperimental
PortabilityPOSIX
Safe HaskellSafe-Inferred
LanguageHaskell2010

Control.Concurrent.Throttle

Description

 
Synopsis

Documentation

throttle :: (Ord id, Eq id, Show id) => Int -> TChan (id, a) -> (a -> IO ()) -> IO () Source #

Throttling with given interval. Here, throttling means: perform action only as frequently as allowed and other calls are DROPPED. This is in contrast to things like Conduit throttling, where actions are just SLOWED DOWN. We use this for asynchronous notifications and, if messages are the same, we can just drop them safely. Our input is the provided TChan.

This function should be spawned as a thread.

We provide separate id and a. id is used for uniquely identifying groups of throttled messages, while a are actual messages that are sent to action callback.