本文整理匯總了Golang中launchpad/net/juju-core/state/multiwatcher.Store.Update方法的典型用法代碼示例。如果您正苦於以下問題:Golang Store.Update方法的具體用法?Golang Store.Update怎麽用?Golang Store.Update使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類launchpad/net/juju-core/state/multiwatcher.Store
的用法示例。
在下文中一共展示了Store.Update方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: updated
func (u *backingUnit) updated(st *State, store *multiwatcher.Store, id interface{}) error {
info := ¶ms.UnitInfo{
Name: u.Name,
Service: u.Service,
Series: u.Series,
PublicAddress: u.PublicAddress,
PrivateAddress: u.PrivateAddress,
MachineId: u.MachineId,
Ports: u.Ports,
}
if u.CharmURL != nil {
info.CharmURL = u.CharmURL.String()
}
oldInfo := store.Get(info.EntityId())
if oldInfo == nil {
// We're adding the entry for the first time,
// so fetch the associated unit status.
sdoc, err := getStatus(st, unitGlobalKey(u.Name))
if err != nil {
return err
}
info.Status = sdoc.Status
info.StatusInfo = sdoc.StatusInfo
} else {
// The entry already exists, so preserve the current status.
oldInfo := oldInfo.(*params.UnitInfo)
info.Status = oldInfo.Status
info.StatusInfo = oldInfo.StatusInfo
}
store.Update(info)
return nil
}