khenaidoo | 59ce9dd | 2019-11-11 13:05:32 -0500 | [diff] [blame] | 1 | // Copyright 2017 The etcd Authors |
| 2 | // |
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | // you may not use this file except in compliance with the License. |
| 5 | // You may obtain a copy of the License at |
| 6 | // |
| 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // |
| 9 | // Unless required by applicable law or agreed to in writing, software |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | // See the License for the specific language governing permissions and |
| 13 | // limitations under the License. |
| 14 | |
| 15 | package mvcc |
| 16 | |
| 17 | import "go.etcd.io/etcd/lease" |
| 18 | |
| 19 | type readView struct{ kv KV } |
| 20 | |
| 21 | func (rv *readView) FirstRev() int64 { |
| 22 | tr := rv.kv.Read() |
| 23 | defer tr.End() |
| 24 | return tr.FirstRev() |
| 25 | } |
| 26 | |
| 27 | func (rv *readView) Rev() int64 { |
| 28 | tr := rv.kv.Read() |
| 29 | defer tr.End() |
| 30 | return tr.Rev() |
| 31 | } |
| 32 | |
| 33 | func (rv *readView) Range(key, end []byte, ro RangeOptions) (r *RangeResult, err error) { |
| 34 | tr := rv.kv.Read() |
| 35 | defer tr.End() |
| 36 | return tr.Range(key, end, ro) |
| 37 | } |
| 38 | |
| 39 | type writeView struct{ kv KV } |
| 40 | |
| 41 | func (wv *writeView) DeleteRange(key, end []byte) (n, rev int64) { |
| 42 | tw := wv.kv.Write() |
| 43 | defer tw.End() |
| 44 | return tw.DeleteRange(key, end) |
| 45 | } |
| 46 | |
| 47 | func (wv *writeView) Put(key, value []byte, lease lease.LeaseID) (rev int64) { |
| 48 | tw := wv.kv.Write() |
| 49 | defer tw.End() |
| 50 | return tw.Put(key, value, lease) |
| 51 | } |