TokTok / hs-msgpack-rpc-conduit

A MessagePack RPC implementation in Haskell
https://toktok.ltd/
Other
3 stars 8 forks source link

Allow to specify `Connection` in execClient #3

Open Martoon-00 opened 8 years ago

Martoon-00 commented 8 years ago

In our application we may need to keep a routing table (Map (S.ByteString, Int) Connection) and so reuse connections. But implementation of it requires execClient to take Connection as argument. Is it acceptable to create following functions: execClientWithConn :: Client a -> StateT Connection IO a initConn :: ByteString -> Int -> IO Connection closeConn :: Connection -> IO () and put them into Network.MessagePack.Client.Internal?

iphydf commented 8 years ago

Ok, seems reasonable. Make sure to:

  1. Write execClientWithConn :: ClientT m a -> StateT Connection m a to allow IO wrappers.
  2. Add an export list to the Internal module, because you're going to export that module now, and we don't want to expose more than necessary. You may need to restructure things a bit, because currently the Internal module is written with the idea that it won't be exposed in the library. E.g. we still want the Connection type to be opaque.
  3. Add a comment to the top of the now exposed Internal module that its API is unstable (in reality, the rest of the API is also unstable until release 1.0, but for internal stuff it makes sense to be more explicit about it).