本文整理汇总了Golang中github.com/coreos/etcd/lease.Lessor.Lookup方法的典型用法代码示例。如果您正苦于以下问题:Golang Lessor.Lookup方法的具体用法?Golang Lessor.Lookup怎么用?Golang Lessor.Lookup使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/coreos/etcd/lease.Lessor
的用法示例。
在下文中一共展示了Lessor.Lookup方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: checkRequestLeases
func checkRequestLeases(le lease.Lessor, reqs []*pb.RequestUnion) error {
for _, requ := range reqs {
preq := requ.RequestPut
if preq == nil || lease.LeaseID(preq.Lease) == lease.NoLease {
continue
}
if l := le.Lookup(lease.LeaseID(preq.Lease)); l == nil {
return lease.ErrLeaseNotFound
}
}
return nil
}
示例2: checkRequestLeases
func checkRequestLeases(le lease.Lessor, reqs []*etcdserverpb.RequestUnion) error {
for _, requ := range reqs {
tv, ok := requ.Request.(*etcdserverpb.RequestUnion_RequestPut)
if !ok {
continue
}
preq := tv.RequestPut
if preq == nil || lease.LeaseID(preq.Lease) == lease.NoLease {
continue
}
if l := le.Lookup(lease.LeaseID(preq.Lease)); l == nil {
return lease.ErrLeaseNotFound
}
}
return nil
}
示例3: applyPut
func applyPut(txnID int64, kv dstorage.KV, le lease.Lessor, p *pb.PutRequest) (*pb.PutResponse, error) {
resp := &pb.PutResponse{}
resp.Header = &pb.ResponseHeader{}
var (
rev int64
err error
)
if txnID != noTxn {
rev, err = kv.TxnPut(txnID, p.Key, p.Value, lease.LeaseID(p.Lease))
if err != nil {
return nil, err
}
} else {
leaseID := lease.LeaseID(p.Lease)
if leaseID != lease.NoLease {
if l := le.Lookup(leaseID); l == nil {
return nil, lease.ErrLeaseNotFound
}
}
rev = kv.Put(p.Key, p.Value, leaseID)
}
resp.Header.Revision = rev
return resp, nil
}
示例4: applyPut
func applyPut(txnID int64, kv mvcc.KV, lessor lease.Lessor, req *etcdserverpb.PutRequest) (*etcdserverpb.PutResponse, error) {
resp := &etcdserverpb.PutResponse{}
resp.Header = &etcdserverpb.ResponseHeader{}
var (
rev int64
err error
)
if txnID != noTxn {
rev, err = kv.TxnPut(txnID, req.Key, req.Value, lease.LeaseID(req.Lease))
if err != nil {
return nil, err
}
} else {
leaseID := lease.LeaseID(req.Lease)
if leaseID != lease.NoLease {
if l := lessor.Lookup(leaseID); l == nil {
return nil, lease.ErrLeaseNotFound
}
}
rev = kv.Put(req.Key, req.Value, leaseID)
}
resp.Header.Revision = rev
return resp, nil
}