cloudi-1.7.4: Haskell CloudI API

Safe HaskellNone
LanguageHaskell2010

Foreign.CloudI

Description

Haskell CloudI API. Example usage is available in the integration tests.

Synopsis

Documentation

data RequestType Source #

provided when handling a service request

Constructors

ASYNC 
SYNC 

type Source = Pid Source #

the Erlang pid that is the source of the service request

data Response s Source #

service request callback function return type

Constructors

Response (ByteString, s, T s) 
ResponseInfo (ByteString, ByteString, s, T s) 
Forward (ByteString, ByteString, ByteString, s, T s) 
Forward_ (ByteString, ByteString, ByteString, Int, Int, s, T s) 
Null (s, T s) 
NullError (String, s, T s) 
Instances
Show s => Show (Response s) Source # 
Instance details

Defined in Foreign.CloudI.Instance

Methods

showsPrec :: Int -> Response s -> ShowS #

show :: Response s -> String #

showList :: [Response s] -> ShowS #

type Callback s = RequestType -> ByteString -> ByteString -> ByteString -> ByteString -> Int -> Int -> ByteString -> Source -> s -> T s -> IO (Response s) Source #

a function to handle a service request

data T s Source #

an instance of the CloudI API

Instances
Show (T s) Source # 
Instance details

Defined in Foreign.CloudI.Instance

Methods

showsPrec :: Int -> T s -> ShowS #

show :: T s -> String #

showList :: [T s] -> ShowS #

transIdNull :: ByteString Source #

a null trans_id is used to check for a timeout or to get the oldest response with recv_async

data Exception s Source #

Instances
Show (Exception s) Source # 
Instance details

Defined in Foreign.CloudI

Typeable s => Exception (Exception s) Source # 
Instance details

Defined in Foreign.CloudI

api :: Typeable s => Int -> s -> IO (Result (T s)) Source #

creates an instance of the CloudI API

threadCount :: IO (Result Int) Source #

returns the thread count from the service configuration

subscribe :: T s -> ByteString -> Callback s -> IO (Result (T s)) Source #

subscribes to a service name pattern with a callback

subscribeCount :: Typeable s => T s -> ByteString -> IO (Result (Int, T s)) Source #

returns the number of subscriptions for a single service name pattern

unsubscribe :: T s -> ByteString -> IO (Result (T s)) Source #

unsubscribes from a service name pattern once

sendAsync :: Typeable s => T s -> ByteString -> ByteString -> Maybe Int -> Maybe ByteString -> Maybe Int -> IO (Result (ByteString, T s)) Source #

sends an asynchronous service request

sendSync :: Typeable s => T s -> ByteString -> ByteString -> Maybe Int -> Maybe ByteString -> Maybe Int -> IO (Result (ByteString, ByteString, ByteString, T s)) Source #

sends a synchronous service request

mcastAsync :: Typeable s => T s -> ByteString -> ByteString -> Maybe Int -> Maybe ByteString -> Maybe Int -> IO (Result (Array Int ByteString, T s)) Source #

sends asynchronous service requests to all subscribers of the matching service name pattern

forward_ :: Typeable s => T s -> RequestType -> ByteString -> ByteString -> ByteString -> Int -> Int -> ByteString -> Source -> IO () Source #

forwards a service request to a different service name

forwardAsync :: Typeable s => T s -> ByteString -> ByteString -> ByteString -> Int -> Int -> ByteString -> Source -> IO () Source #

forwards an asynchronous service request to a different service name

forwardSync :: Typeable s => T s -> ByteString -> ByteString -> ByteString -> Int -> Int -> ByteString -> Source -> IO () Source #

forwards a synchronous service request to a different service name

return_ :: Typeable s => T s -> RequestType -> ByteString -> ByteString -> ByteString -> ByteString -> Int -> ByteString -> Source -> IO () Source #

provides a response to a service request

returnAsync :: Typeable s => T s -> ByteString -> ByteString -> ByteString -> ByteString -> Int -> ByteString -> Source -> IO () Source #

provides a response to an asynchronous service request

returnSync :: Typeable s => T s -> ByteString -> ByteString -> ByteString -> ByteString -> Int -> ByteString -> Source -> IO () Source #

provides a response to a synchronous service request

recvAsync :: Typeable s => T s -> Maybe Int -> Maybe ByteString -> Maybe Bool -> IO (Result (ByteString, ByteString, ByteString, T s)) Source #

blocks to receive an asynchronous service request response

processIndex :: T s -> Int Source #

returns the 0-based index of this process in the service instance

processCount :: T s -> Int Source #

returns the current process count based on the service configuration

processCountMax :: T s -> Int Source #

returns the count_process_dynamic maximum count based on the service configuration

processCountMin :: T s -> Int Source #

returns the count_process_dynamic minimum count based on the service configuration

prefix :: T s -> ByteString Source #

returns the service name pattern prefix from the service configuration

timeoutInitialize :: T s -> Int Source #

returns the service initialization timeout from the service configuration

timeoutAsync :: T s -> Int Source #

returns the default asynchronous service request send timeout from the service configuration

timeoutSync :: T s -> Int Source #

returns the default synchronous service request send timeout from the service configuration

timeoutTerminate :: T s -> Int Source #

returns the service termination timeout based on the service configuration

poll :: Typeable s => T s -> Int -> IO (Result (Bool, T s)) Source #

blocks to process incoming CloudI service requests

threadCreate :: (Int -> IO ()) -> Int -> IO ThreadId Source #

simplifies thread creation and join

Concurrent.setNumCapabilities threadCount
mapM_ (CloudI.threadCreate task) [0..threadCount - 1]
CloudI.threadsWait

threadsWait :: IO () Source #

wait for threads to join after being created by threadCreate

infoKeyValueParse :: ByteString -> Map ByteString [ByteString] Source #

parses "text_pairs" in service request info