Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- data Message a = Message {
- body :: ByteString
- value :: a
- data ConsumeResult a
- = Parsed (Message a)
- | Error ParseError
- data ParseError = ParseError String ByteString
- type Microseconds = Int
- jsonMessage :: ToJSON a => a -> Message
- publishToExchange :: (ToJSON a, MonadIO m) => Connection -> Key Routing a -> a -> m ()
- publish :: (ToJSON a, MonadIO m) => Connection -> Key Routing a -> a -> m ()
- consume :: (FromJSON msg, MonadIO m) => Connection -> Queue msg -> m (Maybe (ConsumeResult msg))
- consumeNext :: (FromJSON msg, MonadIO m) => Microseconds -> Connection -> Queue msg -> m (ConsumeResult msg)
Documentation
a parsed message from the queue
Message | |
|
data ConsumeResult a Source #
Parsed (Message a) | |
Error ParseError |
type Microseconds = Int Source #
jsonMessage :: ToJSON a => a -> Message Source #
publishToExchange :: (ToJSON a, MonadIO m) => Connection -> Key Routing a -> a -> m () Source #
publish a message to a routing key, without making sure a queue exists to handle it or if it is the right type of message body
publishToExchange conn key (User "username")
publish :: (ToJSON a, MonadIO m) => Connection -> Key Routing a -> a -> m () Source #
send a message to a queue. Enforces that the message type and queue name are correct at the type level
publish conn (key "users" :: Key Routing User) (User "username")
consume :: (FromJSON msg, MonadIO m) => Connection -> Queue msg -> m (Maybe (ConsumeResult msg)) Source #
Check for a message once and attempt to parse it
res <- consume conn queue case res of Just (Parsed m) -> print m Just (Error e) -> putStrLn "could not parse message" Nothing -> putStrLn "No messages on the queue"
consumeNext :: (FromJSON msg, MonadIO m) => Microseconds -> Connection -> Queue msg -> m (ConsumeResult msg) Source #
Block while checking for messages every N microseconds. Return once you find one.
res <- consumeNext conn queue case res of (Parsed m) -> print m (Error e) -> putStrLn "could not parse message"