Explorar o código

mvcc: create TxnWrites from TxnRead with NewReadOnlyTxnWrite

Already used internally by mvcc, but needed by etcdserver txns.
Anthony Romano %!s(int64=8) %!d(string=hai) anos
pai
achega
da48f1feaf
Modificáronse 1 ficheiros con 3 adicións e 1 borrados
  1. 3 1
      mvcc/kv.go

+ 3 - 1
mvcc/kv.go

@@ -93,7 +93,9 @@ func (trw *txnReadWrite) DeleteRange(key, end []byte) (n, rev int64) { panic("un
 func (trw *txnReadWrite) Put(key, value []byte, lease lease.LeaseID) (rev int64) {
 	panic("unexpected Put")
 }
-func (trw *txnReadWrite) Changes() []mvccpb.KeyValue { panic("unexpected Changes") }
+func (trw *txnReadWrite) Changes() []mvccpb.KeyValue { return nil }
+
+func NewReadOnlyTxnWrite(txn TxnRead) TxnWrite { return &txnReadWrite{txn} }
 
 type KV interface {
 	ReadView