diff options
author | Paul Oliver <contact@pauloliver.dev> | 2025-01-28 21:59:21 +0000 |
---|---|---|
committer | Paul Oliver <contact@pauloliver.dev> | 2025-01-29 04:13:02 +0000 |
commit | 194800033037f25f4c9fdae365f63f6abe0e110c (patch) | |
tree | f92ffe59b3850c6c2325d8a2c2637ff87c5ac40f /hsm-core/Hsm/Core/Zmq/Client.hs | |
parent | 9d2f95bb58f856aaf9142426e90e5783c98af8f1 (diff) |
Adds logging domain to ZMQ resource operations
Diffstat (limited to 'hsm-core/Hsm/Core/Zmq/Client.hs')
-rw-r--r-- | hsm-core/Hsm/Core/Zmq/Client.hs | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/hsm-core/Hsm/Core/Zmq/Client.hs b/hsm-core/Hsm/Core/Zmq/Client.hs index 97728f7..aa74ed3 100644 --- a/hsm-core/Hsm/Core/Zmq/Client.hs +++ b/hsm-core/Hsm/Core/Zmq/Client.hs @@ -75,14 +75,16 @@ runClient :: ) => Eff (Client : es) a -> Eff es a -runClient action = - withSocket Z.Sub >>= \sock -> - E.evalStaticRep (Client sock) $ do - localDomain domain $ do - logInfo_ "Initializing ZMQ client" - env <- ask @env - forM_ env.subEps $ E.unsafeEff_ . Z.connect sock . unpack - forM_ env.topics $ E.unsafeEff_ . Z.subscribe sock . encodeUtf8 - logTrace_ $ "Listening to " <> pack (show env.subEps) - logTrace_ $ "Subscribed to " <> pack (show env.topics) - action +runClient action = do + sock <- localDomain domain $ withSocket Z.Sub + E.evalStaticRep (Client sock) $ do + localDomain domain $ initialize sock + action + where + initialize sock = do + logInfo_ "Initializing ZMQ client" + env <- ask @env + forM_ env.subEps $ E.unsafeEff_ . Z.connect sock . unpack + forM_ env.topics $ E.unsafeEff_ . Z.subscribe sock . encodeUtf8 + logTrace_ $ "Listening to " <> pack (show env.subEps) + logTrace_ $ "Subscribed to " <> pack (show env.topics) |