Commits

Bryan O'Sullivan committed 381976d

Implement delete.

Comments (0)

Files changed (2)

src/Network/Riak.hs

     , getServerInfo
     , get
     , Network.Riak.put
+    , delete
     ) where
 
 import qualified Data.ByteString.Char8 as B
 import Network.Riakclient.RpbContent
 import Network.Riakclient.RpbPutReq
 import Network.Riakclient.RpbPutResp
+import Network.Riakclient.RpbDelReq
 import Network.Riakclient.RpbGetServerInfoResp
 import Network.Riakextra.RpbPingReq
 import Network.Riakextra.RpbGetClientIdReq
                      (fromQuorum <$> w) (fromQuorum <$> dw) (Just returnBody)
   RpbPutResp{..} <- recvResponse conn
   return (content, VClock <$> vclock)
+
+delete :: Connection -> T.Bucket -> T.Key -> Maybe RW -> IO ()
+delete conn bucket key rw = do
+  sendRequest conn $ RpbDelReq bucket key (fromQuorum <$> rw)
+  recvResponse_ conn DelResp

src/Network/Riak/Socket.hs

 
 recvWith :: (L.ByteString -> IO L.ByteString) -> Connection -> Int64
          -> IO L.ByteString
-recvWith onError Connection{..} n0 = do
+recvWith onError Connection{..} n0
+    | n0 <= 0 = return L.empty
+    | otherwise = do
   bs <- readIORef connBuffer
   let (h,t) = L.splitAt n0 bs
       len = L.length h