# features

name: Server.mqttConfigAuth
go_file: server/mqtt.go
go_class: Server
go_method: mqttConfigAuth
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: NatsServer
dotnet_method: MqttConfigAuth
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
Given the mqtt options, we check if any auth configuration
has been provided. If so, possibly create users/nkey users and
store them in s.mqtt.users/nkeys.
Also update a boolean that indicates if auth is required for
mqtt clients.
Server lock is held on entry.


name: client.getMQTTClientID
go_file: server/mqtt.go
go_class: client
go_method: getMQTTClientID
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: ClientConnection
dotnet_method: GetMQTTClientID
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
If this is an MQTT client, returns the session client ID,
otherwise returns the empty string.
Lock held on entry


name: Server.mqttHandleClosedClient
go_file: server/mqtt.go
go_class: Server
go_method: mqttHandleClosedClient
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: NatsServer
dotnet_method: MqttHandleClosedClient
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
The MQTT client connection has been closed, or the DISCONNECT packet was received.
For a "clean" session, we will delete the session, otherwise, simply removing
the binding. We will also send the "will" message if applicable.

Runs from the client's readLoop.
No lock held on entry.


name: Server.mqttUpdateMaxAckPending
go_file: server/mqtt.go
go_class: Server
go_method: mqttUpdateMaxAckPending
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: NatsServer
dotnet_method: MqttUpdateMaxAckPending
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
Updates the MaxAckPending for all MQTT sessions, updating the
JetStream consumers and updating their max ack pending and forcing
a expiration of pending messages.

Runs from a server configuration reload routine.
No lock held on entry.


name: Server.getOrCreateMQTTAccountSessionManager
go_file: server/mqtt.go
go_class: Server
go_method: getOrCreateMQTTAccountSessionManager
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: NatsServer
dotnet_method: GetOrCreateMQTTAccountSessionManager
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
Returns the MQTT sessions manager for a given account.
If new, creates the required JetStream streams/consumers
for handling of sessions and messages.


name: Server.mqttCreateAccountSessionManager
go_file: server/mqtt.go
go_class: Server
go_method: mqttCreateAccountSessionManager
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: NatsServer
dotnet_method: MqttCreateAccountSessionManager
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
Creates JS streams/consumers for handling of sessions and messages for this account.

Global session manager lock is held on entry.


name: mqttJSA.newRequestExMulti
go_file: server/mqtt.go
go_class: mqttJSA
go_method: newRequestExMulti
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: MqttJetStreamAdapter
dotnet_method: NewRequestExMulti
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
newRequestExMulti sends multiple messages on the same subject and waits for
all responses. It returns the same number of responses in the same order as
msgs parameter. In case of a timeout it returns an error as well as all
responses received as a sparsely populated array, matching msgs, with nils
for the values that have not yet been received.

Note that each response may represent an error and should be inspected as
such by the caller.


name: mqttAccountSessionManager.processJSAPIReplies
go_file: server/mqtt.go
go_class: mqttAccountSessionManager
go_method: processJSAPIReplies
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: MqttAccountSessionManager
dotnet_method: ProcessJSAPIReplies
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
Process JS API replies.

