Skip to content

Instantly share code, notes, and snippets.

@joshmyzie2
Created July 5, 2015 00:09
Show Gist options
  • Save joshmyzie2/7804c53be8ea5942f364 to your computer and use it in GitHub Desktop.
Save joshmyzie2/7804c53be8ea5942f364 to your computer and use it in GitHub Desktop.
From c4d3b8e1e9c40330c2f8c400fe51e08f0fb27ded Mon Sep 17 00:00:00 2001
From: me <me@example.com>
Date: Sat, 4 Jul 2015 20:48:24 +0000
Subject: [PATCH] Add readKdb
---
src/Database/Kdb/Internal/Client.hs | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/src/Database/Kdb/Internal/Client.hs b/src/Database/Kdb/Internal/Client.hs
index 3fd764c..4697145 100644
--- a/src/Database/Kdb/Internal/Client.hs
+++ b/src/Database/Kdb/Internal/Client.hs
@@ -22,7 +22,7 @@ module Database.Kdb.Internal.Client (
-- $actions
-- Reading and writing.
- , writeKdb, query
+ , readKdb, writeKdb, query
)
where
@@ -113,6 +113,13 @@ close Connection {..} = liftIO $! NS.close _socket
-- $actions
-- Primitive read/write actions.
+-- | Blocking read from kdb for use with a subscriber.
+readKdb :: (MonadIO m, MonadCatch m)
+ => Connection
+ -> m Kdb.Value
+readKdb = withConnection (liftIO . read)
+ where read c = Streams.parseFromStream IPC.ipcParser (c ^. inputStream)
+
-- | Asynchronous write to kdb.
writeKdb :: (MonadIO m, MonadCatch m)
=> Kdb.Value
--
1.9.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment