kafka-client-0.7.0.1: Low-level Haskell client library for Apache Kafka 0.7.

Safe HaskellNone
LanguageHaskell2010

Kafka.Internal.Transport

Synopsis

Documentation

class Transport t where Source

Types that provide a means to send and receive bytes.

Methods

send :: t -> ByteString -> IO () Source

Send the given ByteString down the transport.

This must block until the request has been finished.

recv :: t -> Int -> IO ByteString Source

Read up to the given number of bytes from the stream.

The returned ByteString may be empty if the end of the stream was reached.

Instances

recvExactly :: Transport t => t -> Int -> IO ByteString Source

Keep reading from the given transport until the given number of bytes are read or the end of the stream is reached -- whichever comes first.

data Socket :: *

Represents a socket. The fields are, respectively:

  • File descriptor
  • Socket family
  • Socket type
  • Protocol number
  • Status flag

If you are calling the MkSocket constructor directly you should ensure you have called withSocketsDo.

withConnection :: ByteString -> Int -> (Socket -> IO a) -> IO a Source

Open a connection, execute the given operation on it, and ensure it is closed afterwards even if an exception was thrown.

withConnection "localhost" 9092 $ \conn ->
   doStuff conn
   fail "something went wrong"

Throws an IOException if we were unable to open the connection.

connect :: ByteString -> Int -> IO Socket Source

Create a new connection.

Connects to the given hostname and port. Throws an IOException in case of failure.

close :: Socket -> IO ()

Close the socket. All future operations on the socket object will fail. The remote end will receive no more data (after queued data is flushed).