ListKeys will return all keys. Note: On buckets with a large number of keys and frequent writes, duplicate keys may be reported during listing.
(opts ...WatchOpt)
| 903 | // Note: On buckets with a large number of keys and frequent writes, |
| 904 | // duplicate keys may be reported during listing. |
| 905 | func (kv *kvs) ListKeys(opts ...WatchOpt) (KeyLister, error) { |
| 906 | opts = append(opts, IgnoreDeletes(), MetaOnly()) |
| 907 | watcher, err := kv.WatchAll(opts...) |
| 908 | if err != nil { |
| 909 | return nil, err |
| 910 | } |
| 911 | kl := &keyLister{watcher: watcher, keys: make(chan string, 256)} |
| 912 | |
| 913 | go func() { |
| 914 | defer close(kl.keys) |
| 915 | defer watcher.Stop() |
| 916 | for entry := range watcher.Updates() { |
| 917 | if entry == nil { |
| 918 | return |
| 919 | } |
| 920 | kl.keys <- entry.Key() |
| 921 | } |
| 922 | }() |
| 923 | return kl, nil |
| 924 | } |
| 925 | |
| 926 | func (kl *keyLister) Keys() <-chan string { |
| 927 | return kl.keys |