本文整理汇总了Golang中github.com/juju/juju/api/base.APICaller类的典型用法代码示例。如果您正苦于以下问题:Golang APICaller类的具体用法?Golang APICaller怎么用?Golang APICaller使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了APICaller类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: start
// start is a StartFunc for a Worker manifold.
func (config ManifoldConfig) start(context dependency.Context) (worker.Worker, error) {
if err := config.validate(); err != nil {
return nil, errors.Trace(err)
}
var apiCaller base.APICaller
if err := context.Get(config.APICallerName, &apiCaller); err != nil {
return nil, errors.Trace(err)
}
facade, err := config.NewFacade(apiCaller)
if err != nil {
return nil, errors.Trace(err)
}
modelTag, err := apiCaller.ModelTag()
if err != nil {
return nil, errors.Trace(err)
}
worker, err := config.NewWorker(Config{
Facade: facade,
Model: modelTag.Id(),
Check: config.Check,
})
if err != nil {
return nil, errors.Trace(err)
}
return worker, nil
}
开发者ID:makyo,项目名称:juju,代码行数:27,代码来源:manifold.go
示例2: makeWatcherAPICaller
// makeWatcherAPICaller creates a watcherAPICall function for a given facade name
// and watcherId.
func makeWatcherAPICaller(caller base.APICaller, facadeName, watcherId string) watcherAPICall {
bestVersion := caller.BestFacadeVersion(facadeName)
return func(request string, result interface{}) error {
return caller.APICall(facadeName, bestVersion,
watcherId, request, nil, &result)
}
}
开发者ID:imoapps,项目名称:juju,代码行数:9,代码来源:watcher.go
示例3: newUnitFacadeClient
func (r resources) newUnitFacadeClient(unitName string, caller base.APICaller) (context.APIClient, error) {
facadeCaller := base.NewFacadeCallerForVersion(caller, context.HookContextFacade, internalserver.FacadeVersion)
httpClient, err := caller.HTTPClient()
if err != nil {
return nil, errors.Trace(err)
}
unitHTTPClient := internalclient.NewUnitHTTPClient(httpClient, unitName)
return internalclient.NewUnitFacadeClient(facadeCaller, unitHTTPClient), nil
}
开发者ID:AlexisBruemmer,项目名称:juju,代码行数:11,代码来源:resource.go
示例4: NewClient
// NewClient creates a new client for accessing the undertaker API.
func NewClient(caller base.APICaller, newWatcher NewWatcherFunc) (*Client, error) {
modelTag, ok := caller.ModelTag()
if !ok {
return nil, errors.New("undertaker client is not appropriate for controller-only API")
}
return &Client{
modelTag: modelTag,
caller: base.NewFacadeCaller(caller, "Undertaker"),
newWatcher: newWatcher,
}, nil
}
开发者ID:bac,项目名称:juju,代码行数:12,代码来源:undertaker.go
示例5: NewClient
// NewClient creates a new client for accessing the undertaker API.
func NewClient(caller base.APICaller, newWatcher NewWatcherFunc) (*Client, error) {
modelTag, err := caller.ModelTag()
if err != nil {
return nil, errors.Trace(err)
}
return &Client{
modelTag: modelTag,
caller: base.NewFacadeCaller(caller, "Undertaker"),
newWatcher: newWatcher,
}, nil
}
开发者ID:makyo,项目名称:juju,代码行数:12,代码来源:undertaker.go
示例6: NewClient
// NewClient creates a new client for accessing the metricsmanager api
func NewClient(apiCaller base.APICaller) (*Client, error) {
modelTag, err := apiCaller.ModelTag()
if err != nil {
return nil, errors.Trace(err)
}
facade := base.NewFacadeCaller(apiCaller, "MetricsManager")
return &Client{
modelTag: modelTag,
facade: facade,
}, nil
}
开发者ID:exekias,项目名称:juju,代码行数:12,代码来源:client.go
示例7: NewClient
// NewClient creates a new client for accessing the metricsmanager api
func NewClient(apiCaller base.APICaller) (*Client, error) {
modelTag, ok := apiCaller.ModelTag()
if !ok {
return nil, errors.New("metricsmanager client is not appropriate for controller-only API")
}
facade := base.NewFacadeCaller(apiCaller, "MetricsManager")
return &Client{
modelTag: modelTag,
facade: facade,
}, nil
}
开发者ID:bac,项目名称:juju,代码行数:13,代码来源:client.go
示例8: NewAPI
// NewAPI creates a new client-side machine undertaker facade.
func NewAPI(caller base.APICaller, newWatcher NewWatcherFunc) (*API, error) {
modelTag, ok := caller.ModelTag()
if !ok {
return nil, errors.New("machine undertaker client requires a model API connection")
}
api := API{
facade: base.NewFacadeCaller(caller, "MachineUndertaker"),
modelTag: modelTag,
newWatcher: newWatcher,
}
return &api, nil
}
开发者ID:bac,项目名称:juju,代码行数:13,代码来源:undertaker.go
示例9: NewAPI
// NewAPI returns a new API client for the Singular facade. It exposes methods
// for claiming and observing administration responsibility for the apiCaller's
// model, on behalf of the supplied controller machine.
func NewAPI(apiCaller base.APICaller, controllerTag names.MachineTag) (*API, error) {
controllerId := controllerTag.Id()
if !names.IsValidMachine(controllerId) {
return nil, errors.NotValidf("controller tag")
}
modelTag, ok := apiCaller.ModelTag()
if !ok {
return nil, errors.New("cannot use singular API on controller-only connection")
}
facadeCaller := base.NewFacadeCaller(apiCaller, "Singular")
return &API{
modelTag: modelTag,
controllerTag: controllerTag,
facadeCaller: facadeCaller,
}, nil
}
开发者ID:bac,项目名称:juju,代码行数:19,代码来源:api.go
示例10: NewAPI
// NewAPI returns a new API client for the Singular facade. It exposes methods
// for claiming and observing administration responsibility for the apiCaller's
// model, on behalf of the supplied controller machine.
func NewAPI(apiCaller base.APICaller, controllerTag names.MachineTag) (*API, error) {
controllerId := controllerTag.Id()
if !names.IsValidMachine(controllerId) {
return nil, errors.NotValidf("controller tag")
}
modelTag, err := apiCaller.ModelTag()
if err != nil {
return nil, errors.Trace(err)
}
facadeCaller := base.NewFacadeCaller(apiCaller, "Singular")
return &API{
modelTag: modelTag,
controllerTag: controllerTag,
facadeCaller: facadeCaller,
}, nil
}
开发者ID:pmatulis,项目名称:juju,代码行数:19,代码来源:api.go
注:本文中的github.com/juju/juju/api/base.APICaller类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论