Can run from various go routines (consumer's loop, system send loop, etc..).


name: mqttAccountSessionManager.processRetainedMsg
go_file: server/mqtt.go
go_class: mqttAccountSessionManager
go_method: processRetainedMsg
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: MqttAccountSessionManager
dotnet_method: ProcessRetainedMsg
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
This will both load all retained messages and process updates from the cluster.

Run from various go routines (JS consumer, etc..).
No lock held on entry.


name: mqttAccountSessionManager.processSessionPersist
go_file: server/mqtt.go
go_class: mqttAccountSessionManager
go_method: processSessionPersist
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: MqttAccountSessionManager
dotnet_method: ProcessSessionPersist
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
This will receive all JS API replies for a request to store a session record,
including the reply for our own server, which we will ignore.
This allows us to detect that some application somewhere else in the cluster
is connecting with the same client ID, and therefore we need to close the
connection that is currently using this client ID.

Can run from various go routines (system send loop, etc..).
No lock held on entry.


name: mqttAccountSessionManager.addSessToFlappers
go_file: server/mqtt.go
go_class: mqttAccountSessionManager
go_method: addSessToFlappers
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: MqttAccountSessionManager
dotnet_method: AddSessToFlappers
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
Adds this client ID to the flappers map, and if needed start the timer
for map cleanup.

Lock held on entry.


name: mqttAccountSessionManager.cleanupRetainedMessageCache
go_file: server/mqtt.go
go_class: mqttAccountSessionManager
go_method: cleanupRetainedMessageCache
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: MqttAccountSessionManager
dotnet_method: CleanupRetainedMessageCache
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
A timer loop to cleanup up expired cached retained messages for a given MQTT account.
The closeCh is used by the caller to be able to interrupt this routine
if the rest of the initialization fails, since the quitCh is really
only used when the server shutdown.

No lock held on entry.


name: mqttAccountSessionManager.sendJSAPIrequests
go_file: server/mqtt.go
go_class: mqttAccountSessionManager
go_method: sendJSAPIrequests
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: MqttAccountSessionManager
dotnet_method: SendJSAPIrequests
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
Loop to send JS API requests for a given MQTT account.
The closeCh is used by the caller to be able to interrupt this routine
if the rest of the initialization fails, since the quitCh is really
only used when the server shutdown.

No lock held on entry.


name: mqttAccountSessionManager.addRetainedMsg
go_file: server/mqtt.go
go_class: mqttAccountSessionManager
go_method: addRetainedMsg
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: MqttAccountSessionManager
dotnet_method: AddRetainedMsg
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
Add/Replace this message from the retained messages map.
If a message for this topic already existed, the existing record is updated
with the provided information.
Lock not held on entry.


name: mqttAccountSessionManager.removeRetainedMsg
go_file: server/mqtt.go
go_class: mqttAccountSessionManager
go_method: removeRetainedMsg
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: MqttAccountSessionManager
dotnet_method: RemoveRetainedMsg
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
Remove the retained message stored with the `subject` key from the map/cache.
When invoked from the retained message stream's consumer, this function will
be called with `seq == 0`, this is because add/remove are serialized in this
stream and so the request is to remove the current retained message.
But in some conditions, we will invoke this function from some other places
with `seq > 0` which means that the retained message will be removed only if
its sequence is the same than the provided one.
This function returns the sequence associated with the existing retained
message that is being removed (used with `seq == 0`) and returns 0 if the
retained message was not removed from the map (not found or sequence did not
match).


name: mqttAccountSessionManager.lockSession
go_file: server/mqtt.go
go_class: mqttAccountSessionManager
go_method: lockSession
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: MqttAccountSessionManager
dotnet_method: LockSession
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
First check if this session's client ID is already in the "locked" map,
which if it is the case means that another client is now bound to this
session and this should return an error.
If not in the "locked" map, but the client is not bound with this session,
then same error is returned.
Finally, if all checks ok, then the session's ID is added to the "locked" map.

No lock held on entry.


name: mqttAccountSessionManager.addSession
go_file: server/mqtt.go
go_class: mqttAccountSessionManager
go_method: addSession
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: MqttAccountSessionManager
dotnet_method: AddSession
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
Simply adds the session to the various sessions maps.
The boolean `lock` indicates if this function should acquire the lock
prior to adding to the maps.

No lock held on entry.


name: mqttAccountSessionManager.removeSession
go_file: server/mqtt.go
go_class: mqttAccountSessionManager
go_method: removeSession
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: MqttAccountSessionManager
dotnet_method: RemoveSession
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
Simply removes the session from the various sessions maps.
The boolean `lock` indicates if this function should acquire the lock
prior to removing from the maps.

No lock held on entry.


name: mqttSession.processQOS12Sub
go_file: server/mqtt.go
go_class: mqttSession
go_method: processQOS12Sub
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: MqttSession
dotnet_method: ProcessQOS12Sub
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
Helper to set the sub's mqtt fields and possibly serialize (pre-loaded)
retained messages.

Session lock held on entry. Acquires the subs lock and holds it for
the duration. Non-MQTT messages coming into mqttDeliverMsgCbQoS0 will be
waiting.


name: mqttAccountSessionManager.processSubs
go_file: server/mqtt.go
go_class: mqttAccountSessionManager
go_method: processSubs
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: MqttAccountSessionManager
dotnet_method: ProcessSubs
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
Process subscriptions for the given session/client.

When `fromSubProto` is false, it means that this is invoked from the CONNECT
protocol, when restoring subscriptions that were saved for this session.
In that case, there is no need to update the session record.

When `fromSubProto` is true, it means that this call is invoked from the
processing of the SUBSCRIBE protocol, which means that the session needs to
be updated. It also means that if a subscription on same subject with same
QoS already exist, we should not be recreating the subscription/JS durable,
since it was already done when processing the CONNECT protocol.

Runs from the client's readLoop.
Lock not held on entry, but session is in the locked map.


name: mqttAccountSessionManager.serializeRetainedMsgsForSub
go_file: server/mqtt.go
go_class: mqttAccountSessionManager
go_method: serializeRetainedMsgsForSub
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: MqttAccountSessionManager
dotnet_method: SerializeRetainedMsgsForSub
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
Retained publish messages matching this subscription are serialized in the
subscription's `prm` mqtt writer. This buffer will be queued for outbound
after the subscription is processed and SUBACK is sent or possibly when
server processes an incoming published message matching the newly
registered subscription.

Runs from the client's readLoop.
Account session manager lock held on entry.
Session lock held on entry.


name: mqttAccountSessionManager.addRetainedSubjectsForSubject
go_file: server/mqtt.go
go_class: mqttAccountSessionManager
go_method: addRetainedSubjectsForSubject
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: MqttAccountSessionManager
dotnet_method: AddRetainedSubjectsForSubject
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
Appends the stored message subjects for all retained message records that
match the given subscription's `subject` (which could have wildcards).

Account session manager NOT lock held on entry.


name: mqttEncodeRetainedMessage
go_file: server/mqtt.go
go_method: mqttEncodeRetainedMessage
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: MqttHandler
dotnet_method: MqttEncodeRetainedMessage
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
Composes a NATS message for a storeable mqttRetainedMsg.
If the body is empty, the flags are encoded in a way that will cause older
servers to fail to decode the message in processRetainedMsg callback and
will simply ignore it, which is what we want.


name: mqttDecodeRetainedMessage
go_file: server/mqtt.go
go_method: mqttDecodeRetainedMessage
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: MqttHandler
dotnet_method: MqttDecodeRetainedMessage
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
Decodes a retained message based on the content of the header `h`.
The returned `*mqttRetainedMsg` object will hold a reference to `m`.
If the buffer `m` is not owned by the caller, it is the caller
responsibility to make a copy of the byte slice.


name: mqttAccountSessionManager.createOrRestoreSession
go_file: server/mqtt.go
go_class: mqttAccountSessionManager
go_method: createOrRestoreSession
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: MqttAccountSessionManager
dotnet_method: CreateOrRestoreSession
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
Creates the session stream (limit msgs of 1) for this client ID if it does
not already exist. If it exists, recover the single record to rebuild the
state of the session. If there is a session record but this session is not
registered in the runtime of this server, then a request is made to the
owner to close the client associated with this session since specification
[MQTT-3.1.4-2] specifies that if the ClientId represents a Client already
connected to the Server then the Server MUST disconnect the existing client.

Runs from the client's readLoop.
Lock not held on entry, but session is in the locked map.


name: mqttAccountSessionManager.notifyRetainedMsgDeleted
go_file: server/mqtt.go
go_class: mqttAccountSessionManager
go_method: notifyRetainedMsgDeleted
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: MqttAccountSessionManager
dotnet_method: NotifyRetainedMsgDeleted
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
Sends a message indicating that a retained message on a given subject and stream sequence
is being removed.
NOTE: This is maintained for backward compatibility reasons. Should be removed in 2.14/2.15?


name: mqttAccountSessionManager.setCachedRetainedMsg
go_file: server/mqtt.go
go_class: mqttAccountSessionManager
go_method: setCachedRetainedMsg
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: MqttAccountSessionManager
dotnet_method: SetCachedRetainedMsg
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
If cache is enabled, the expiration for the `rm` is bumped by
`mqttRetainedCacheTTL` seconds.
If `onlyReplace` is true, then the `rm` object is stored in the cache using
the `subject` key only if there was already an object stored under that key.
If `copyMsgBytes` is true, then the `rm.Msg` bytes are copied (because it
references some buffer that is not owned by the caller).

Note: currently `onlyReplace` and `cloneMsgBytes` always have the same
value (all `true` or all `false`) however we use different booleans to
better express the intent.


name: mqttSessionCreate
go_file: server/mqtt.go
go_method: mqttSessionCreate
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: MqttHandler
dotnet_method: MqttSessionCreate
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
Returns a new mqttSession object with max ack pending set based on
option or use mqttDefaultMaxAckPending if no option set.


name: mqttSession.save
go_file: server/mqtt.go
go_class: mqttSession
go_method: save
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: MqttSession
dotnet_method: Save
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
Persists a session. Note that if the session's current client does not match
the given client, nothing is done.

Lock not held on entry.


name: mqttSession.clear
go_file: server/mqtt.go
go_class: mqttSession
go_method: clear
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: MqttSession
dotnet_method: Clear
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
Clear the session.

Runs from the client's readLoop.
Lock not held on entry, but session is in the locked map.


name: mqttSession.update
go_file: server/mqtt.go
go_class: mqttSession
go_method: update
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: MqttSession
dotnet_method: Update
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
This will update the session record for this client in the account's MQTT
sessions stream if the session had any change in the subscriptions.

Runs from the client's readLoop.
Lock not held on entry, but session is in the locked map.


name: mqttSession.trackPublishRetained
go_file: server/mqtt.go
go_class: mqttSession
go_method: trackPublishRetained
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: MqttSession
dotnet_method: TrackPublishRetained
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
trackPublishRetained is invoked when a retained (QoS) message is published.
It need a new PI to be allocated, so we add it to the pendingPublish map,
with an empty value. Since cpending (not pending) is used to serialize the PI
mappings, we need to add this PI there as well. Make a unique key by using
mqttRetainedMsgsStreamName for the durable name, and PI for sseq.

Lock held on entry


name: mqttSession.trackPublish
go_file: server/mqtt.go
go_class: mqttSession
go_method: trackPublish
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: MqttSession
dotnet_method: TrackPublish
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
trackPublish is invoked when a (QoS) PUBLISH message is to be delivered. It
detects an untracked (new) message based on its sequence extracted from its
delivery-time jsAckSubject, and adds it to the tracking maps. Returns a PI to
use for the message (new, or previously used), and whether this is a
duplicate delivery attempt.

Lock held on entry


name: mqttSession.untrackPublish
go_file: server/mqtt.go
go_class: mqttSession
go_method: untrackPublish
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: MqttSession
dotnet_method: UntrackPublish
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
Stops a PI from being tracked as a PUBLISH. It can still be in use for a
pending PUBREL.

Lock held on entry


name: mqttSession.trackAsPubRel
go_file: server/mqtt.go
go_class: mqttSession
go_method: trackAsPubRel
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: MqttSession
dotnet_method: TrackAsPubRel
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
trackAsPubRel is invoked in 2 cases: (a) when we receive a PUBREC and we need
to change from tracking the PI as a PUBLISH to a PUBREL; and (b) when we
attempt to deliver the PUBREL to record the JS ack subject for it.

Lock held on entry


name: Server.mqttProcessConnect
go_file: server/mqtt.go
go_class: Server
go_method: mqttProcessConnect
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: NatsServer
dotnet_method: MqttProcessConnect
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
Process the CONNECT packet.

For the first session on the account, an account session manager will be created,
along with the JetStream streams/consumer necessary for the working of MQTT.

The session, identified by a client ID, will be registered, or if already existing,
will be resumed. If the session exists but is associated with an existing client,
the old client is evicted, as per the specifications.

Due to specific locking requirements around JS API requests, we cannot hold some
locks for the entire duration of processing of some protocols, therefore, we use
a map that registers the client ID in a "locked" state. If a different client tries
to connect and the server detects that the client ID is in that map, it will try
a little bit until it is not, or fail the new client, since we can't protect
processing of protocols in the original client. This is not expected to happen often.

Runs from the client's readLoop.
No lock held on entry.


name: mqttComputeNatsMsgSize
go_file: server/mqtt.go
go_method: mqttComputeNatsMsgSize
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: MqttHandler
dotnet_method: MqttComputeNatsMsgSize
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
mqttComputeNatsMsgSize computes the size the NATS message to be delivered
based on a MQTT PUBLISH packet.
encodePP: whether to encode complete MQTT PUBLISH packet header information
  - false: initial delivery (QoS 0/1) needs only base header
  - true: QoS2 storage needs to encode Nmqtt-Subject and Nmqtt-Mapped


name: mqttNewDeliverableMessage
go_file: server/mqtt.go
go_method: mqttNewDeliverableMessage
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: MqttHandler
dotnet_method: MqttNewDeliverableMessage
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
Composes a NATS message from a MQTT PUBLISH packet. The message includes an
internal header containint the original packet's QoS, and for QoS2 packets
the original subject.

Example (QoS2, subject: "foo.bar"):

	NATS/1.0\r\n
	Nmqtt-Pub:2foo.bar\r\n
	\r\n


name: mqttNewDeliverablePubRel
go_file: server/mqtt.go
go_method: mqttNewDeliverablePubRel
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: MqttHandler
dotnet_method: MqttNewDeliverablePubRel
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
Composes a NATS message for a pending PUBREL packet. The message includes an
internal header containing the PI for PUBREL/PUBCOMP.

Example (PI:123):

		NATS/1.0\r\n
	 	Nmqtt-PubRel:123\r\n
		\r\n


name: Server.mqttProcessPubRel
go_file: server/mqtt.go
go_class: Server
go_method: mqttProcessPubRel
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: NatsServer
dotnet_method: MqttProcessPubRel
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
Process a PUBREL packet (QoS2, acting as Receiver).

Runs from the client's readLoop.
No lock held on entry.


name: client.mqttHandlePubRetain
go_file: server/mqtt.go
go_class: client
go_method: mqttHandlePubRetain
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: ClientConnection
dotnet_method: MqttHandlePubRetain
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
Invoked when processing an inbound client message. If the "retain" flag is
set, the message is stored so it can be later resent to (re)starting
subscriptions that match the subject.

Invoked from the MQTT publisher's readLoop. No client lock is held on entry.


name: Server.mqttCheckPubRetainedPerms
go_file: server/mqtt.go
go_class: Server
go_method: mqttCheckPubRetainedPerms
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: NatsServer
dotnet_method: MqttCheckPubRetainedPerms
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
After a config reload, it is possible that the source of a publish retained
message is no longer allowed to publish on the given topic. If that is the
case, the retained message is removed from the map and will no longer be
sent to (re)starting subscriptions.

Server lock MUST NOT be held on entry.


name: client.mqttProcessPublishReceived
go_file: server/mqtt.go
go_class: client
go_method: mqttProcessPublishReceived
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: ClientConnection
dotnet_method: MqttProcessPublishReceived
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
Process a PUBACK (QoS1) or a PUBREC (QoS2) packet, acting as Sender. Set
isPubRec to false to process as a PUBACK.

Runs from the client's readLoop. No lock held on entry.


name: mqttDeliverMsgCbQoS0
go_file: server/mqtt.go
go_method: mqttDeliverMsgCbQoS0
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: MqttHandler
dotnet_method: MqttDeliverMsgCbQoS0
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
For a MQTT QoS0 subscription, we create a single NATS subscription on the
actual subject, for instance "foo.bar".

For a MQTT QoS1+ subscription, we create 2 subscriptions, one on "foo.bar"
(as for QoS0, but sub.mqtt.qos will be 1 or 2), and one on the subject
"$MQTT.sub.<uid>" which is the delivery subject of the JS durable consumer
with the filter subject "$MQTT.msgs.foo.bar".

This callback delivers messages to the client as QoS0 messages, either
because: (a) they have been produced as MQTT QoS0 messages (and therefore
only this callback can receive them); (b) they are MQTT QoS1+ published
messages but this callback is for a subscription that is QoS0; or (c) the
published messages come from (other) NATS publishers on the subject.

This callback must reject a message if it is known to be a QoS1+ published
message and this is the callback for a QoS1+ subscription because in that
case, it will be handled by the other callback. This avoid getting duplicate
deliveries.


name: mqttDeliverMsgCbQoS12
go_file: server/mqtt.go
go_method: mqttDeliverMsgCbQoS12
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: MqttHandler
dotnet_method: MqttDeliverMsgCbQoS12
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
This is the callback attached to a JS durable subscription for a MQTT QoS 1+
sub. Only JETSTREAM should be sending a message to this subject (the delivery
subject associated with the JS durable consumer), but in cluster mode, this
can be coming from a route, gw, etc... We make sure that if this is the case,
the message contains a NATS/MQTT header that indicates that this is a
published QoS1+ message.


name: mqttMustIgnoreForReservedSub
go_file: server/mqtt.go
go_method: mqttMustIgnoreForReservedSub
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: MqttHandler
dotnet_method: MqttMustIgnoreForReservedSub
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
The MQTT Server MUST NOT match Topic Filters starting with a wildcard
character (# or +) with Topic Names beginning with a $ character, Spec
[MQTT-4.7.2-1]. We will return true if there is a violation.

Session or subMu lock must be held on entry to protect access to sub.mqtt.


name: client.mqttProcessSubs
go_file: server/mqtt.go
go_class: client
go_method: mqttProcessSubs
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: ClientConnection
dotnet_method: MqttProcessSubs
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
Process the SUBSCRIBE packet.

Process the list of subscriptions and update the given filter
with the QoS that has been accepted (or failure).

Spec [MQTT-3.8.4-3] says that if an exact same subscription is
found, it needs to be replaced with the new one (possibly updating
the qos) and that the flow of publications must not be interrupted,
which I read as the replacement cannot be a "remove then add" if there
is a chance that in between the 2 actions, published messages
would be "lost" because there would not be any matching subscription.

Run from client's readLoop.
No lock held on entry.


name: mqttSession.cleanupFailedSub
go_file: server/mqtt.go
go_class: mqttSession
go_method: cleanupFailedSub
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: MqttSession
dotnet_method: CleanupFailedSub
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
Cleanup that is performed in processSubs if there was an error.

Runs from client's readLoop.
Lock not held on entry, but session is in the locked map.


name: mqttSession.processJSConsumer
go_file: server/mqtt.go
go_class: mqttSession
go_method: processJSConsumer
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: MqttSession
dotnet_method: ProcessJSConsumer
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
When invoked with a QoS of 0, looks for an existing JS durable consumer for
the given sid and if one is found, delete the JS durable consumer and unsub
the NATS subscription on the delivery subject.

With a QoS > 0, creates or update the existing JS durable consumer along with
its NATS subscription on a delivery subject.

Session lock is acquired and released as needed. Session is in the locked
map.


name: client.mqttProcessUnsubs
go_file: server/mqtt.go
go_class: client
go_method: mqttProcessUnsubs
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: ClientConnection
dotnet_method: MqttProcessUnsubs
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
Process the UNSUBSCRIBE packet.

Given the list of topics, this is going to unsubscribe the low level NATS subscriptions
and delete the JS durable consumers when applicable.

Runs from the client's readLoop.
No lock held on entry.


name: mqttTopicToNATSPubSubject
go_file: server/mqtt.go
go_method: mqttTopicToNATSPubSubject
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: MqttHandler
dotnet_method: MqttTopicToNATSPubSubject
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
Converts an MQTT Topic Name to a NATS Subject (used by PUBLISH)
See mqttToNATSSubjectConversion() for details.


name: mqttFilterToNATSSubject
go_file: server/mqtt.go
go_method: mqttFilterToNATSSubject
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: MqttHandler
dotnet_method: MqttFilterToNATSSubject
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
Converts an MQTT Topic Filter to a NATS Subject (used by SUBSCRIBE)
See mqttToNATSSubjectConversion() for details.


name: mqttToNATSSubjectConversion
go_file: server/mqtt.go
go_method: mqttToNATSSubjectConversion
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: MqttHandler
dotnet_method: MqttToNATSSubjectConversion
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
Converts an MQTT Topic Name or Filter to a NATS Subject.
In MQTT:
- a Topic Name does not have wildcard (PUBLISH uses only topic names).
- a Topic Filter can include wildcards (SUBSCRIBE uses those).
- '+' and '#' are wildcard characters (single and multiple levels respectively)
- '/' is the topic level separator.

Conversion that occurs:
  - '/' is replaced with '/.' if it is the first character in mt
  - '/' is replaced with './' if the last or next character in mt is '/'
    For instance, foo//bar would become foo./.bar
  - '/' is replaced with '.' for all other conditions (foo/bar -> foo.bar)
  - '.' is replaced with '//'.
  - ' ' cause an error to be returned.

If there is no need to convert anything (say "foo" remains "foo"), then
the no memory is allocated and the returned slice is the original `mt`.


name: natsSubjectStrToMQTTTopic
go_file: server/mqtt.go
go_method: natsSubjectStrToMQTTTopic
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: MqttHandler
dotnet_method: NatsSubjectStrToMQTTTopic
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
Converts a NATS subject to MQTT topic. This is for publish
messages only, so there is no checking for wildcards.
Rules are reversed of mqttToNATSSubjectConversion.


name: client.isMsgTraceEnabled
go_file: server/msgtrace.go
go_class: client
go_method: isMsgTraceEnabled
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: ClientConnection
dotnet_method: IsMsgTraceEnabled
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
Returns the message trace object, if message is being traced,
and `true` if we want to only trace, not actually deliver the message.


name: client.msgTraceSupport
go_file: server/msgtrace.go
go_class: client
go_method: msgTraceSupport
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: ClientConnection
dotnet_method: MsgTraceSupport
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
For LEAF/ROUTER/GATEWAY, return false if the remote does not support
message tracing (important if the tracing requests trace-only).


name: genHeaderMapIfTraceHeadersPresent
go_file: server/msgtrace.go
go_method: genHeaderMapIfTraceHeadersPresent
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: MessageTracer
dotnet_method: GenHeaderMapIfTraceHeadersPresent
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
This function will return the header as a map (instead of http.Header because
we want to preserve the header names' case) and a boolean that indicates if
the headers have been lifted due to the presence of the external trace header
only.
Note that because of the traceParentHdr, the search is done in a case
insensitive way. We used to rewrite it in lower case but no longer do since v2.14.


name: client.initAndSendIngressErrEvent
go_file: server/msgtrace.go
go_class: client
go_method: initAndSendIngressErrEvent
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: ClientConnection
dotnet_method: InitAndSendIngressErrEvent
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
Special case where we create a trace event before parsing the message.
This is for cases where the connection will be closed when detecting
an error during early message processing (for instance max payload).


name: msgTrace.traceOnly
go_file: server/msgtrace.go
go_class: msgTrace
go_method: traceOnly
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: MsgTrace
dotnet_method: TraceOnly
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
Returns `true` if message tracing is enabled and we are tracing only,
that is, we are not going to deliver the inbound message, returns
`false` otherwise (no tracing, or tracing and message delivery).


name: Server.NonceRequired
description: NonceRequired tells us if we should send a nonce.
go_file: server/nkey.go
go_class: Server
go_method: NonceRequired
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: NatsServer
dotnet_method: NonceRequired
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
notes:
Server struct methods — will be ported as part of Server class in session 09; nonce generation belongs in auth/handshake flow


name: Server.NewOCSPMonitor
go_file: server/ocsp.go
go_class: Server
go_method: NewOCSPMonitor
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: NatsServer
dotnet_method: NewOCSPMonitor
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
NewOCSPMonitor takes a TLS configuration then wraps it with the callbacks set for OCSP verification
along with a monitor that will periodically fetch OCSP staples.


name: OCSPMonitor.writeOCSPStatus
go_file: server/ocsp.go
go_class: OCSPMonitor
go_method: writeOCSPStatus
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: OCSPMonitor
dotnet_method: WriteOCSPStatus
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
writeOCSPStatus writes an OCSP status to a temporary file then moves it to a
new path, in an attempt to avoid corrupting existing data.


name: getOCSPIssuer
go_file: server/ocsp.go
go_method: getOCSPIssuer
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: OcspHandler
dotnet_method: GetOCSPIssuer
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
getOCSPIssuer determines an issuer certificate from the cert (bundle) or the file-based CA trust store


name: Server.plugTLSOCSPPeer
go_file: server/ocsp_peer.go
go_class: Server
go_method: plugTLSOCSPPeer
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: NatsServer
dotnet_method: PlugTLSOCSPPeer
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
plugTLSOCSPPeer will plug the TLS handshake lifecycle for client mTLS connections and Leaf connections


name: Server.tlsServerOCSPValid
go_file: server/ocsp_peer.go
go_class: Server
go_method: tlsServerOCSPValid
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: NatsServer
dotnet_method: TlsServerOCSPValid
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
tlsServerOCSPValid evaluates verified chains (post successful TLS handshake) against OCSP
eligibility. A verified chain is considered OCSP Valid if either none of the links are
OCSP eligible, or current "good" responses from the CA can be obtained for each eligible link.
Upon first OCSP Valid chain found, the Server is deemed OCSP Valid. If none of the chains are
OCSP Valid, the Server is deemed OCSP Invalid. A verified self-signed certificate (chain length 1)
is also considered OCSP Valid.


name: Server.tlsClientOCSPValid
go_file: server/ocsp_peer.go
go_class: Server
go_method: tlsClientOCSPValid
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: NatsServer
dotnet_method: TlsClientOCSPValid
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
tlsClientOCSPValid evaluates verified chains (post successful TLS handshake) against OCSP
eligibility. A verified chain is considered OCSP Valid if either none of the links are
OCSP eligible, or current "good" responses from the CA can be obtained for each eligible link.
Upon first OCSP Valid chain found, the Client is deemed OCSP Valid. If none of the chains are
OCSP Valid, the Client is deemed OCSP Invalid. A verified self-signed certificate (chain length 1)
is also considered OCSP Valid.


name: LocalCache.Delete
go_file: server/ocsp_responsecache.go
go_class: LocalCache
go_method: Delete
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: LocalCache
dotnet_method: Delete
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
Delete removes a CA OCSP response from the OCSP peer cache matching the response fingerprint (a hash)


name: LocalCache.Start
go_file: server/ocsp_responsecache.go
go_class: LocalCache
go_method: Start
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: LocalCache
dotnet_method: Start
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
Start initializes the configured OCSP peer cache, loads a saved cache from disk (if present), and initializes runtime statistics


name: NoErrOnUnknownFields
go_file: server/opts.go
go_method: NoErrOnUnknownFields
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: ServerOptions
dotnet_method: NoErrOnUnknownFields
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
NoErrOnUnknownFields can be used to change the behavior the processing
of a configuration file. By default, an error is reported if unknown
fields are found. If `noError` is set to true, no error will be reported
if top-level unknown fields are found.


name: unwrapValue
go_file: server/opts.go
go_method: unwrapValue
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: ServerOptions
dotnet_method: UnwrapValue
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
unwrapValue can be used to get the token and value from an item
to be able to report the line number in case of an incorrect
configuration.
also stores the token in lastToken for use in convertPanicToError


name: Options.ProcessConfigFile
go_file: server/opts.go
go_class: Options
go_method: ProcessConfigFile
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: ServerOptions
dotnet_method: ProcessConfigFileOverload2510
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
ProcessConfigFile updates the Options structure with options
present in the given configuration file.
This version is convenient if one wants to set some default
options and then override them with what is in the config file.
For instance, this version allows you to do something such as:

opts := &Options{Debug: true}
opts.ProcessConfigFile(myConfigFile)

If the config file contains "debug: false", after this call,
opts.Debug would really be false. It would be impossible to
achieve that with the non receiver ProcessConfigFile() version,
since one would not know after the call if "debug" was not present
or was present but set to false.


name: Options.ProcessConfigString
go_file: server/opts.go
go_class: Options
go_method: ProcessConfigString
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: ServerOptions
dotnet_method: ProcessConfigString
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
ProcessConfigString is the same as ProcessConfigFile, but expects the
contents of the config file to be passed in rather than the file name.


name: parseCompression
go_file: server/opts.go
go_method: parseCompression
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: ServerOptions
dotnet_method: ParseCompression
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
The parameter `chosenModeForOn` indicates which compression mode to use
when the user selects "on" (or enabled, true, etc..). This is because
we may have different defaults depending on where the compression is used.


name: parseJetStreamForAccount
go_file: server/opts.go
go_method: parseJetStreamForAccount
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: ServerOptions
dotnet_method: ParseJetStreamForAccount
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
Parses jetstream account limits for an account. Simple setup with boolen is allowed, and we will
use dynamic account limits.


name: parseLeafUsers
go_file: server/opts.go
go_method: parseLeafUsers
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: ServerOptions
dotnet_method: ParseLeafUsers
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
This is a trimmed down version of parseUsers that is adapted
for the users possibly defined in the authorization{} section
of leafnodes {}.


name: parseExportStreamOrService
go_file: server/opts.go
go_method: parseExportStreamOrService
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: ServerOptions
dotnet_method: ParseExportStreamOrService
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
Parse an export stream or service.
e.g.
{stream: "public.>"} # No accounts means public.
{stream: "synadia.private.>", accounts: [cncf, natsio]}
{service: "pub.request"} # No accounts means public.
{service: "pub.special.request", accounts: [nats.io]}


name: parseImportStreamOrService
go_file: server/opts.go
go_method: parseImportStreamOrService
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: ServerOptions
dotnet_method: ParseImportStreamOrService
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
Parse an import stream or service.
e.g.
{stream: {account: "synadia", subject:"public.synadia"}, prefix: "imports.synadia"}
{stream: {account: "synadia", subject:"synadia.private.*"}}
{service: {account: "synadia", subject: "pub.special.request"}, to: "synadia.request"}


name: ConfigureOptions
go_file: server/opts.go
go_method: ConfigureOptions
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: ServerOptions
dotnet_method: ConfigureOptions
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
ConfigureOptions accepts a flag set and augments it with NATS Server
specific flags. On success, an options structure is returned configured
based on the selected flags and/or configuration file.
The command line options take precedence to the ones in the configuration file.


name: overrideCluster
go_file: server/opts.go
go_method: overrideCluster
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: ServerOptions
dotnet_method: OverrideCluster
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
overrideCluster updates Options.Cluster if that flag "cluster" (or "cluster_listen")
has explicitly be set in the command line. If it is set to empty string, it will
clear the Cluster options.


name: maybeReadPidFile
go_file: server/opts.go
go_method: maybeReadPidFile
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: ServerOptions
dotnet_method: MaybeReadPidFile
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
maybeReadPidFile returns a PID or Windows service name obtained via the following method:
1. Try to open a file with path "pidStr" (absolute or relative).
2. If such a file exists and can be read, return its contents.
3. Otherwise, return the original "pidStr" string.


name: client.overMaxControlLineLimit
go_file: server/parser.go
go_class: client
go_method: overMaxControlLineLimit
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: ClientConnection
dotnet_method: OverMaxControlLineLimit
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
Check if the length of buffer `arg` is over the max control line limit `mcl`.
If so, an error is sent to the client and the connection is closed.
The error ErrMaxControlLine is returned.


name: client.clonePubArg
go_file: server/parser.go
go_class: client
go_method: clonePubArg
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: ClientConnection
dotnet_method: ClonePubArg
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
clonePubArg is used when the split buffer scenario has the pubArg in the existing read buffer, but
we need to hold onto it into the next read.


name: Server.initRaftNode
go_file: server/raft.go
go_class: Server
go_method: initRaftNode
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: NatsServer
dotnet_method: InitRaftNode
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
initRaftNode will initialize the raft node, to be used by startRaftNode or when testing to not run the Go routine.


name: raft.checkAccountNRGStatus
go_file: server/raft.go
go_class: raft
go_method: checkAccountNRGStatus
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: RaftNode
dotnet_method: CheckAccountNRGStatus
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
Returns whether peers within this group claim to support
moving NRG traffic into the asset account.
Lock must be held.


name: Server.lookupRaftNode
go_file: server/raft.go
go_class: Server
go_method: lookupRaftNode
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: NatsServer
dotnet_method: LookupRaftNode
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
Finds the Raft node for a given Raft group, if any. If there is no Raft node
running for this group then it can return nil.


name: Server.reloadDebugRaftNodes
go_file: server/raft.go
go_class: Server
go_method: reloadDebugRaftNodes
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: NatsServer
dotnet_method: ReloadDebugRaftNodes
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
Reloads the debug state for all running Raft nodes. This is necessary when
the configuration has been reloaded and the debug log level has changed.


name: Server.stepdownRaftNodes
go_file: server/raft.go
go_class: Server
go_method: stepdownRaftNodes
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: NatsServer
dotnet_method: StepdownRaftNodes
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
Requests that all Raft nodes on this server step down and place them into
observer mode. This is called when the server is shutting down.


name: Server.shutdownRaftNodes
go_file: server/raft.go
go_class: Server
go_method: shutdownRaftNodes
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: NatsServer
dotnet_method: ShutdownRaftNodes
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
Shuts down all Raft nodes on this server. This is called either when the
server is either entering lame duck mode, shutting down or when JetStream
has been disabled.


name: Server.transferRaftLeaders
go_file: server/raft.go
go_class: Server
go_method: transferRaftLeaders
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: NatsServer
dotnet_method: TransferRaftLeaders
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
Used in lameduck mode to move off the leaders.
We also put all nodes in observer mode so new leaders
can not be placed on this server.


name: raft.ForwardProposal
go_file: server/raft.go
go_class: raft
go_method: ForwardProposal
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: RaftNode
dotnet_method: ForwardProposal
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
ForwardProposal will forward the proposal to the leader if known.
If we are the leader this is the same as calling propose.


name: raft.AdjustBootClusterSize
go_file: server/raft.go
go_class: raft
go_method: AdjustBootClusterSize
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: RaftNode
dotnet_method: AdjustBootClusterSize
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
AdjustBootClusterSize can be called to adjust the boot cluster size.
Will error if called on a group with a leader or a previous leader.
This can be helpful in mixed mode.


name: raft.PauseApply
go_file: server/raft.go
go_class: raft
go_method: PauseApply
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: RaftNode
dotnet_method: PauseApply
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
PauseApply will allow us to pause processing of append entries onto our
external apply queue. In effect this means that the upper layer will no longer
receive any new entries from the Raft group.


name: raft.ResumeApply
go_file: server/raft.go
go_class: raft
go_method: ResumeApply
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: RaftNode
dotnet_method: ResumeApply
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
ResumeApply will resume sending applies to the external apply queue. This
means that we will start sending new entries to the upper layer.


name: raft.DrainAndReplaySnapshot
go_file: server/raft.go
go_class: raft
go_method: DrainAndReplaySnapshot
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: RaftNode
dotnet_method: DrainAndReplaySnapshot
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
DrainAndReplaySnapshot will drain the apply queue and replay the snapshot.
Our highest known commit will be preserved by pausing applies. The caller
should make sure to call ResumeApply() when handling the snapshot from the
queue, which will populate the rest of the committed entries in the queue.


name: raft.Applied
go_file: server/raft.go
go_class: raft
go_method: Applied
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: RaftNode
dotnet_method: Applied
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
Applied is a callback that must be called by the upper layer when it
has successfully applied the committed entries that it received from the
apply queue. It will return the number of entries and an estimation of the
byte size that could be removed with a snapshot/compact.


name: raft.Processed
go_file: server/raft.go
go_class: raft
go_method: Processed
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: RaftNode
dotnet_method: Processed
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
Processed is a callback that must be called by the upper layer when it
has processed the committed entries that it received from the apply queue,
but it (maybe) hasn't applied all the processed entries yet.
Used to indicate a commit was processed, even if it wasn't applied yet and
can't be compacted away by a snapshot just yet. Which allows us to try to
become leader if we've processed all commits, even if they're not all applied.


name: raft.SendSnapshot
go_file: server/raft.go
go_class: raft
go_method: SendSnapshot
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: RaftNode
dotnet_method: SendSnapshot
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
SendSnapshot will send the latest snapshot as a normal AE.
Should only be used when the upper layers know this is most recent.
Used when restoring streams, moving a stream from R1 to R>1, etc.


name: raft.InstallSnapshot
go_file: server/raft.go
go_class: raft
go_method: InstallSnapshot
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: RaftNode
dotnet_method: InstallSnapshot
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
Used to install a snapshot for the given term and applied index. This will release
all of the log entries up to and including index. This should not be called with
entries that have been applied to the FSM but have not been applied to the raft state.


name: raft.CreateSnapshotCheckpoint
go_file: server/raft.go
go_class: raft
go_method: CreateSnapshotCheckpoint
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: RaftNode
dotnet_method: CreateSnapshotCheckpoint
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
CreateSnapshotCheckpoint creates a checkpoint to allow installing a snapshot asynchronously.
Caller MUST make sure it only ever has one checkpoint handle at most, and either installs or
aborts the checkpoint.
See also: RaftNodeCheckpoint


name: checkpoint.InstallSnapshot
go_file: server/raft.go
go_class: checkpoint
go_method: InstallSnapshot
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: Checkpoint
dotnet_method: InstallSnapshot
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
InstallSnapshot allows asynchronous installation of a snapshot by unlocking when
performing operations that don't strictly need to be locked. When the lock is re-acquired
n.snapshotting will be checked to ensure we're still meant to.
Async snapshots can only be used when using CreateSnapshotCheckpoint.
Lock should be held.


name: raft.NeedSnapshot
go_file: server/raft.go
go_class: raft
go_method: NeedSnapshot
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: RaftNode
dotnet_method: NeedSnapshot
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
NeedSnapshot returns true if it is necessary to try to install a snapshot, i.e.
after we have finished recovering/replaying at startup, on a regular interval or
as a part of cleaning up when shutting down.


name: termAndIndexFromSnapFile
go_file: server/raft.go
go_method: termAndIndexFromSnapFile
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: RaftNode
dotnet_method: TermAndIndexFromSnapFile
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
termAndIndexFromSnapfile tries to load the snapshot file and returns the term
and index from that snapshot.


name: raft.setupLastSnapshot
go_file: server/raft.go
go_class: raft
go_method: setupLastSnapshot
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: RaftNode
dotnet_method: SetupLastSnapshot
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
setupLastSnapshot is called at startup to try and recover the last snapshot from
the disk if possible. We will try to recover the term, index and commit/applied
indices and then notify the upper layer what we found. Compacts the WAL if needed.


name: raft.Leader
go_file: server/raft.go
go_class: raft
go_method: Leader
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: RaftNode
dotnet_method: Leader
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
Leader returns if we are the leader for our group.
We use an atomic here now vs acquiring the read lock.


name: raft.stepdown
go_file: server/raft.go
go_class: raft
go_method: stepdown
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: RaftNode
dotnet_method: Stepdown
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
stepdown immediately steps down the Raft node to the
follower state. This will take the lock itself.


name: raft.stepdownLocked
go_file: server/raft.go
go_class: raft
go_method: stepdownLocked
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: RaftNode
dotnet_method: StepdownLocked
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
stepdownLocked immediately steps down the Raft node to the
follower state. This requires the lock is already held.


name: raft.isCurrent
go_file: server/raft.go
go_class: raft
go_method: isCurrent
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: RaftNode
dotnet_method: IsCurrent
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
isCurrent is called from the healthchecks and returns true if we believe
that the upper layer is current with the Raft layer, i.e. that it has applied
all of the commits that we have given it.
Optionally we can also check whether or not we're making forward progress if we
aren't current, in which case this function may block for up to ~10ms to find out.
Lock should be held.


name: raft.Leaderless
go_file: server/raft.go
go_class: raft
go_method: Leaderless
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: RaftNode
dotnet_method: Leaderless
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
Leaderless is a lockless way of finding out if the group has a
leader or not. Use instead of GroupLeader in hot paths.


name: raft.State
go_file: server/raft.go
go_class: raft
go_method: State
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: RaftNode
dotnet_method: State
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
State returns the current state for this node.
Upper layers should not check State to check if we're Leader, use n.Leader() instead.


name: raft.run
go_file: server/raft.go
go_class: raft
go_method: run
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: RaftNode
dotnet_method: Run
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
run is the top-level runner for the Raft state machine. Depending on the
state of the node (leader, follower, candidate, observer), this will call
through to other functions. It is expected that this function will run for
the entire life of the Raft node once started.


name: raft.processAppendEntries
go_file: server/raft.go
go_class: raft
go_method: processAppendEntries
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: RaftNode
dotnet_method: ProcessAppendEntries
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
processAppendEntries is called by the Raft state machine when there are
new append entries to be committed and sent to the upper state machine.


name: raft.runAsFollower
go_file: server/raft.go
go_class: raft
go_method: runAsFollower
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: RaftNode
dotnet_method: RunAsFollower
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
runAsFollower is called by run and will block for as long as the node is
running in the follower state.


name: newCommittedEntry
go_file: server/raft.go
go_method: newCommittedEntry
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: RaftNode
dotnet_method: NewCommittedEntry
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
Create a new CommittedEntry. When the returned entry is no longer needed, it
should be returned to the pool by calling ReturnToPool.


name: CommittedEntry.ReturnToPool
go_file: server/raft.go
go_class: CommittedEntry
go_method: ReturnToPool
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: CommittedEntry
dotnet_method: ReturnToPool
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
ReturnToPool returns the CommittedEntry to the pool, after which point it is
no longer safe to reuse.


name: newEntry
go_file: server/raft.go
go_method: newEntry
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: RaftNode
dotnet_method: NewEntry
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
Helper to create new entries. When the returned entry is no longer needed, it
should be returned to the entryPool pool.


name: raft.addPeer
go_file: server/raft.go
go_class: raft
go_method: addPeer
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: RaftNode
dotnet_method: AddPeer
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
Adds peer with the given id to our membership,
and adjusts cluster size and quorum accordingly.
Lock should be held.


name: raft.removePeer
go_file: server/raft.go
go_class: raft
go_method: removePeer
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: RaftNode
dotnet_method: RemovePeer
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
Remove the peer with the given id from our membership,
and adjusts cluster size and quorum accordingly.
Lock should be held.


name: raft.sendMembershipChange
go_file: server/raft.go
go_class: raft
go_method: sendMembershipChange
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: RaftNode
dotnet_method: SendMembershipChange
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
Build and send appendEntry request for the given entry that changes
membership (EntryAddPeer / EntryRemovePeer).
Returns true if the entry made it to the WAL and was sent to the followers


name: raft.notActive
go_file: server/raft.go
go_class: raft
go_method: notActive
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: RaftNode
dotnet_method: NotActive
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
Check for being not active in terms of sending entries.
Used in determining if we need to send a heartbeat.


name: raft.applyCommit
go_file: server/raft.go
go_class: raft
go_method: applyCommit
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: RaftNode
dotnet_method: ApplyCommit
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
applyCommit will update our commit index and apply the entry to the apply queue.
lock should be held.


name: raft.tryCommit
go_file: server/raft.go
go_class: raft
go_method: tryCommit
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: RaftNode
dotnet_method: TryCommit
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
Check if there is a quorum for the given index, and if
so, commit the corresponding entry.
Return true if the index was committed, false otherwise.
Lock should be held.


name: raft.trackResponse
go_file: server/raft.go
go_class: raft
go_method: trackResponse
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: RaftNode
dotnet_method: TrackResponse
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
Used to track a success response. Returns true if the
response was tracked, false if the response was ignored
(the response is old, the index is already committed, ...)
Lock should be held.


name: raft.handleAppendEntry
go_file: server/raft.go
go_class: raft
go_method: handleAppendEntry
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: RaftNode
dotnet_method: HandleAppendEntry
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
handleAppendEntry handles an append entry from the wire. This function
is an internal callback from the "asubj" append entry subscription.


name: raft.cancelCatchup
go_file: server/raft.go
go_class: raft
go_method: cancelCatchup
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: RaftNode
dotnet_method: CancelCatchup
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
cancelCatchup will stop an in-flight catchup by unsubscribing from the
catchup subscription.
Lock should be held.


name: raft.catchupStalled
go_file: server/raft.go
go_class: raft
go_method: catchupStalled
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: RaftNode
dotnet_method: CatchupStalled
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
catchupStalled will try to determine if we are stalled. This is called
on a new entry from our leader.
Lock should be held.


name: raft.createCatchup
go_file: server/raft.go
go_class: raft
go_method: createCatchup
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: RaftNode
dotnet_method: CreateCatchup
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
createCatchup will create the state needed to track a catchup as it
runs. It then creates a unique inbox for this catchup and subscribes
to it. The remote side will stream entries to that subject.
Lock should be held.


name: raft.processAppendEntry
go_file: server/raft.go
go_class: raft
go_method: processAppendEntry
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: RaftNode
dotnet_method: ProcessAppendEntry
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
processAppendEntry will process an appendEntry. This is called either
during recovery or from processAppendEntries when there are new entries
to be committed.


name: raft.resetInitializing
go_file: server/raft.go
go_class: raft
go_method: resetInitializing
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: RaftNode
dotnet_method: ResetInitializing
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
resetInitializing resets the notion of initializing.
If we were scaling up, also leaves observer mode.
Lock should be held.


name: raft.processPeerState
go_file: server/raft.go
go_class: raft
go_method: processPeerState
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: RaftNode
dotnet_method: ProcessPeerState
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
processPeerState is called when a peer state entry is received
over the wire or when we're updating known peers.
Lock should be held.


name: raft.processAppendEntryResponse
go_file: server/raft.go
go_class: raft
go_method: processAppendEntryResponse
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: RaftNode
dotnet_method: ProcessAppendEntryResponse
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
processAppendEntryResponse is called when we receive an append entry
response from another node. They will send a confirmation to tell us
whether they successfully committed the entry or not.


name: raft.cachePendingEntry
go_file: server/raft.go
go_class: raft
go_method: cachePendingEntry
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: RaftNode
dotnet_method: CachePendingEntry
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
cachePendingEntry saves append entries in memory for faster processing during applyCommit.
Only save so many however to avoid memory bloat.


name: raft.readTermVote
go_file: server/raft.go
go_class: raft
go_method: readTermVote
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: RaftNode
dotnet_method: ReadTermVote
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
readTermVote will read the largest term and who we voted from to stable storage.
Lock should be held.


name: raft.writeTermVote
go_file: server/raft.go
go_class: raft
go_method: writeTermVote
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: RaftNode
dotnet_method: WriteTermVoteInternal
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
writeTermVote will record the largest term and who we voted for to stable storage.
Lock should be held.


name: debugOption.Apply
go_file: server/reload.go
go_class: debugOption
go_method: Apply
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: DebugOption
dotnet_method: Apply
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
Apply is mostly a no-op because logging will be reloaded after options are applied.
However we will kick the raft nodes if they exist to reload.


name: maxConnOption.Apply
go_file: server/reload.go
go_class: maxConnOption
go_method: Apply
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: MaxConnOption
dotnet_method: Apply
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
Apply the max connections change by closing random connections til we are
below the limit if necessary.


name: Server.recheckPinnedCerts
go_file: server/reload.go
go_class: Server
go_method: recheckPinnedCerts
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: NatsServer
dotnet_method: RecheckPinnedCerts
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
Compares options and disconnects clients that are no longer listed in pinned certs. Lock must not be held.


name: Server.Reload
go_file: server/reload.go
go_class: Server
go_method: Reload
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: NatsServer
dotnet_method: Reload
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
Reload reads the current configuration file and calls out to ReloadOptions
to apply the changes. This returns an error if the server was not started
with a config file or an option which doesn't support hot-swapping was changed.


name: Server.ReloadOptions
go_file: server/reload.go
go_class: Server
go_method: ReloadOptions
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: NatsServer
dotnet_method: ReloadOptions
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
ReloadOptions applies any supported options from the provided Options
type. This returns an error if an option which doesn't support
hot-swapping was changed.
The provided Options type should not be re-used afterwards.
Either use Options.Clone() to pass a copy, or make a new one.


name: Server.reloadOptions
go_file: server/reload.go
go_class: Server
go_method: reloadOptions
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: NatsServer
dotnet_method: ReloadOptionsInternal
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
reloadOptions reloads the server config with the provided options. If an
option that doesn't support hot-swapping is changed, this returns an error.


name: Server.diffOptions
go_file: server/reload.go
go_class: Server
go_method: diffOptions
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: NatsServer
dotnet_method: DiffOptions
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
diffOptions returns a slice containing options which have been changed. If
an option that doesn't support hot-swapping is changed, this returns an
error.


name: Server.reloadAuthorization
go_file: server/reload.go
go_class: Server
go_method: reloadAuthorization
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: NatsServer
dotnet_method: ReloadAuthorization
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
reloadAuthorization reconfigures the server authorization settings,
disconnects any clients who are no longer authorized, and removes any
unauthorized subscriptions.


name: Server.clientHasMovedToDifferentAccount
go_file: server/reload.go
go_class: Server
go_method: clientHasMovedToDifferentAccount
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: NatsServer
dotnet_method: ClientHasMovedToDifferentAccount
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
Returns true if given client current account has changed (or user
no longer exist) in the new config, false if the user did not
change accounts.
Server lock is held on entry.


name: Server.reloadClusterPermissions
go_file: server/reload.go
go_class: Server
go_method: reloadClusterPermissions
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: NatsServer
dotnet_method: ReloadClusterPermissions
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
reloadClusterPermissions reconfigures the cluster's permssions
and set the permissions to all existing routes, sending an
update INFO protocol so that remote can resend their local
subs if needed, and sending local subs matching cluster's
import subjects.


name: validateClusterOpts
go_file: server/reload.go
go_method: validateClusterOpts
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: ConfigReloader
dotnet_method: ValidateClusterOpts
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
validateClusterOpts ensures the new ClusterOpts does not change some of the
fields that do not support reload.


name: diffRoutes
go_file: server/reload.go
go_method: diffRoutes
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: ConfigReloader
dotnet_method: DiffRoutes
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
diffRoutes diffs the old routes and the new routes and returns the ones that
should be added and removed from the server.


name: closedRingBuffer.closedClients
go_file: server/ring.go
go_class: closedRingBuffer
go_method: closedClients
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: ClosedRingBuffer,ClosedClient
dotnet_method: ClosedClients
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
This will return a sorted copy of the list which recipient can
modify. If the contents of the client itself need to be modified,
meaning swapping in any optional items, a copy should be made. We
could introduce a new lock and hold that but since we return this
list inside monitor which allows programatic access, we do not
know when it would be done.


name: client.processRoutedOriginClusterMsgArgs
go_file: server/route.go
go_class: client
go_method: processRoutedOriginClusterMsgArgs
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: ClientConnection
dotnet_method: ProcessRoutedOriginClusterMsgArgs
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
Process an inbound LMSG specification from the remote route. This means
we have an origin cluster and we force header semantics.


name: computeRoutePoolIdx
go_file: server/route.go
go_method: computeRoutePoolIdx
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: RouteHandler
dotnet_method: ComputeRoutePoolIdx
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
Returns a route pool index for this account based on the given pool size.
If `poolSize` is smaller or equal to 1, the returned value will always
be 0, regardless of the account name. If not, the returned value will
be in the range [0..poolSize-1]. The value for a given account name
is constant and same on all servers (given the same `poolSize` value).


name: Server.updateRemoteRoutePerms
go_file: server/route.go
go_class: Server
go_method: updateRemoteRoutePerms
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: NatsServer
dotnet_method: UpdateRemoteRoutePerms
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
Possibly sends local subscriptions interest to this route
based on changes in the remote's Export permissions.


name: Server.sendAsyncInfoToClients
go_file: server/route.go
go_class: Server
go_method: sendAsyncInfoToClients
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: NatsServer
dotnet_method: SendAsyncInfoToClients
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
sendAsyncInfoToClients sends an INFO protocol to all
connected clients that accept async INFO updates.
The server lock is held on entry.


name: Server.processImplicitRoute
go_file: server/route.go
go_class: Server
go_method: processImplicitRoute
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: NatsServer
dotnet_method: ProcessImplicitRoute
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
This will process implicit route information received from another server.
We will check to see if we have configured or are already connected,
and if so we will ignore. Otherwise we will attempt to connect.


name: Server.hasThisRouteConfigured
go_file: server/route.go
go_class: Server
go_method: hasThisRouteConfigured
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: NatsServer
dotnet_method: HasThisRouteConfigured
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
hasThisRouteConfigured returns true if info.Host:info.Port is present
in the server's opts.Routes, false otherwise.
Server lock is assumed to be held by caller.


name: Server.forwardNewRouteInfoToKnownServers
go_file: server/route.go
go_class: Server
go_method: forwardNewRouteInfoToKnownServers
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: NatsServer
dotnet_method: ForwardNewRouteInfoToKnownServers
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
forwardNewRouteInfoToKnownServers possibly sends the INFO protocol of the
new route to all routes known by this server. In turn, each server will
contact this new route.
Server lock held on entry.


name: client.canImport
go_file: server/route.go
go_class: client
go_method: canImport
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: ClientConnection
dotnet_method: CanImport
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
canImport is whether or not we will send a SUB for interest to the other side.
This is for ROUTER connections only.
Lock is held on entry.


name: client.canExport
go_file: server/route.go
go_class: client
go_method: canExport
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: ClientConnection
dotnet_method: CanExport
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
canExport is whether or not we will accept a SUB from the remote for a given subject.
This is for ROUTER connections only.
Lock is held on entry


name: client.setRoutePermissions
go_file: server/route.go
go_class: client
go_method: setRoutePermissions
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: ClientConnection
dotnet_method: SetRoutePermissions
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
Initialize or reset cluster's permissions.
This is for ROUTER connections only.
Client lock is held on entry


name: getAccNameFromRoutedSubKey
go_file: server/route.go
go_method: getAccNameFromRoutedSubKey
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: RouteHandler
dotnet_method: GetAccNameFromRoutedSubKey
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
Returns the account name from the subscription's key.
This is invoked knowing that the key contains an account name, so for a sub
that is not from a pinned-account route.
The `keyHasSubType` boolean indicates that the key starts with the indicator
for leaf or regular routed subscriptions.


name: client.getRoutedSubKeyInfo
go_file: server/route.go
go_class: client
go_method: getRoutedSubKeyInfo
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: ClientConnection
dotnet_method: GetRoutedSubKeyInfo
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
Returns if the route is dedicated to an account, its name, and a boolean
that indicates if this route uses the routed subscription indicator at
the beginning of the subscription key.
Lock held on entry.


name: client.removeRemoteSubsForAcc
go_file: server/route.go
go_class: client
go_method: removeRemoteSubsForAcc
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: ClientConnection
dotnet_method: RemoveRemoteSubsForAcc
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
Removes (and returns) the subscriptions from this route's subscriptions map
that belong to the given account.
Lock is held on entry


name: Server.sendSubsToRoute
go_file: server/route.go
go_class: Server
go_method: sendSubsToRoute
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: NatsServer
dotnet_method: SendSubsToRoute
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
sendSubsToRoute will send over our subject interest to
the remote side. For each account we will send the
complete interest for all subjects, both normal as a binary
and queue group weights.

Server lock held on entry.


name: client.sendRouteSubProtos
go_file: server/route.go
go_class: client
go_method: sendRouteSubProtos
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: ClientConnection
dotnet_method: SendRouteSubProtos
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
Sends SUBs protocols for the given subscriptions. If a filter is specified, it is
invoked for each subscription. If the filter returns false, the subscription is skipped.
This function may release the route's lock due to flushing of outbound data. A boolean
is returned to indicate if the connection has been closed during this call.
Lock is held on entry.


name: client.sendRouteUnSubProtos
go_file: server/route.go
go_class: client
go_method: sendRouteUnSubProtos
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: ClientConnection
dotnet_method: SendRouteUnSubProtos
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
Sends UNSUBs protocols for the given subscriptions. If a filter is specified, it is
invoked for each subscription. If the filter returns false, the subscription is skipped.
This function may release the route's lock due to flushing of outbound data. A boolean
is returned to indicate if the connection has been closed during this call.
Lock is held on entry.


name: client.sendRouteSubOrUnSubProtos
go_file: server/route.go
go_class: client
go_method: sendRouteSubOrUnSubProtos
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: ClientConnection
dotnet_method: SendRouteSubOrUnSubProtos
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
Low-level function that sends RS+ or RS- protocols for the given subscriptions.
This can now also send LS+ and LS- for origin cluster based leafnode subscriptions for cluster no-echo.
Use sendRouteSubProtos or sendRouteUnSubProtos instead for clarity.
Lock is held on entry.


name: Server.generateRouteInitialInfoJSON
go_file: server/route.go
go_class: Server
go_method: generateRouteInitialInfoJSON
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: NatsServer
dotnet_method: GenerateRouteInitialInfoJSON
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
Generates a nonce and set some route info's fields before marshal'ing into JSON.
To be used only when a route is created (to send the initial INFO protocol).

Server lock held on entry.


name: Server.updateRouteSubscriptionMap
go_file: server/route.go
go_class: Server
go_method: updateRouteSubscriptionMap
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: NatsServer
dotnet_method: UpdateRouteSubscriptionMap
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
updateRouteSubscriptionMap will make sure to update the route map for the subscription. Will
also forward to all routes if needed.


name: Server.startRouteAcceptLoop
go_file: server/route.go
go_class: Server
go_method: startRouteAcceptLoop
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: NatsServer
dotnet_method: StartRouteAcceptLoop
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
This starts the route accept loop in a go routine, unless it
is detected that the server has already been shutdown.
It will also start soliciting explicit routes.


name: Server.StartRouting
go_file: server/route.go
go_class: Server
go_method: StartRouting
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: NatsServer
dotnet_method: StartRouting
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
StartRouting will start the accept loop on the cluster host:port
and will actively try to connect to listed routes.


name: Server.saveRouteTLSName
go_file: server/route.go
go_class: Server
go_method: saveRouteTLSName
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: NatsServer
dotnet_method: SaveRouteTLSName
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
Save the first hostname found in route URLs. This will be used in gossip mode
when trying to create a TLS connection by setting the tlsConfig.ServerName.
Lock is held on entry


name: Server.solicitRoutes
go_file: server/route.go
go_class: Server
go_method: solicitRoutes
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: NatsServer
dotnet_method: SolicitRoutes
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
Start connection process to provided routes. Each route connection will
be started in a dedicated go routine.
Lock is held on entry


name: Server.forEachNonPerAccountRoute
go_file: server/route.go
go_class: Server
go_method: forEachNonPerAccountRoute
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: NatsServer
dotnet_method: ForEachNonPerAccountRoute
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
Goes over each non-nil route connection for all remote servers
and invokes the function `f`. It does not go over per-account
routes.
Server lock is held on entry.


name: Server.forEachRoute
go_file: server/route.go
go_class: Server
go_method: forEachRoute
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: NatsServer
dotnet_method: ForEachRoute
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
Goes over each non-nil route connection for all remote servers
and invokes the function `f`. This also includes the per-account
routes.
Server lock is held on entry.


name: Server.forEachRouteIdx
go_file: server/route.go
go_class: Server
go_method: forEachRouteIdx
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: NatsServer
dotnet_method: ForEachRouteIdx
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
Goes over each non-nil route connection at the given pool index
location in the slice and invokes the function `f`. If the
callback returns `true`, this function moves to the next remote.
Otherwise, the iteration over removes stops.
This does not include per-account routes.
Server lock is held on entry.


name: Server.forEachRemote
go_file: server/route.go
go_class: Server
go_method: forEachRemote
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: NatsServer
dotnet_method: ForEachRemote
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
Goes over each remote and for the first non nil route connection,
invokes the function `f`.
Server lock is held on entry.


name: MsgScheduling.encode
go_file: server/scheduler.go
go_class: MsgScheduling
go_method: encode
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: Scheduler
dotnet_method: Encode
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
encode writes out the contents of the schedule into a binary snapshot
and returns it. The high seq number is included in the snapshot and will
be returned on decode.


name: MsgScheduling.decode
go_file: server/scheduler.go
go_class: MsgScheduling
go_method: decode
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: Scheduler
dotnet_method: Decode
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
decode snapshots a binary-encoded schedule and replaces the contents of this
schedule with them. Returns the high seq number from the snapshot.


name: parseMsgSchedule
go_file: server/scheduler.go
go_method: parseMsgSchedule
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: Scheduler
dotnet_method: ParseMsgSchedule
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
parseMsgSchedule parses a message schedule pattern and returns the time
to fire, whether it is a repeating schedule, and whether the pattern was valid.


name: isSubjectDeleteMarker
go_file: server/sdm.go
go_method: isSubjectDeleteMarker
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: StreamDeletionMeta,SdmBySeq
dotnet_method: IsSubjectDeleteMarker
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
isSubjectDeleteMarker returns whether the headers indicate this message is a subject delete marker.
Either it's a usual marker with JSMarkerReason, or it's a KV Purge marker as the KVOperation.


name: validateAndNormalizeCompressionOption
go_file: server/server.go
go_method: validateAndNormalizeCompressionOption
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: NatsServer
dotnet_method: ValidateAndNormalizeCompressionOption
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
For a given user provided string, matches to one of the compression mode
constant and updates the provided string to that constant. Returns an
error if the provided compression mode is not known.
The parameter `chosenModeForOn` indicates which compression mode to use
when the user selects "on" (or enabled, true, etc..). This is because
we may have different defaults depending on where the compression is used.


name: needsCompression
go_file: server/server.go
go_method: needsCompression
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: NatsServer
dotnet_method: NeedsCompression
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
Returns `true` if the compression mode `m` indicates that the server
will negotiate compression with the remote server, `false` otherwise.
Note that the provided compression mode is assumed to have been
normalized and validated.


name: selectCompressionMode
go_file: server/server.go
go_method: selectCompressionMode
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: NatsServer
dotnet_method: SelectCompressionMode
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
Compression is asymmetric, meaning that one side can have a different
compression level than the other. However, we need to check for cases
when this server `scm` or the remote `rcm` do not support compression
(say older server, or test to make it behave as it is not), or have
the compression off.
Note that `scm` is assumed to not be "off" or "not supported".


name: compressionModeForInfoProtocol
go_file: server/server.go
go_method: compressionModeForInfoProtocol
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: NatsServer
dotnet_method: CompressionModeForInfoProtocol
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
If the configured compression mode is "auto" then will return that,
otherwise will return the given `cm` compression mode.


name: selectS2AutoModeBasedOnRTT
go_file: server/server.go
go_method: selectS2AutoModeBasedOnRTT
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: NatsServer
dotnet_method: SelectS2AutoModeBasedOnRTT
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
Given a connection RTT and a list of thresholds durations, this
function will return an S2 compression level such as "uncompressed",
"fast", "better" or "best". For instance, with the following slice:
[5ms, 10ms, 15ms, 20ms], a RTT of up to 5ms will result
in the compression level "uncompressed", ]5ms..10ms] will result in
"fast" compression, etc..
However, the 0 value allows for disabling of some compression levels.
For instance, the following slice: [0, 0, 20, 30] means that a RTT of
[0..20ms] would result in the "better" compression - effectively disabling
the use of "uncompressed" and "fast", then anything above 20ms would
result in the use of "best" level (the 30 in the list has no effect
and the list could have been simplified to [0, 0, 20]).


name: s2WriterOptions
go_file: server/server.go
go_method: s2WriterOptions
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: NatsServer
dotnet_method: S2WriterOptions
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
Returns an array of s2 WriterOption based on the route compression mode.
So far we return a single option, but this way we can call s2.NewWriter()
with a nil []s2.WriterOption, but not with a nil s2.WriterOption, so
this is more versatile.


name: NewServer
go_file: server/server.go
go_method: NewServer
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: NatsServer
dotnet_method: NewServer
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
NewServer will setup a new server struct after parsing the options.
Could return an error if options can not be validated.
The provided Options type should not be re-used afterwards.
Either use Options.Clone() to pass a copy, or make a new one.


name: Server.initRouteStructures
go_file: server/server.go
go_class: Server
go_method: initRouteStructures
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: NatsServer
dotnet_method: InitRouteStructures
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
Initializes route structures based on pooling and/or per-account routes.

Server lock is held on entry


name: Server.ClientURL
go_file: server/server.go
go_class: Server
go_method: ClientURL
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: NatsServer
dotnet_method: ClientURL
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
ClientURL returns the URL used to connect clients.
Helpful in tests and with in-process servers using a random client port (-1).


name: Server.WebsocketURL
go_file: server/server.go
go_class: Server
go_method: WebsocketURL
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: NatsServer
dotnet_method: WebsocketURL
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
WebsocketURL returns the URL used to connect websocket clients.
Helpful in tests and with in-process servers using a random websocket port (-1).


name: Server.configureAccounts
go_file: server/server.go
go_class: Server
go_method: configureAccounts
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: NatsServer
dotnet_method: ConfigureAccounts
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
Used to setup or update Accounts.
Returns a map that indicates which accounts have had their stream imports
changed (in case of an update in configuration reload).
Lock is held upon entry, but will be released/reacquired in this function.


name: Server.configureResolver
go_file: server/server.go
go_class: Server
go_method: configureResolver
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: NatsServer
dotnet_method: ConfigureResolver
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
Setup the account resolver. For memory resolver, make sure the JWTs are
properly formed but do not enforce expiration etc.
Lock is held on entry, but may be released/reacquired during this call.


name: Server.isTrustedIssuer
go_file: server/server.go
go_class: Server
go_method: isTrustedIssuer
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: NatsServer
dotnet_method: IsTrustedIssuer
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
isTrustedIssuer will check that the issuer is a trusted public key.
This is used to make sure an account was signed by a trusted operator.


name: Server.initStampedTrustedKeys
go_file: server/server.go
go_class: Server
go_method: initStampedTrustedKeys
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: NatsServer
dotnet_method: InitStampedTrustedKeys
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
initStampedTrustedKeys will check the stamped trusted keys
and will set the server field 'trustedKeys'. Returns whether
it succeeded or not.


name: ProcessCommandLineArgs
go_file: server/server.go
go_method: ProcessCommandLineArgs
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: NatsServer
dotnet_method: ProcessCommandLineArgs
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
ProcessCommandLineArgs takes the command line arguments
validating and setting flags for handling in case any
sub command was present.


name: Server.numReservedAccounts
go_file: server/server.go
go_class: Server
go_method: numReservedAccounts
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: NatsServer
dotnet_method: NumReservedAccounts
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
numReservedAccounts will return the number of reserved accounts configured in the server.
Currently this is 1, one for the global default account.


name: Server.numAccounts
go_file: server/server.go
go_class: Server
go_method: numAccounts
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: NatsServer
dotnet_method: NumAccounts
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
This should be used for testing only. Will be slow since we have to
range over all accounts in the sync.Map to count.


name: Server.SetSystemAccount
go_file: server/server.go
go_class: Server
go_method: SetSystemAccount
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: NatsServer
dotnet_method: SetSystemAccount
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
SetSystemAccount will set the internal system account.
If root operators are present it will also check validity.


name: Server.setSystemAccount
go_file: server/server.go
go_class: Server
go_method: setSystemAccount
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: NatsServer
dotnet_method: SetSystemAccountInternal
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
Assign a system account. Should only be called once.
This sets up a server to send and receive messages from
inside the server itself.


name: Server.shouldTrackSubscriptions
go_file: server/server.go
go_class: Server
go_method: shouldTrackSubscriptions
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: NatsServer
dotnet_method: ShouldTrackSubscriptions
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
Determine if accounts should track subscriptions for
efficient propagation.
Lock should be held on entry.


name: Server.registerAccount
go_file: server/server.go
go_class: Server
go_method: registerAccount
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: NatsServer
dotnet_method: RegisterAccountInternal
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
Invokes registerAccountNoLock under the protection of the server lock.
That is, server lock is acquired/released in this function.
See registerAccountNoLock for comment on returned value.


name: Server.registerAccountNoLock
go_file: server/server.go
go_class: Server
go_method: registerAccountNoLock
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: NatsServer
dotnet_method: RegisterAccountNoLock
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
Registers an account in the server.
Due to some locking considerations, we may end-up trying
to register the same account twice. This function will
then return the already registered account.
Lock should be held on entry.


name: Server.setRouteInfo
go_file: server/server.go
go_class: Server
go_method: setRouteInfo
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: NatsServer
dotnet_method: SetRouteInfo
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
Sets the account's routePoolIdx depending on presence or not of
pooling or per-account routes. Also updates a map used by
gateway code to retrieve a route based on some route hash.

Both Server and Account lock held on entry.


name: Server.lookupAccount
go_file: server/server.go
go_class: Server
go_method: lookupAccount
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: NatsServer
dotnet_method: LookupAccountInternal
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
lookupAccount is a function to return the account structure
associated with an account name.
Lock MUST NOT be held upon entry.


name: Server.lookupOrFetchAccount
go_file: server/server.go
go_class: Server
go_method: lookupOrFetchAccount
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: NatsServer
dotnet_method: LookupOrFetchAccount
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
lookupOrFetchAccount is a function to return the account structure
associated with an account name.
Lock MUST NOT be held upon entry.


name: Server.updateAccount
go_file: server/server.go
go_class: Server
go_method: updateAccount
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: NatsServer
dotnet_method: UpdateAccount
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
This will fetch new claims and if found update the account with new claims.
Lock MUST NOT be held upon entry.


name: Server.fetchRawAccountClaims
go_file: server/server.go
go_class: Server
go_method: fetchRawAccountClaims
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: NatsServer
dotnet_method: FetchRawAccountClaims
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
fetchRawAccountClaims will grab raw account claims iff we have a resolver.
Lock is NOT held upon entry.


name: Server.fetchAccountClaims
go_file: server/server.go
go_class: Server
go_method: fetchAccountClaims
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: NatsServer
dotnet_method: FetchAccountClaims
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
fetchAccountClaims will attempt to fetch new claims if a resolver is present.
Lock is NOT held upon entry.


name: Server.Start
go_file: server/server.go
go_class: Server
go_method: Start
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: NatsServer
dotnet_method: Start
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
Start up the server, this will not block.

WaitForShutdown can be used to block and wait for the server to shutdown properly if needed
after calling s.Shutdown()


name: Server.Shutdown
go_file: server/server.go
go_class: Server
go_method: Shutdown
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: NatsServer
dotnet_method: Shutdown
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
Shutdown will shutdown the server instance by kicking out the AcceptLoop
and closing all associated clients.


name: Server.getServerListener
go_file: server/server.go
go_class: Server
go_method: getServerListener
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: NatsServer
dotnet_method: GetServerListener
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
getServerListener returns a network listener for the given host-port address.
If the Server already has an active listener (s.listener), it returns that listener
along with any previous error (s.listenerErr). Otherwise, it creates and returns
a new TCP listener on the specified address using natsListen.


name: Server.InProcessConn
go_file: server/server.go
go_class: Server
go_method: InProcessConn
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: NatsServer
dotnet_method: InProcessConn
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
InProcessConn returns an in-process connection to the server,
avoiding the need to use a TCP listener for local connectivity
within the same process. This can be used regardless of the
state of the DontListen option.


name: Server.setInfoHostPort
go_file: server/server.go
go_class: Server
go_method: setInfoHostPort
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: NatsServer
dotnet_method: SetInfoHostPort
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
This function sets the server's info Host/Port based on server Options.
Note that this function may be called during config reload, this is why
Host/Port may be reset to original Options if the ClientAdvertise option
is not set (since it may have previously been).


name: Server.getMonitoringTLSConfig
go_file: server/server.go
go_class: Server
go_method: getMonitoringTLSConfig
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: NatsServer
dotnet_method: GetMonitoringTLSConfig
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
The TLS configuration is passed to the listener when the monitoring
"server" is setup. That prevents TLS configuration updates on reload
from being used. By setting this function in tls.Config.GetConfigForClient
we instruct the TLS handshake to ask for the tls configuration to be
used for a specific client. We don't care which client, we always use
the same TLS configuration.


name: Server.HTTPHandler
go_file: server/server.go
go_class: Server
go_method: HTTPHandler
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: NatsServer
dotnet_method: HTTPHandler
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
HTTPHandler returns the http.Handler object used to handle monitoring
endpoints. It will return nil if the server is not configured for
monitoring, or if the server has not been started yet (Server.Start()).


name: Server.copyInfo
go_file: server/server.go
go_class: Server
go_method: copyInfo
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: NatsServer
dotnet_method: CopyInfo
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
Perform a conditional deep copy due to reference nature of [Client|WS]ConnectURLs.
If updates are made to Info, this function should be consulted and updated.
Assume lock is held.


name: Server.saveClosedClient
go_file: server/server.go
go_class: Server
go_method: saveClosedClient
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: NatsServer
dotnet_method: SaveClosedClient
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
This will save off a closed client in a ring buffer such that
/connz can inspect. Useful for debugging, etc.


name: Server.addConnectURLsAndSendINFOToClients
go_file: server/server.go
go_class: Server
go_method: addConnectURLsAndSendINFOToClients
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: NatsServer
dotnet_method: AddConnectURLsAndSendINFOToClients
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
Adds to the list of client and websocket clients connect URLs.
If there was a change, an INFO protocol is sent to registered clients
that support async INFO protocols.
Server lock held on entry.


name: Server.removeConnectURLsAndSendINFOToClients
go_file: server/server.go
go_class: Server
go_method: removeConnectURLsAndSendINFOToClients
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: NatsServer
dotnet_method: RemoveConnectURLsAndSendINFOToClients
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
Removes from the list of client and websocket clients connect URLs.
If there was a change, an INFO protocol is sent to registered clients
that support async INFO protocols.
Server lock held on entry.


name: Server.updateServerINFOAndSendINFOToClients
go_file: server/server.go
go_class: Server
go_method: updateServerINFOAndSendINFOToClients
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: NatsServer
dotnet_method: UpdateServerINFOAndSendINFOToClients
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
Updates the list of client and websocket clients connect URLs and if any change
sends an async INFO update to clients that support it.
Server lock held on entry.


name: Server.removeProxiedConn
go_file: server/server.go
go_class: Server
go_method: removeProxiedConn
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: NatsServer
dotnet_method: RemoveProxiedConn
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
Remove the connection with id `cid` from the map of connections
under the public key `key` of the trusted proxies.

Server lock must be held on entry.


name: Server.ReadyForConnections
go_file: server/server.go
go_class: Server
go_method: ReadyForConnections
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: NatsServer
dotnet_method: ReadyForConnections
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
ReadyForConnections returns `true` if the server is ready to accept clients
and, if routing is enabled, route connections. If after the duration
`dur` the server is still not ready, returns `false`.


name: Server.getClientConnectURLs
go_file: server/server.go
go_class: Server
go_method: getClientConnectURLs
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: NatsServer
dotnet_method: GetClientConnectURLs
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
getClientConnectURLs returns suitable URLs for clients to connect to the listen
port based on the server options' Host and Port. If the Host corresponds to
"any" interfaces, this call returns the list of resolved IP addresses.
If ClientAdvertise is set, returns the client advertise host and port.
The server lock is assumed held on entry.


name: Server.getConnectURLs
go_file: server/server.go
go_class: Server
go_method: getConnectURLs
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: NatsServer
dotnet_method: GetConnectURLs
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
Generic version that will return an array of URLs based on the given
advertise, host and port values.


name: Server.getNonLocalIPsIfHostIsIPAny
go_file: server/server.go
go_class: Server
go_method: getNonLocalIPsIfHostIsIPAny
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: NatsServer
dotnet_method: GetNonLocalIPsIfHostIsIPAny
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
Returns an array of non local IPs if the provided host is
0.0.0.0 or ::. It returns the first resolved if `all` is
false.
The boolean indicate if the provided host was 0.0.0.0 (or ::)
so that if the returned array is empty caller can decide
what to do next.


name: Server.PortsInfo
go_file: server/server.go
go_class: Server
go_method: PortsInfo
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: NatsServer
dotnet_method: PortsInfo
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
PortsInfo attempts to resolve all the ports. If after maxWait the ports are not
resolved, it returns nil. Otherwise it returns a Ports struct
describing ports where the server can be contacted


name: Server.portFile
go_file: server/server.go
go_class: Server
go_method: portFile
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: NatsServer
dotnet_method: PortFile
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
Returns the portsFile. If a non-empty dirHint is provided, the dirHint
path is used instead of the server option value


name: Server.deletePortsFile
go_file: server/server.go
go_class: Server
go_method: deletePortsFile
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: NatsServer
dotnet_method: DeletePortsFile
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
Delete the ports file. If a non-empty dirHint is provided, the dirHint
path is used instead of the server option value


name: Server.logPorts
go_file: server/server.go
go_class: Server
go_method: logPorts
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: NatsServer
dotnet_method: LogPorts
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
Writes a file with a serialized Ports to the specified ports_file_dir.
The name of the file is `exename_pid.ports`, typically nats-server_pid.ports.
if ports file is not set, this function has no effect


name: Server.serviceListeners
go_file: server/server.go
go_class: Server
go_method: serviceListeners
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: NatsServer
dotnet_method: ServiceListeners
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
returns a list of listeners that are intended for the process
if the entry is nil, the interface is yet to be resolved


name: Server.LameDuckShutdown
go_file: server/server.go
go_class: Server
go_method: LameDuckShutdown
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: NatsServer
dotnet_method: LameDuckShutdown
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
LameDuckShutdown will perform a lame duck shutdown of NATS, whereby
the client listener is closed, existing client connections are
kicked, Raft leaderships are transferred, JetStream is shutdown
and then finally shutdown the the NATS Server itself.
This function blocks and will not return until the NATS Server
has completed the entire shutdown operation.


name: Server.lameDuckMode
go_file: server/server.go
go_class: Server
go_method: lameDuckMode
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: NatsServer
dotnet_method: LameDuckMode
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
This function will close the client listener then close the clients
at some interval to avoid a reconnect storm.
We will also transfer any raft leaders and shutdown JetStream.


name: Server.sendLDMToRoutes
go_file: server/server.go
go_class: Server
go_method: sendLDMToRoutes
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: NatsServer
dotnet_method: SendLDMToRoutes
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
Send an INFO update to routes with the indication that this server is in LDM mode.
Server lock is held on entry.


name: Server.sendLDMToClients
go_file: server/server.go
go_class: Server
go_method: sendLDMToClients
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: NatsServer
dotnet_method: SendLDMToClients
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
Send an INFO update to clients with the indication that this server is in
LDM mode and with only URLs of other nodes.
Server lock is held on entry.


name: Server.acceptError
go_file: server/server.go
go_class: Server
go_method: acceptError
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: NatsServer
dotnet_method: AcceptError
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
If given error is a net.Error and is temporary, sleeps for the given
delay and double it, but cap it to ACCEPT_MAX_SLEEP. The sleep is
interrupted if the server is shutdown.
An error message is displayed depending on the type of error.
Returns the new (or unchanged) delay, or a negative value if the
server has been or is being shutdown.


name: Server.shouldReportConnectErr
go_file: server/server.go
go_class: Server
go_method: shouldReportConnectErr
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: NatsServer
dotnet_method: ShouldReportConnectErr
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
Returns true for the first attempt and depending on the nature
of the attempt (first connect or a reconnect), when the number
of attempts is equal to the configured report attempts.


name: Run
go_file: server/service.go
go_method: Run
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: ServiceManager
dotnet_method: Run
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
Run starts the NATS server. This wrapper function allows Windows to add a
hook for running NATS as a service.


name: winServiceWrapper.Execute
go_file: server/service_windows.go
go_class: winServiceWrapper
go_method: Execute
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: ServiceManager
dotnet_method: Execute
notes: Windows-specific Go code. Replaced by Microsoft.Extensions.Hosting.WindowsServices in .NET.
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
Execute will be called by the package code at the start of
the service, and the service will exit once Execute completes.
Inside Execute you must read service change requests from r and
act accordingly. You must keep service control manager up to date
about state of your service by writing into s as required.
args contains service name followed by argument strings passed
to the service.
You can provide service exit code in exitCode return parameter,
with 0 being "no error". You can also indicate if exit code,
if any, is service specific or not by using svcSpecificEC
parameter.


name: ProcessSignal
go_file: server/signal.go
go_method: ProcessSignal
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: SignalHandler
dotnet_method: ProcessSignal
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
ProcessSignal sends the given signal command to the given process. If pidStr
is empty, this will send the signal to the single running instance of
nats-server. If multiple instances are running, pidStr can be a globular
expression ending with '*'. This returns an error if the given process is
not running or the command is invalid.


name: ProcessSignal
go_file: server/signal_windows.go
go_method: ProcessSignal
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: SignalHandler
dotnet_method: ProcessSignal
notes: Windows-specific Go code. Replaced by Microsoft.Extensions.Hosting.WindowsServices in .NET.
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
ProcessSignal sends the given signal command to the running nats-server service.
If service is empty, this signals the "nats-server" service. This returns an
error is the given service is not running or the command is invalid.


name: bytesToString
go_file: server/store.go
go_method: bytesToString
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: StorageEngine
dotnet_method: BytesToString
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
Note this will avoid a copy of the data used for the string, but it will also reference the existing slice's data pointer.
So this should be used sparingly when we know the encompassing byte slice's lifetime is the same.


name: copyString
go_file: server/store.go
go_method: copyString
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: StorageEngine
dotnet_method: CopyString
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
Forces a copy of a string, for use in the case that you might have been passed a value when bytesToString was used,
but now you need a separate copy of it to store for longer-term use.


name: StreamConfig.clone
go_file: server/stream.go
go_class: StreamConfig
go_method: clone
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: StreamConfig
dotnet_method: Clone
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
clone performs a deep copy of the StreamConfig struct, returning a new clone with
all values copied.


name: JSPubAckResponse.ToError
go_file: server/stream.go
go_class: JSPubAckResponse
go_method: ToError
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: JSPubAckResponse
dotnet_method: ToError
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
ToError checks if the response has a error and if it does converts it to an error
avoiding the pitfalls described by https://yourbasic.org/golang/gotcha-why-nil-error-not-equal-nil/


name: StreamSource.composeIName
go_file: server/stream.go
go_class: StreamSource
go_method: composeIName
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: StreamSource
dotnet_method: ComposeIName
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
Composes the index name. Contains the stream name, subject filter, and transform destination
when the stream is external we will use the api prefix as part of the index name
(as the same stream name could be used in multiple JS domains)


name: stream.isLeaderNodeState
go_file: server/stream.go
go_class: stream
go_method: isLeaderNodeState
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: NatsStream
dotnet_method: IsLeaderNodeState
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
isLeaderNodeState should NOT be used normally, use isLeader instead.
Returns whether the node thinks it is the leader, regardless of whether applies are up-to-date yet
(unlike isLeader, which requires applies to be caught up).
May be used to respond to clients after a leader change, when applying entries from a former leader.
Lock should be held.


name: stream.autoTuneFileStorageBlockSize
go_file: server/stream.go
go_class: stream
go_method: autoTuneFileStorageBlockSize
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: NatsStream
dotnet_method: AutoTuneFileStorageBlockSize
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
If we are file based and the file storage config was not explicitly set
we can autotune block sizes to better match. Our target will be to store 125%
of the theoretical limit. We will round up to nearest 100 bytes as well.


name: stream.rebuildDedupe
go_file: server/stream.go
go_class: stream
go_method: rebuildDedupe
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: NatsStream
dotnet_method: RebuildDedupe
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
rebuildDedupe will rebuild any dedupe structures needed after recovery of a stream.
Will be called lazily to avoid penalizing startup times.
TODO(dlc) - Might be good to know if this should be checked at all for streams with no
headers and msgId in them. Would need signaling from the storage layer.
mset.mu and mset.ddMu locks should be held.


name: jsAccount.subjectsOverlap
go_file: server/stream.go
go_class: jsAccount
go_method: subjectsOverlap
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: JsAccount
dotnet_method: SubjectsOverlap
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
subjectsOverlap to see if these subjects overlap with existing subjects.
Use only for non-clustered JetStream
RLock minimum should be held.


name: stream.getCfgName
go_file: server/stream.go
go_class: stream
go_method: getCfgName
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: NatsStream
dotnet_method: GetCfgName
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
Small helper to return the Name field from mset.cfg, protected by
the mset.cfgMu mutex. This is simply because we have several places
in consumer.go where we need it.


name: stream.retryDisconnectedSyncConsumers
go_file: server/stream.go
go_class: stream
go_method: retryDisconnectedSyncConsumers
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: NatsStream
dotnet_method: RetryDisconnectedSyncConsumers
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
retryDisconnectedSyncConsumers() will check if we have any disconnected
sync consumers for either mirror or a source and will reset and retry to connect.


name: sourceInfo.isCurrentSub
go_file: server/stream.go
go_class: sourceInfo
go_method: isCurrentSub
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: SourceInfo
dotnet_method: IsCurrentSub
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
Checks that the message is from our current direct consumer. We can not depend on sub comparison
since cross account imports break.


name: stream.retryMirrorConsumer
go_file: server/stream.go
go_class: stream
go_method: retryMirrorConsumer
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: NatsStream
dotnet_method: RetryMirrorConsumer
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
Similar to setupMirrorConsumer except that it will print a debug statement
indicating that there is a retry.

Lock is acquired in this function


name: stream.scheduleSetupMirrorConsumerRetry
go_file: server/stream.go
go_class: stream
go_method: scheduleSetupMirrorConsumerRetry
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: NatsStream
dotnet_method: ScheduleSetupMirrorConsumerRetry
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
This will schedule a call to setupMirrorConsumer, taking into account the last
time it was retried and determine the soonest setupMirrorConsumer can be called
without tripping the sourceConsumerRetryThreshold. We will also take into account
number of failures and will back off our retries.
The mset.mirror pointer has been verified to be not nil by the caller.

Lock held on entry


name: stream.cancelSourceInfo
go_file: server/stream.go
go_class: stream
go_method: cancelSourceInfo
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: NatsStream
dotnet_method: CancelSourceInfo
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
The `si` has been verified to be not nil. The sourceInfo's sub will
be unsubscribed and set to nil (if not already done) and the
cname will be reset. The message processing's go routine quit channel
will be closed if still opened.

Lock should be held


name: stream.setupSourceConsumer
go_file: server/stream.go
go_class: stream
go_method: setupSourceConsumer
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: NatsStream
dotnet_method: SetupSourceConsumer
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
This is the main function to call when needing to setup a new consumer for the source.
It actually only does the scheduling of the execution of trySetupSourceConsumer in order to implement retry backoff
and throttle the number of requests.
Lock should be held.


name: stream.processAllSourceMsgs
go_file: server/stream.go
go_class: stream
go_method: processAllSourceMsgs
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: NatsStream
dotnet_method: ProcessAllSourceMsgs
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
This will process all inbound source msgs.
We mux them into one go routine to avoid lock contention and high cpu and thread thrashing.
TODO(dlc) make this more then one and pin sources to one of a group.


name: stream.handleFlowControl
go_file: server/stream.go
go_class: stream
go_method: handleFlowControl
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: NatsStream
dotnet_method: HandleFlowControl
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
handleFlowControl will properly handle flow control messages for both R==1 and R>1.
Lock should be held.


name: sourceInfo.genSourceHeader
go_file: server/stream.go
go_class: sourceInfo
go_method: genSourceHeader
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: SourceInfo
dotnet_method: GenSourceHeader
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
Generate a new (2.10) style source header (stream name, sequence number, source filter, source destination transform).


name: streamAndSeq
go_file: server/stream.go
go_method: streamAndSeq
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: NatsStream
dotnet_method: StreamAndSeq
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
Extract the stream name, the source index name and the message sequence number from the source header.
Uses the filter and transform arguments to provide backwards compatibility


name: stream.startingSequenceForSources
go_file: server/stream.go
go_class: stream
go_method: startingSequenceForSources
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: NatsStream
dotnet_method: StartingSequenceForSources
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
This will do a reverse scan on startup or leader election
searching for the starting sequence number.
This can be slow in degenerative cases.
Lock should be held.


name: stream.unsubscribeInternal
go_file: server/stream.go
go_class: stream
go_method: unsubscribeInternal
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: NatsStream
dotnet_method: UnsubscribeInternal
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
This will unsubscribe us from the exact subject given.
We do not currently track the subs so do not have the sid.
This should be called only on an update.
Lock does NOT need to be held, we set the client on setup and never change it at this point.


name: stream.storeUpdates
go_file: server/stream.go
go_class: stream
go_method: storeUpdates
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: NatsStream
dotnet_method: StoreUpdates
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
Called for any updates to the underlying stream. We pass through the bytes to the
jetstream account. We do local processing for stream pending for consumers, but only
for removals.
Lock should not be held.


name: getMessageTTL
go_file: server/stream.go
go_method: getMessageTTL
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: NatsStream
dotnet_method: GetMessageTTL
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
Fast lookup of the message TTL from headers:
- Positive return value: duration in seconds.
- Zero return value: no TTL or parse error.
- Negative return value: never expires.


name: parseMessageTTL
go_file: server/stream.go
go_method: parseMessageTTL
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: NatsStream
dotnet_method: ParseMessageTTL
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
- Positive return value: duration in seconds.
- Zero return value: no TTL or parse error.
- Negative return value: never expires.


name: getMessageScheduleTTL
go_file: server/stream.go
go_method: getMessageScheduleTTL
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: NatsStream
dotnet_method: GetMessageScheduleTTL
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
Fast lookup of the message schedule TTL from headers.
The TTL is confirmed to be valid, but the raw TTL string is returned.


name: stream.getDirectRequest
go_file: server/stream.go
go_class: stream
go_method: getDirectRequest
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: NatsStream
dotnet_method: GetDirectRequest
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
Do actual work on a direct msg request.
This could be called in a Go routine if we are inline for a non-client connection.


name: stream.processJetStreamBatchMsg
go_file: server/stream.go
go_class: stream
go_method: processJetStreamBatchMsg
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: NatsStream
dotnet_method: ProcessJetStreamBatchMsg
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
processJetStreamBatchMsg processes a JetStream message that's part of an atomic batch publish.
Handles constraints around the batch, storing messages, doing consistency checks, and performing the commit.


name: stream.setupSendCapabilities
go_file: server/stream.go
go_class: stream
go_method: setupSendCapabilities
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: NatsStream
dotnet_method: SetupSendCapabilities
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
This is similar to system semantics but did not want to overload the single system sendq,
or require system account when doing simple setup with jetstream.


name: stream.checkInterestState
go_file: server/stream.go
go_class: stream
go_method: checkInterestState
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: NatsStream
dotnet_method: CheckInterestState
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
Will check for interest retention and make sure messages
that have been acked are processed and removed.
This will check the ack floors of all consumers, and adjust our first sequence accordingly.


name: stream.noInterest
go_file: server/stream.go
go_class: stream
go_method: noInterest
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: NatsStream
dotnet_method: NoInterest
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
Check if there is no interest in this sequence number across our consumers.
The consumer passed is optional if we are processing the ack for that consumer.
Write lock should be held.


name: stream.noInterestWithSubject
go_file: server/stream.go
go_class: stream
go_method: noInterestWithSubject
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: NatsStream
dotnet_method: NoInterestWithSubject
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
Check if there is no interest in this sequence number and subject across our consumers.
The consumer passed is optional if we are processing the ack for that consumer.
Write lock should be held.


name: stream.registerPreAck
go_file: server/stream.go
go_class: stream
go_method: registerPreAck
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: NatsStream
dotnet_method: RegisterPreAck
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
This will register an ack for a consumer if it arrives before
the actual message.
Write lock should be held.


name: stream.ackMsg
go_file: server/stream.go
go_class: stream
go_method: ackMsg
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: NatsStream
dotnet_method: AckMsg
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
ackMsg is called into from a consumer when we have a WorkQueue or Interest Retention Policy.
Returns whether the message at seq was removed as a result of the ACK.
(Or should be removed in the case of clustered streams, since it requires a message delete proposal)


name: stream.checkForOrphanMsgs
go_file: server/stream.go
go_class: stream
go_method: checkForOrphanMsgs
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: NatsStream
dotnet_method: CheckForOrphanMsgs
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
This is to check for dangling messages on interest retention streams. Only called on account enable.
Issue https://github.com/nats-io/nats-server/issues/3612


name: stream.checkConsumerReplication
go_file: server/stream.go
go_class: stream
go_method: checkConsumerReplication
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: NatsStream
dotnet_method: CheckConsumerReplication
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
Check on startup to make sure that consumers replication matches us.
Interest retention requires replication matches.


name: indexPlaceHolders
go_file: server/subject_transform.go
go_method: indexPlaceHolders
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: SubjectTransform
dotnet_method: IndexPlaceHolders
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
Helper to ingest and index the subjectTransform destination token (e.g. $x or {{}}) in the token
returns a transformation type, and three function arguments: an array of source subject token indexes,
and a single number (e.g. number of partitions, or a slice size), and a string (e.g.a split delimiter)


name: transformTokenize
go_file: server/subject_transform.go
go_method: transformTokenize
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: SubjectTransform
dotnet_method: TransformTokenize
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
Helper function to tokenize subjects with partial wildcards into formal transform destinations.
e.g. "foo.*.*" -> "foo.$1.$2"


name: transformUntokenize
go_file: server/subject_transform.go
go_method: transformUntokenize
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: SubjectTransform
dotnet_method: TransformUntokenize
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
Helper function to go from transform destination to a subject with partial wildcards and ordered list of placeholders
E.g.:

		"bar" -> "bar", []
		"foo.$2.$1" -> "foo.*.*", ["$2","$1"]
	    "foo.{{wildcard(2)}}.{{wildcard(1)}}" -> "foo.*.*", ["{{wildcard(2)}}","{{wildcard(1)}}"]


name: subjectTransform.Match
go_file: server/subject_transform.go
go_class: subjectTransform
go_method: Match
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: SubjectTransform
dotnet_method: Match
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
Match will take a literal published subject that is associated with a client and will match and subjectTransform
the subject if possible.

This API is not part of the public API and not subject to SemVer protections


name: subjectTransform.TransformSubject
go_file: server/subject_transform.go
go_class: subjectTransform
go_method: TransformSubject
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: SubjectTransform
dotnet_method: TransformSubject
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
TransformSubject transforms a subject

This API is not part of the public API and not subject to SemVer protection


name: Sublist.RegisterNotification
go_file: server/sublist.go
go_class: Sublist
go_method: RegisterNotification
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: SubscriptionIndex
dotnet_method: RegisterNotification
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
RegisterNotification will register for notifications when interest for the given
subject changes. The subject must be a literal publish type subject.
The notification is true for when the first interest for a subject is inserted,
and false when all interest in the subject is removed. Note that this interest
needs to be exact and that wildcards will not trigger the notifications. The sublist
will not block when trying to send the notification. Its up to the caller to make
sure the channel send will not block.


name: Sublist.chkForInsertNotification
go_file: server/sublist.go
go_class: Sublist
go_method: chkForInsertNotification
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: SubscriptionIndex
dotnet_method: ChkForInsertNotification
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
chkForInsertNotification will check to see if we need to notify on this subject.
Write lock should be held.


name: Sublist.chkForRemoveNotification
go_file: server/sublist.go
go_class: Sublist
go_method: chkForRemoveNotification
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: SubscriptionIndex
dotnet_method: ChkForRemoveNotification
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
chkForRemoveNotification will check to see if we need to notify on this subject.
Write lock should be held.


name: Sublist.addToCache
go_file: server/sublist.go
go_class: Sublist
go_method: addToCache
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: SubscriptionIndex
dotnet_method: AddToCache
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
addToCache will add the new entry to the existing cache
entries if needed. Assumes write lock is held.
Assumes write lock is held.


name: Sublist.NumInterest
go_file: server/sublist.go
go_class: Sublist
go_method: NumInterest
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: SubscriptionIndex
dotnet_method: NumInterest
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
NumInterest will return the number of subs/qsubs interested in the subject.
In cases where more detail is not required, this may be faster than Match.


name: Sublist.reduceCacheCount
go_file: server/sublist.go
go_class: Sublist
go_method: reduceCacheCount
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: SubscriptionIndex
dotnet_method: ReduceCacheCount
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
Remove entries in the cache until we are under the maximum.
TODO(dlc) this could be smarter now that its not inline.


name: findQSlot
go_file: server/sublist.go
go_method: findQSlot
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: SubscriptionIndex
dotnet_method: FindQSlot
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
We do not use a map here since we want iteration to be past when
processing publishes in L1 on client. So we need to walk sequentially
for now. Keep an eye on this in case we start getting large number of
different queue subscribers for the same subject.


name: subjectIsLiteral
go_file: server/sublist.go
go_method: subjectIsLiteral
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: SubscriptionIndex
dotnet_method: SubjectIsLiteral
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
Determine if the subject has any wildcards. Fast version, does not check for
valid subject. Used in caching layer.


name: IsValidLiteralSubject
go_file: server/sublist.go
go_method: IsValidLiteralSubject
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: SubscriptionIndex
dotnet_method: IsValidLiteralSubject
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
IsValidLiteralSubject returns true if a subject is valid and literal (no wildcards), false otherwise


name: isValidLiteralSubject
go_file: server/sublist.go
go_method: isValidLiteralSubject
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: SubscriptionIndex
dotnet_method: IsValidLiteralSubjectInternal
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
isValidLiteralSubject returns true if the tokens are valid and literal (no wildcards), false otherwise


name: isSubsetMatch
go_file: server/sublist.go
go_method: isSubsetMatch
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: SubscriptionIndex
dotnet_method: IsSubsetMatch
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
This will test a subject as an array of tokens against a test subject
Calls into the function isSubsetMatchTokenized


name: isSubsetMatchTokenized
go_file: server/sublist.go
go_method: isSubsetMatchTokenized
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: SubscriptionIndex
dotnet_method: IsSubsetMatchTokenized
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
This will test a subject as an array of tokens against a test subject (also encoded as array of tokens)
and determine if the tokens are matched. Both test subject and tokens
may contain wildcards. So foo.* is a subset match of [">", "*.*", "foo.*"],
but not of foo.bar, etc.


name: matchLiteral
go_file: server/sublist.go
go_method: matchLiteral
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: SubscriptionIndex
dotnet_method: MatchLiteral
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
matchLiteral is used to test literal subjects, those that do not have any
wildcards, with a target subject. This is used in the cache layer.


name: Sublist.ReverseMatch
go_file: server/sublist.go
go_class: Sublist
go_method: ReverseMatch
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: SubscriptionIndex
dotnet_method: ReverseMatch
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
For a given subject (which may contain wildcards), this call returns all
subscriptions that would match that subject. For instance, suppose that
the sublist contains: foo.bar, foo.bar.baz and foo.baz, ReverseMatch("foo.*")
would return foo.bar and foo.baz.
This is used in situations where the sublist is likely to contain only
literals and one wants to get all the subjects that would have been a match
to a subscription on `subject`.


name: parseHostPort
go_file: server/util.go
go_method: parseHostPort
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: ServerUtilities
dotnet_method: ParseHostPort
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
Parse a host/port string with a default port to use
if none (or 0 or -1) is specified in `hostPort` string.


name: comma
go_file: server/util.go
go_method: comma
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: ServerUtilities
dotnet_method: Comma
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
comma produces a string form of the given number in base 10 with
commas after every three orders of magnitude.

e.g. comma(834142) -> 834,142

This function was copied from the github.com/dustin/go-humanize
package (MIT License) and is Copyright Dustin Sallings <dustin@spy.net>


name: refCountedUrlSet.addUrl
go_file: server/util.go
go_class: refCountedUrlSet
go_method: addUrl
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: ServerUtilities
dotnet_method: AddUrl
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
Adds urlStr to the given map. If the string was already present, simply
bumps the reference count.
Returns true only if it was added for the first time.


name: refCountedUrlSet.removeUrl
go_file: server/util.go
go_class: refCountedUrlSet
go_method: removeUrl
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: ServerUtilities
dotnet_method: RemoveUrl
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
Removes urlStr from the given map. If the string is not present, nothing
is done and false is returned.
If the string was present, its reference count is decreased. Returns true
if this was the last reference, false otherwise.


name: natsListen
go_file: server/util.go
go_method: natsListen
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: ServerUtilities
dotnet_method: NatsListen
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
natsListen() is the same as net.Listen() except that TCP keepalives are
disabled (to match Go's behavior before Go 1.13).


name: natsDialTimeout
go_file: server/util.go
go_method: natsDialTimeout
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: ServerUtilities
dotnet_method: NatsDialTimeout
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
natsDialTimeout is the same as net.DialTimeout() except the TCP keepalives
are disabled (to match Go's behavior before Go 1.13).


name: redactURLList
go_file: server/util.go
go_method: redactURLList
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: ServerUtilities
dotnet_method: RedactURLList
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
redactURLList() returns a copy of a list of URL pointers where each item
in the list will either be the same pointer if the URL does not contain a
password, or to a new object if there is a password.
The intended use-case is for logging lists of URLs safely.


name: copyBytes
go_file: server/util.go
go_method: copyBytes
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: ServerUtilities
dotnet_method: CopyBytes
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
copyBytes make a new slice of the same size as `src` and copy its content.
If `src` is nil or its length is 0, then this returns `nil`


name: copyStrings
go_file: server/util.go
go_method: copyStrings
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: ServerUtilities
dotnet_method: CopyStrings
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
copyStrings make a new slice of the same size than `src` and copy its content.
If `src` is nil, then this returns `nil`


name: parallelTaskQueue
go_file: server/util.go
go_method: parallelTaskQueue
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: ServerUtilities
dotnet_method: ParallelTaskQueue
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
parallelTaskQueue starts a number of goroutines and returns a channel
which functions can be sent to for queued parallel execution. The
goroutines will stop running when the returned channel is closed and
all queued tasks have completed. The passed in mp limits concurrency,
or a value <= 0 will default to GOMAXPROCS.


name: wsGet
go_file: server/websocket.go
go_method: wsGet
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: WebSocketHandler
dotnet_method: WsGet
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
Returns a slice containing `needed` bytes from the given buffer `buf`
starting at position `pos`, and possibly read from the given reader `r`.
When bytes are present in `buf`, the `pos` is incremented by the number
of bytes found up to `needed` and the new position is returned. If not
enough bytes are found, the bytes found in `buf` are copied to the returned
slice and the remaning bytes are read from `r`.


name: client.wsRead
go_file: server/websocket.go
go_class: client
go_method: wsRead
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: ClientConnection
dotnet_method: WsRead
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
Returns a slice of byte slices corresponding to payload of websocket frames.
The byte slice `buf` is filled with bytes from the connection's read loop.
This function will decode the frame headers and unmask the payload(s).
It is possible that the returned slices point to the given `buf` slice, so
`buf` should not be overwritten until the returned slices have been parsed.

Client lock MUST NOT be held on entry.


name: wsReadInfo.decompress
go_file: server/websocket.go
go_class: wsReadInfo
go_method: decompress
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: WsReadInfo
dotnet_method: Decompress
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
decompress decompresses the collected buffers.
The size of the decompressed buffer will be limited to the `mpay` value.
If, while decompressing, the resulting uncompressed buffer exceeds this
limit, the decompression stops and an empty buffer and the ErrMaxPayload
error are returned.


name: wsCreateFrameHeader
go_file: server/websocket.go
go_method: wsCreateFrameHeader
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: WebSocketHandler
dotnet_method: WsCreateFrameHeader
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
Create the frame header.
Encodes the frame type and optional compression flag, and the size of the payload.


name: client.wsEnqueueControlMessageLocked
go_file: server/websocket.go
go_class: client
go_method: wsEnqueueControlMessageLocked
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: ClientConnection
dotnet_method: WsEnqueueControlMessageLocked
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
Enqueues a websocket control message.
If the control message is a wsCloseMessage, then marks this client
has having sent the close message (since only one should be sent).
This will prevent the generic closeConnection() to enqueue one.

Client lock held on entry.


name: client.wsEnqueueCloseMessage
go_file: server/websocket.go
go_class: client
go_method: wsEnqueueCloseMessage
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: ClientConnection
dotnet_method: WsEnqueueCloseMessage
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
Enqueues a websocket close message with a status mapped from the given `reason`.

Client lock held on entry


name: client.wsHandleProtocolError
go_file: server/websocket.go
go_class: client
go_method: wsHandleProtocolError
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: ClientConnection
dotnet_method: WsHandleProtocolError
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
Create and then enqueue a close message with a protocol error and the
given message. This is invoked when parsing websocket frames.

Lock MUST NOT be held on entry.


name: wsCreateCloseMessage
go_file: server/websocket.go
go_method: wsCreateCloseMessage
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: WebSocketHandler
dotnet_method: WsCreateCloseMessage
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
Create a close message with the given `status` and `body`.
If the `body` is more than the maximum allows control frame payload size,
it is truncated and "..." is added at the end (as a hint that message
is not complete).


name: Server.wsUpgrade
go_file: server/websocket.go
go_class: Server
go_method: wsUpgrade
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: NatsServer
dotnet_method: WsUpgrade
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
Process websocket client handshake. On success, returns the raw net.Conn that
will be used to create a *client object.
Invoked from the HTTP server listening on websocket port.


name: wsReturnHTTPError
go_file: server/websocket.go
go_method: wsReturnHTTPError
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: WebSocketHandler
dotnet_method: WsReturnHTTPError
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
Send an HTTP error with the given `status` to the given http response writer `w`.
Return an error created based on the `reason` string.


name: srvWebsocket.checkOrigin
go_file: server/websocket.go
go_class: srvWebsocket
go_method: checkOrigin
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: SrvWebsocket
dotnet_method: CheckOrigin
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
If the server is configured to accept any origin, then this function returns
`nil` without checking if the Origin is present and valid. This is also
the case if the request does not have the Origin header.
Otherwise, this will check that the Origin matches the same origin or
any origin in the allowed list.


name: wsAcceptKey
go_file: server/websocket.go
go_method: wsAcceptKey
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: WebSocketHandler
dotnet_method: WsAcceptKey
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
Concatenate the key sent by the client with the GUID, then computes the SHA1 hash
and returns it as a based64 encoded string.


name: Server.wsConfigAuth
go_file: server/websocket.go
go_class: Server
go_method: wsConfigAuth
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: NatsServer
dotnet_method: WsConfigAuth
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
Given the websocket options, we check if any auth configuration
has been provided. If so, possibly create users/nkey users and
store them in s.websocket.users/nkeys.
Also update a boolean that indicates if auth is required for
websocket clients.
Server lock is held on entry.


name: Server.wsGetTLSConfig
go_file: server/websocket.go
go_class: Server
go_method: wsGetTLSConfig
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: NatsServer
dotnet_method: WsGetTLSConfig
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
The TLS configuration is passed to the listener when the websocket
"server" is setup. That prevents TLS configuration updates on reload
from being used. By setting this function in tls.Config.GetConfigForClient
we instruct the TLS handshake to ask for the tls configuration to be
used for a specific client. We don't care which client, we always use
the same TLS configuration.


name: Server.createWSClient
go_file: server/websocket.go
go_class: Server
go_method: createWSClient
status: deferred
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: NatsServer
dotnet_method: CreateWSClient
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-27 02:53:35
description:
This is similar to createClient() but has some modifications
specific to handle websocket clients.
The comments have been kept to minimum to reduce code size.
Check createClient() for more details.


name: node10.addChild
go_file: server/stree/node10.go
go_class: node10
go_method: addChild
status: verified
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: SubjectTreeNode10
dotnet_method: AddChild
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-26 23:53:32
description:
Currently we do not keep node10 sorted or use bitfields for traversal so just add to the end.
TODO(dlc) - We should revisit here with more detailed benchmarks.


name: node16.addChild
go_file: server/stree/node16.go
go_class: node16
go_method: addChild
status: verified
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: SubjectTreeNode16
dotnet_method: AddChild
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-26 23:53:32
description:
Currently we do not keep node16 sorted or use bitfields for traversal so just add to the end.
TODO(dlc) - We should revisit here with more detailed benchmarks.


name: genParts
go_file: server/stree/parts.go
go_method: genParts
status: verified
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: SubjectTreeParts
dotnet_method: GenParts
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-26 23:53:32
description:
genParts will break a filter subject up into parts.
We need to break this up into chunks based on wildcards, either pwc '*' or fwc '>'.
We do not care about other tokens per se, just parts that are separated by wildcards with an optional end fwc.


name: .Match
go_file: server/stree/stree.go
go_method: Match
status: verified
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: SubjectTree
dotnet_method: Match
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-26 23:53:32
description:
Match will match against a subject that can have wildcards and invoke the callback func for each matched value.


name: .MatchUntil
go_file: server/stree/stree.go
go_method: MatchUntil
status: verified
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: SubjectTree
dotnet_method: MatchUntil
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-26 23:53:32
description:
MatchUntil will match against a subject that can have wildcards and invoke
the callback func for each matched value.
Returning false from the callback will stop matching immediately.
Returns true if matching ran to completion, false if callback stopped it early.


name: .IterOrdered
go_file: server/stree/stree.go
go_method: IterOrdered
status: verified
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: SubjectTree
dotnet_method: IterOrdered
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-26 23:53:32
description:
IterOrdered will walk all entries in the SubjectTree lexicographically. The callback can return false to terminate the walk.


name: .IterFast
go_file: server/stree/stree.go
go_method: IterFast
status: verified
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: SubjectTree
dotnet_method: IterFast
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-26 23:53:32
description:
IterFast will walk all entries in the SubjectTree with no guarantees of ordering. The callback can return false to terminate the walk.


name: .delete
go_file: server/stree/stree.go
go_method: delete
status: verified
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: SubjectTree
dotnet_method: DeleteInternal
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-26 23:53:32
description:
internal function to recursively find the leaf to delete. Will do compaction if the item is found and removed.


name: .match
go_file: server/stree/stree.go
go_method: match
status: verified
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: SubjectTree
dotnet_method: MatchInternal
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-26 23:53:32
description:
Internal function which can be called recursively to match all leaf nodes to a given filter subject which
once here has been decomposed to parts. These parts only care about wildcards, both pwc and fwc.
Returns false if the callback requested to stop matching.


name: LazyIntersect
go_file: server/stree/stree.go
go_method: LazyIntersect
status: verified
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: SubjectTree
dotnet_method: LazyIntersect
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-26 23:53:32
description:
LazyIntersect iterates the smaller of the two provided subject trees and
looks for matching entries in the other. It is lazy in that it does not
aggressively optimize against repeated walks, but is considerably faster
in most cases than intersecting against a potentially large sublist.


name: IntersectGSL
go_file: server/stree/stree.go
go_method: IntersectGSL
status: verified
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: SubjectTree
dotnet_method: IntersectGSL
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-26 23:53:32
description:
IntersectGSL will match all items in the given subject tree that
have interest expressed in the given sublist. The callback will only be called
once for each subject, regardless of overlapping subscriptions in the sublist.


name: hasInterestForTokens
go_file: server/stree/stree.go
go_method: hasInterestForTokens
status: verified
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: SubjectTree
dotnet_method: HasInterestForTokens
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-26 23:53:32
description:
The subject tree can return partial tokens so we need to check starting interest
only from whole tokens when we encounter a tsep.


name: pivot
go_file: server/stree/util.go
go_method: pivot
status: verified
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: SubjectTreeUtilities
dotnet_method: Pivot
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-26 23:53:32
description:
Can return 127 (DEL) if we have all the subject as prefixes.
We used to use 0, but when that was in the subject would cause infinite recursion in some situations.


name: HashWheel.ExpireTasks
go_file: server/thw/thw.go
go_class: HashWheel
go_method: ExpireTasks
status: verified
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: TimeHashWheel
dotnet_method: ExpireTasks
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-26 23:53:33
description:
ExpireTasks processes all expired tasks using a callback, but only expires a task if the callback returns true.


name: HashWheel.GetNextExpiration
go_file: server/thw/thw.go
go_class: HashWheel
go_method: GetNextExpiration
status: verified
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: TimeHashWheel
dotnet_method: GetNextExpiration
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-26 23:53:33
description:
GetNextExpiration returns the earliest expiration time before the given time.
Returns math.MaxInt64 if no expirations exist before the specified time.


name: HashWheel.Encode
go_file: server/thw/thw.go
go_class: HashWheel
go_method: Encode
status: verified
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: TimeHashWheel
dotnet_method: Encode
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-26 23:53:33
description:
Encode writes out the contents of the THW into a binary snapshot
and returns it. The high seq number is included in the snapshot and will
be returned on decode.


name: HashWheel.Decode
go_file: server/thw/thw.go
go_class: HashWheel
go_method: Decode
status: verified
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: TimeHashWheel
dotnet_method: Decode
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-26 23:53:33
description:
Decode snapshots a binary-encoded THW and replaces the contents of this
THW with them. Returns the high seq number from the snapshot.


name: regenerateSRK
description: Gets/Regenerates the Storage Root Key (SRK) from the TPM. Caller MUST flush this handle when done.
go_file: server/tpm/js_ek_tpm_windows.go
go_method: regenerateSRK
status: verified
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: TpmKeyProvider
dotnet_method: RegenerateSRK
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-26 23:53:34
notes:
Windows-only Tpm2Lib internal helper; cross-platform entry point handles PlatformNotSupportedException


name: writeTPMKeysToFile
go_file: server/tpm/js_ek_tpm_windows.go
go_method: writeTPMKeysToFile
status: verified
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: TpmKeyProvider
dotnet_method: WriteTPMKeysToFile
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-26 23:53:34
description:
Writes the private and public blobs to disk in a single file. If the directory does
not exist, it will be created. If the file already exists it will be overwritten.

notes:
Windows-only Tpm2Lib internal helper; cross-platform entry point handles PlatformNotSupportedException


name: readTPMKeysFromFile
go_file: server/tpm/js_ek_tpm_windows.go
go_method: readTPMKeysFromFile
status: verified
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: TpmKeyProvider
dotnet_method: ReadTPMKeysFromFile
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-26 23:53:34
description:
Reads the private and public blobs from a single file. If the file does not exist,
or the file cannot be read and the keys decoded, an error is returned.

notes:
Windows-only Tpm2Lib internal helper; cross-platform entry point handles PlatformNotSupportedException


name: createAndSealJsEncryptionKey
go_file: server/tpm/js_ek_tpm_windows.go
go_method: createAndSealJsEncryptionKey
status: verified
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: TpmKeyProvider
dotnet_method: CreateAndSealJsEncryptionKey
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-26 23:53:34
description:
Creates a new JetStream encryption key, seals it to the TPM, and saves the public and
private blobs to disk in a JSON encoded file. The key is returned as a string.


name: unsealJsEncrpytionKey
go_file: server/tpm/js_ek_tpm_windows.go
go_method: unsealJsEncrpytionKey
status: verified
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: TpmKeyProvider
dotnet_method: UnsealJsEncrpytionKey
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-26 23:53:34
description:
Unseals the JetStream encryption key from the TPM with the provided keys.
The key is returned as a string.


name: LoadJetStreamEncryptionKeyFromTPM
go_file: server/tpm/js_ek_tpm_windows.go
go_method: LoadJetStreamEncryptionKeyFromTPM
status: verified
dotnet_project: ZB.MOM.NatsNet.Server
dotnet_class: TpmKeyProvider
dotnet_method: LoadJetStreamEncryptionKeyFromTPM
created_at: 2026-02-26 12:04:36
updated_at: 2026-02-26 23:53:34
description:
LoadJetStreamEncryptionKeyFromTPM loads the JetStream encryption key from the TPM.
If the keyfile does not exist, a key will be created and sealed. Public and private blobs
used to decrypt the key in future sessions will be saved to disk in the file provided.
The key will be unsealed and returned only with the correct password and PCR value.


