ngx-export-tools 1.2.6.2 → 1.2.6.3
raw patch · 8 files changed
+55/−47 lines, 8 filesdep ~bytestringPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
Dependency ranges changed: bytestring
API changes (from Hackage documentation)
- NgxExport.Tools.Combinators: voidHandler :: IO a -> IO ByteString
+ NgxExport.Tools.Combinators: voidHandler :: IO a -> IO LazyByteString
- NgxExport.Tools.Combinators: voidHandler' :: IO a -> b -> IO ByteString
+ NgxExport.Tools.Combinators: voidHandler' :: IO a -> b -> IO LazyByteString
- NgxExport.Tools.Combinators: voidService :: a -> Bool -> IO ByteString
+ NgxExport.Tools.Combinators: voidService :: a -> Bool -> IO LazyByteString
- NgxExport.Tools.SimpleService: type NgxExportService = Bool -> IO ByteString
+ NgxExport.Tools.SimpleService: type NgxExportService = Bool -> IO LazyByteString
- NgxExport.Tools.SplitService: deferredService :: (a -> IO ByteString) -> a -> NgxExportService
+ NgxExport.Tools.SplitService: deferredService :: (a -> IO LazyByteString) -> a -> NgxExportService
- NgxExport.Tools.SplitService: ignitionService :: (a -> IO ByteString) -> a -> NgxExportService
+ NgxExport.Tools.SplitService: ignitionService :: (a -> IO LazyByteString) -> a -> NgxExportService
- NgxExport.Tools.SplitService: splitService :: (a -> IO ByteString) -> (a -> IO ByteString) -> a -> NgxExportService
+ NgxExport.Tools.SplitService: splitService :: (a -> IO LazyByteString) -> (a -> IO LazyByteString) -> a -> NgxExportService
- NgxExport.Tools.SplitService: type NgxExportService = Bool -> IO ByteString
+ NgxExport.Tools.SplitService: type NgxExportService = Bool -> IO LazyByteString
- NgxExport.Tools.Types: type NgxExportService = Bool -> IO ByteString
+ NgxExport.Tools.Types: type NgxExportService = Bool -> IO LazyByteString
Files
- Changelog.md +4/−0
- NgxExport/Tools/Combinators.hs +8/−7
- NgxExport/Tools/Read.hs +7/−7
- NgxExport/Tools/SimpleService.hs +19/−17
- NgxExport/Tools/SplitService.hs +8/−7
- NgxExport/Tools/System.hs +4/−4
- NgxExport/Tools/Types.hs +3/−3
- ngx-export-tools.cabal +2/−2
Changelog.md view
@@ -1,3 +1,7 @@+### 1.2.6.3++- Use type synonym *LazyByteString* from *bytestring ≥ 0.11.2.0*.+ ### 1.2.6.2 - In module *NgxExport.Tools.Read*, compute the wrapped type of data *Readable*
NgxExport/Tools/Combinators.hs view
@@ -30,6 +30,7 @@ import NgxExport.Tools.TimeInterval import qualified Data.ByteString.Lazy as L+import Data.ByteString.Lazy (LazyByteString) import Control.Monad -- $description@@ -37,10 +38,10 @@ -- A set of functions to combine effectful actions for building handlers and -- services tuned for special purposes. --- | Runs an effectful computation and then returns an empty 'L.ByteString'.+-- | Runs an effectful computation and then returns an empty 'LazyByteString'. -- -- This function saves printing the final @return L.empty@ action in handlers--- that return unused or empty 'L.ByteString'.+-- that return unused or empty 'LazyByteString'. -- -- For example, service /signalUpconf/ being used as an -- [/update callback/](https://github.com/lyokha/nginx-haskell-module#update-callbacks)@@ -70,10 +71,10 @@ -- -- @since 1.2.0 voidHandler :: IO a -- ^ Target computation- -> IO L.ByteString+ -> IO LazyByteString voidHandler = (>> return L.empty) --- | Runs an effectful computation and then returns an empty 'L.ByteString'.+-- | Runs an effectful computation and then returns an empty 'LazyByteString'. -- -- The same as 'voidHandler' except it accepts an additional value which is -- ignored. Implemented as@@ -97,10 +98,10 @@ -- @since 1.2.1 voidHandler' :: IO a -- ^ Target computation -> b -- ^ Ignored value- -> IO L.ByteString+ -> IO LazyByteString voidHandler' = const . voidHandler --- | A void service which does nothing and returns an empty 'L.ByteString'.+-- | A void service which does nothing and returns an empty 'LazyByteString'. -- -- The service is implemented as a /split/ service in terms of module -- "NgxExport.Tools.SplitService". On the first iteration the service returns@@ -139,7 +140,7 @@ -- @since 1.2.3 voidService :: a -- ^ Ignored configuration -> Bool -- ^ Ignored boolean value- -> IO L.ByteString+ -> IO LazyByteString voidService = splitService (voidHandler' $ return ()) $ voidHandler' $ forever $ threadDelaySec $ toSec $ Hr 24
NgxExport/Tools/Read.hs view
@@ -60,12 +60,12 @@ -- import NgxExport.Tools.Read -- -- import Data.ByteString (ByteString)--- import qualified Data.ByteString.Lazy as L+-- import Data.ByteString.Lazy (LazyByteString) -- import qualified Data.ByteString.Lazy.Char8 as C8L -- import Data.Aeson -- import GHC.Generics ----- showAsLazyByteString :: Show a => a -> L.ByteString+-- showAsLazyByteString :: Show a => a -> LazyByteString -- showAsLazyByteString = C8L.pack . show -- -- newtype Conf = Conf Int deriving (Read, Show)@@ -74,27 +74,27 @@ -- | ConfJSONCon2 deriving (Generic, Show) -- instance FromJSON ConfJSON ----- testReadIntHandler :: ByteString -> L.ByteString+-- testReadIntHandler :: ByteString -> LazyByteString -- __/testReadIntHandler/__ = showAsLazyByteString . -- 'readFromByteString' \@Int -- 'NgxExport.ngxExportYY' \'testReadIntHandler ----- testReadConfHandler :: ByteString -> L.ByteString+-- testReadConfHandler :: ByteString -> LazyByteString -- __/testReadConfHandler/__ = showAsLazyByteString . -- 'readFromByteString' \@Conf -- 'NgxExport.ngxExportYY' \'testReadConfHandler ----- testReadConfJSONHandler :: ByteString -> IO L.ByteString+-- testReadConfJSONHandler :: ByteString -> IO LazyByteString -- __/testReadConfJSONHandler/__ = return . showAsLazyByteString . -- 'readFromByteStringAsJSON' \@ConfJSON -- 'NgxExport.ngxExportAsyncIOYY' \'testReadConfJSONHandler ----- testReadConfWithRPtrHandler :: ByteString -> L.ByteString+-- testReadConfWithRPtrHandler :: ByteString -> LazyByteString -- __/testReadConfWithRPtrHandler/__ = showAsLazyByteString . -- 'readFromByteStringWithRPtr' \@Conf -- 'NgxExport.ngxExportYY' \'testReadConfWithRPtrHandler ----- testReadConfWithRPtrJSONHandler :: ByteString -> L.ByteString+-- testReadConfWithRPtrJSONHandler :: ByteString -> LazyByteString -- __/testReadConfWithRPtrJSONHandler/__ = showAsLazyByteString . -- 'readFromByteStringWithRPtrAsJSON' \@ConfJSON -- 'NgxExport.ngxExportYY' \'testReadConfWithRPtrJSONHandler
NgxExport/Tools/SimpleService.hs view
@@ -45,6 +45,7 @@ import Foreign.C.Types import Data.ByteString (ByteString) import qualified Data.ByteString.Lazy as L+import Data.ByteString.Lazy (LazyByteString) import Data.IORef import Data.Maybe import Control.Monad@@ -62,7 +63,7 @@ -- services have type -- -- @--- 'ByteString' -> 'Prelude.Bool' -> 'IO' 'L.ByteString'+-- 'ByteString' -> 'Prelude.Bool' -> 'IO' 'LazyByteString' -- @ -- -- which corresponds to the type of usual services from module "NgxExport". The@@ -70,10 +71,10 @@ -- and may have two different types: -- -- @--- 'Read' a => a -> 'Prelude.Bool' -> 'IO' 'L.ByteString'+-- 'Read' a => a -> 'Prelude.Bool' -> 'IO' 'LazyByteString' -- @ -- @--- t'Data.Aeson.FromJSON' a => a -> 'Prelude.Bool' -> 'IO' 'L.ByteString'+-- t'Data.Aeson.FromJSON' a => a -> 'Prelude.Bool' -> 'IO' 'LazyByteString' -- @ -- -- The choice of a certain type of a typed service depends on the format in@@ -92,36 +93,37 @@ -- -- import Data.ByteString (ByteString) -- import qualified Data.ByteString.Lazy as L+-- import Data.ByteString.Lazy (LazyByteString) -- import qualified Data.ByteString.Lazy.Char8 as C8L -- import Data.Aeson -- import Data.IORef -- import Control.Monad -- import GHC.Generics ----- test :: ByteString -> Bool -> IO L.ByteString+-- test :: ByteString -> Bool -> IO LazyByteString -- __/test/__ = const . return . L.fromStrict -- 'ngxExportSimpleService' \'test $ -- 'PersistentService' $ Just $ 'Sec' 10 ----- showAsLazyByteString :: Show a => a -> L.ByteString+-- showAsLazyByteString :: Show a => a -> LazyByteString -- showAsLazyByteString = C8L.pack . show ----- testRead :: Show a => a -> IO L.ByteString+-- testRead :: Show a => a -> IO LazyByteString -- testRead = return . showAsLazyByteString ----- testReadInt :: Int -> Bool -> IO L.ByteString+-- testReadInt :: Int -> Bool -> IO LazyByteString -- __/testReadInt/__ = const . testRead -- 'ngxExportSimpleServiceTyped' \'testReadInt \'\'Int $ -- 'PersistentService' $ Just $ 'Sec' 10 -- -- newtype Conf = Conf Int deriving (Read, Show) ----- testReadConf :: Conf -> Bool -> IO L.ByteString+-- testReadConf :: Conf -> Bool -> IO LazyByteString -- __/testReadConf/__ = const . testRead -- 'ngxExportSimpleServiceTyped' \'testReadConf \'\'Conf $ -- 'PersistentService' $ Just $ 'Sec' 10 ----- testConfStorage :: ByteString -> IO L.ByteString+-- testConfStorage :: ByteString -> IO LazyByteString -- __/testConfStorage/__ = const $ -- showAsLazyByteString \<$\> readIORef __/storage_Conf_testReadConf/__ -- 'ngxExportIOYY' \'testConfStorage@@ -130,7 +132,7 @@ -- , value :: Int -- } deriving (Read, Show) ----- testReadConfWithDelay :: ConfWithDelay -> Bool -> IO L.ByteString+-- testReadConfWithDelay :: ConfWithDelay -> Bool -> IO LazyByteString -- __/testReadConfWithDelay/__ c\@ConfWithDelay {..} fstRun = do -- unless fstRun $ 'threadDelaySec' $ 'toSec' delay -- testRead c@@ -141,7 +143,7 @@ -- | ConfJSONCon2 deriving (Generic, Show) -- instance FromJSON ConfJSON ----- testReadConfJSON :: ConfJSON -> Bool -> IO L.ByteString+-- testReadConfJSON :: ConfJSON -> Bool -> IO LazyByteString -- __/testReadConfJSON/__ = 'NgxExport.Tools.SplitService.ignitionService' testRead -- 'ngxExportSimpleServiceTypedAsJSON' \'testReadConfJSON \'\'ConfJSON -- 'SingleShotService'@@ -389,7 +391,7 @@ concat <$> sequence [sequence $ makeStorage ++- [sigD nameSsf [t|ByteString -> Bool -> IO L.ByteString|]+ [sigD nameSsf [t|ByteString -> Bool -> IO LazyByteString|] ,funD nameSsf [clause [varP confBs, varP fstRun] (normalB@@ -408,7 +410,7 @@ -- | Exports a simple service of type -- -- @--- 'ByteString' -> 'Prelude.Bool' -> 'IO' 'L.ByteString'+-- 'ByteString' -> 'Prelude.Bool' -> 'IO' 'LazyByteString' -- @ -- -- with specified name and service mode.@@ -421,7 +423,7 @@ -- | Exports a simple service of type -- -- @--- 'Read' a => a -> 'Prelude.Bool' -> 'IO' 'L.ByteString'+-- 'Read' a => a -> 'Prelude.Bool' -> 'IO' 'LazyByteString' -- @ -- -- with specified name and service mode.@@ -449,7 +451,7 @@ -- | Exports a simple service of type -- -- @--- t'Data.Aeson.FromJSON' a => a -> 'Prelude.Bool' -> 'IO' 'L.ByteString'+-- t'Data.Aeson.FromJSON' a => a -> 'Prelude.Bool' -> 'IO' 'LazyByteString' -- @ -- -- with specified name and service mode.@@ -477,7 +479,7 @@ -- | Exports a simple service of type -- -- @--- 'Read' a => a -> 'Prelude.Bool' -> 'IO' 'L.ByteString'+-- 'Read' a => a -> 'Prelude.Bool' -> 'IO' 'LazyByteString' -- @ -- -- with specified name and service mode.@@ -498,7 +500,7 @@ -- | Exports a simple service of type -- -- @--- t'Data.Aeson.FromJSON' a => a -> 'Prelude.Bool' -> 'IO' 'L.ByteString'+-- t'Data.Aeson.FromJSON' a => a -> 'Prelude.Bool' -> 'IO' 'LazyByteString' -- @ -- -- with specified name and service mode.
NgxExport/Tools/SplitService.hs view
@@ -26,6 +26,7 @@ import NgxExport.Tools.Types (NgxExportService) import qualified Data.ByteString.Lazy as L+import Data.ByteString.Lazy (LazyByteString) -- $description --@@ -37,17 +38,17 @@ -- When used as a single-shot service (in terms of module -- "NgxExport.Tools.SimpleService"), the second action only runs on exit of a -- worker process, and therefore can be used as a cleanup handler.-splitService :: (a -> IO L.ByteString) -- ^ Ignition service- -> (a -> IO L.ByteString) -- ^ Deferred service- -> a -- ^ Configuration+splitService :: (a -> IO LazyByteString) -- ^ Ignition service+ -> (a -> IO LazyByteString) -- ^ Deferred service+ -> a -- ^ Configuration -> NgxExportService splitService is ds c fstRun | fstRun = is c | otherwise = ds c -- | Sets an action as an ignition service.-ignitionService :: (a -> IO L.ByteString) -- ^ Ignition service- -> a -- ^ Configuration+ignitionService :: (a -> IO LazyByteString) -- ^ Ignition service+ -> a -- ^ Configuration -> NgxExportService ignitionService is = splitService is $ const $ return L.empty @@ -56,8 +57,8 @@ -- When used as a single-shot service (in terms of module -- "NgxExport.Tools.SimpleService"), the action only runs on exit of a worker -- process, and therefore can be used as a cleanup handler.-deferredService :: (a -> IO L.ByteString) -- ^ Deferred service- -> a -- ^ Configuration+deferredService :: (a -> IO LazyByteString) -- ^ Deferred service+ -> a -- ^ Configuration -> NgxExportService deferredService = splitService $ const $ return L.empty
NgxExport/Tools/System.hs view
@@ -45,7 +45,7 @@ -- | Terminates the Nginx worker process from a Haskell service. -- -- Nginx master process shall /not/ spawn a new worker process thereafter. This--- function throws exception 'TerminateWorkerProcess', and therefore terminates+-- function throws exception t'TerminateWorkerProcess', and therefore terminates -- the worker process effectively only from a Haskell service. terminateWorkerProcess :: String -> IO a terminateWorkerProcess = throwIO . TerminateWorkerProcess@@ -53,7 +53,7 @@ -- | Restarts the Nginx worker process from a Haskell service. -- -- Nginx master process shall spawn a new worker process after termination of--- the current one. This function throws exception 'RestartWorkerProcess', and+-- the current one. This function throws exception t'RestartWorkerProcess', and -- therefore terminates the worker process effectively only from a Haskell -- service. restartWorkerProcess :: String -> IO a@@ -62,13 +62,13 @@ -- | Finalizes the current HTTP request from a Haskell asynchronous variable -- handler. ----- This function throws exception 'FinalizeHTTPRequest', and therefore+-- This function throws exception t'FinalizeHTTPRequest', and therefore -- terminates the HTTP request effectively only from a Haskell asynchronous -- variable handler. finalizeHTTPRequest :: Int -> Maybe String -> IO a finalizeHTTPRequest = (throwIO .) . FinalizeHTTPRequest --- | Checks that a generic exception is of type 'WorkerProcessIsExiting'.+-- | Checks that a generic exception is of type t'WorkerProcessIsExiting'. -- -- This can be useful to check quickly in an exception handler whether a -- Haskell service has been interrupted because the worker process is exiting.
NgxExport/Tools/Types.hs view
@@ -16,7 +16,7 @@ NgxExportService ) where -import qualified Data.ByteString.Lazy as L+import Data.ByteString.Lazy (LazyByteString) -- | Allows writing fancier declarations of services. --@@ -25,7 +25,7 @@ -- @ -- type Upconf = [Text] ----- signalUpconf :: Upconf -> 'Bool' -> 'IO' 'L.ByteString'+-- signalUpconf :: Upconf -> Bool -> IO LazyByteString -- signalUpconf = 'NgxExport.Tools.Combinators.voidHandler'' . mapConcurrently_ getUrl -- -- 'NgxExport.Tools.SimpleService.ngxExportSimpleServiceTyped' \'signalUpconf \'\'Upconf $@@ -41,5 +41,5 @@ -- -- @since 1.2.2 type NgxExportService = Bool -- ^ First-run flag- -> IO L.ByteString+ -> IO LazyByteString
ngx-export-tools.cabal view
@@ -1,5 +1,5 @@ name: ngx-export-tools-version: 1.2.6.2+version: 1.2.6.3 synopsis: Extra tools for Nginx Haskell module description: Extra tools for <https://github.com/lyokha/nginx-haskell-module Nginx Haskell module>.@@ -19,7 +19,7 @@ default-language: Haskell2010 build-depends: base >= 4.8 && < 5 , template-haskell >= 2.11.0.0- , bytestring >= 0.10.0.0+ , bytestring >= 0.11.2.0 , binary >= 0.4 , ngx-export >= 1.7.1 , aeson >= 1.0