Skip to content

ServerSettings

Constructs an embedded NATS server. Every field has an equivalent in nats-server's own options, because an embedded server is the same server — see why that is not a compromise.

Field Type Default Meaning
InProcessOnly bool false Run with no listener at all, not even loopback
Host string "" Interface to bind. Empty binds every interface
Port int 0 Client listener port. Zero asks the OS for one
Routes []string nil Peer servers to mesh with
ClusterName string "" Required when Routes is set
ClusterPort int 0 Port peers connect to, distinct from Port
JetStream bool false Enable persistence, streams, KV, object store
StoreDir string "" Required when JetStream is set
MaxMemory int64 0 JetStream memory bound. Zero takes the server's own
MaxStore int64 0 JetStream disk bound. Zero takes the server's own
ReadyTimeout time.Duration 10s How long Start waits for the server to accept connections

InProcessOnly

Maps to DontListen. With it set there is no socket, so nothing outside the process can reach the server whatever the network allows — which is a security property as much as a performance one.

Clients reach it through client.InProcess, which takes an in-memory net.Conn from the server rather than dialling.

ClientURL() returns empty for such a server. Reporting an address that cannot be dialled would be worse than reporting none.

ReadyTimeout

Start blocks until the server accepts connections or this elapses, then returns ErrNotReady.

Blocking is the point. A server that never becomes ready fails at startup, where an operator is watching, rather than at the first publish — which might be hours later, and will be blamed on the publisher.

What is deliberately not here

NoSigs is set unconditionally and is not a setting. go/controls owns signal handling for the process, and a broker that also traps signals produces a shutdown where neither party is in charge.

Gateways, leaf nodes and account configuration are not exposed yet. They are fields on the same underlying options struct, reachable through Server.Raw(), and a second caller reaching for the same one is a request for it to become a setting.