本文整理匯總了Golang中github.com/coreos/fleet/registry.Registry.RemoveUnitState方法的典型用法代碼示例。如果您正苦於以下問題:Golang Registry.RemoveUnitState方法的具體用法?Golang Registry.RemoveUnitState怎麽用?Golang Registry.RemoveUnitState使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/coreos/fleet/registry.Registry
的用法示例。
在下文中一共展示了Registry.RemoveUnitState方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: newPublisher
// newPublisher returns a publishFunc that publishes a single UnitState
// by the given name to the provided Registry, with the given TTL
func newPublisher(reg registry.Registry, ttl time.Duration) publishFunc {
return func(name string, us *unit.UnitState) {
if us == nil {
log.V(1).Infof("Destroying UnitState(%s) in Registry", name)
err := reg.RemoveUnitState(name)
if err != nil {
log.Errorf("Failed to destroy UnitState(%s) in Registry: %v", name, err)
}
} else {
// Sanity check - don't want to publish incomplete UnitStates
// TODO(jonboulle): consider teasing apart a separate UnitState-like struct
// so we can rely on a UnitState always being fully hydrated?
// See https://github.com/coreos/fleet/issues/720
//if len(us.UnitHash) == 0 {
// log.Errorf("Refusing to push UnitState(%s), no UnitHash: %#v", name, us)
if len(us.MachineID) == 0 {
log.Errorf("Refusing to push UnitState(%s), no MachineID: %#v", name, us)
} else {
log.V(1).Infof("Pushing UnitState(%s) to Registry: %#v", name, us)
reg.SaveUnitState(name, us, ttl)
}
}
}
}