当前位置: 首页>>代码示例>>Golang>>正文


Golang lease.Lessor类代码示例

本文整理汇总了Golang中github.com/coreos/etcd/lease.Lessor的典型用法代码示例。如果您正苦于以下问题:Golang Lessor类的具体用法?Golang Lessor怎么用?Golang Lessor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Lessor类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: applyLeaseCreate

func applyLeaseCreate(le lease.Lessor, lc *pb.LeaseCreateRequest) (*pb.LeaseCreateResponse, error) {
	l, err := le.Grant(lease.LeaseID(lc.ID), lc.TTL)
	resp := &pb.LeaseCreateResponse{}
	if err == nil {
		resp.ID = int64(l.ID)
		resp.TTL = l.TTL
	}
	return resp, err
}
开发者ID:oywc410,项目名称:MYPG,代码行数:9,代码来源:v3demo_server.go

示例2: applyLeaseGrant

func applyLeaseGrant(lessor lease.Lessor, req *etcdserverpb.LeaseGrantRequest) (*etcdserverpb.LeaseGrantResponse, error) {
	l, err := lessor.Grant(lease.LeaseID(req.ID), req.TTL)
	resp := &etcdserverpb.LeaseGrantResponse{}
	if err == nil {
		resp.ID = int64(l.ID)
		resp.TTL = l.TTL
	}
	return resp, err
}
开发者ID:weaveworks,项目名称:mesh,代码行数:9,代码来源:etcd_store.go

示例3: 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
}
开发者ID:Gwill,项目名称:etcd,代码行数:12,代码来源:v3demo_server.go

示例4: 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
}
开发者ID:weaveworks,项目名称:mesh,代码行数:16,代码来源:etcd_store.go

示例5: 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
}
开发者ID:oywc410,项目名称:MYPG,代码行数:24,代码来源:v3demo_server.go

示例6: 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
}
开发者ID:weaveworks,项目名称:mesh,代码行数:24,代码来源:etcd_store.go

示例7: applyLeaseRevoke

func applyLeaseRevoke(le lease.Lessor, lc *pb.LeaseRevokeRequest) (*pb.LeaseRevokeResponse, error) {
	err := le.Revoke(lease.LeaseID(lc.ID))

	return &pb.LeaseRevokeResponse{}, err
}
开发者ID:oywc410,项目名称:MYPG,代码行数:5,代码来源:v3demo_server.go

示例8: applyLeaseCreate

func applyLeaseCreate(le lease.Lessor, lc *pb.LeaseCreateRequest) (*pb.LeaseCreateResponse, error) {
	l := le.Grant(lc.TTL)

	return &pb.LeaseCreateResponse{ID: int64(l.ID), TTL: l.TTL}, nil
}
开发者ID:DonnchadhCameron,项目名称:etcd,代码行数:5,代码来源:v3demo_server.go

示例9: applyLeaseRevoke

func applyLeaseRevoke(lessor lease.Lessor, req *etcdserverpb.LeaseRevokeRequest) (*etcdserverpb.LeaseRevokeResponse, error) {
	err := lessor.Revoke(lease.LeaseID(req.ID))
	return &etcdserverpb.LeaseRevokeResponse{}, err
}
开发者ID:weaveworks,项目名称:mesh,代码行数:4,代码来源:etcd_store.go


注:本文中的github.com/coreos/etcd/lease.Lessor类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。