packages feed

tmp-proc-zipkin 0.5.1.4 → 0.5.3.0

raw patch · 4 files changed

+77/−74 lines, 4 filesdep ~http-clientPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: http-client

API changes (from Hackage documentation)

+ System.TmpProc.Docker.Zipkin: only :: x -> HList '[x]

Files

ChangeLog.md view
@@ -1,5 +1,11 @@ # Revision history for tmp-proc-zipkin +`tmp-proc-zipkin` uses [PVP Versioning][1].++## 0.5.3.0 -- 2023-08-11++* Use new `only` constructor+ ## 0.5.1.4 -- 2023-07-12  * Extend the version bounds of bytestring to allow 0.12@@ -16,3 +22,5 @@  * First version * Initial upload to hackage++[1]: https://pvp.haskell.org
src/System/TmpProc/Docker/Zipkin.hs view
@@ -1,12 +1,13 @@-{-# LANGUAGE DataKinds             #-}+{-# LANGUAGE DataKinds #-} {-# LANGUAGE MultiParamTypeClasses #-}-{-# LANGUAGE NamedFieldPuns        #-}-{-# LANGUAGE OverloadedStrings     #-}-{-# LANGUAGE ScopedTypeVariables   #-}-{-# LANGUAGE TypeApplications      #-}-{-# LANGUAGE TypeFamilies          #-}+{-# LANGUAGE NamedFieldPuns #-}+{-# LANGUAGE OverloadedStrings #-}+{-# LANGUAGE ScopedTypeVariables #-}+{-# LANGUAGE TypeApplications #-}+{-# LANGUAGE TypeFamilies #-} {-# OPTIONS_HADDOCK prune not-home #-}-{-|++{- | Copyright   : (c) 2020-2021 Tim Emiola SPDX-License-Identifier: BSD3 Maintainer  : Tim Emiola <adetokunbo@users.noreply.github.com >@@ -17,11 +18,10 @@  It's also possible to write other instances that launch @ZipKin@ in different ways; for those, this instance can be used as a reference example.- -} module System.TmpProc.Docker.Zipkin   ( -- * 'Proc' instance-    TmpZipkin(..)+    TmpZipkin (..)      -- * Useful definitions   , aProc@@ -32,73 +32,76 @@   ) where -import           Control.Monad.IO.Class    (MonadIO, liftIO)-import           Control.Monad.Trace.Class (MonadTrace, alwaysSampled, rootSpan)-import qualified Data.ByteString.Char8     as C8-import           Data.Proxy                (Proxy (..))-import           Data.String               (fromString)-import qualified Data.Text                 as Text-import           Network.HTTP.Client       (HttpException)-import           System.IO                 (Handle, IOMode (..), hPutStrLn,-                                            openBinaryFile)--import qualified Monitor.Tracing.Zipkin    as ZPK--import           System.TmpProc            (Connectable (..), HList (..),-                                            HandlesOf, HostIpAddress,-                                            Pinged (..), Proc (..),-                                            ProcHandle (..), SvcURI, startupAll,-                                            toPinged, withTmpConn)+import Control.Monad.IO.Class (MonadIO, liftIO)+import Control.Monad.Trace.Class (MonadTrace, alwaysSampled, rootSpan)+import qualified Data.ByteString.Char8 as C8+import Data.Proxy (Proxy (..))+import Data.String (fromString)+import qualified Data.Text as Text+import qualified Monitor.Tracing.Zipkin as ZPK+import Network.HTTP.Client (HttpException)+import System.IO+  ( Handle+  , IOMode (..)+  , hPutStrLn+  , openBinaryFile+  )+import System.TmpProc+  ( Connectable (..)+  , HList (..)+  , HandlesOf+  , HostIpAddress+  , Pinged (..)+  , Proc (..)+  , ProcHandle (..)+  , SvcURI+  , only+  , startupAll+  , toPinged+  , withTmpConn+  )  -{-| A singleton 'HList' containing a 'TmpZipkin'. -}+-- | A singleton 'HList' containing a 'TmpZipkin'. aProc :: HList '[TmpZipkin]-aProc = TmpZipkin `HCons` HNil+aProc = only TmpZipkin  -{-| An 'HList' that just contains the handle created by 'aProc'. -}+-- | An 'HList' that just contains the handle created by 'aProc'. aHandle :: IO (HandlesOf '[TmpZipkin]) aHandle = startupAll aProc  -{-| Provides the capability to launch a Zipkin instance as a @tmp proc@. -}+-- | Provides the capability to launch a Zipkin instance as a @tmp proc@. data TmpZipkin = TmpZipkin  -{-| Specifies how to run @ZipKin@ as a @tmp proc@. -}+-- | Specifies how to run @ZipKin@ as a @tmp proc@. instance Proc TmpZipkin where   type Image TmpZipkin = "openzipkin/zipkin-slim"   type Name TmpZipkin = "a-zipkin-server"-   uriOf = mkUri'   runArgs = []-+  pingCount = 6   ping h = toPinged @HttpException Proxy $ do-    z <- openConn' h+    z <- ZPK.new $ toSettings h     ZPK.run tracedPing z     ZPK.publish z-   reset _ = pure ()  -{-| Specifies how to connect to a tmp @ZipKin@ service.+{- | Specifies how to connect to a tmp @ZipKin@ service.  In this case, there is not really a connection type, but 'ZPK.Zipkin' provides a close analogue.- -} instance Connectable TmpZipkin where   type Conn TmpZipkin = ZPK.Zipkin--  openConn = openConn'+  openConn = ZPK.new . toSettings   closeConn _ = pure ()  -openConn' :: ProcHandle TmpZipkin -> IO ZPK.Zipkin-openConn' = ZPK.new . toSettings---{-| Make a simple HTTP uri to the zipkin server. -}+-- | Make a simple HTTP uri to the zipkin server. mkUri' :: HostIpAddress -> SvcURI mkUri' ip = "http://" <> C8.pack (Text.unpack ip) <> "/" @@ -116,4 +119,4 @@   devNull :: IO Handle-devNull = openBinaryFile "/dev/null"  WriteMode+devNull = openBinaryFile "/dev/null" WriteMode
test/Test/TmpProc/Docker/ZipkinSpec.hs view
@@ -1,34 +1,24 @@-{-# LANGUAGE DataKinds         #-}+{-# LANGUAGE DataKinds #-} {-# LANGUAGE OverloadedStrings #-}-{-# LANGUAGE TypeApplications  #-}+{-# LANGUAGE TypeApplications #-}+ module Test.TmpProc.Docker.ZipkinSpec where -import           Test.Hspec-import           Test.Hspec.TmpProc+import Data.Proxy (Proxy (..))+import qualified Data.Text as Text+import System.TmpProc.Docker.Zipkin+import Test.Hspec+import Test.Hspec.TmpProc -import           Data.Proxy                     (Proxy (..))-import qualified Data.Text                      as Text -import           System.TmpProc.Docker.Zipkin- spec :: Spec spec = tdescribe desc $ do-  beforeAll setupHandles $ afterAll terminateAll $ do+  beforeAll (startupAll aProc) $ afterAll terminateAll $ do     context "when using the Proc from the HList by its 'Name'" $ do-       context "ixPing" $ do--        it "should succeed" $ \hs-          -> ixPing @"a-zipkin-server" Proxy hs `shouldReturn` OK---setupHandles :: IO (HList '[ProcHandle TmpZipkin])-setupHandles = startupAll $ testProc `HCons` HNil---testProc :: TmpZipkin-testProc = TmpZipkin+        it "should succeed" $ \hs ->+          ixPing @"a-zipkin-server" Proxy hs `shouldReturn` OK   desc :: String-desc = "Tmp.Proc:Zipkin:" ++ Text.unpack (nameOf testProc)+desc = "Tmp.Proc:Zipkin:" ++ Text.unpack (nameOf $ hHead aProc)
tmp-proc-zipkin.cabal view
@@ -1,16 +1,16 @@ cabal-version:      3.0 name:               tmp-proc-zipkin-version:            0.5.1.4-synopsis:           Shows how to run redis as a tmp proc+version:            0.5.3.0+synopsis:           Launch ZipKin in docker using tmp-proc description:-  An example of using tmp-proc to launch dockerized ZipKin in integration tests.+  Demos how to use tmp-proc to run ZipKin in docker in a unittest.  license:            BSD-3-Clause license-file:       LICENSE copyright:          2021 Tim Emiola author:             Tim Emiola maintainer:         adetokunbo@users.noreply.github.com-category:           testing+category:           testing, docker, zipkin bug-reports:        https://github.com/adetokunbo/tmp-proc/issues build-type:         Simple extra-source-files:@@ -18,13 +18,15 @@   README.md tested-with:   GHC == 8.8.4-  GHC == 8.10.5   GHC == 8.10.7-  GHC == 9.2.2+  GHC == 9.0.2+  GHC == 9.2.8+  GHC == 9.4.5  source-repository head   type:     git   location: https://github.com/adetokunbo/tmp-proc.git+  subdir:   tmp-proc-zipkin  library   exposed-modules:  System.TmpProc.Docker.Zipkin@@ -32,7 +34,7 @@   build-depends:     , base         >=4.11     && <5     , bytestring   >=0.10.8.2 && <0.12.1-    , http-client+    , http-client  >=0.5.13.1 && <0.8.0.0     , text         >=1.2.3 && <2.2     , tmp-proc     >=0.5  && <0.6     , tracing      >=0.0.7.2  && <0.1.0