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

Function ExampleWatcher_watchWithPrefix

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

Source from the content-addressed store, hash-verified

53}
54
55func ExampleWatcher_watchWithPrefix() {
56 forUnitTestsRunInMockedContext(mockWatcher_watchWithPrefix, func() {
57 cli, err := clientv3.New(clientv3.Config{
58 Endpoints: exampleEndpoints(),
59 DialTimeout: dialTimeout,
60 })
61 if err != nil {
62 log.Fatal(err)
63 }
64 defer cli.Close()
65
66 rch := cli.Watch(context.Background(), "foo", clientv3.WithPrefix())
67 for wresp := range rch {
68 for _, ev := range wresp.Events {
69 fmt.Printf("%s %q : %q\n", ev.Type, ev.Kv.Key, ev.Kv.Value)
70 }
71 }
72 })
73 // PUT "foo1" : "bar"
74}
75
76func mockWatcher_watchWithRange() {
77 fmt.Println(`PUT "foo1" : "bar1"`)

Callers

nothing calls this directly

Calls 6

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

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…