This Example shows a synchronous subscriber.
()
| 104 | |
| 105 | // This Example shows a synchronous subscriber. |
| 106 | func ExampleConn_SubscribeSync() { |
| 107 | nc, _ := nats.Connect(nats.DefaultURL) |
| 108 | defer nc.Close() |
| 109 | |
| 110 | sub, _ := nc.SubscribeSync("foo") |
| 111 | m, err := sub.NextMsg(1 * time.Second) |
| 112 | if err == nil { |
| 113 | fmt.Printf("Received a message: %s\n", string(m.Data)) |
| 114 | } else { |
| 115 | fmt.Println("NextMsg timed out.") |
| 116 | } |
| 117 | } |
| 118 | |
| 119 | func ExampleSubscription_NextMsg() { |
| 120 | nc, _ := nats.Connect(nats.DefaultURL) |
nothing calls this directly
no test coverage detected