packages feed

ngx-export-tools-extra 1.2.10 → 1.2.11

raw patch · 4 files changed

+46/−17 lines, 4 filesdep ~ngx-export-toolsPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

Dependency ranges changed: ngx-export-tools

API changes (from Hackage documentation)

- NgxExport.Tools.Resolve: instance Data.Hashable.Class.Hashable a => Data.Hashable.Class.Hashable (NgxExport.Tools.Resolve.UQueryGen a)
- NgxExport.Tools.Resolve: instance GHC.Classes.Eq a => GHC.Classes.Eq (NgxExport.Tools.Resolve.UQueryGen a)
- NgxExport.Tools.Resolve: instance GHC.Generics.Generic (NgxExport.Tools.Resolve.UQueryGen a)
- NgxExport.Tools.Resolve: instance GHC.Read.Read a => GHC.Read.Read (NgxExport.Tools.Resolve.UQueryGen a)
+ NgxExport.Tools.Resolve: instance Data.Hashable.Class.Hashable NgxExport.Tools.Resolve.HashUQuery
+ NgxExport.Tools.Resolve: instance GHC.Classes.Eq NgxExport.Tools.Resolve.HashUQuery
+ NgxExport.Tools.Resolve: instance GHC.Generics.Generic NgxExport.Tools.Resolve.HashUQuery

Files

Changelog.md view
@@ -1,3 +1,11 @@+### 1.2.11++- Module *NgxExport.Tools.Resolve*.+  + A smarter implementation of the internal hashable data *HashUQuery*.+- Module *NgxExport.Tools.PCRE*.+  + Replace *rareService* mode declaration in service *declareRegexes* by+    *restartPromptly* declaration from *ngx-export-tools ≥ 1.2.6*.+ ### 1.2.10  - Module *NgxExport.Tools.Resolve*.
NgxExport/Tools/PCRE.hs view
@@ -163,7 +163,7 @@ declareRegexes :: InputRegexes -> NgxExportService declareRegexes = voidService -ngxExportSimpleServiceTyped 'declareRegexes ''InputRegexes rareService+ngxExportSimpleServiceTyped 'declareRegexes ''InputRegexes restartPromptly  compileRegexes :: ByteString -> IO L.ByteString compileRegexes = voidHandler' $ do
NgxExport/Tools/Resolve.hs view
@@ -43,6 +43,7 @@ import           NgxExport.Tools.SimpleService import           NgxExport.Tools.TimeInterval +import           Language.Haskell.TH hiding (Name) import           Network.DNS import           Network.HTTP.Client import           Network.HTTP.Client.TLS (newTlsManager)@@ -330,18 +331,6 @@ -- | Priority policy of upstream names. type UNamePriorityPolicy = PriorityPolicy UName --- FIXME: an awkward hack to avoid using orphan instance Hashable Name,--- make sure that HashUQuery and UQuery have the same internal representation!-data UQueryGen a = UQueryAGen (WeightedList a) UNamePriorityPolicy-                 | UQerySRVGen a UNamePriorityPolicy-                 deriving (Read, Eq, Generic)-                 deriving anyclass Hashable--type HashUQuery = UQueryGen ByteString--hashUQuery :: UQuery -> HashUQuery-hashUQuery = unsafeCoerce- -- | Upstream configuration. -- -- Includes DNS query model and parameters for Nginx /server/ description.@@ -381,6 +370,39 @@ -- | Collected server data. type CollectedServerData = Map UName [ServerData] +-- FIXME: an awkward hack to avoid using orphan instance Hashable Name,+-- the Template Haskell splice below produces the following definitions:+--   1. data HashUQuery deriving Hashable which is essentially data UQuery+--      with all Name entries replaced with ByteString,+--   2. hashUQuery :: UQuery -> HashUQuery which is mere unsafeCoerce+do+    TyConI (DataD [] name [] Nothing cs _) <- reify ''UQuery+    let name' = nameBase name+        (hashU, hashL) = ("Hash", "hash")+        nameHashT = mkName $ hashU ++ name'+        nameHashF = mkName $ hashL ++ name'+    sequence+        [dataD (return []) nameHashT [] Nothing+            (map (\case+                      NormalC n ts ->+                          normalC (mkName $ hashU ++ nameBase n) $+                              map (\(b, t) -> bangType (return b) $+                                      case t of+                                          ConT c+                                              | c == ''Name -> [t|ByteString|]+                                              | c == ''NameList ->+                                                  [t|WeightedList ByteString|]+                                          _ -> return t+                                  ) ts+                      _ -> undefined+                 ) cs+            ) [derivClause Nothing [[t|Eq|], [t|Generic|]]+              ,derivClause (Just AnyclassStrategy) [[t|Hashable|]]+              ]+        ,sigD nameHashF [t|$(conT name) -> $(conT nameHashT)|]+        ,funD nameHashF [clause [] (normalB [|unsafeCoerce|]) []]+        ]+ collectedServerData ::     IORef (TimeInterval, HashMap HashUQuery CollectedServerData) collectedServerData = unsafePerformIO $ newIORef (Unset, HM.empty)@@ -557,11 +579,10 @@     -- causes the latter restarts later, and vice versa, an unhealthy instance     -- may write a short TTL which causes a healthy instance restarts sooner     if new `HM.isSubmapOf` old-        then do+        then voidHandler $             when (nwt /= wt) $                 atomicModifyIORef' collectedServerData $                     (, ()) . first (const nwt)-            return ""         else do             atomicModifyIORef' collectedServerData $                 (, ()) . (const nwt *** (new `HM.union`))
ngx-export-tools-extra.cabal view
@@ -1,5 +1,5 @@ name:                       ngx-export-tools-extra-version:                    1.2.10+version:                    1.2.11 synopsis:                   More extra tools for Nginx Haskell module description:                More extra tools for         <https://github.com/lyokha/nginx-haskell-module Nginx Haskell module>.@@ -40,7 +40,7 @@                           , bytestring >= 0.10.0.0                           , base64 >= 0.3.0.0                           , ngx-export-                          , ngx-export-tools >= 1.2.5+                          , ngx-export-tools >= 1.2.6                           , http-types >= 0.7.0                           , http-client >= 0.5.3                           , http-client-tls >= 0.3.4