blob: bd2e77729ff2c3d280545e361057968d3e72e633 [file] [log] [blame]
khenaidoo59ce9dd2019-11-11 13:05:32 -05001// 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
15package mvcc
16
17import "go.etcd.io/etcd/lease"
18
19type readView struct{ kv KV }
20
21func (rv *readView) FirstRev() int64 {
22 tr := rv.kv.Read()
23 defer tr.End()
24 return tr.FirstRev()
25}
26
27func (rv *readView) Rev() int64 {
28 tr := rv.kv.Read()
29 defer tr.End()
30 return tr.Rev()
31}
32
33func (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
39type writeView struct{ kv KV }
40
41func (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
47func (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}