nc, err := nats.Connect(nats.DefaultURL)
if err != nil {
log.Fatal(err)
}
defer nc.Close()
// Do something with the connection
Connection nc = Nats.connect();
// Do something with the connection
nc.close();
const nc = await connect();
// Do something with the connection
doSomething();
// When done close it
await nc.close();
nc = NATS()
await nc.connect()
# Do something with the connection
await nc.close()
require 'nats/client'
NATS.start do |nc|
# Do something with the connection
# Close the connection
nc.close
end
natsConnection *conn = NULL;
natsStatus s;
s = natsConnection_ConnectTo(&conn, NATS_DEFAULT_URL);
if (s != NATS_OK)
// handle error
// Destroy connection, no-op if conn is NULL.
natsConnection_Destroy(conn);