From ebb88408c1d0884b5ca9b7d68bf76d31c33d2e5b Mon Sep 17 00:00:00 2001 From: Paul Oliver Date: Fri, 17 Jan 2025 14:37:20 -0800 Subject: Allows services to publish different topics --- hsm-dummy-poller/Main.hs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'hsm-dummy-poller/Main.hs') 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 -- cgit v1.2.1