glats/connection

Types

Command to send to the connection actor.

pub opaque type Command

Error returned by a NATS server.

pub type ServerError {
  Timeout
  NoResponders
  Unknown
}

Constructors

  • Timeout
  • NoResponders
  • Unknown

Connection settings for NATS connection.

pub type Settings {
  Settings(
    host: Option(String),
    port: Option(Int),
    tls: Option(Bool),
    ssl_opts: Option(Map(String, String)),
  )
}

Constructors

  • Settings(
      host: Option(String),
      port: Option(Int),
      tls: Option(Bool),
      ssl_opts: Option(Map(String, String)),
    )

Functions

pub fn publish(conn: Subject(Command), subject: String, message: String) -> Result(
  Nil,
  String,
)

Publishes a single message to NATS on a provided subject.

pub fn publish_message(conn: Subject(Command), message: Message) -> Result(
  Nil,
  String,
)

Publishes a single message to NATS using the data from a provided Message record.

pub fn request(conn: Subject(Command), subject: String, message: String) -> Result(
  Message,
  ServerError,
)

Sends a request and listens for a response synchronously.

pub fn start(settings: Settings) -> Result(
  Subject(Command),
  StartError,
)

Start an actor that handles a connection to NATS using the provided settings.

pub fn subscribe(conn: Subject(Command), receiver: Subject(
    Dynamic,
  ), subject: String) -> Result(String, String)
Search Document