| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Client
Description
Construct a NATS client satisfying the contract in API.
Synopsis
- data Server
- data ServerConfigError
- server :: String -> Int -> Either ServerConfigError Server
- serverWithDefaultPort :: String -> Either ServerConfigError Server
- serverHost :: Server -> String
- serverPort :: Server -> Int
- connect :: [Server] -> [ConfigOption] -> IO (Either ConnectError Client)
- newClient :: [(String, Int)] -> [ConfigOption] -> IO (Either ConnectError Client)
- type ConfigOption = CallOption ClientOptions
- withConnectName :: ByteString -> ConfigOption
- withEcho :: Bool -> ConfigOption
- withAuthToken :: AuthTokenData -> ConfigOption
- withAuthTokenHandler :: AuthTokenHandler -> ConfigOption
- withUserPass :: UserPassData -> ConfigOption
- withUserPassHandler :: UserPassHandler -> ConfigOption
- withNKey :: NKeyData -> ConfigOption
- withNKeyHandler :: NKeyPublicKey -> SignatureHandler -> ConfigOption
- withJWT :: JWTTokenData -> ConfigOption
- withJWTHandlers :: JWTHandler -> SignatureHandler -> ConfigOption
- withTLS :: ConfigOption
- withTLSCert :: TLSCertData -> ConfigOption
- withTLSRootCA :: ByteString -> ConfigOption
- withTLSServerName :: String -> ConfigOption
- withTLSInsecure :: ConfigOption
- withMinimumLogLevel :: LogLevel -> ConfigOption
- withLogAction :: (LogEntry -> IO ()) -> ConfigOption
- withConnectionAttempts :: Int -> ConfigOption
- withConnectTimeoutMicros :: Int -> ConfigOption
- withCallbackConcurrency :: Int -> ConfigOption
- withMessageLimit :: Int -> ConfigOption
- withPendingDeliveryLimits :: Int -> Int -> ConfigOption
- withErrorHandler :: (NatsError -> IO ()) -> ConfigOption
- withServerErrorHandler :: (ServerError -> IO ()) -> ConfigOption
- withConnectionEventHandler :: (ConnectionEvent -> IO ()) -> ConfigOption
- withBufferLimit :: Int -> ConfigOption
- withExitAction :: (ClientExitReason -> IO ()) -> ConfigOption
- data LogLevel
- data LogEntry = LogEntry {}
- renderLogEntry :: LogEntry -> String
- type AuthTokenData = ByteString
- type AuthTokenHandler = IO (Either AuthError AuthTokenData)
- type UserPassData = (User, Pass)
- type UserPassHandler = IO (Either AuthError UserPassData)
- type NKeyData = ByteString
- type NKeyPublicKey = ByteString
- type JWTTokenData = ByteString
- type JWTHandler = IO (Either AuthError JWTTokenData)
- type SignatureHandler = Nonce -> IO (Either AuthError Signature)
- newtype AuthError = AuthError String
- type TLSPublicKey = ByteString
- type TLSPrivateKey = ByteString
- type TLSCertData = (TLSPublicKey, TLSPrivateKey)
- data TLSConfig = TLSConfig {}
- data ClientExitReason
- data ConnectionEvent
- data ServerError
- data ServerErrorKind
- serverErrorReason :: ServerError -> ByteString
- serverErrorKind :: ServerError -> ServerErrorKind
- data ConnectError
- data ConnectAttemptError = ConnectAttemptError {}
- data ConnectFailure
Documentation
An opaque NATS server endpoint.
Keeping this representation private allows endpoint schemes and transports to be added without changing the connection API.
data ServerConfigError Source #
Constructors
| EmptyServerHost | |
| InvalidServerPort Int |
Instances
| Show ServerConfigError Source # | |
Defined in Client.Implementation Methods showsPrec :: Int -> ServerConfigError -> ShowS # show :: ServerConfigError -> String # showList :: [ServerConfigError] -> ShowS # | |
| Eq ServerConfigError Source # | |
Defined in Client.Implementation Methods (==) :: ServerConfigError -> ServerConfigError -> Bool # (/=) :: ServerConfigError -> ServerConfigError -> Bool # | |
server :: String -> Int -> Either ServerConfigError Server Source #
Construct a TCP NATS server endpoint.
serverWithDefaultPort :: String -> Either ServerConfigError Server Source #
Construct a server using the standard NATS port, 4222.
serverHost :: Server -> String Source #
serverPort :: Server -> Int Source #
connect :: [Server] -> [ConfigOption] -> IO (Either ConnectError Client) Source #
Connect to one of the configured NATS servers.
newClient :: [(String, Int)] -> [ConfigOption] -> IO (Either ConnectError Client) Source #
Compatibility connection entry point using raw (host, port) tuples.
type ConfigOption = CallOption ClientOptions Source #
withEcho :: Bool -> ConfigOption Source #
withAuthTokenHandler :: AuthTokenHandler -> ConfigOption Source #
Fetch a token for every connection and reconnection attempt.
withUserPassHandler :: UserPassHandler -> ConfigOption Source #
Fetch a username and password for every connection and reconnection attempt.
withNKey :: NKeyData -> ConfigOption Source #
withNKeyHandler :: NKeyPublicKey -> SignatureHandler -> ConfigOption Source #
Authenticate with a public NKey and a handler that signs the server nonce. The handler returns the raw 64-byte Ed25519 signature; natskell performs the protocol's base64url encoding.
withJWT :: JWTTokenData -> ConfigOption Source #
withJWTHandlers :: JWTHandler -> SignatureHandler -> ConfigOption Source #
Fetch a user JWT and sign the server nonce for every connection attempt.
withTLS :: ConfigOption Source #
Require TLS using the operating system trust store.
withTLSRootCA :: ByteString -> ConfigOption Source #
Trust a PEM-encoded root certificate for this client. Once configured, these roots replace the operating-system trust store for the connection.
withTLSServerName :: String -> ConfigOption Source #
Override the host name used for certificate verification and SNI.
withTLSInsecure :: ConfigOption Source #
Disable server certificate verification. This is unsafe and should only be used when the peer is trusted by some mechanism outside TLS.
withLogAction :: (LogEntry -> IO ()) -> ConfigOption Source #
withConnectTimeoutMicros :: Int -> ConfigOption Source #
Set the total time budget for TCP acquisition, INFO, TLS, CONNECT, PONG, and reconnect resubscription/readiness on each server attempt. Values below one microsecond are clamped to one.
withMessageLimit :: Int -> ConfigOption Source #
Set the largest encoded message body this client accepts. For messages with headers, the encoded header block and payload both count toward the limit. Outbound messages are also constrained by the server's max_payload.
withPendingDeliveryLimits :: Int -> Int -> ConfigOption Source #
Bound callback deliveries pending across the entire client. The first limit is a message count and the second is encoded message bytes.
withErrorHandler :: (NatsError -> IO ()) -> ConfigOption Source #
Receive asynchronous client errors such as slow-consumer notifications. The handler runs on the callback worker pool, never the socket reader.
withServerErrorHandler :: (ServerError -> IO ()) -> ConfigOption Source #
Receive protocol -ERR values on a bounded, dedicated serial worker.
Protocol processing, including PONG handling, does not wait for the handler.
withConnectionEventHandler :: (ConnectionEvent -> IO ()) -> ConfigOption Source #
Receive completed disconnect, reconnect, and close transitions on the same serial callback worker as server errors. Lifecycle delivery is reserved independently from the bounded server-error backlog.
withBufferLimit :: Int -> ConfigOption Source #
Deprecated: Use withMessageLimit instead.
Compatibility alias for withMessageLimit.
withExitAction :: (ClientExitReason -> IO ()) -> ConfigOption Source #
Constructors
| LogEntry | |
renderLogEntry :: LogEntry -> String #
type AuthTokenData = ByteString #
type AuthTokenHandler = IO (Either AuthError AuthTokenData) #
type UserPassData = (User, Pass) #
type UserPassHandler = IO (Either AuthError UserPassData) #
type NKeyData = ByteString #
type NKeyPublicKey = ByteString #
type JWTTokenData = ByteString #
type JWTHandler = IO (Either AuthError JWTTokenData) #
type SignatureHandler = Nonce -> IO (Either AuthError Signature) #
type TLSPublicKey = ByteString #
type TLSPrivateKey = ByteString #
type TLSCertData = (TLSPublicKey, TLSPrivateKey) #
Constructors
| TLSConfig | |
Fields | |
data ClientExitReason #
Constructors
| ExitClosedByUser | |
| ExitRetriesExhausted (Maybe String) | |
| ExitServerError ServerError | |
| ExitInboundMessageTooLarge Int Int | |
| ExitResetRequested |
Instances
| Show ClientExitReason | |
Defined in State.Types Methods showsPrec :: Int -> ClientExitReason -> ShowS # show :: ClientExitReason -> String # showList :: [ClientExitReason] -> ShowS # | |
| Eq ClientExitReason | |
Defined in State.Types Methods (==) :: ClientExitReason -> ClientExitReason -> Bool # (/=) :: ClientExitReason -> ClientExitReason -> Bool # | |
data ConnectionEvent #
Constructors
| ConnectionEventDisconnected | |
| ConnectionEventReconnected | |
| ConnectionEventClosed ClientExitReason |
Instances
| Show ConnectionEvent | |
Defined in State.Types Methods showsPrec :: Int -> ConnectionEvent -> ShowS # show :: ConnectionEvent -> String # showList :: [ConnectionEvent] -> ShowS # | |
| Eq ConnectionEvent | |
Defined in State.Types Methods (==) :: ConnectionEvent -> ConnectionEvent -> Bool # (/=) :: ConnectionEvent -> ConnectionEvent -> Bool # | |
data ServerError #
Instances
| Show ServerError | |
Defined in State.Types Methods showsPrec :: Int -> ServerError -> ShowS # show :: ServerError -> String # showList :: [ServerError] -> ShowS # | |
| Eq ServerError | |
Defined in State.Types | |
data ServerErrorKind #
Constructors
| ServerErrorAuthentication | |
| ServerErrorPermission | |
| ServerErrorProtocol | |
| ServerErrorResourceLimit | |
| ServerErrorConnection | |
| ServerErrorUnknown |
Instances
| Show ServerErrorKind | |
Defined in State.Types Methods showsPrec :: Int -> ServerErrorKind -> ShowS # show :: ServerErrorKind -> String # showList :: [ServerErrorKind] -> ShowS # | |
| Eq ServerErrorKind | |
Defined in State.Types Methods (==) :: ServerErrorKind -> ServerErrorKind -> Bool # (/=) :: ServerErrorKind -> ServerErrorKind -> Bool # | |
data ConnectError #
Constructors
| ConnectNoServers | |
| ConnectAttemptsExhausted [ConnectAttemptError] |
Instances
| Show ConnectError | |
Defined in State.Types Methods showsPrec :: Int -> ConnectError -> ShowS # show :: ConnectError -> String # showList :: [ConnectError] -> ShowS # | |
| Eq ConnectError | |
Defined in State.Types | |
data ConnectAttemptError #
Constructors
| ConnectAttemptError | |
Fields | |
Instances
| Show ConnectAttemptError | |
Defined in State.Types Methods showsPrec :: Int -> ConnectAttemptError -> ShowS # show :: ConnectAttemptError -> String # showList :: [ConnectAttemptError] -> ShowS # | |
| Eq ConnectAttemptError | |
Defined in State.Types Methods (==) :: ConnectAttemptError -> ConnectAttemptError -> Bool # (/=) :: ConnectAttemptError -> ConnectAttemptError -> Bool # | |
data ConnectFailure #
Constructors
| ConnectTransportFailure String | |
| ConnectTLSFailure String | |
| ConnectProtocolFailure String | |
| ConnectAuthenticationFailure String | |
| ConnectHandshakeTimeout |
Instances
| Show ConnectFailure | |
Defined in State.Types Methods showsPrec :: Int -> ConnectFailure -> ShowS # show :: ConnectFailure -> String # showList :: [ConnectFailure] -> ShowS # | |
| Eq ConnectFailure | |
Defined in State.Types Methods (==) :: ConnectFailure -> ConnectFailure -> Bool # (/=) :: ConnectFailure -> ConnectFailure -> Bool # | |