Examples on how to assign a particular name to a NATS.io connection.
Programmming languages:
While creating a connection to NATS, you can provide client connection name.
This is how it looks like in Go:
nc, err := nats.Connect("demo.nats.io", nats.Name("currency-conversion-app"))
Via the NATS monitoring endpoint, you can see all connected clients, including their names.
PS: The NATS team offers a demo server at demo.nats.io
. See http://demo.nats.io:8222/connz.
$ curl http://127.0.0.1:8222/connz
{
[...]
"connections": [
{
"ip": "172.17.0.1",
"port": 57046,
[...]
"lang": "go",
"version": "1.11.0"
}
]
}
$ curl http://127.0.0.1:8222/connz
{
[...]
"connections": [
{
"ip": "172.17.0.1",
"port": 57054,
[...]
"name": "currency-conversion-app",
"lang": "go",
"version": "1.11.0"
}
]
}
Read the original blog post your database connection deserves a name @ andygrunwald.com.
Additionally, you can check out the projects README.