當前位置: 首頁>>代碼示例>>Golang>>正文


Golang etcdserverpb.DeleteRangeRequest類代碼示例

本文整理匯總了Golang中github.com/coreos/etcd/etcdserver/etcdserverpb.DeleteRangeRequest的典型用法代碼示例。如果您正苦於以下問題:Golang DeleteRangeRequest類的具體用法?Golang DeleteRangeRequest怎麽用?Golang DeleteRangeRequest使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了DeleteRangeRequest類的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: applyDeleteRange

func applyDeleteRange(txnID int64, kv dstorage.KV, dr *pb.DeleteRangeRequest) (*pb.DeleteRangeResponse, error) {
	resp := &pb.DeleteRangeResponse{}
	resp.Header = &pb.ResponseHeader{}

	var (
		n   int64
		rev int64
		err error
	)

	if isGteRange(dr.RangeEnd) {
		dr.RangeEnd = []byte{}
	}

	if txnID != noTxn {
		n, rev, err = kv.TxnDeleteRange(txnID, dr.Key, dr.RangeEnd)
		if err != nil {
			return nil, err
		}
	} else {
		n, rev = kv.DeleteRange(dr.Key, dr.RangeEnd)
	}

	resp.Deleted = n
	resp.Header.Revision = rev
	return resp, nil
}
開發者ID:oywc410,項目名稱:MYPG,代碼行數:27,代碼來源:v3demo_server.go

示例2: DeleteRange

func (a *applierV3backend) DeleteRange(txnID int64, dr *pb.DeleteRangeRequest) (*pb.DeleteRangeResponse, error) {
	resp := &pb.DeleteRangeResponse{}
	resp.Header = &pb.ResponseHeader{}

	var (
		n   int64
		rev int64
		err error
	)

	if isGteRange(dr.RangeEnd) {
		dr.RangeEnd = []byte{}
	}

	if txnID != noTxn {
		n, rev, err = a.s.KV().TxnDeleteRange(txnID, dr.Key, dr.RangeEnd)
		if err != nil {
			return nil, err
		}
	} else {
		n, rev = a.s.KV().DeleteRange(dr.Key, dr.RangeEnd)
	}

	resp.Deleted = n
	resp.Header.Revision = rev
	return resp, nil
}
開發者ID:CodeJuan,項目名稱:kubernetes,代碼行數:27,代碼來源:apply.go

示例3: applyDeleteRange

func applyDeleteRange(txnID int64, kv mvcc.KV, req *etcdserverpb.DeleteRangeRequest) (*etcdserverpb.DeleteRangeResponse, error) {
	resp := &etcdserverpb.DeleteRangeResponse{}
	resp.Header = &etcdserverpb.ResponseHeader{}

	var (
		n   int64
		rev int64
		err error
	)

	if isGteRange(req.RangeEnd) {
		req.RangeEnd = []byte{}
	}

	if txnID != noTxn {
		n, rev, err = kv.TxnDeleteRange(txnID, req.Key, req.RangeEnd)
		if err != nil {
			return nil, err
		}
	} else {
		n, rev = kv.DeleteRange(req.Key, req.RangeEnd)
	}

	resp.Deleted = n
	resp.Header.Revision = rev
	return resp, nil
}
開發者ID:weaveworks,項目名稱:mesh,代碼行數:27,代碼來源:etcd_store.go

示例4: DeleteRange

func (a *applierV3backend) DeleteRange(txnID int64, dr *pb.DeleteRangeRequest) (*pb.DeleteRangeResponse, error) {
	resp := &pb.DeleteRangeResponse{}
	resp.Header = &pb.ResponseHeader{}

	var (
		n   int64
		rev int64
		err error
	)

	if isGteRange(dr.RangeEnd) {
		dr.RangeEnd = []byte{}
	}

	var rr *mvcc.RangeResult
	if dr.PrevKv {
		if txnID != noTxn {
			rr, err = a.s.KV().TxnRange(txnID, dr.Key, dr.RangeEnd, mvcc.RangeOptions{})
			if err != nil {
				return nil, err
			}
		} else {
			rr, err = a.s.KV().Range(dr.Key, dr.RangeEnd, mvcc.RangeOptions{})
			if err != nil {
				return nil, err
			}
		}
	}

	if txnID != noTxn {
		n, rev, err = a.s.KV().TxnDeleteRange(txnID, dr.Key, dr.RangeEnd)
		if err != nil {
			return nil, err
		}
	} else {
		n, rev = a.s.KV().DeleteRange(dr.Key, dr.RangeEnd)
	}

	resp.Deleted = n
	if rr != nil {
		for i := range rr.KVs {
			resp.PrevKvs = append(resp.PrevKvs, &rr.KVs[i])
		}
	}
	resp.Header.Revision = rev
	return resp, nil
}
開發者ID:mgurevin,項目名稱:etcd,代碼行數:47,代碼來源:apply.go


注:本文中的github.com/coreos/etcd/etcdserver/etcdserverpb.DeleteRangeRequest類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。