()
| 53 | } |
| 54 | |
| 55 | func 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 | |
| 76 | func mockWatcher_watchWithRange() { |
| 77 | fmt.Println(`PUT "foo1" : "bar1"`) |
nothing calls this directly
no test coverage detected
searching dependent graphs…