Skip to main content

Module nats_config

Module nats_config 

Source
Expand description

Shared NATS server-list and JetStream context helpers.

The streamer, archiver, exporter and subscriber all connect to a NATS server (by default the local one), and the streamer and archiver open JetStream contexts, including ones on a central server for configuration mirroring. These helpers read the server list and the optional JetStream domain from the environment in one consistent way.

§Configuration

  • NATS_SERVERS - Comma-separated NATS server URLs, read by servers_from_env. Default: nats://127.0.0.1:4222.
  • JS_DOMAIN - JetStream domain, read by jetstream_context. Unset or blank means no domain.

Constants§

DEFAULT_NATS_SERVERS 🔒
Default NATS server URL used when NATS_SERVERS is unset: the local server on the standard NATS port.

Functions§

jetstream_context
Creates the default JetStream context, using JS_DOMAIN as the domain if set.
jetstream_context_for_domain
Creates a JetStream context for an explicit optional domain.
jetstream_context_from_env
Creates a JetStream context using a domain name read from an environment variable.
servers_from_env
Parses NATS_SERVERS, defaulting to DEFAULT_NATS_SERVERS.
servers_from_env_var
Parses a comma-separated NATS server list from an environment variable.