Connect will attempt to connect to the NATS system. The url can contain username/password semantics. e.g. nats://derek:pass@localhost:4222 Comma separated arrays are also supported, e.g. urlA, urlB. Options start with the defaults but can be overridden. To connect to a NATS Server's websocket port,
(url string, options ...Option)
| 974 | // To connect to a NATS Server's websocket port, use the `ws` or `wss` scheme, such as |
| 975 | // `ws://localhost:8080`. Note that websocket schemes cannot be mixed with others (nats/tls). |
| 976 | func Connect(url string, options ...Option) (*Conn, error) { |
| 977 | opts := GetDefaultOptions() |
| 978 | opts.Servers = processUrlString(url) |
| 979 | for _, opt := range options { |
| 980 | if opt != nil { |
| 981 | if err := opt(&opts); err != nil { |
| 982 | return nil, err |
| 983 | } |
| 984 | } |
| 985 | } |
| 986 | return opts.Connect() |
| 987 | } |
| 988 | |
| 989 | // Options that can be passed to Connect. |
| 990 |