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
- data FatalError
- type Result a = Either String a
- api :: Typeable s => Int -> s -> Maybe Bool -> 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
- processIndex_ :: IO (Result Int)
- processCount :: T s -> Int
- processCountMax :: T s -> Int
- processCountMax_ :: IO (Result Int)
- processCountMin :: T s -> Int
- processCountMin_ :: IO (Result Int)
- prefix :: T s -> ByteString
- timeoutInitialize :: T s -> Int
- timeoutInitialize_ :: IO (Result Int)
- timeoutAsync :: T s -> Int
- timeoutSync :: T s -> Int
- timeoutTerminate :: T s -> Int
- timeoutTerminate_ :: IO (Result Int)
- priorityDefault :: T s -> Int
- poll :: Typeable s => T s -> Int -> IO (Result (Bool, T s))
- shutdown :: T s -> Maybe ByteString -> IO (Result (T s))
- threadCreate :: (Int -> IO ()) -> Int -> IO ThreadId
- threadsWait :: IO ()
- infoKeyValueParse :: ByteString -> Map ByteString [ByteString]
- infoKeyValueNew :: Map ByteString [ByteString] -> Maybe Bool -> ByteString
Documentation
data RequestType #
provided when handling a service request
Instances
Eq RequestType # | |
Defined in Foreign.CloudI.Instance (==) :: RequestType -> RequestType -> Bool # (/=) :: RequestType -> RequestType -> Bool # | |
Show RequestType # | |
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) #
a function to handle a service request
an instance of the CloudI API
transIdNull :: ByteString #
a null trans_id is used to check for a timeout or to get the oldest response with recv_async
Instances
Show (Exception s) # | |
Typeable s => Exception (Exception s) # | |
Defined in Foreign.CloudI toException :: Exception s -> SomeException # fromException :: SomeException -> Maybe (Exception s) # displayException :: Exception s -> String # |
data FatalError #
Instances
Show FatalError # | |
Defined in Foreign.CloudI showsPrec :: Int -> FatalError -> ShowS # show :: FatalError -> String # showList :: [FatalError] -> ShowS # | |
Exception FatalError # | |
Defined in Foreign.CloudI toException :: FatalError -> SomeException # fromException :: SomeException -> Maybe FatalError # displayException :: FatalError -> String # |
api :: Typeable s => Int -> s -> Maybe Bool -> IO (Result (T s)) #
creates an instance of the CloudI API
threadCount :: IO (Result Int) #
returns the thread count from the service configuration
subscribe :: T s -> ByteString -> Callback s -> IO (Result (T s)) #
subscribes to a service name pattern with a callback
subscribeCount :: Typeable s => T s -> ByteString -> IO (Result (Int, T s)) #
returns the number of subscriptions for a single service name pattern
unsubscribe :: T s -> ByteString -> IO (Result (T s)) #
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)) #
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)) #
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)) #
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 () #
forwards a service request to a different service name
forwardAsync :: Typeable s => T s -> ByteString -> ByteString -> ByteString -> Int -> Int -> ByteString -> Source -> IO () #
forwards an asynchronous service request to a different service name
forwardSync :: Typeable s => T s -> ByteString -> ByteString -> ByteString -> Int -> Int -> ByteString -> Source -> IO () #
forwards a synchronous service request to a different service name
return_ :: Typeable s => T s -> RequestType -> ByteString -> ByteString -> ByteString -> ByteString -> Int -> ByteString -> Source -> IO () #
provides a response to a service request
returnAsync :: Typeable s => T s -> ByteString -> ByteString -> ByteString -> ByteString -> Int -> ByteString -> Source -> IO () #
provides a response to an asynchronous service request
returnSync :: Typeable s => T s -> ByteString -> ByteString -> ByteString -> ByteString -> Int -> ByteString -> Source -> IO () #
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)) #
blocks to receive an asynchronous service request response
processIndex :: T s -> Int #
returns the 0-based index of this process in the service instance
processIndex_ :: IO (Result Int) #
returns the 0-based index of this process in the service instance
processCount :: T s -> Int #
returns the current process count based on the service configuration
processCountMax :: T s -> Int #
returns the count_process_dynamic maximum count based on the service configuration
processCountMax_ :: IO (Result Int) #
returns the count_process_dynamic maximum count based on the service configuration
processCountMin :: T s -> Int #
returns the count_process_dynamic minimum count based on the service configuration
processCountMin_ :: IO (Result Int) #
returns the count_process_dynamic minimum count based on the service configuration
timeoutInitialize :: T s -> Int #
returns the service initialization timeout from the service configuration
timeoutInitialize_ :: IO (Result Int) #
returns the service initialization timeout from the service configuration
timeoutAsync :: T s -> Int #
returns the default asynchronous service request send timeout from the service configuration
timeoutSync :: T s -> Int #
returns the default synchronous service request send timeout from the service configuration
timeoutTerminate :: T s -> Int #
returns the service termination timeout based on the service configuration
timeoutTerminate_ :: IO (Result Int) #
returns the service termination timeout based on the service configuration
priorityDefault :: T s -> Int #
returns the default service request send priority from the service configuration
poll :: Typeable s => T s -> Int -> IO (Result (Bool, T s)) #
blocks to process incoming CloudI service requests
threadCreate :: (Int -> IO ()) -> Int -> IO ThreadId #
simplifies thread creation and join
Concurrent.setNumCapabilities threadCount mapM_ (CloudI.threadCreate task) [0..threadCount - 1] CloudI.threadsWait
threadsWait :: IO () #
wait for threads to join after being created by threadCreate
infoKeyValueParse :: ByteString -> Map ByteString [ByteString] #
decode service request info key/value data
infoKeyValueNew :: Map ByteString [ByteString] -> Maybe Bool -> ByteString #
encode service response info key/value data