-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/
-- | Haskell bindings for the Apache Thrift RPC system
--
@package thrift
@version 0.9.2
module Thrift.Transport.IOBuffer
type WriteBuffer = IORef Builder
newWriteBuffer :: IO WriteBuffer
writeBuf :: WriteBuffer -> ByteString -> IO ()
flushBuf :: WriteBuffer -> IO ByteString
type ReadBuffer = IORef ByteString
newReadBuffer :: IO ReadBuffer
fillBuf :: ReadBuffer -> ByteString -> IO ()
readBuf :: ReadBuffer -> Int -> IO ByteString
peekBuf :: ReadBuffer -> IO (Maybe Word8)
module Thrift.Arbitraries
instance (Eq k, Hashable k, Arbitrary k, Arbitrary v) => Arbitrary (HashMap k v)
instance (Eq k, Hashable k, Arbitrary k) => Arbitrary (HashSet k)
instance Arbitrary Text
instance Arbitrary k => Arbitrary (Vector k)
instance (Ord k, Arbitrary k) => Arbitrary (Set k)
instance (Ord k, Arbitrary k, Arbitrary v) => Arbitrary (Map k v)
instance Arbitrary ByteString
module Thrift.Types
type TypeMap = HashMap Int16 (Text, ThriftType)
data ThriftVal
TStruct :: (HashMap Int16 (Text, ThriftVal)) -> ThriftVal
TMap :: ThriftType -> ThriftType -> [(ThriftVal, ThriftVal)] -> ThriftVal
TList :: ThriftType -> [ThriftVal] -> ThriftVal
TSet :: ThriftType -> [ThriftVal] -> ThriftVal
TBool :: Bool -> ThriftVal
TByte :: Int8 -> ThriftVal
TI16 :: Int16 -> ThriftVal
TI32 :: Int32 -> ThriftVal
TI64 :: Int64 -> ThriftVal
TString :: ByteString -> ThriftVal
TDouble :: Double -> ThriftVal
data ThriftType
T_STOP :: ThriftType
T_VOID :: ThriftType
T_BOOL :: ThriftType
T_BYTE :: ThriftType
T_DOUBLE :: ThriftType
T_I16 :: ThriftType
T_I32 :: ThriftType
T_I64 :: ThriftType
T_STRING :: ThriftType
T_STRUCT :: TypeMap -> ThriftType
T_MAP :: ThriftType -> ThriftType -> ThriftType
T_SET :: ThriftType -> ThriftType
T_LIST :: ThriftType -> ThriftType
data MessageType
M_CALL :: MessageType
M_REPLY :: MessageType
M_EXCEPTION :: MessageType
M_ONEWAY :: MessageType
instance Eq ThriftType
instance Show ThriftType
instance Eq ThriftVal
instance Show ThriftVal
instance Eq MessageType
instance Show MessageType
instance Arbitrary MessageType
instance Enum MessageType
instance Enum ThriftType
instance Hashable a => Hashable (Vector a)
instance Hashable a => Hashable (HashSet a)
instance (Hashable k, Hashable v) => Hashable (HashMap k v)
module Thrift.Transport
class Transport a where tReadAll _ 0 = return mempty tReadAll a len = do { result <- tRead a len; let rlen = fromIntegral $ length result; when (rlen == 0) (throw $ TransportExn "Cannot read. Remote side has closed." TE_UNKNOWN); if len <= rlen then return result else (result `mappend`) <$> tReadAll a (len - rlen) }
tIsOpen :: Transport a => a -> IO Bool
tClose :: Transport a => a -> IO ()
tRead :: Transport a => a -> Int -> IO ByteString
tPeek :: Transport a => a -> IO (Maybe Word8)
tWrite :: Transport a => a -> ByteString -> IO ()
tFlush :: Transport a => a -> IO ()
tReadAll :: Transport a => a -> Int -> IO ByteString
data TransportExn
TransportExn :: String -> TransportExnType -> TransportExn
data TransportExnType
TE_UNKNOWN :: TransportExnType
TE_NOT_OPEN :: TransportExnType
TE_ALREADY_OPEN :: TransportExnType
TE_TIMED_OUT :: TransportExnType
TE_END_OF_FILE :: TransportExnType
instance Typeable TransportExnType
instance Typeable TransportExn
instance Eq TransportExnType
instance Show TransportExnType
instance Show TransportExn
instance Exception TransportExn
module Thrift.Protocol
class Protocol a where writeMessageEnd _ = return () readMessageEnd _ = return () writeVal p = tWrite (getTransport p) . serializeVal p
getTransport :: (Protocol a, Transport t) => a t -> t
writeMessageBegin :: (Protocol a, Transport t) => a t -> (Text, MessageType, Int32) -> IO ()
writeMessageEnd :: (Protocol a, Transport t) => a t -> IO ()
readMessageBegin :: (Protocol a, Transport t) => a t -> IO (Text, MessageType, Int32)
readMessageEnd :: (Protocol a, Transport t) => a t -> IO ()
serializeVal :: (Protocol a, Transport t) => a t -> ThriftVal -> ByteString
deserializeVal :: (Protocol a, Transport t) => a t -> ThriftType -> ByteString -> ThriftVal
writeVal :: (Protocol a, Transport t) => a t -> ThriftVal -> IO ()
readVal :: (Protocol a, Transport t) => a t -> ThriftType -> IO ThriftVal
data ProtocolExn
ProtocolExn :: ProtocolExnType -> String -> ProtocolExn
data ProtocolExnType
PE_UNKNOWN :: ProtocolExnType
PE_INVALID_DATA :: ProtocolExnType
PE_NEGATIVE_SIZE :: ProtocolExnType
PE_SIZE_LIMIT :: ProtocolExnType
PE_BAD_VERSION :: ProtocolExnType
PE_NOT_IMPLEMENTED :: ProtocolExnType
PE_MISSING_REQUIRED_FIELD :: ProtocolExnType
getTypeOf :: ThriftVal -> ThriftType
runParser :: (Protocol p, Transport t, Show a) => p t -> Parser a -> IO a
versionMask :: Int32
version1 :: Int32
-- | Converts a ByteString to a Floating point number The ByteString is
-- assumed to be encoded in network order (Big Endian) therefore the
-- behavior of this function varies based on whether the local machine is
-- big endian or little endian.
bsToDouble :: ByteString -> Double
instance Typeable ProtocolExnType
instance Typeable ProtocolExn
instance Eq ProtocolExnType
instance Show ProtocolExnType
instance Show ProtocolExn
instance Exception ProtocolExn
module Thrift.Protocol.Binary
data BinaryProtocol a
BinaryProtocol :: a -> BinaryProtocol a
instance Protocol BinaryProtocol
module Thrift.Protocol.Compact
-- | the Compact Protocol implements the standard Thrift
-- TCompactProcotol which is similar to the
-- TBinaryProtocol, but takes less space on the wire. Integral
-- types are encoded using as varints.
data CompactProtocol a
-- | Constuct a CompactProtocol with a Transport
CompactProtocol :: a -> CompactProtocol a
instance Protocol CompactProtocol
module Thrift.Protocol.JSON
-- | The JSON Protocol data uses the standard TSimpleJSONProtocol.
-- Data is encoded as a JSON ByteString
data JSONProtocol t
-- | Construct a JSONProtocol with a Transport
JSONProtocol :: t -> JSONProtocol t
instance Protocol JSONProtocol
module Thrift.Transport.Handle
-- | Type class for all types that can open a Handle. This class is used to
-- replace tOpen in the Transport type class.
class HandleSource s
hOpen :: HandleSource s => s -> IO Handle
instance HandleSource (HostName, PortID)
instance HandleSource FilePath
instance Transport Handle
module Thrift.Transport.Empty
data EmptyTransport
EmptyTransport :: EmptyTransport
instance Transport EmptyTransport
module Thrift.Transport.Framed
-- | FramedTransport wraps a given transport in framed mode.
data FramedTransport t
-- | Create a new framed transport which wraps the given transport.
openFramedTransport :: Transport t => t -> IO (FramedTransport t)
instance Transport t => Transport (FramedTransport t)
module Thrift.Transport.HttpClient
-- | HttpClient, or THttpClient implements the Thrift Transport |
-- Layer over http or https.
data HttpClient
HttpClient :: HandleStream ByteString -> URI -> WriteBuffer -> ReadBuffer -> HttpClient
hstream :: HttpClient -> HandleStream ByteString
uri :: HttpClient -> URI
writeBuffer :: HttpClient -> WriteBuffer
readBuffer :: HttpClient -> ReadBuffer
-- | Use openHttpClient to create an HttpClient connected to
-- uri
openHttpClient :: URI -> IO HttpClient
instance Transport HttpClient
module Thrift
data AppExnType
AE_UNKNOWN :: AppExnType
AE_UNKNOWN_METHOD :: AppExnType
AE_INVALID_MESSAGE_TYPE :: AppExnType
AE_WRONG_METHOD_NAME :: AppExnType
AE_BAD_SEQUENCE_ID :: AppExnType
AE_MISSING_RESULT :: AppExnType
AE_INTERNAL_ERROR :: AppExnType
AE_PROTOCOL_ERROR :: AppExnType
AE_INVALID_TRANSFORM :: AppExnType
AE_INVALID_PROTOCOL :: AppExnType
AE_UNSUPPORTED_CLIENT_TYPE :: AppExnType
data AppExn
AppExn :: AppExnType -> String -> AppExn
ae_type :: AppExn -> AppExnType
ae_message :: AppExn -> String
readAppExn :: (Protocol p, Transport t) => p t -> IO AppExn
writeAppExn :: (Protocol p, Transport t) => p t -> AppExn -> IO ()
data ThriftException
ThriftException :: ThriftException
instance Typeable ThriftException
instance Typeable AppExnType
instance Typeable AppExn
instance Show ThriftException
instance Eq AppExnType
instance Show AppExnType
instance Show AppExn
instance Exception AppExn
instance Enum AppExnType
instance Exception ThriftException
module Thrift.Server
-- | A basic threaded binary protocol socket server.
runBasicServer :: h -> (h -> (BinaryProtocol Handle, BinaryProtocol Handle) -> IO Bool) -> PortNumber -> IO a
-- | A threaded sever that is capable of using any Transport or Protocol
-- instances.
runThreadedServer :: (Transport t, Protocol i, Protocol o) => (Socket -> IO (i t, o t)) -> h -> (h -> (i t, o t) -> IO Bool) -> PortID -> IO a