MCPcopy
hub / github.com/nats-io/nats.go / ListKeys

Method ListKeys

kv.go:905–924  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

903// Note: On buckets with a large number of keys and frequent writes,
904// duplicate keys may be reported during listing.
905func (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
926func (kl *keyLister) Keys() <-chan string {
927 return kl.keys

Callers

nothing calls this directly

Calls 6

WatchAllMethod · 0.95
IgnoreDeletesFunction · 0.70
MetaOnlyFunction · 0.70
StopMethod · 0.65
UpdatesMethod · 0.65
KeyMethod · 0.65

Tested by

no test coverage detected