natskell
Safe HaskellNone
LanguageHaskell2010

Client

Description

High-level client implementation for NATS.

Synopsis

Documentation

data Server Source #

An opaque NATS server endpoint.

Keeping this representation private allows endpoint schemes and transports to be added without changing the connection API.

Instances

Instances details
Show Server Source # 
Instance details

Defined in Client

Eq Server Source # 
Instance details

Defined in Client

Methods

(==) :: Server -> Server -> Bool #

(/=) :: Server -> Server -> 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.

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 #

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.

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.

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.

withConnectTimeoutMicros :: Int -> ConfigOption Source #

Set the maximum time for INFO, TLS, CONNECT, and PONG negotiation 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.

withBufferLimit :: Int -> ConfigOption Source #

Deprecated: Use withMessageLimit instead.

Compatibility alias for withMessageLimit.

data LogLevel #

Constructors

Debug 
Info 
Warn 
Error 
Fatal 

Instances

Instances details
Show LogLevel 
Instance details

Defined in Lib.Logger.Types

Eq LogLevel 
Instance details

Defined in Lib.Logger.Types

Ord LogLevel 
Instance details

Defined in Lib.Logger.Types

data LogEntry #

Instances

Instances details
Show LogEntry 
Instance details

Defined in Lib.Logger.Types

Eq LogEntry 
Instance details

Defined in Lib.Logger.Types

type UserPassData = (User, Pass) #

type SignatureHandler = Nonce -> IO (Either AuthError Signature) #

newtype AuthError #

Constructors

AuthError String 

Instances

Instances details
Show AuthError 
Instance details

Defined in Auth.Types

Eq AuthError 
Instance details

Defined in Auth.Types

data TLSConfig #

Instances

Instances details
Show TLSConfig 
Instance details

Defined in Types.TLS

Eq TLSConfig 
Instance details

Defined in Types.TLS

data ServerError #

Instances

Instances details
Show ServerError 
Instance details

Defined in State.Types

Eq ServerError 
Instance details

Defined in State.Types

data ConnectError #

Instances

Instances details
Show ConnectError 
Instance details

Defined in State.Types

Eq ConnectError 
Instance details

Defined in State.Types