Shows different ways to create a Conn.
()
| 25 | |
| 26 | // Shows different ways to create a Conn. |
| 27 | func ExampleConnect() { |
| 28 | nc, _ := nats.Connect("demo.nats.io") |
| 29 | nc.Close() |
| 30 | |
| 31 | nc, _ = nats.Connect("nats://derek:secretpassword@demo.nats.io:4222") |
| 32 | nc.Close() |
| 33 | |
| 34 | nc, _ = nats.Connect("tls://derek:secretpassword@demo.nats.io:4443") |
| 35 | nc.Close() |
| 36 | |
| 37 | opts := nats.Options{ |
| 38 | AllowReconnect: true, |
| 39 | MaxReconnect: 10, |
| 40 | ReconnectWait: 5 * time.Second, |
| 41 | Timeout: 1 * time.Second, |
| 42 | } |
| 43 | |
| 44 | nc, _ = opts.Connect() |
| 45 | nc.Close() |
| 46 | } |
| 47 | |
| 48 | type skipTLSDialer struct { |
| 49 | dialer *net.Dialer |