diff options
author | Paul Oliver <contact@pauloliver.dev> | 2025-01-23 14:22:33 -0800 |
---|---|---|
committer | Paul Oliver <contact@pauloliver.dev> | 2025-01-24 16:36:25 -0800 |
commit | 367aaf43ef9c52f454a721b1924808aeb2d7944f (patch) | |
tree | ce166cf19d119510ba36f4b3c1fdcb9f2214c299 /hsm-dummy-poller | |
parent | 85d856e87ad7875e5dfab19e22e71c4118f4cbad (diff) |
Replaces Int with Word type for numerical values
Diffstat (limited to 'hsm-dummy-poller')
-rw-r--r-- | hsm-dummy-poller/Main.hs | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/hsm-dummy-poller/Main.hs b/hsm-dummy-poller/Main.hs index bc60c7c..8e6908b 100644 --- a/hsm-dummy-poller/Main.hs +++ b/hsm-dummy-poller/Main.hs @@ -23,7 +23,7 @@ data Env = Env { name :: Text , subEps :: [Text] , topics :: [Text] - , period :: Int + , period :: Word } $(deriveFromYaml ''Env) @@ -32,16 +32,18 @@ handle :: (Concurrent :> es, Log :> es, Reader Env :> es) => S.Stream (Eff es) [ByteString] -> Eff es () -handle = - S.fold S.drain . S.mapM (\ps -> asks period >>= threadDelay >> handler ps) +handle = S.fold S.drain . S.mapM handler where receiverDomain = "receiver" - handler [] = localDomain receiverDomain $ logInfo_ "No pulse received yet" - handler ps = - forM_ ps $ \p -> - localDomain receiverDomain - $ logInfo_ - $ "Received pulse #" <> pack (show $ body @Int p) + delay = asks period >>= threadDelay . fromIntegral + handler [] = do + localDomain receiverDomain $ logInfo_ "No pulse received yet" + delay + handler ps = do + localDomain receiverDomain + $ forM_ ps + $ logInfo_ . mappend "Received pulse #" . pack . show . body @Word + delay -- Dummy poller service: -- Proof of concept. Polls for "pulses" through ZMQ at a set interval and |