module Control.Concurrent.Async.Refresh.Tokens.Conf
( TokenConf
, defaultTokenConf
, tokenConfSetFactor
, tokenConfAddRequest
) where
import Control.Concurrent.Async.Refresh.Tokens.Prelude
import qualified Control.Concurrent.Async.Refresh.Tokens.Lenses as Lens
import Control.Concurrent.Async.Refresh.Tokens.Types
import Lens.Micro
defaultTokenConf :: TokenConf m
defaultTokenConf =
TokenConf { _tokenConfRefreshFactor = defaultRefreshTimeFactor
, _tokenConfRequests = [] }
defaultRefreshTimeFactor :: Double
defaultRefreshTimeFactor = 0.8
tokenConfSetFactor :: Double -> TokenConf m -> TokenConf m
tokenConfSetFactor = (Lens.refreshFactor .~)
tokenConfAddRequest :: RequestToken m -> TokenConf m -> TokenConf m
tokenConfAddRequest req = Lens.requests %~ (req :)