Safe Haskell | None |
---|---|
Language | Haskell2010 |
- class (Monad m, MonadIO m) => Connection m where
- newtype Subject = Subject ByteString
- newtype SubscriptionId = SubscriptionId ByteString
- data QueueGroup
- defaultConnectionOptions :: NatsConnectionOptions
- defaultTimeout :: Int
- receiveMessage :: (MonadThrow m, Connection m) => Handle -> Int -> m Message
- receiveServerBanner :: Connection m => Handle -> m (Either String NatsServerInfo)
- sendConnect :: Connection m => Handle -> NatsConnectionOptions -> m ()
- sendPong :: Connection m => Handle -> m ()
- sendPub :: Connection m => Handle -> Subject -> Int -> ByteString -> m ()
- sendSub :: Connection m => Handle -> Subject -> SubscriptionId -> Maybe QueueGroup -> m ()
- sendUnsub :: Connection m => Handle -> SubscriptionId -> Maybe Int -> m ()
- data Message
- parseMessage :: MonadThrow m => ByteString -> m Message
- parseServerBanner :: ByteString -> Either String NatsServerInfo
- parseSubject :: ByteString -> Either String Subject
- module Network.Nats.Protocol.Types
Documentation
class (Monad m, MonadIO m) => Connection m where Source #
Connection context for abstracting away IO
receiveRawMessage :: Handle -> Int -> m ByteString Source #
sendRawMessage :: Handle -> Builder -> m () Source #
Connection IO Source # | Default IO implementation using bytestrings |
Name of a NATS subject. Must be a dot-separated alphanumeric string, with ">" and "." as wildcard characters. See http://nats.io/documentation/internals/nats-protocol/
newtype SubscriptionId Source #
A Subscription
identifier
data QueueGroup Source #
Type for representing Queue Groups, used to implement round-robin receivers
defaultConnectionOptions :: NatsConnectionOptions Source #
Default client connection options, for convenience.
defaultTimeout :: Int Source #
Default client timeout, in millisseconds
receiveMessage :: (MonadThrow m, Connection m) => Handle -> Int -> m Message Source #
Receive a Message
from the server
receiveServerBanner :: Connection m => Handle -> m (Either String NatsServerInfo) Source #
Receive the initial server banner from an INFO message, or an error message if it cannot be parsed.
sendConnect :: Connection m => Handle -> NatsConnectionOptions -> m () Source #
Send a CONNECT message to the server
sendPong :: Connection m => Handle -> m () Source #
Send a PONG message to the server, typically in reply to a PING challenge.
sendPub :: Connection m => Handle -> Subject -> Int -> ByteString -> m () Source #
Send a publish request to the server
sendSub :: Connection m => Handle -> Subject -> SubscriptionId -> Maybe QueueGroup -> m () Source #
Send a Subscription request to a Subject
, with a SubscriptionId
and optionally a QueueGroup
.
sendUnsub :: Connection m => Handle -> SubscriptionId -> Maybe Int -> m () Source #
Send an unsubscription request with a SubscriptionId
and optionally a maximum number of messages that will still be listened to.
Messages received from the NATS server
Message ByteString | A published message, containing a payload |
OKMsg | Acknowledgment from server after a client request |
ErrorMsg ByteString | Error message from server after a client request |
Banner ByteString | Server "banner" received via an INFO message |
Ping | Server ping challenge |
parseMessage :: MonadThrow m => ByteString -> m Message Source #
Parses a Message from a ByteString
parseServerBanner :: ByteString -> Either String NatsServerInfo Source #
Specialized parsed to return a NatsServerInfo
parseSubject :: ByteString -> Either String Subject Source #
Parse a ByteString
into a Subject
or return an error message. See http://nats.io/documentation/internals/nats-protocol/
module Network.Nats.Protocol.Types