本文整理汇总了Golang中github.com/snapcore/snapd/overlord/state.State.NewLane方法的典型用法代码示例。如果您正苦于以下问题:Golang State.NewLane方法的具体用法?Golang State.NewLane怎么用?Golang State.NewLane使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/snapcore/snapd/overlord/state.State
的用法示例。
在下文中一共展示了State.NewLane方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: UpdateMany
// UpdateMany updates everything from the given list of names that the
// store says is updateable. If the list is empty, update everything.
// Note that the state must be locked by the caller.
func UpdateMany(st *state.State, names []string, userID int) ([]string, []*state.TaskSet, error) {
user, err := userFromUserID(st, userID)
if err != nil {
return nil, nil, err
}
updates, stateByID, err := refreshCandidates(st, names, user)
if err != nil {
return nil, nil, err
}
if ValidateRefreshes != nil && len(updates) != 0 {
updates, err = ValidateRefreshes(st, updates, userID)
if err != nil {
// not doing "refresh all" report the error
if len(names) != 0 {
return nil, nil, err
}
// doing "refresh all", log the problems
logger.Noticef("cannot refresh some snaps: %v", err)
}
}
updated := make([]string, 0, len(updates))
tasksets := make([]*state.TaskSet, 0, len(updates))
for _, update := range updates {
snapst := stateByID[update.SnapID]
ss := &SnapSetup{
Channel: snapst.Channel,
UserID: userID,
Flags: snapst.Flags.ForSnapSetup(),
DownloadInfo: &update.DownloadInfo,
SideInfo: &update.SideInfo,
}
ts, err := doInstall(st, snapst, ss)
if err != nil {
if len(names) == 0 {
// doing "refresh all", just skip this snap
logger.Noticef("cannot refresh snap %q: %v", update.Name(), err)
continue
}
return nil, nil, err
}
ts.JoinLane(st.NewLane())
updated = append(updated, update.Name())
tasksets = append(tasksets, ts)
}
return updated, tasksets, nil
}