MCPcopy
hub / github.com/etcd-io/etcd / ExampleWatcher_watchWithProgressNotify

Function ExampleWatcher_watchWithProgressNotify

client/v3/example_watch_test.go:128–159  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

126}
127
128func ExampleWatcher_watchWithProgressNotify() {
129 forUnitTestsRunInMockedContext(mockWatcher_watchWithProgressNotify, func() {
130 cli, err := clientv3.New(clientv3.Config{
131 Endpoints: exampleEndpoints(),
132 DialTimeout: dialTimeout,
133 })
134 if err != nil {
135 log.Fatal(err)
136 }
137
138 rch := cli.Watch(context.Background(), "foo", clientv3.WithProgressNotify())
139 closedch := make(chan bool)
140 go func() {
141 // This assumes that cluster is configured with frequent WatchProgressNotifyInterval
142 // e.g. WatchProgressNotifyInterval: 200 * time.Millisecond.
143 time.Sleep(time.Second)
144 err := cli.Close()
145 if err != nil {
146 log.Fatal(err)
147 }
148 close(closedch)
149 }()
150 wresp := <-rch
151 fmt.Println("wresp.IsProgressNotify:", wresp.IsProgressNotify())
152 <-closedch
153 })
154
155 // TODO: Rather wresp.IsProgressNotify: true should be expected
156
157 // Output:
158 // wresp.IsProgressNotify: true
159}

Callers

nothing calls this directly

Calls 6

IsProgressNotifyMethod · 0.80
exampleEndpointsFunction · 0.70
FatalMethod · 0.65
WatchMethod · 0.65
CloseMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…