连接到默认服务器
Some libraries also provide a special way to connect to a default url, which is generally nats://localhost:4222:
nc, err := nats.Connect(nats.DefaultURL)
if err != nil {
log.Fatal(err)
}
defer nc.Close()
// Do something with the connectionConnection 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()最后更新于