mirror of
https://github.com/k3s-io/k3s.git
synced 2024-06-07 19:41:36 +00:00
35 lines
893 B
Go
35 lines
893 B
Go
package server
|
|
|
|
import (
|
|
"context"
|
|
|
|
"go.etcd.io/etcd/etcdserver/etcdserverpb"
|
|
)
|
|
|
|
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
|
|
}
|