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

Method Keys

kv.go:875–895  ·  view source on GitHub ↗

Keys will return all keys, filtering out any duplicates.

(opts ...WatchOpt)

Source from the content-addressed store, hash-verified

873
874// Keys will return all keys, filtering out any duplicates.
875func (kv *kvs) Keys(opts ...WatchOpt) ([]string, error) {
876 opts = append(opts, IgnoreDeletes(), MetaOnly())
877 watcher, err := kv.WatchAll(opts...)
878 if err != nil {
879 return nil, err
880 }
881 defer watcher.Stop()
882
883 var keys []string
884 for entry := range watcher.Updates() {
885 if entry == nil {
886 break
887 }
888 keys = append(keys, entry.Key())
889 }
890 if len(keys) == 0 {
891 return nil, ErrNoKeysFound
892 }
893 slices.Sort(keys)
894 return slices.Compact(keys), nil
895}
896
897type keyLister struct {
898 watcher KeyWatcher

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