本文整理汇总了Golang中github.com/juju/juju/apiserver/common.RegisterStandardFacade函数的典型用法代码示例。如果您正苦于以下问题:Golang RegisterStandardFacade函数的具体用法?Golang RegisterStandardFacade怎么用?Golang RegisterStandardFacade使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了RegisterStandardFacade函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: TestFindMethodCachesFacades
func (r *rootSuite) TestFindMethodCachesFacades(c *gc.C) {
srvRoot := apiserver.TestingApiRoot(nil)
defer common.Facades.Discard("my-counting-facade", 0)
defer common.Facades.Discard("my-counting-facade", 1)
var count int64
newCounter := func(
*state.State, *common.Resources, common.Authorizer,
) (
*countingType, error,
) {
count += 1
return &countingType{count: count, id: ""}, nil
}
common.RegisterStandardFacade("my-counting-facade", 0, newCounter)
common.RegisterStandardFacade("my-counting-facade", 1, newCounter)
// The first time we call FindMethod, it should lookup a facade, and
// request a new object.
caller, err := srvRoot.FindMethod("my-counting-facade", 0, "Count")
c.Assert(err, jc.ErrorIsNil)
assertCallResult(c, caller, "", "1")
// The second time we ask for a method on the same facade, it should
// reuse that object, rather than creating another instance
caller, err = srvRoot.FindMethod("my-counting-facade", 0, "AltCount")
c.Assert(err, jc.ErrorIsNil)
assertCallResult(c, caller, "", "ALT-1")
// But when we ask for a different version, we should get a new
// instance
caller, err = srvRoot.FindMethod("my-counting-facade", 1, "Count")
c.Assert(err, jc.ErrorIsNil)
assertCallResult(c, caller, "", "2")
// But it, too, should be cached
caller, err = srvRoot.FindMethod("my-counting-facade", 1, "AltCount")
c.Assert(err, jc.ErrorIsNil)
assertCallResult(c, caller, "", "ALT-2")
}
开发者ID:imoapps,项目名称:juju,代码行数:35,代码来源:root_test.go
示例2: init
func init() {
common.RegisterStandardFacade("Application", 1, newAPI)
// Facade version 2 adds support for the ConfigSettings
// and StorageConstraints fields in SetCharm.
common.RegisterStandardFacade("Application", 2, newAPI)
}
开发者ID:bac,项目名称:juju,代码行数:7,代码来源:application.go
示例3: init
func init() {
common.RegisterStandardFacade("Provisioner", 1, NewProvisionerAPI)
// Version 1 has the same set of methods as 0, with the same
// signatures, but its ProvisioningInfo returns additional
// information. Clients may require version 1 so that they
// receive this additional information; otherwise they are
// compatible.
common.RegisterStandardFacade("Provisioner", 2, NewProvisionerAPI)
}
开发者ID:AlexisBruemmer,项目名称:juju,代码行数:10,代码来源:provisioner.go
示例4: init
func init() {
common.RegisterStandardFacade(
FacadeName,
2,
NewLeadershipServiceFacade,
)
}
开发者ID:AlexisBruemmer,项目名称:juju,代码行数:7,代码来源:leadership.go
示例5: registerPublicFacade
func (c payloads) registerPublicFacade() {
common.RegisterStandardFacade(
payload.ComponentName,
0,
c.newPublicFacade,
)
}
开发者ID:imoapps,项目名称:juju,代码行数:7,代码来源:payload.go
示例6: init
func init() {
common.RegisterStandardFacade(
"LifeFlag", 1,
func(st *state.State, resources facade.Resources, authorizer facade.Authorizer) (*Facade, error) {
return NewFacade(st, resources, authorizer)
},
)
}
开发者ID:bac,项目名称:juju,代码行数:8,代码来源:shim.go
示例7: init
func init() {
common.RegisterStandardFacade(
"Singular", 1,
func(st *state.State, _ facade.Resources, auth facade.Authorizer) (*Facade, error) {
return NewFacade(st, auth)
},
)
}
开发者ID:bac,项目名称:juju,代码行数:8,代码来源:singular.go
示例8: init
func init() {
common.RegisterStandardFacade(
FacadeName,
1,
NewLeadershipServiceFn(leaderMgr),
)
}
开发者ID:Pankov404,项目名称:juju,代码行数:8,代码来源:leadership.go
示例9: TestRegisterStandardFacade
func (s *facadeRegistrySuite) TestRegisterStandardFacade(c *gc.C) {
common.SanitizeFacades(s)
common.RegisterStandardFacade("testing", 0, validFactory)
wrapped, err := common.Facades.GetFactory("testing", 0)
c.Assert(err, gc.IsNil)
val, err := wrapped(nil, nil, nil, "")
c.Assert(err, gc.IsNil)
c.Check(*(val.(*int)), gc.Equals, 100)
}
开发者ID:kapilt,项目名称:juju,代码行数:9,代码来源:registry_test.go
示例10: TestRegisterStandardFacadePanic
func (s *facadeRegistrySuite) TestRegisterStandardFacadePanic(c *gc.C) {
common.SanitizeFacades(s)
c.Assert(
func() { common.RegisterStandardFacade("badtest", 0, noArgs) },
gc.PanicMatches,
`function ".*noArgs" does not take 3 parameters and return 2`)
_, err := common.Facades.GetFactory("badtest", 0)
c.Assert(err, jc.Satisfies, errors.IsNotFound)
c.Assert(err, gc.ErrorMatches, `badtest\(0\) not found`)
}
开发者ID:kapilt,项目名称:juju,代码行数:10,代码来源:registry_test.go
示例11: registerPublicFacade
// registerPublicFacade adds the resources public API facade
// to the API server.
func (r resources) registerPublicFacade() {
if !markRegistered(resource.ComponentName, "public-facade") {
return
}
common.RegisterStandardFacade(
resource.ComponentName,
server.Version,
r.newPublicFacade,
)
api.RegisterFacadeVersion(resource.ComponentName, server.Version)
}
开发者ID:OSBI,项目名称:juju,代码行数:14,代码来源:resource.go
示例12: registerPublicFacade
func (c payloads) registerPublicFacade() {
if !markRegistered(payload.ComponentName, "public-facade") {
return
}
// NOTE: facade is also defined in api/facadeversions.go.
const version = 1
common.RegisterStandardFacade(
payload.FacadeName,
version,
c.newPublicFacade,
)
}
开发者ID:bac,项目名称:juju,代码行数:13,代码来源:payload.go
示例13: TestFindMethodHandlesInterfaceTypes
func (r *rootSuite) TestFindMethodHandlesInterfaceTypes(c *gc.C) {
srvRoot := apiserver.TestingApiRoot(nil)
defer common.Facades.Discard("my-interface-facade", 0)
defer common.Facades.Discard("my-interface-facade", 1)
common.RegisterStandardFacade("my-interface-facade", 0, func(
*state.State, *common.Resources, common.Authorizer,
) (
smallInterface, error,
) {
return &firstImpl{}, nil
})
common.RegisterStandardFacade("my-interface-facade", 1, func(
*state.State, *common.Resources, common.Authorizer,
) (
smallInterface, error,
) {
return &secondImpl{}, nil
})
caller, err := srvRoot.FindMethod("my-interface-facade", 0, "OneMethod")
c.Assert(err, jc.ErrorIsNil)
assertCallResult(c, caller, "", "first")
caller2, err := srvRoot.FindMethod("my-interface-facade", 1, "OneMethod")
c.Assert(err, jc.ErrorIsNil)
assertCallResult(c, caller2, "", "second")
// We should *not* be able to see AMethod or ZMethod
caller, err = srvRoot.FindMethod("my-interface-facade", 1, "AMethod")
c.Check(err, gc.FitsTypeOf, (*rpcreflect.CallNotImplementedError)(nil))
c.Check(err, gc.ErrorMatches,
`no such request - method my-interface-facade\(1\)\.AMethod is not implemented`)
c.Check(caller, gc.IsNil)
caller, err = srvRoot.FindMethod("my-interface-facade", 1, "ZMethod")
c.Check(err, gc.FitsTypeOf, (*rpcreflect.CallNotImplementedError)(nil))
c.Check(err, gc.ErrorMatches,
`no such request - method my-interface-facade\(1\)\.ZMethod is not implemented`)
c.Check(caller, gc.IsNil)
}
开发者ID:imoapps,项目名称:juju,代码行数:36,代码来源:root_test.go
示例14: TestFindMethodUnknownVersion
func (r *rootSuite) TestFindMethodUnknownVersion(c *gc.C) {
srvRoot := apiserver.TestingApiRoot(nil)
defer common.Facades.Discard("my-testing-facade", 0)
myGoodFacade := func(
*state.State, *common.Resources, common.Authorizer,
) (
*testingType, error,
) {
return &testingType{}, nil
}
common.RegisterStandardFacade("my-testing-facade", 0, myGoodFacade)
caller, err := srvRoot.FindMethod("my-testing-facade", 1, "Exposed")
c.Check(caller, gc.IsNil)
c.Check(err, gc.FitsTypeOf, (*rpcreflect.CallNotImplementedError)(nil))
c.Check(err, gc.ErrorMatches, `unknown version \(1\) of interface "my-testing-facade"`)
}
开发者ID:imoapps,项目名称:juju,代码行数:16,代码来源:root_test.go
示例15: registerPublicFacade
// registerPublicFacade adds the resources public API facade
// to the API server.
func (r resources) registerPublicFacade() {
if !markRegistered(resource.ComponentName, "public-facade") {
return
}
common.RegisterStandardFacade(
resource.ComponentName,
server.Version,
resourceadapters.NewPublicFacade,
)
coreapi.RegisterFacadeVersion(resource.ComponentName, server.Version)
common.RegisterAPIModelEndpoint(api.HTTPEndpointPattern, apihttp.HandlerSpec{
Constraints: apihttp.HandlerConstraints{
AuthKind: names.UserTagKind,
StrictValidation: true,
ControllerModelOnly: false,
},
NewHandler: resourceadapters.NewUploadHandler,
})
}
开发者ID:AlexisBruemmer,项目名称:juju,代码行数:23,代码来源:resource.go
示例16: init
func init() {
common.RegisterStandardFacade("ModelManager", 2, newFacade)
}
开发者ID:bac,项目名称:juju,代码行数:3,代码来源:modelmanager.go
示例17: init
func init() {
common.RegisterStandardFacade("MetricsDebug", 1, NewMetricsDebugAPI)
}
开发者ID:exekias,项目名称:juju,代码行数:3,代码来源:metricsdebug.go
示例18: init
func init() {
common.RegisterStandardFacade("Controller", 1, NewControllerAPI)
}
开发者ID:imoapps,项目名称:juju,代码行数:3,代码来源:controller.go
示例19: init
func init() {
common.RegisterStandardFacade("Service", 3, NewAPI)
}
开发者ID:exekias,项目名称:juju,代码行数:3,代码来源:service.go
示例20: init
func init() {
common.RegisterStandardFacade("Resumer", 2, NewResumerAPI)
}
开发者ID:AlexisBruemmer,项目名称:juju,代码行数:3,代码来源:resumer.go
注:本文中的github.com/juju/juju/apiserver/common.RegisterStandardFacade函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论