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

Function ExampleConn_Flush

example_test.go:156–168  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

154}
155
156func ExampleConn_Flush() {
157 nc, _ := nats.Connect(nats.DefaultURL)
158 defer nc.Close()
159
160 msg := &nats.Msg{Subject: "foo", Reply: "bar", Data: []byte("Hello World!")}
161 for i := 0; i < 1000; i++ {
162 nc.PublishMsg(msg)
163 }
164 err := nc.Flush()
165 if err == nil {
166 // Everything has been processed by the server for nc *Conn.
167 }
168}
169
170func ExampleConn_FlushTimeout() {
171 nc, _ := nats.Connect(nats.DefaultURL)

Callers

nothing calls this directly

Calls 4

ConnectMethod · 0.80
PublishMsgMethod · 0.65
CloseMethod · 0.45
FlushMethod · 0.45

Tested by

no test coverage detected