k3s/vendor/github.com/rancher/kine/pkg/server/compact.go

35 lines
893 B
Go
Raw Normal View History

2019-08-22 05:12:46 +00:00
package server
import (
"context"
2019-12-12 01:27:03 +00:00
"go.etcd.io/etcd/etcdserver/etcdserverpb"
2019-08-22 05:12:46 +00:00
)
func isCompact(txn *etcdserverpb.TxnRequest) bool {
return len(txn.Compare) == 1 &&
txn.Compare[0].Target == etcdserverpb.Compare_VERSION &&
txn.Compare[0].Result == etcdserverpb.Compare_EQUAL &&
len(txn.Success) == 1 &&
txn.Success[0].GetRequestPut() != nil &&
len(txn.Failure) == 1 &&
txn.Failure[0].GetRequestRange() != nil &&
string(txn.Compare[0].Key) == "compact_rev_key"
}
func (l *LimitedServer) compact(ctx context.Context) (*etcdserverpb.TxnResponse, error) {
return &etcdserverpb.TxnResponse{
Header: &etcdserverpb.ResponseHeader{},
Succeeded: true,
Responses: []*etcdserverpb.ResponseOp{
{
Response: &etcdserverpb.ResponseOp_ResponsePut{
ResponsePut: &etcdserverpb.PutResponse{
Header: &etcdserverpb.ResponseHeader{},
},
},
},
},
}, nil
}