History will return all historical values for the key.
(ctx context.Context, key string, opts ...WatchOpt)
| 1468 | |
| 1469 | // History will return all historical values for the key. |
| 1470 | func (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. |
| 1492 | func (kv *kvs) Bucket() string { |
nothing calls this directly
no test coverage detected