Reference
ConnectOption
Base class for connect options.
A connect option is a callable which can transform a
ConnectOpts
object.
Source code in src/nats_contrib/connect_opts/connect_opts.py
ConnectOpts
dataclass
Connect options for NATS python client.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
servers |
str | list[str]
|
A single server URL or a list of server URLs. |
'nats://localhost:4222'
|
name |
str | None
|
The connection name. |
None
|
dont_randomize |
bool
|
Disable randomizing the server list. |
False
|
inbox_prefix |
str | bytes
|
The inbox prefix to use. |
b'_INBOX'
|
pedantic |
bool
|
Enable pedantic mode. |
False
|
verbose |
bool
|
Enable verbose logging. |
False
|
no_echo |
bool
|
Disable echo. |
False
|
connect_timeout |
float
|
The connection timeout in seconds. |
2
|
drain_timeout |
float
|
The drain timeout in seconds. |
30
|
allow_reconnect |
bool
|
Enable automatic reconnection. |
True
|
max_reconnect_attempts |
int
|
The maximum number of reconnection attempts. |
-1
|
reconnect_time_wait |
float
|
The delay between reconnection attempts in seconds. |
2
|
ping_interval |
float
|
The ping interval in seconds. |
60
|
max_outstanding_pings |
int
|
The maximum number of outstanding pings before closing the connection. |
2
|
pending_size |
int
|
The maximum size of the pending queue in bytes. |
1024 * 1024 * 2
|
flusher_queue_size |
int
|
The size of the flusher queue in number of messages. |
1024
|
flush_timeout |
float | None
|
The flusher timeout in seconds. |
None
|
tls |
SSLContext | None
|
The TLS context to use. |
None
|
tls_hostname |
str | None
|
The hostname to use for TLS verification. |
None
|
user |
str | None
|
The username to use for authentication. |
None
|
password |
str | None
|
The password to use for authentication. |
None
|
token |
str | None
|
The token to use for authentication. |
None
|
user_credentials |
str | tuple[str, str] | None
|
The path to the credentials file to use for authentication. |
None
|
nkeys_seed |
str | None
|
The nkeys seed to use for authentication. |
None
|
signature_cb |
Callable[[str], bytes] | None
|
The callback function to sign the nonce during authentication. |
None
|
user_jwt_cb |
Callable[[], bytearray | bytes] | None
|
The callback function to return the jwt during authentication. |
None
|
error_cb |
Callable[[Exception], Awaitable[None]] | None
|
The callback function to call each time an error occurs. |
None
|
disconnected_cb |
Callable[[], Awaitable[None]] | None
|
The callback function to call each time connection is lost. |
None
|
closed_cb |
Callable[[], Awaitable[None]] | None
|
The callback function to call once connection is closed. |
None
|
discovered_server_cb |
Callable[[], Awaitable[None]] | None
|
The callback function to call each time a new server is discovered. |
None
|
reconnected_cb |
Callable[[], Awaitable[None]] | None
|
The callback function to call each time connection is reestablished. |
None
|