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

Function ExampleConn_ForceReconnect

example_test.go:92–103  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

90}
91
92func ExampleConn_ForceReconnect() {
93 nc, _ := nats.Connect(nats.DefaultURL)
94 defer nc.Close()
95
96 nc.Subscribe("foo", func(m *nats.Msg) {
97 fmt.Printf("Received a message: %s\n", string(m.Data))
98 })
99
100 // Reconnect to the server.
101 // the subscription will be recreated after the reconnect.
102 nc.ForceReconnect()
103}
104
105// This Example shows a synchronous subscriber.
106func ExampleConn_SubscribeSync() {

Callers

nothing calls this directly

Calls 4

ConnectMethod · 0.80
ForceReconnectMethod · 0.80
SubscribeMethod · 0.65
CloseMethod · 0.45

Tested by

no test coverage detected