async-refresh-tokens 0.3.0.1 → 0.4.0.0
raw patch · 8 files changed
+64/−85 lines, 8 filesdep +unliftiodep +unliftio-coredep −lifted-asyncdep −monad-controldep −stmdep ~async-refreshPVP ok
version bump matches the API change (PVP)
Dependencies added: unliftio, unliftio-core
Dependencies removed: lifted-async, monad-control, stm
Dependency ranges changed: async-refresh
API changes (from Hackage documentation)
- Control.Concurrent.Async.Refresh.Tokens: class IsToken t where tokenName _ = tshow (Proxy :: Proxy t)
+ Control.Concurrent.Async.Refresh.Tokens: class IsToken t
- Control.Concurrent.Async.Refresh.Tokens: newTokenRefresher :: forall m. (MonadIO m, MonadBaseControl IO m, MonadMask m, MonadLogger m, Forall (Pure m)) => TokenConf m -> m TokenRefresher
+ Control.Concurrent.Async.Refresh.Tokens: newTokenRefresher :: forall m. (MonadUnliftIO m, MonadMask m, MonadLogger m) => TokenConf m -> m TokenRefresher
Files
- LICENSE +1/−1
- async-refresh-tokens.cabal +20/−17
- src/Control/Concurrent/Async/Refresh/Tokens.hs +17/−20
- src/Control/Concurrent/Async/Refresh/Tokens/Conf.hs +1/−1
- src/Control/Concurrent/Async/Refresh/Tokens/Lenses.hs +7/−7
- src/Control/Concurrent/Async/Refresh/Tokens/Prelude.hs +6/−28
- src/Control/Concurrent/Async/Refresh/Tokens/Types.hs +10/−8
- test/Spec.hs +2/−3
LICENSE view
@@ -1,4 +1,4 @@-Copyright Moritz Schulte (c) 2017+Copyright Moritz Clasmeier (c) 2017, 2018 All rights reserved.
async-refresh-tokens.cabal view
@@ -1,17 +1,19 @@--- This file has been generated from package.yaml by hpack version 0.17.0.+-- This file has been generated from package.yaml by hpack version 0.20.0. -- -- see: https://github.com/sol/hpack+--+-- hash: 9c48fd1aba83bd450ec2ad17f3ec3f52d13c6349a8171c86be2f21cf1d22bf23 name: async-refresh-tokens-version: 0.3.0.1+version: 0.4.0.0 synopsis: Package implementing core logic for refreshing of expiring access tokens description: This package can be used for renewal of expiring access tokens according to user-provided actions. Tokens will be stored in a transactional variable (TVar). category: Control homepage: https://github.com/mtesseract/async-refresh-tokens#readme bug-reports: https://github.com/mtesseract/async-refresh-tokens/issues-author: Moritz Schulte+author: Moritz Clasmeier maintainer: mtesseract@silverratio.net-copyright: (c) 2017 Moritz Schulte+copyright: (c) 2017, 2018 Moritz Clasmeier license: BSD3 license-file: LICENSE build-type: Simple@@ -30,18 +32,17 @@ default-extensions: OverloadedStrings NoImplicitPrelude ghc-options: -Wall build-depends:- monad-logger- , stm+ async-refresh >=0.3.0.0 , base >=4.7 && <5- , async-refresh >=0.2.0.2- , lifted-async+ , bytestring+ , formatting , microlens >=0.4 , microlens-th >=0.4- , text- , monad-control+ , monad-logger , safe-exceptions- , bytestring- , formatting+ , text+ , unliftio+ , unliftio-core exposed-modules: Control.Concurrent.Async.Refresh.Tokens other-modules:@@ -60,12 +61,14 @@ default-extensions: OverloadedStrings ghc-options: -threaded -rtsopts -with-rtsopts=-N -Wall -fno-warn-type-defaults build-depends:- monad-logger- , stm- , base+ HUnit , async-refresh-tokens- , HUnit+ , base+ , criterion+ , monad-logger , test-framework , test-framework-hunit- , criterion+ , unliftio+ other-modules:+ Paths_async_refresh_tokens default-language: Haskell2010
src/Control/Concurrent/Async/Refresh/Tokens.hs view
@@ -1,16 +1,7 @@-{-# LANGUAGE DataKinds #-}-{-# LANGUAGE ExistentialQuantification #-}-{-# LANGUAGE FlexibleContexts #-}-{-# LANGUAGE MultiParamTypeClasses #-}-{-# LANGUAGE NoImplicitPrelude #-}-{-# LANGUAGE OverloadedStrings #-}-{-# LANGUAGE PolyKinds #-}-{-# LANGUAGE ScopedTypeVariables #-}- {-| Module : Control.Concurrent.Async.Refresh.Tokens Description : This module exposes the API of the async-refresh-tokens package.-Copyright : (c) Moritz Schulte, 2017+Copyright : (c) Moritz Clasmeier, 2017-2018 License : BSD3 Maintainer : mtesseract@silverratio.net Stability : experimental@@ -21,6 +12,15 @@ tokens according to user-provided actions. -} +{-# LANGUAGE DataKinds #-}+{-# LANGUAGE ExistentialQuantification #-}+{-# LANGUAGE FlexibleContexts #-}+{-# LANGUAGE MultiParamTypeClasses #-}+{-# LANGUAGE NoImplicitPrelude #-}+{-# LANGUAGE OverloadedStrings #-}+{-# LANGUAGE PolyKinds #-}+{-# LANGUAGE ScopedTypeVariables #-}+ module Control.Concurrent.Async.Refresh.Tokens ( IsToken(..) , Token(..)@@ -39,23 +39,22 @@ import Control.Concurrent.Async.Refresh.Tokens.Prelude -import Control.Concurrent.Async.Lifted.Safe (cancel,- waitAny) import Control.Concurrent.Async.Refresh import Control.Concurrent.Async.Refresh.Tokens.Conf import qualified Control.Concurrent.Async.Refresh.Tokens.Lenses as Lens import Control.Concurrent.Async.Refresh.Tokens.Types+import Control.Monad.IO.Unlift import Lens.Micro+import UnliftIO.Async+import UnliftIO.STM -- | Start a new token refresher for the provided configuration. -- Returns a 'TokenRefresher' handle representing the running token -- refresher. newTokenRefresher :: forall m.- ( MonadIO m- , MonadBaseControl IO m+ ( MonadUnliftIO m , MonadMask m- , MonadLogger m- , Forall (Pure m) )+ , MonadLogger m ) => TokenConf m -> m TokenRefresher newTokenRefresher conf = do asyncHandle <- async $@@ -70,11 +69,9 @@ -- | Spawn an async refresher for the provided token. spawnSingleTokenRefresher :: forall m.- ( MonadIO m- , MonadBaseControl IO m+ ( MonadUnliftIO m , MonadMask m- , MonadLogger m- , Forall (Pure m) )+ , MonadLogger m ) => RequestToken m -> m (Async ()) spawnSingleTokenRefresher (RequestToken store action) = do let conf = newAsyncRefreshConf action
src/Control/Concurrent/Async/Refresh/Tokens/Conf.hs view
@@ -1,7 +1,7 @@ {-| Module : Control.Concurrent.Async.Refresh.Tokens.Conf Description : Configuration related functions for the async-refresh-tokens package.-Copyright : (c) Moritz Schulte, 2017+Copyright : (c) Moritz Clasmeier, 2017-2018 License : BSD3 Maintainer : mtesseract@silverratio.net Stability : experimental
src/Control/Concurrent/Async/Refresh/Tokens/Lenses.hs view
@@ -1,21 +1,21 @@-{-# LANGUAGE FlexibleInstances #-}-{-# LANGUAGE FunctionalDependencies #-}-{-# LANGUAGE MultiParamTypeClasses #-}-{-# LANGUAGE TemplateHaskell #-}- {-| Module : Control.Concurrent.Async.Refresh.Tokens.Lenses Description : This module defines lenses used within the async-refresh-tokens package.-Copyright : (c) Moritz Schulte, 2017+Copyright : (c) Moritz Clasmeier, 2017-2018 License : BSD3 Maintainer : mtesseract@silverratio.net Stability : experimental Portability : POSIX -} +{-# LANGUAGE FlexibleInstances #-}+{-# LANGUAGE FunctionalDependencies #-}+{-# LANGUAGE MultiParamTypeClasses #-}+{-# LANGUAGE TemplateHaskell #-}+ module Control.Concurrent.Async.Refresh.Tokens.Lenses where -import Lens.Micro.TH import Control.Concurrent.Async.Refresh.Tokens.Types+import Lens.Micro.TH makeFields ''TokenConf
src/Control/Concurrent/Async/Refresh/Tokens/Prelude.hs view
@@ -1,7 +1,7 @@ {-| Module : Control.Concurrent.Async.Refresh.Tokens.Prelude Description : Prelude for the async-refresh-tokens package.-Copyright : (c) Moritz Schulte, 2017+Copyright : (c) Moritz Clasmeier, 2017-2018 License : BSD3 Maintainer : mtesseract@silverratio.net Stability : experimental@@ -13,41 +13,26 @@ , module Control.Exception.Safe , module Formatting , module Control.Monad.Logger- , atomically- , Control.Concurrent.STM.TVar- , Control.Concurrent.STM.readTVar- , Control.Concurrent.STM.writeTVar- , Control.Concurrent.STM.newTVar- , Control.Concurrent.STM.newTVarIO , Text , ByteString , fromMaybe- , Async, Forall, Pure, withAsync, async- , threadDelay , forever, void , MonadIO- , MonadBaseControl , undefined , tshow ) where -import qualified Control.Concurrent-import Control.Concurrent.Async.Lifted.Safe-import Control.Concurrent.STM (STM)-import qualified Control.Concurrent.STM import Control.Exception.Safe import Control.Monad import Control.Monad.IO.Class import Control.Monad.Logger-import Control.Monad.Trans.Control-import Data.ByteString (ByteString)-import Data.Maybe (fromMaybe)-import Data.Text (Text)+import Data.ByteString (ByteString)+import Data.Maybe (fromMaybe)+import Data.Text (Text) import qualified Data.Text import Formatting-import Prelude hiding (head, tail,- undefined)-import qualified Prelude as Prelude+import Prelude hiding (head, tail, undefined)+import qualified Prelude as Prelude -- | Version of 'undefined' with a deprecated pragma. undefined :: a@@ -58,10 +43,3 @@ -- 'String'. tshow :: Show a => a -> Text tshow = Data.Text.pack . show---- | Generalization of 'Control.Concurrent.threadDelay'.-threadDelay :: MonadIO m => Int -> m ()-threadDelay = liftIO . Control.Concurrent.threadDelay--atomically :: MonadIO m => STM a -> m a-atomically = liftIO . Control.Concurrent.STM.atomically
src/Control/Concurrent/Async/Refresh/Tokens/Types.hs view
@@ -1,26 +1,28 @@-{-# LANGUAGE ExistentialQuantification #-}-{-# LANGUAGE KindSignatures #-}-{-# LANGUAGE OverloadedLists #-}-{-# LANGUAGE PolyKinds #-}-{-# LANGUAGE Rank2Types #-}-{-# LANGUAGE TypeFamilies #-}- {-| Module : Control.Concurrent.Async.Refresh.Tokens.Lenses Description : This module defines the types used within the async-refresh-tokens package.-Copyright : (c) Moritz Schulte, 2017+Copyright : (c) Moritz Clasmeier, 2017-2018 License : BSD3 Maintainer : mtesseract@silverratio.net Stability : experimental Portability : POSIX -} +{-# LANGUAGE ExistentialQuantification #-}+{-# LANGUAGE KindSignatures #-}+{-# LANGUAGE OverloadedLists #-}+{-# LANGUAGE PolyKinds #-}+{-# LANGUAGE Rank2Types #-}+{-# LANGUAGE TypeFamilies #-}+ module Control.Concurrent.Async.Refresh.Tokens.Types where import Control.Concurrent.Async.Refresh.Tokens.Prelude import Control.Concurrent.Async.Refresh import Data.Proxy+import UnliftIO.Async+import UnliftIO.STM -- | Exceptions specific to this package. data TokenException = TokenNotFound Text
test/Spec.hs view
@@ -2,17 +2,16 @@ module Main where -import Control.Concurrent (threadDelay) import Control.Concurrent.Async.Refresh.Tokens-import Control.Concurrent.STM import Control.Monad.IO.Class import Control.Monad.Logger import Data.Function ((&))-import Data.Proxy import Test.Framework (defaultMain, testGroup) import Test.Framework.Providers.HUnit (testCase) import Test.HUnit ((@?=))+import UnliftIO.Concurrent+import UnliftIO.STM data TokenFoo