本文整理汇总了Golang中github.com/juju/juju/worker/uniter/relation.StateDir.State方法的典型用法代码示例。如果您正苦于以下问题:Golang StateDir.State方法的具体用法?Golang StateDir.State怎么用?Golang StateDir.State使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/juju/juju/worker/uniter/relation.StateDir
的用法示例。
在下文中一共展示了StateDir.State方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: NewRelationer
// NewRelationer creates a new Relationer. The unit will not join the
// relation until explicitly requested.
func NewRelationer(ru *apiuniter.RelationUnit, dir *relation.StateDir, hooks chan<- hook.Info) *Relationer {
return &Relationer{
ctx: NewContextRelation(ru, dir.State().Members),
ru: ru,
dir: dir,
hooks: hooks,
}
}
示例2: assertState
func assertState(c *gc.C, dir *relation.StateDir, relsdir string, relationId int, members msi, pending string, deleted bool) {
expect := &relation.State{
RelationId: relationId,
Members: map[string]int64(members),
ChangedPending: pending,
}
c.Assert(dir.State(), gc.DeepEquals, expect)
if deleted {
_, err := os.Stat(filepath.Join(relsdir, strconv.Itoa(relationId)))
c.Assert(err, jc.Satisfies, os.IsNotExist)
} else {
fresh, err := relation.ReadStateDir(relsdir, relationId)
c.Assert(err, jc.ErrorIsNil)
c.Assert(fresh.State(), gc.DeepEquals, expect)
}
}