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

Function ExampleConn_FlushTimeout

example_test.go:170–183  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

168}
169
170func ExampleConn_FlushTimeout() {
171 nc, _ := nats.Connect(nats.DefaultURL)
172 defer nc.Close()
173
174 msg := &nats.Msg{Subject: "foo", Reply: "bar", Data: []byte("Hello World!")}
175 for i := 0; i < 1000; i++ {
176 nc.PublishMsg(msg)
177 }
178 // Only wait for up to 1 second for Flush
179 err := nc.FlushTimeout(1 * time.Second)
180 if err == nil {
181 // Everything has been processed by the server for nc *Conn.
182 }
183}
184
185func ExampleConn_Request() {
186 nc, _ := nats.Connect(nats.DefaultURL)

Callers

nothing calls this directly

Calls 4

ConnectMethod · 0.80
PublishMsgMethod · 0.65
CloseMethod · 0.45
FlushTimeoutMethod · 0.45

Tested by

no test coverage detected