ngx-export-tools 0.4.2.4 → 0.4.3.0
raw patch · 4 files changed
+48/−28 lines, 4 filesdep ~ngx-exportPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
Dependency ranges changed: ngx-export
API changes (from Hackage documentation)
- NgxExport.Tools: exitWorkerProcess :: IO ()
+ NgxExport.Tools: finalizeHTTPRequest :: Int -> Maybe String -> IO ()
+ NgxExport.Tools: restartWorkerProcess :: String -> IO ()
- NgxExport.Tools: terminateWorkerProcess :: IO ()
+ NgxExport.Tools: terminateWorkerProcess :: String -> IO ()
Files
- Changelog.md +8/−0
- LICENSE +1/−1
- NgxExport/Tools.hs +36/−24
- ngx-export-tools.cabal +3/−3
Changelog.md view
@@ -1,3 +1,11 @@+### 0.4.3.0++- Function *exitWorkerProcess* was renamed to *restartWorkerProcess*.+- A new function *finalizeHTTPRequest* was added.+- Functions *terminateWorkerProcess* and *restartWorkerProcess* were+ reimplemented using API exceptions from package *ngx-export 1.6.3*, and+ therefore now they can be effectively used only in Haskell services.+ ### 0.4.2.3 - Using *TypeApplications* instead of *PartialTypeSignatures* in examples.
LICENSE view
@@ -1,7 +1,7 @@ The following license covers this documentation, and the source code, except where otherwise indicated. -Copyright 2016-2018, Alexey Radkov. All rights reserved.+Copyright 2018-2019, Alexey Radkov. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
NgxExport/Tools.hs view
@@ -1,11 +1,10 @@-{-# LANGUAGE TemplateHaskell, ForeignFunctionInterface, TypeFamilies #-}-{-# LANGUAGE EmptyDataDecls, DeriveGeneric, DeriveLift #-}-{-# LANGUAGE LambdaCase, NumDecimals #-}+{-# LANGUAGE TemplateHaskell, TypeFamilies, EmptyDataDecls #-}+{-# LANGUAGE DeriveGeneric, DeriveLift, LambdaCase, NumDecimals #-} ----------------------------------------------------------------------------- -- | -- Module : NgxExport.Tools--- Copyright : (c) Alexey Radkov 2018+-- Copyright : (c) Alexey Radkov 2018-2019 -- License : BSD-style -- -- Maintainer : alexey.radkov@gmail.com@@ -20,8 +19,9 @@ module NgxExport.Tools ( -- * Various useful functions and data- exitWorkerProcess- ,terminateWorkerProcess+ terminateWorkerProcess+ ,restartWorkerProcess+ ,finalizeHTTPRequest ,ngxRequestPtr ,ngxNow -- *** Time intervals@@ -74,19 +74,31 @@ import System.IO.Unsafe (unsafePerformIO) import Safe -foreign import ccall unsafe "exit" exit :: CInt -> IO ()+-- | 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+-- the worker process effectively only from a Haskell service.+terminateWorkerProcess :: String -> IO ()+terminateWorkerProcess = throwIO . TerminateWorkerProcess --- | Terminates current Nginx worker process.+-- | Restarts the Nginx worker process from a Haskell service. ----- Nginx master process shall spawn a new worker process thereafter.-exitWorkerProcess :: IO ()-exitWorkerProcess = exit 1+-- Nginx master process shall spawn a new worker process after termination of+-- the current one. This function throws exception 'RestartWorkerProcess', and+-- therefore terminates the worker process effectively only from a Haskell+-- service.+restartWorkerProcess :: String -> IO ()+restartWorkerProcess = throwIO . RestartWorkerProcess --- | Terminates current Nginx worker process.+-- | Finalizes the current HTTP request from a Haskell asynchronous variable+-- handler. ----- Nginx master process shall /not/ spawn a new worker process thereafter.-terminateWorkerProcess :: IO ()-terminateWorkerProcess = exit 2+-- This function throws exception 'FinalizeHTTPRequest', and therefore+-- terminates the HTTP request effectively only from a Haskell asynchronous+-- variable handler.+finalizeHTTPRequest :: Int -> Maybe String -> IO ()+finalizeHTTPRequest = (throwIO .) . FinalizeHTTPRequest -- | Unmarshals the value of Nginx variable __/$_r_ptr/__ into a pointer to -- the Nginx request object.@@ -100,7 +112,8 @@ ngxRequestPtr :: ByteString -> Ptr () ngxRequestPtr = wordPtrToPtr . fromIntegral . runGet getWordhost . L.fromStrict --- | Returns current time as the number of seconds elapsed since UNIX epoch.+-- | Returns the current time as the number of seconds elapsed since the UNIX+-- epoch. -- -- The value is taken from Nginx core, so no additional system calls get -- involved. On the other hand, it means that this is only safe to use from@@ -128,7 +141,7 @@ toSec (HrMin h m) = 3600 * h + 60 * m toSec (MinSec m s) = 60 * m + s --- | Delays current thread for the specified number of seconds.+-- | Delays the current thread for the specified number of seconds. threadDelaySec :: Int -> IO () threadDelaySec = threadDelay . (* 1e6) @@ -539,9 +552,8 @@ let conf_data__ = $(readConf) $(eConfBs) when (isNothing conf_data__) $- throwIO $- TerminateWorkerProcess- unreadableConfMsg+ terminateWorkerProcess+ unreadableConfMsg writeIORef $(storage) conf_data__ return conf_data__ ) (return . Just)@@ -637,8 +649,8 @@ -- with __/storage_/__. The stored data is wrapped in 'Maybe' container. -- -- When reading of the custom object fails on the first service run, the--- service terminates the worker process by throwing an exception--- 'TerminateWorkerProcess' with a corresponding message.+-- service terminates the worker process by calling 'terminateWorkerProcess'+-- with a corresponding message. ngxExportSimpleServiceTyped :: Name -- ^ Name of the service -> Name -- ^ Name of the custom type -> ServiceMode -- ^ Service mode@@ -664,8 +676,8 @@ -- container. -- -- When reading of the custom object fails on the first service run, the--- service terminates the worker process by throwing an exception--- 'TerminateWorkerProcess' with a corresponding message.+-- service terminates the worker process by calling 'terminateWorkerProcess'+-- with a corresponding message. ngxExportSimpleServiceTypedAsJSON :: Name -- ^ Name of the service -> Name -- ^ Name of the custom type -> ServiceMode -- ^ Service mode
ngx-export-tools.cabal view
@@ -1,5 +1,5 @@ name: ngx-export-tools-version: 0.4.2.4+version: 0.4.3.0 synopsis: Extra tools for Nginx haskell module description: Extra tools for <http://github.com/lyokha/nginx-haskell-module Nginx haskell module>.@@ -10,7 +10,7 @@ author: Alexey Radkov <alexey.radkov@gmail.com> maintainer: Alexey Radkov <alexey.radkov@gmail.com> stability: experimental-copyright: 2018 Alexey Radkov+copyright: 2018-2019 Alexey Radkov category: Network build-type: Simple cabal-version: >= 1.8@@ -20,7 +20,7 @@ , template-haskell >= 2.11.0.0 , bytestring >= 0.10.0.0 , binary >= 0.4- , ngx-export >= 1.6.2+ , ngx-export >= 1.6.3 , aeson >= 1.0 , safe