本文整理汇总了Golang中github.com/wallyworld/core/state.RelationUnit类的典型用法代码示例。如果您正苦于以下问题:Golang RelationUnit类的具体用法?Golang RelationUnit怎么用?Golang RelationUnit使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了RelationUnit类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: changeSettings
func changeSettings(c *gc.C, ru *state.RelationUnit) {
node, err := ru.Settings()
c.Assert(err, gc.IsNil)
value, _ := node.Get("value")
v, _ := value.(int)
node.Set("value", v+1)
_, err = node.Write()
c.Assert(err, gc.IsNil)
}
开发者ID:jameinel,项目名称:core,代码行数:9,代码来源:relationunit_test.go
示例2: setSettings
func setSettings(c *gc.C, ru *state.RelationUnit, settings map[string]interface{}) {
node, err := ru.Settings()
c.Assert(err, gc.IsNil)
for _, k := range node.Keys() {
node.Delete(k)
}
node.Update(settings)
_, err = node.Write()
c.Assert(err, gc.IsNil)
}
开发者ID:jameinel,项目名称:core,代码行数:10,代码来源:util_test.go
示例3: watchOneRelationUnit
func (u *UniterAPI) watchOneRelationUnit(relUnit *state.RelationUnit) (params.RelationUnitsWatchResult, error) {
watch := relUnit.Watch()
// Consume the initial event and forward it to the result.
if changes, ok := <-watch.Changes(); ok {
return params.RelationUnitsWatchResult{
RelationUnitsWatcherId: u.resources.Register(watch),
Changes: changes,
}, nil
}
return params.RelationUnitsWatchResult{}, watcher.MustErr(watch)
}
开发者ID:jameinel,项目名称:core,代码行数:11,代码来源:uniter.go
示例4: checkRemoteUnit
func (u *UniterAPI) checkRemoteUnit(relUnit *state.RelationUnit, remoteUnitTag string) (string, error) {
// Make sure the unit is indeed remote.
if remoteUnitTag == u.auth.GetAuthTag() {
return "", common.ErrPerm
}
// Check remoteUnit is indeed related. Note that we don't want to actually get
// the *Unit, because it might have been removed; but its relation settings will
// persist until the relation itself has been removed (and must remain accessible
// because the local unit's view of reality may be time-shifted).
_, remoteUnitName, err := names.ParseTag(remoteUnitTag, names.UnitTagKind)
if err != nil {
return "", err
}
remoteServiceName := names.UnitService(remoteUnitName)
rel := relUnit.Relation()
_, err = rel.RelatedEndpoints(remoteServiceName)
if err != nil {
return "", common.ErrPerm
}
return remoteUnitName, nil
}
开发者ID:jameinel,项目名称:core,代码行数:21,代码来源:uniter.go
示例5: assertInScope
func (s *uniterSuite) assertInScope(c *gc.C, relUnit *state.RelationUnit, inScope bool) {
ok, err := relUnit.InScope()
c.Assert(err, gc.IsNil)
c.Assert(ok, gc.Equals, inScope)
}
开发者ID:jameinel,项目名称:core,代码行数:5,代码来源:uniter_test.go
示例6: assertNotInScope
func assertNotInScope(c *gc.C, ru *state.RelationUnit) {
ok, err := ru.InScope()
c.Assert(err, gc.IsNil)
c.Assert(ok, jc.IsFalse)
}
开发者ID:jameinel,项目名称:core,代码行数:5,代码来源:relationunit_test.go
注:本文中的github.com/wallyworld/core/state.RelationUnit类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论