History will return all values for the key.
(key string, opts ...WatchOpt)
| 937 | |
| 938 | // History will return all values for the key. |
| 939 | func (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 |
| 961 | type watcher struct { |
nothing calls this directly
no test coverage detected