blob: f40ba8edc22b596cae720f4f5e90230315a73a8d [file] [log] [blame]
khenaidood948f772021-08-11 17:49:24 -04001// 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 (
18 "github.com/coreos/etcd/lease"
19)
20
21type readView struct{ kv KV }
22
23func (rv *readView) FirstRev() int64 {
24 tr := rv.kv.Read()
25 defer tr.End()
26 return tr.FirstRev()
27}
28
29func (rv *readView) Rev() int64 {
30 tr := rv.kv.Read()
31 defer tr.End()
32 return tr.Rev()
33}
34
35func (rv *readView) Range(key, end []byte, ro RangeOptions) (r *RangeResult, err error) {
36 tr := rv.kv.Read()
37 defer tr.End()
38 return tr.Range(key, end, ro)
39}
40
41type writeView struct{ kv KV }
42
43func (wv *writeView) DeleteRange(key, end []byte) (n, rev int64) {
44 tw := wv.kv.Write()
45 defer tw.End()
46 return tw.DeleteRange(key, end)
47}
48
49func (wv *writeView) Put(key, value []byte, lease lease.LeaseID) (rev int64) {
50 tw := wv.kv.Write()
51 defer tw.End()
52 return tw.Put(key, value, lease)
53}