on master help sign in
fix streamly usage to use Streamly.Internal.Data.Parser instead of Streamly.Internal.Data.Parser.ParserK
edcdd54AgentM
src/Network/RPC/Curryer/Server.hs+11−13
@@ -7,7 +7,7 @@ import Streamly.Network.Socket
7import Streamly.Internal.Network.Socket (handleWithM)
7import Streamly.Internal.Network.Socket (handleWithM)
8import Network.Socket as Socket
8import Network.Socket as Socket
9import Network.Socket.ByteString as Socket
9import Network.Socket.ByteString as Socket
10−import Streamly.Internal.Data.Parser.ParserD as PD
10+import Streamly.Internal.Data.Parser as P
11import Codec.Winery
11import Codec.Winery
12import Codec.Winery.Internal (varInt, decodeVarInt, getBytes)
12import Codec.Winery.Internal (varInt, decodeVarInt, getBytes)
13import Codec.Winery.Class (mkExtractor)
13import Codec.Winery.Class (mkExtractor)
@@ -37,7 +37,7 @@ import Foreign.ForeignPtr (plusForeignPtr)
37import Foreign.ForeignPtr.Unsafe (unsafeForeignPtrToPtr)
37import Foreign.ForeignPtr.Unsafe (unsafeForeignPtrToPtr)
38import GHC.Ptr (plusPtr)
38import GHC.Ptr (plusPtr)
39
39
40−import Debug.Trace
40+--import Debug.Trace
41
41
42data ClientHelloMessage = ClientHelloMessage Int Int
42data ClientHelloMessage = ClientHelloMessage Int Int
43 deriving Generic
43 deriving Generic
@@ -105,13 +105,13 @@ localHostAddr = (127,0,0,1)
105messageBoundaryP :: Parser IO Word8 BS.ByteString
105messageBoundaryP :: Parser IO Word8 BS.ByteString
106messageBoundaryP = do
106messageBoundaryP = do
107 let x = FL.toList
107 let x = FL.toList
108− w4x8 <- PD.take 4 x
108+ w4x8 <- P.take 4 x
109− traceShowM ("w4x8"::String, w4x8)
109+ --traceShowM ("w4x8"::String, w4x8)
110 let c = fromIntegral (BO.word32 (BS.pack w4x8))
110 let c = fromIntegral (BO.word32 (BS.pack w4x8))
111− traceShowM ("c"::String, c)
111+ --traceShowM ("c"::String, c)
112− vals <- PD.take c x
112+ vals <- P.take c x
113 let bytes = BS.pack vals
113 let bytes = BS.pack vals
114− traceShowM ("parsedBytes"::String, c, BS.length bytes, bytes)
114+ --traceShowM ("parsedBytes"::String, c, BS.length bytes, bytes)
115 pure bytes
115 pure bytes
116
116
117type NewConnectionHandler msg = IO (Maybe msg)
117type NewConnectionHandler msg = IO (Maybe msg)
@@ -186,22 +186,20 @@ drainSocketMessages sock msgHandler = do
186 print err
186 print err
187 Right val ->
187 Right val ->
188 msgHandler val --add response function
188 msgHandler val --add response function
189− S.drain $ serially $ S.parseManyD messageBoundaryP sockStream & S.mapM handler
189+ S.drain $ serially $ S.parseMany messageBoundaryP sockStream & S.mapM handler
190
190
191--send length-tagged bytestring, perhaps should be in network byte order?
191--send length-tagged bytestring, perhaps should be in network byte order?
192sendMessage :: Serialise a => Message a -> Socket -> IO ()
192sendMessage :: Serialise a => Message a -> Socket -> IO ()
193sendMessage msg socket' = do
193sendMessage msg socket' = do
194− let -- byteArray = toArraySlow fullbytes
194+ let
195− --dbgByteString = BS.pack (SA.toList byteArray)
196 msgbytes = serialise msg
195 msgbytes = serialise msg
197 fullbytes = lenbytes <> msgbytes
196 fullbytes = lenbytes <> msgbytes
198 len = BS.length msgbytes
197 len = BS.length msgbytes
199 lenbytes = BO.bytestring32 (fromIntegral len)
198 lenbytes = BO.bytestring32 (fromIntegral len)
200− --when (dbgByteString /= msgbytes) (error "mismatch!")
201
199
202 byteCount <- Socket.send socket' fullbytes
200 byteCount <- Socket.send socket' fullbytes
203 when (byteCount /= BS.length fullbytes) (error "bytes sent mismatch")
201 when (byteCount /= BS.length fullbytes) (error "bytes sent mismatch")
204− traceShowM ("sent bytes:" :: String, byteCount, fullbytes)
202+ --traceShowM ("sent bytes:" :: String, byteCount, fullbytes)
205
203
206
204
207
205
@@ -219,6 +217,6 @@ toArrayS (BSI.PS fp off len) = SA.Array nfp endPtr
219 endPtr = unsafeForeignPtrToPtr nfp `plusPtr` len `plusPtr` 1 -- ? why +1?
217 endPtr = unsafeForeignPtrToPtr nfp `plusPtr` len `plusPtr` 1 -- ? why +1?
220
218
221toArraySlow :: BS.ByteString -> SA.Array Word8
219toArraySlow :: BS.ByteString -> SA.Array Word8
222−toArraySlow bs = traceShow ("arr" :: String, SA.length arr) arr
220+toArraySlow bs = arr
223 where
221 where
224 arr = SA.fromList (BS.unpack bs)
222 arr = SA.fromList (BS.unpack bs)
test/Curryer/Test/Basic.hs+1−1
@@ -127,7 +127,7 @@ testSyncClientCallTimeout = do
127 mkConn = connect clientHandler localHostAddr port
127 mkConn = connect clientHandler localHostAddr port
128 conn <- mkConn
128 conn <- mkConn
129 let c :: IO (Either ConnectionError TestResponse)
129 let c :: IO (Either ConnectionError TestResponse)
130− c = callTimeout (Just 1000) conn (DelayMicrosecondsReq 500)
130+ c = callTimeout (Just 500) conn (DelayMicrosecondsReq 1000)
131 x <- c
131 x <- c
132 assertEqual "client sync timeout" (Left TimeoutError) x
132 assertEqual "client sync timeout" (Left TimeoutError) x
133 close conn
133 close conn