本文整理汇总了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
}