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

Method History

kv.go:939–958  ·  view source on GitHub ↗

History will return all values for the key.

(key string, opts ...WatchOpt)

Source from the content-addressed store, hash-verified

937
938// History will return all values for the key.
939func (kv *kvs) History(key string, opts ...WatchOpt) ([]KeyValueEntry, error) {
940 opts = append(opts, IncludeHistory())
941 watcher, err := kv.Watch(key, opts...)
942 if err != nil {
943 return nil, err
944 }
945 defer watcher.Stop()
946
947 var entries []KeyValueEntry
948 for entry := range watcher.Updates() {
949 if entry == nil {
950 break
951 }
952 entries = append(entries, entry)
953 }
954 if len(entries) == 0 {
955 return nil, ErrKeyNotFound
956 }
957 return entries, nil
958}
959
960// Implementation for Watch
961type watcher struct {

Callers

nothing calls this directly

Calls 4

WatchMethod · 0.95
IncludeHistoryFunction · 0.70
StopMethod · 0.65
UpdatesMethod · 0.65

Tested by

no test coverage detected