aboutsummaryrefslogtreecommitdiff
path: root/hsm-dummy-poller
diff options
context:
space:
mode:
Diffstat (limited to 'hsm-dummy-poller')
-rw-r--r--hsm-dummy-poller/Main.hs8
-rw-r--r--hsm-dummy-poller/hsm-dummy-poller.cabal1
2 files changed, 6 insertions, 3 deletions
diff --git a/hsm-dummy-poller/Main.hs b/hsm-dummy-poller/Main.hs
index 9f2fad9..bc60c7c 100644
--- a/hsm-dummy-poller/Main.hs
+++ b/hsm-dummy-poller/Main.hs
@@ -3,6 +3,7 @@
{-# LANGUAGE TemplateHaskell #-}
import Control.Monad (forM_)
+import Data.ByteString (ByteString)
import Data.Function ((&))
import Data.Text (Text, pack)
import Effectful (Eff, (:>), runEff)
@@ -12,6 +13,7 @@ import Effectful.Reader.Static (Reader, asks, runReader)
import Effectful.Resource (runResource)
import Hsm.Core.App (launch)
import Hsm.Core.Env (deriveFromYaml)
+import Hsm.Core.Message (body)
import Hsm.Core.Zmq.Client (poll, runClient)
import Streamly.Data.Fold qualified as S (drain)
import Streamly.Data.Stream qualified as S (Stream, fold, mapM)
@@ -28,10 +30,10 @@ $(deriveFromYaml ''Env)
handle ::
(Concurrent :> es, Log :> es, Reader Env :> es)
- => S.Stream (Eff es) [Int]
+ => S.Stream (Eff es) [ByteString]
-> Eff es ()
handle =
- S.fold S.drain . S.mapM (\p -> asks period >>= threadDelay >> handler p)
+ S.fold S.drain . S.mapM (\ps -> asks period >>= threadDelay >> handler ps)
where
receiverDomain = "receiver"
handler [] = localDomain receiverDomain $ logInfo_ "No pulse received yet"
@@ -39,7 +41,7 @@ handle =
forM_ ps $ \p ->
localDomain receiverDomain
$ logInfo_
- $ "Received pulse #" <> pack (show p)
+ $ "Received pulse #" <> pack (show $ body @Int p)
-- Dummy poller service:
-- Proof of concept. Polls for "pulses" through ZMQ at a set interval and
diff --git a/hsm-dummy-poller/hsm-dummy-poller.cabal b/hsm-dummy-poller/hsm-dummy-poller.cabal
index 801cf68..ad04874 100644
--- a/hsm-dummy-poller/hsm-dummy-poller.cabal
+++ b/hsm-dummy-poller/hsm-dummy-poller.cabal
@@ -8,6 +8,7 @@ version: 0.1.0.0
executable dummy-poller
build-depends:
, base
+ , bytestring
, echo
, effectful
, hsm-core