27 Nov 2012 11:57
Conduit and pipelined protocol processing using a threadpool
Nicolas Trangez <nicolas <at> incubaid.com>
2012-11-27 10:57:09 GMT
2012-11-27 10:57:09 GMT
All, I've written a library to implement servers for some protocol using Conduit (I'll announce more details later). The protocol supports pipelining, i.e. a client can send a 'command' which contains some opaque 'handle' chosen by the client, the server processes this command, then returns some reply which contains this handle. The client is free to send other commands before receiving a reply for any previous request, and the server can process these commands in any order, sequential or concurrently. The library is based on network-conduit's "Application" style [1], as such now I write code like (OTOH) > application :: AppData IO -> IO () > application client = appSource client $= handler $$ appSink client > where > handler = do > negotiateResult <- MyLib.negotiate > liftIO $ validateNegotiateResult negotiateResult > MyLib.sendInformation 123 > loop > > loop = do > command <- MyLib.getCommand > case command of > CommandA handle arg -> do > result <- liftIO $ doComplexProcessingA arg > MyLib.sendReply handle result(Continue reading)
If only I could figure out what to put on the 3 lines of comment I left
in there...
Thanks for your help,
Nicolas
RSS Feed