aboutsummaryrefslogtreecommitdiff
path: root/hsm-dummy-poller/Main.hs
diff options
context:
space:
mode:
authorPaul Oliver <contact@pauloliver.dev>2025-01-17 14:37:20 -0800
committerPaul Oliver <contact@pauloliver.dev>2025-01-17 19:16:43 -0800
commitebb88408c1d0884b5ca9b7d68bf76d31c33d2e5b (patch)
treec7c2c6b636e8eb89f2d4c6accf77a8c671b8ab9f /hsm-dummy-poller/Main.hs
parentdc6bf1472c930ff1448c419d3205148bce1b787e (diff)
Allows services to publish different topicsHEADmaster
Diffstat (limited to 'hsm-dummy-poller/Main.hs')
-rw-r--r--hsm-dummy-poller/Main.hs8
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