Safe Haskell | None |
---|---|
Language | Haskell2010 |
Haskell CloudI API. Example usage is available in the integration tests.
Synopsis
- data RequestType
- type Source = Pid
- data Response s
- type Callback s = RequestType -> ByteString -> ByteString -> ByteString -> ByteString -> Int -> Int -> ByteString -> Source -> s -> T s -> IO (Response s)
- data T s
- transIdNull :: ByteString
- invalidInputError :: String
- messageDecodingError :: String
- terminateError :: String
- data Exception s
- type Result a = Either String a
- api :: Typeable s => Int -> s -> IO (Result (T s))
- threadCount :: IO (Result Int)
- subscribe :: T s -> ByteString -> Callback s -> IO (Result (T s))
- subscribeCount :: Typeable s => T s -> ByteString -> IO (Result (Int, T s))
- unsubscribe :: T s -> ByteString -> IO (Result (T s))
- sendAsync :: Typeable s => T s -> ByteString -> ByteString -> Maybe Int -> Maybe ByteString -> Maybe Int -> IO (Result (ByteString, T s))
- sendSync :: Typeable s => T s -> ByteString -> ByteString -> Maybe Int -> Maybe ByteString -> Maybe Int -> IO (Result (ByteString, ByteString, ByteString, T s))
- mcastAsync :: Typeable s => T s -> ByteString -> ByteString -> Maybe Int -> Maybe ByteString -> Maybe Int -> IO (Result (Array Int ByteString, T s))
- forward_ :: Typeable s => T s -> RequestType -> ByteString -> ByteString -> ByteString -> Int -> Int -> ByteString -> Source -> IO ()
- forwardAsync :: Typeable s => T s -> ByteString -> ByteString -> ByteString -> Int -> Int -> ByteString -> Source -> IO ()
- forwardSync :: Typeable s => T s -> ByteString -> ByteString -> ByteString -> Int -> Int -> ByteString -> Source -> IO ()
- return_ :: Typeable s => T s -> RequestType -> ByteString -> ByteString -> ByteString -> ByteString -> Int -> ByteString -> Source -> IO ()
- returnAsync :: Typeable s => T s -> ByteString -> ByteString -> ByteString -> ByteString -> Int -> ByteString -> Source -> IO ()
- returnSync :: Typeable s => T s -> ByteString -> ByteString -> ByteString -> ByteString -> Int -> ByteString -> Source -> IO ()
- recvAsync :: Typeable s => T s -> Maybe Int -> Maybe ByteString -> Maybe Bool -> IO (Result (ByteString, ByteString, ByteString, T s))
- processIndex :: T s -> Int
- processCount :: T s -> Int
- processCountMax :: T s -> Int
- processCountMin :: T s -> Int
- prefix :: T s -> ByteString
- timeoutInitialize :: T s -> Int
- timeoutAsync :: T s -> Int
- timeoutSync :: T s -> Int
- timeoutTerminate :: T s -> Int
- poll :: Typeable s => T s -> Int -> IO (Result (Bool, T s))
- threadCreate :: (Int -> IO ()) -> Int -> IO ThreadId
- threadsWait :: IO ()
- infoKeyValueParse :: ByteString -> Map ByteString [ByteString]
Documentation
data RequestType Source #
provided when handling a service request
Instances
Eq RequestType Source # | |
Defined in Foreign.CloudI.Instance (==) :: RequestType -> RequestType -> Bool # (/=) :: RequestType -> RequestType -> Bool # | |
Show RequestType Source # | |
Defined in Foreign.CloudI.Instance showsPrec :: Int -> RequestType -> ShowS # show :: RequestType -> String # showList :: [RequestType] -> ShowS # |
service request callback function return type
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
an instance of the CloudI API
transIdNull :: ByteString Source #
a null trans_id is used to check for a timeout or to get the oldest response with recv_async
Instances
Show (Exception s) Source # | |
Typeable s => Exception (Exception s) Source # | |
Defined in Foreign.CloudI toException :: Exception s -> SomeException # fromException :: SomeException -> Maybe (Exception s) # displayException :: Exception s -> String # |
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