ngx-export 1.7.10 → 1.7.10.1
raw patch · 3 files changed
+33/−35 lines, 3 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- Changelog.md +5/−0
- NgxExport.hs +27/−34
- ngx-export.cabal +1/−1
Changelog.md view
@@ -1,3 +1,8 @@+### 1.7.10.1++- Use *DerivingStrategies* in the exception types.+- Minor stylistic updates.+ ### 1.7.10 - Added exporter *ngxExportInitHook* which can be used for writing global data
NgxExport.hs view
@@ -1,4 +1,5 @@ {-# LANGUAGE CPP, TemplateHaskell, ForeignFunctionInterface #-}+{-# LANGUAGE DerivingStrategies, GeneralizedNewtypeDeriving, DeriveAnyClass #-} {-# LANGUAGE ViewPatterns, PatternSynonyms, TupleSections, LambdaCase #-} -----------------------------------------------------------------------------@@ -244,14 +245,14 @@ sequence $ [sigD tName [t|NgxExport -> IO CInt|] ,funD tName $- map (\(fst -> c, i) ->- clause [conP c [wildP]] (normalB [|return i|]) []- ) (zip tCons [1 ..] :: [((Name, Type), Int)])+ zipWith (\(c, _) i ->+ clause [conP c [wildP]] (normalB [|return i|]) []+ ) tCons [1 :: Int ..] ,sigD aName [t|NgxExportTypeAmbiguityTag -> IO CInt|] ,funD aName $- map (\(c, i) ->- clause [conP c []] (normalB [|return i|]) []- ) (zip aCons [0 ..] :: [(Name, Int)])+ zipWith (\c i ->+ clause [conP c []] (normalB [|return i|]) []+ ) aCons [0 :: Int ..] ] ++ map (\(c, t) -> tySynD (mkName $ nameBase c) [] $ return t) tCons@@ -268,9 +269,9 @@ ngxExport' :: (Name -> Q Exp) -> NgxExportDec ngxExport' mode e a h f = do #if MIN_VERSION_template_haskell(2,16,0)- AppT (AppT ArrowT _) typeF@(ConT _) <- reifyType h+ AppT (AppT ArrowT _) typeF@ConT {} <- reifyType h #else- VarI _ (AppT (AppT ArrowT _) typeF@(ConT _)) _ <- reify h+ VarI _ (AppT (AppT ArrowT _) typeF@ConT {}) _ <- reify h #endif sequence [sigD nameFt typeFt@@ -607,10 +608,10 @@ -- -- as a synchronous initialization hook. ----- This can be used to initialize global data /synchronously/ before handling--- client requests. Note that asynchronous services that write global data on--- the first run cannot guarantee the data has been written before the start of--- processing client requests.+-- This can be used to initialize global data /synchronously/ before starting+-- services and handling client requests. Note that asynchronous services that+-- write global data on the first run cannot guarantee the data has been+-- written before the start of processing client requests. -- -- It is not possible to load more than one initialization hook. The hook is -- only loaded if it has been directly declared in the target library,@@ -633,16 +634,14 @@ typeF = [t|InitHookImpl|] data ServiceHookInterrupt = ServiceHookInterrupt+ deriving anyclass Exception -instance Exception ServiceHookInterrupt instance Show ServiceHookInterrupt where show = const "Service was interrupted by a service hook" newtype ServiceSomeInterrupt = ServiceSomeInterrupt String--instance Exception ServiceSomeInterrupt-instance Show ServiceSomeInterrupt where- show (ServiceSomeInterrupt s) = s+ deriving anyclass Exception+ deriving newtype Show -- | Terminates the worker process. --@@ -654,11 +653,8 @@ -- @since 1.6.2 newtype TerminateWorkerProcess = TerminateWorkerProcess String -- ^ Contains the message to log- deriving Eq--instance Exception TerminateWorkerProcess-instance Show TerminateWorkerProcess where- show (TerminateWorkerProcess s) = s+ deriving anyclass Exception+ deriving newtype (Show, Eq) -- | Restarts the worker process. --@@ -668,11 +664,8 @@ -- @since 1.6.3 newtype RestartWorkerProcess = RestartWorkerProcess String -- ^ Contains the message to log- deriving Eq--instance Exception RestartWorkerProcess-instance Show RestartWorkerProcess where- show (RestartWorkerProcess s) = s+ deriving anyclass Exception+ deriving newtype (Show, Eq) -- | Signals that the worker process is exiting. --@@ -698,9 +691,9 @@ -- @since 1.6.3 data FinalizeHTTPRequest = FinalizeHTTPRequest Int (Maybe String) -- ^ Contains HTTP status and body+ deriving anyclass Exception deriving Eq -instance Exception FinalizeHTTPRequest instance Show FinalizeHTTPRequest where show (FinalizeHTTPRequest _ (Just s)) = s show (FinalizeHTTPRequest _ Nothing) = ""@@ -810,20 +803,20 @@ safeAsyncYYHandler :: IO (L.ByteString, (CUInt, Bool)) -> IO (L.ByteString, (CUInt, Bool)) safeAsyncYYHandler = handle $ \e ->- return (C8L.pack $ show e,- (case fromException e of+ return (C8L.pack $ show e+ ,(case fromException e of Just ServiceHookInterrupt -> 2 _ -> case fromException e of- Just (TerminateWorkerProcess _) -> 3+ Just TerminateWorkerProcess {} -> 3 _ -> case fromException e of- Just (RestartWorkerProcess _) -> 4+ Just RestartWorkerProcess {} -> 4 _ -> case fromException e of- Just (FinalizeHTTPRequest st (Just _)) ->+ Just (FinalizeHTTPRequest st Just {}) -> 0x80000000 .|. fromIntegral st Just (FinalizeHTTPRequest st Nothing) -> 0xC0000000 .|. fromIntegral st _ -> case fromException e of- Just (ServiceSomeInterrupt _) -> 5+ Just ServiceSomeInterrupt {} -> 5 _ -> 1 ,case asyncExceptionFromException e of Just WorkerProcessIsExiting -> True
ngx-export.cabal view
@@ -1,5 +1,5 @@ name: ngx-export-version: 1.7.10+version: 1.7.10.1 synopsis: Helper module for Nginx Haskell module description: Helper module for <https://github.com/lyokha/nginx-haskell-module Nginx Haskell module>.