diff options
Diffstat (limited to 'hsm-dummy-poller/Main.hs')
-rw-r--r-- | hsm-dummy-poller/Main.hs | 8 |
1 files changed, 5 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 |