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-receiver/Main.hs | 5 ++++- hsm-dummy-receiver/hsm-dummy-receiver.cabal | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) (limited to 'hsm-dummy-receiver') diff --git a/hsm-dummy-receiver/Main.hs b/hsm-dummy-receiver/Main.hs index 451e9c4..6f3db81 100644 --- a/hsm-dummy-receiver/Main.hs +++ b/hsm-dummy-receiver/Main.hs @@ -2,6 +2,7 @@ {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE TemplateHaskell #-} +import Data.ByteString (ByteString) import Data.Function ((&)) import Data.Text (Text, pack) import Effectful (Eff, (:>), runEff) @@ -10,6 +11,7 @@ import Effectful.Reader.Static (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 (receive, runClient) import Streamly.Data.Fold qualified as S (drain) import Streamly.Data.Stream qualified as S (Stream, fold, mapM) @@ -23,7 +25,7 @@ data Env = Env $(deriveFromYaml ''Env) -handle :: Log :> es => S.Stream (Eff es) Int -> Eff es () +handle :: Log :> es => S.Stream (Eff es) ByteString -> Eff es () handle = S.fold S.drain . S.mapM handler where handler = @@ -32,6 +34,7 @@ handle = S.fold S.drain . S.mapM handler . mappend "Received pulse #" . pack . show + . body @Int -- Dummy receiver service: -- Proof of concept. Listens for "pulses" through ZMQ and logs each time one diff --git a/hsm-dummy-receiver/hsm-dummy-receiver.cabal b/hsm-dummy-receiver/hsm-dummy-receiver.cabal index 9738bbe..61f24a3 100644 --- a/hsm-dummy-receiver/hsm-dummy-receiver.cabal +++ b/hsm-dummy-receiver/hsm-dummy-receiver.cabal @@ -8,6 +8,7 @@ version: 0.1.0.0 executable dummy-receiver build-depends: , base + , bytestring , echo , effectful-core , hsm-core -- cgit v1.2.1