Connection Name

    {% tabs %} {% tab title=”Go” %}

    {% endtab %}

    {% tab title=”Java” %}

    1. server("nats://demo.nats.io:4222").
    2. connectionName("API Name Option Example"). // Set Name
    3. build();
    4. Connection nc = Nats.connect(options);
    5. // Do something with the connection
    6. nc.close();

    {% tab title=”JavaScript” %}

    {% endtab %}

    {% tab title=”Python” %}

    1. nc = NATS()
    2. servers=["nats://demo.nats.io:4222"],
    3. name="API Name Option Example")
    4. # Do something with the connection
    5. await nc.close()

    {% tab title=”Ruby” %}

    {% endtab %}

    {% tab title=”C” %}

    1. natsConnection *conn = NULL;
    2. natsOptions *opts = NULL;
    3. natsStatus s = NATS_OK;
    4. if (s == NATS_OK)
    5. s = natsOptions_SetName(opts, "API Name Option Example");
    6. if (s == NATS_OK)
    7. s = natsConnection_Connect(&conn, opts);
    8. (...)
    9. // Destroy objects that were created
    10. natsOptions_Destroy(opts);