MCPcopy
hub / github.com/nats-io/nats.go / connect

Function connect

test/compat_test.go:513–524  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

511}
512
513func connect(t *testing.T) *nats.Conn {
514 t.Helper()
515 natsURL := os.Getenv("NATS_URL")
516 if natsURL == "" {
517 natsURL = nats.DefaultURL
518 }
519 nc, err := nats.Connect(natsURL, nats.Timeout(1*time.Hour))
520 if err != nil {
521 t.Fatalf("Error connecting to NATS: %v", err)
522 }
523 return nc
524}
525
526func connectJS(t *testing.T) (*nats.Conn, nats.JetStreamContext) {
527 nc := connect(t)

Calls 3

ConnectMethod · 0.80
FatalfMethod · 0.80
TimeoutMethod · 0.65

Tested by

no test coverage detected