本文整理汇总了Golang中github.com/coreos/fleet/registry.Registry.LeaseRole方法的典型用法代码示例。如果您正苦于以下问题:Golang Registry.LeaseRole方法的具体用法?Golang Registry.LeaseRole怎么用?Golang Registry.LeaseRole使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/coreos/fleet/registry.Registry
的用法示例。
在下文中一共展示了Registry.LeaseRole方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: ensureLeader
// ensureLeader will attempt to renew a non-nil Lease, falling back to
// acquiring a new Lease on the lead engine role.
func ensureLeader(prev registry.Lease, reg registry.Registry, machID string) (cur registry.Lease) {
if prev != nil {
err := prev.Renew(engineRoleLeasePeriod)
if err == nil {
cur = prev
return
} else {
log.Errorf("Engine leadership could not be renewed: %v", err)
}
}
var err error
cur, err = reg.LeaseRole(engineRoleName, machID, engineRoleLeasePeriod)
if err != nil {
log.Errorf("Failed acquiring engine leadership: %v", err)
} else if cur == nil {
log.V(1).Infof("Unable to acquire engine leadership")
} else {
log.Infof("Acquired engine leadership")
}
return
}
示例2: ensureLeader
// ensureLeader will attempt to renew a non-nil Lease, falling back to
// acquiring a new Lease on the lead engine role.
func ensureLeader(prev registry.Lease, reg registry.Registry, machID string, ttl time.Duration) (cur registry.Lease) {
if prev != nil {
err := prev.Renew(ttl)
if err == nil {
log.V(1).Infof("Engine leadership renewed")
cur = prev
return
} else {
log.Errorf("Engine leadership lost, renewal failed: %v", err)
}
}
var err error
cur, err = reg.LeaseRole(engineRoleName, machID, ttl)
if err != nil {
log.Errorf("Engine leadership acquisition failed: %v", err)
} else if cur == nil {
log.V(1).Infof("Unable to acquire engine leadership")
} else {
log.Infof("Engine leadership acquired")
}
return
}