Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

NATS.io logo

your NATS connection deserves a name

Examples on how to assign a particular name to a NATS.io connection.

Programmming languages:

How it works

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.

How it looks like

Before

$ curl http://127.0.0.1:8222/connz
{
  [...]
  "connections": [
    {
      "ip": "172.17.0.1",
      "port": 57046,
      [...]
      "lang": "go",
      "version": "1.11.0"
    }
  ]
}

After

$ 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"
    }
  ]
}

Don't know what this is all about?

Read the original blog post your database connection deserves a name @ andygrunwald.com.

Additionally, you can check out the projects README.