aboutsummaryrefslogtreecommitdiff
path: root/hsm-dummy-fail
diff options
context:
space:
mode:
Diffstat (limited to 'hsm-dummy-fail')
-rw-r--r--hsm-dummy-fail/Main.hs14
-rw-r--r--hsm-dummy-fail/hsm-dummy-fail.cabal1
2 files changed, 10 insertions, 5 deletions
diff --git a/hsm-dummy-fail/Main.hs b/hsm-dummy-fail/Main.hs
index 4e293c8..b2b8988 100644
--- a/hsm-dummy-fail/Main.hs
+++ b/hsm-dummy-fail/Main.hs
@@ -2,15 +2,17 @@
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TemplateHaskell #-}
+import Data.ByteString (ByteString)
import Data.Function ((&))
import Data.Text (Text)
import Effectful (Eff, (:>), runEff)
import Effectful.Concurrent (Concurrent, runConcurrent, threadDelay)
import Effectful.Log (runLog)
-import Effectful.Reader.Static (Reader, asks, runReader)
+import Effectful.Reader.Static (Reader, ask, runReader)
import Effectful.Resource (runResource)
import Hsm.Core.App (launch)
import Hsm.Core.Env (deriveFromYaml)
+import Hsm.Core.Message (message)
import Hsm.Core.Zmq.Server (runServer, send)
import Hsm.Status.Error (Error(Error))
import Streamly.Data.Stream (Stream, fromEffect)
@@ -24,13 +26,15 @@ data Env = Env
$(deriveFromYaml ''Env)
-singleError :: (Concurrent :> es, Reader Env :> es) => Stream (Eff es) Error
+singleError ::
+ (Concurrent :> es, Reader Env :> es) => Stream (Eff es) ByteString
singleError =
fromEffect $ do
-- Seemingly, the service needs to be alive for a bit for ZMQ comms to
-- kick in.
- asks alive >>= threadDelay
- return $ Error 0 "Sent from dummy-fail service"
+ env <- ask @Env
+ threadDelay env.alive
+ return $ message env.name $ Error 0 "Sent from dummy-fail service"
-- Dummy fail service:
-- Proof of concept. Publishes a single error that can be catched by a
@@ -38,7 +42,7 @@ singleError =
main :: IO ()
main =
launch @Env "dummy-fail" withoutInputEcho $ \env logger level ->
- (singleError & send @Env)
+ (singleError & send)
& runServer @Env
& runConcurrent
& runLog env.name logger level
diff --git a/hsm-dummy-fail/hsm-dummy-fail.cabal b/hsm-dummy-fail/hsm-dummy-fail.cabal
index 269ea9c..ed0941c 100644
--- a/hsm-dummy-fail/hsm-dummy-fail.cabal
+++ b/hsm-dummy-fail/hsm-dummy-fail.cabal
@@ -8,6 +8,7 @@ version: 0.1.0.0
executable dummy-fail
build-depends:
, base
+ , bytestring
, echo
, effectful
, hsm-core