mongoDB-2.0.4: Driver (client) for MongoDB, a free, scalable, fast, document DBMS

Safe HaskellNone




Pipelining is sending multiple requests over a socket and receiving the responses later in the same order (a' la HTTP pipelining). This is faster than sending one request, waiting for the response, then sending the next request, and so on. This implementation returns a promise (future) response for each request that when invoked waits for the response if not already arrived. Multiple threads can send on the same pipeline (and get promises back); it will send each thread's request right away without waiting.

A pipeline closes itself when a read or write causes an error, so you can detect a broken pipeline by checking isClosed. It also closes itself when garbage collected, or you can close it explicitly.



data IOStream i o Source

An IO sink and source where value of type o are sent and values of type i are received.




writeStream :: o -> IO ()
readStream :: IO i
closeStream :: IO ()


data Pipeline i o Source

Thread-safe and pipelined connection

newPipeline :: IOStream i o -> IO (Pipeline i o) Source

Create new Pipeline over given handle. You should close pipeline when finished, which will also close handle. If pipeline is not closed but eventually garbage collected, it will be closed along with handle.

send :: Pipeline i o -> o -> IO () Source

Send message to destination; the destination must not response (otherwise future calls will get these responses instead of their own). Throw IOError and close pipeline if send fails

call :: Pipeline i o -> o -> IO (IO i) Source

Send message to destination and return promise of response from one message only. The destination must reply to the message (otherwise promises will have the wrong responses in them). Throw IOError and closes pipeline if send fails, likewise for promised response.

close :: Pipeline i o -> IO () Source

Close pipe and underlying connection