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

Method History

jetstream/kv.go:1470–1489  ·  view source on GitHub ↗

History will return all historical values for the key.

(ctx context.Context, key string, opts ...WatchOpt)

Source from the content-addressed store, hash-verified

1468
1469// History will return all historical values for the key.
1470func (kv *kvs) History(ctx context.Context, key string, opts ...WatchOpt) ([]KeyValueEntry, error) {
1471 opts = append(opts, IncludeHistory())
1472 watcher, err := kv.Watch(ctx, key, opts...)
1473 if err != nil {
1474 return nil, err
1475 }
1476 defer watcher.Stop()
1477
1478 var entries []KeyValueEntry
1479 for entry := range watcher.Updates() {
1480 if entry == nil {
1481 break
1482 }
1483 entries = append(entries, entry)
1484 }
1485 if len(entries) == 0 {
1486 return nil, ErrKeyNotFound
1487 }
1488 return entries, nil
1489}
1490
1491// Bucket returns the current bucket name.
1492func (kv *kvs) Bucket() string {

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