本文整理匯總了Golang中launchpad/net/juju-core/state.Machine.WatchUnits方法的典型用法代碼示例。如果您正苦於以下問題:Golang Machine.WatchUnits方法的具體用法?Golang Machine.WatchUnits怎麽用?Golang Machine.WatchUnits使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類launchpad/net/juju-core/state.Machine
的用法示例。
在下文中一共展示了Machine.WatchUnits方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: WatchUnits
// WatchUnits starts a StringsWatcher to watch all units deployed to
// any machine passed in args, in order to track which ones should be
// deployed or recalled.
func (d *DeployerAPI) WatchUnits(args params.Entities) (params.StringsWatchResults, error) {
result := params.StringsWatchResults{
Results: make([]params.StringsWatchResult, len(args.Entities)),
}
for i, entity := range args.Entities {
err := common.ErrPerm
if d.authorizer.AuthOwner(entity.Tag) {
var machine *state.Machine
machine, err = d.st.Machine(state.MachineIdFromTag(entity.Tag))
if err == nil {
watch := machine.WatchUnits()
// Consume the initial event and forward it to the result.
if changes, ok := <-watch.Changes(); ok {
result.Results[i].StringsWatcherId = d.resources.Register(watch)
result.Results[i].Changes = changes
} else {
err = watcher.MustErr(watch)
}
}
}
result.Results[i].Error = common.ServerError(err)
}
return result, nil
}