Module nats

Simplified NATS (https://nats.io) client

Functions

Nats.subscribe (subject, callbackFn)
Subscribe to a nats subject the callback will be envoked whenever a message on the subject is received

Parameters:

  • subject string The topic to subscribe to
  • callbackFn function

Returns:

    string subscriptionId the subscription ID to unsubscribe with
Nats.subscribeSync (subject)
Subscribe synchronously to a nats subject use nats.nextMsg to get the messages

Parameters:

  • subject

Returns:

    string subscriptionId the subscription ID to unsubscribe with
Nats.nextMsg (subscriptionId)
Get the next message after a synchronous subscription

Parameters:

  • subscriptionId string the subscriptionId to get the next message
Nats.publish (subject, payload)
Publish a nats message with subject and payload The payload is a binary string

Parameters:

  • subject
  • payload
Nats.request (subject, payload)
Publish a message and wait for a response The payload is a binary string

Parameters:

  • subject
  • payload
Nats.requestWithTimeout (subject, payload, timeoutInMs)
Publish a message and wait for a response with a timeout The payload is a binary string

Parameters:

  • subject
  • payload
  • timeoutInMs
Nats.store (bucket, key, value)
Store a value in a NATS key value bucket

Parameters:

  • bucket
  • key
  • value
Nats.read (bucket, key)
Read a value from a NATS key value bucket

Parameters:

  • bucket
  • key
Nats.unsubsribe (subscriptionId)
Unsubsribe the last subscription

Parameters:

  • subscriptionId string
Nats.unsubsribeAll ()
Unsubsribe all
Nats.split (subject)
Split a nats subject into its parts

Parameters:

  • subject
generated by LDoc 1.5.0 Last updated 2025-06-05 18:17:56