diff options
author | Paul Oliver <contact@pauloliver.dev> | 2025-01-17 14:37:20 -0800 |
---|---|---|
committer | Paul Oliver <contact@pauloliver.dev> | 2025-01-17 19:16:43 -0800 |
commit | ebb88408c1d0884b5ca9b7d68bf76d31c33d2e5b (patch) | |
tree | c7c2c6b636e8eb89f2d4c6accf77a8c671b8ab9f /hsm-dummy-poller | |
parent | dc6bf1472c930ff1448c419d3205148bce1b787e (diff) |
Diffstat (limited to 'hsm-dummy-poller')
-rw-r--r-- | hsm-dummy-poller/Main.hs | 8 | ||||
-rw-r--r-- | hsm-dummy-poller/hsm-dummy-poller.cabal | 1 |
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 |