• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Golang instancepoller.NewAPI函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/juju/juju/api/instancepoller.NewAPI函数的典型用法代码示例。如果您正苦于以下问题:Golang NewAPI函数的具体用法?Golang NewAPI怎么用?Golang NewAPI使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了NewAPI函数的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: TestWatchEnvironMachinesSuccess

func (s *InstancePollerSuite) TestWatchEnvironMachinesSuccess(c *gc.C) {
	// We're not testing the watcher logic here as it's already tested elsewhere.
	var numFacadeCalls int
	var numWatcherCalls int
	expectResult := params.StringsWatchResult{
		StringsWatcherId: "42",
		Changes:          []string{"foo", "bar"},
	}
	watcherFunc := func(caller base.APICaller, result params.StringsWatchResult) watcher.StringsWatcher {
		numWatcherCalls++
		c.Check(caller, gc.NotNil)
		c.Check(result, jc.DeepEquals, expectResult)
		return nil
	}
	s.PatchValue(instancepoller.NewStringsWatcher, watcherFunc)

	apiCaller := successAPICaller(c, "WatchEnvironMachines", nil, expectResult, &numFacadeCalls)

	api := instancepoller.NewAPI(apiCaller)
	w, err := api.WatchEnvironMachines()
	c.Assert(err, jc.ErrorIsNil)
	c.Assert(numFacadeCalls, gc.Equals, 1)
	c.Assert(numWatcherCalls, gc.Equals, 1)
	c.Assert(w, gc.IsNil)
}
开发者ID:imoapps,项目名称:juju,代码行数:25,代码来源:instancepoller_test.go


示例2: start

func (config ManifoldConfig) start(context dependency.Context) (worker.Worker, error) {
	var clock clock.Clock
	if err := context.Get(config.ClockName, &clock); err != nil {
		return nil, errors.Trace(err)
	}
	var environ environs.Environ
	if err := context.Get(config.EnvironName, &environ); 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 := instancepoller.NewAPI(apiCaller)

	w, err := NewWorker(Config{
		Clock:   clock,
		Delay:   config.Delay,
		Facade:  facade,
		Environ: environ,
	})
	if err != nil {
		return nil, errors.Trace(err)
	}
	return w, nil
}
开发者ID:bac,项目名称:juju,代码行数:27,代码来源:manifold.go


示例3: manifoldStart

// manifoldStart creates an instancepoller worker, given a base.APICaller.
func manifoldStart(apiCaller base.APICaller) (worker.Worker, error) {
	api := instancepoller.NewAPI(apiCaller)
	w, err := NewWorker(api)
	if err != nil {
		return nil, errors.Trace(err)
	}
	return w, nil
}
开发者ID:exekias,项目名称:juju,代码行数:9,代码来源:manifold.go


示例4: TestWatchEnvironMachinesClientError

func (s *InstancePollerSuite) TestWatchEnvironMachinesClientError(c *gc.C) {
	var called int
	apiCaller := clientErrorAPICaller(c, "WatchEnvironMachines", nil, &called)
	api := instancepoller.NewAPI(apiCaller)
	w, err := api.WatchEnvironMachines()
	c.Assert(err, gc.ErrorMatches, "client error!")
	c.Assert(w, gc.IsNil)
	c.Assert(called, gc.Equals, 1)
}
开发者ID:imoapps,项目名称:juju,代码行数:9,代码来源:instancepoller_test.go


示例5: TestEnvironConfigClientError

func (s *InstancePollerSuite) TestEnvironConfigClientError(c *gc.C) {
	var called int
	apiCaller := clientErrorAPICaller(c, "EnvironConfig", nil, &called)
	api := instancepoller.NewAPI(apiCaller)
	cfg, err := api.EnvironConfig()
	c.Assert(err, gc.ErrorMatches, "client error!")
	c.Assert(cfg, gc.IsNil)
	c.Assert(called, gc.Equals, 1)
}
开发者ID:imoapps,项目名称:juju,代码行数:9,代码来源:instancepoller_test.go


示例6: TestWatchForEnvironConfigChangesClientError

func (s *InstancePollerSuite) TestWatchForEnvironConfigChangesClientError(c *gc.C) {
	// We're not testing the success case as we're not patching the
	// NewNotifyWatcher call the embedded EnvironWatcher is calling.
	var called int
	apiCaller := clientErrorAPICaller(c, "WatchForEnvironConfigChanges", nil, &called)

	api := instancepoller.NewAPI(apiCaller)
	w, err := api.WatchForEnvironConfigChanges()
	c.Assert(err, gc.ErrorMatches, "client error!")
	c.Assert(called, gc.Equals, 1)
	c.Assert(w, gc.IsNil)
}
开发者ID:imoapps,项目名称:juju,代码行数:12,代码来源:instancepoller_test.go


示例7: TestWatchEnvironMachinesServerError

func (s *InstancePollerSuite) TestWatchEnvironMachinesServerError(c *gc.C) {
	var called int
	expectedResults := params.StringsWatchResult{
		Error: apiservertesting.ServerError("server boom!"),
	}
	apiCaller := successAPICaller(c, "WatchEnvironMachines", nil, expectedResults, &called)

	api := instancepoller.NewAPI(apiCaller)
	w, err := api.WatchEnvironMachines()
	c.Assert(err, gc.ErrorMatches, "server boom!")
	c.Assert(called, gc.Equals, 1)
	c.Assert(w, gc.IsNil)
}
开发者ID:imoapps,项目名称:juju,代码行数:13,代码来源:instancepoller_test.go


示例8: TestNewAPI

func (s *InstancePollerSuite) TestNewAPI(c *gc.C) {
	var called int
	apiCaller := clientErrorAPICaller(c, "Life", nil, &called)
	api := instancepoller.NewAPI(apiCaller)
	c.Check(api, gc.NotNil)
	c.Check(called, gc.Equals, 0)

	// Nothing happens until we actually call something else.
	m, err := api.Machine(names.MachineTag{})
	c.Assert(err, gc.ErrorMatches, "client error!")
	c.Assert(m, gc.IsNil)
	c.Assert(called, gc.Equals, 1)
}
开发者ID:imoapps,项目名称:juju,代码行数:13,代码来源:instancepoller_test.go


示例9: TestEnvironConfigServerError

func (s *InstancePollerSuite) TestEnvironConfigServerError(c *gc.C) {
	var called int
	expectResults := params.EnvironConfigResult{
		Config: params.EnvironConfig{"type": "foo"},
	}
	apiCaller := successAPICaller(c, "EnvironConfig", nil, expectResults, &called)

	api := instancepoller.NewAPI(apiCaller)
	cfg, err := api.EnvironConfig()
	c.Assert(err, gc.NotNil) // the actual error doesn't matter
	c.Assert(called, gc.Equals, 1)
	c.Assert(cfg, gc.IsNil)
}
开发者ID:imoapps,项目名称:juju,代码行数:13,代码来源:instancepoller_test.go


示例10: TestEnvironConfigSuccess

func (s *InstancePollerSuite) TestEnvironConfigSuccess(c *gc.C) {
	var called int
	expectedConfig := coretesting.EnvironConfig(c)
	expectedResults := params.EnvironConfigResult{
		Config: params.EnvironConfig(expectedConfig.AllAttrs()),
	}
	apiCaller := successAPICaller(c, "EnvironConfig", nil, expectedResults, &called)

	api := instancepoller.NewAPI(apiCaller)
	cfg, err := api.EnvironConfig()
	c.Assert(err, jc.ErrorIsNil)
	c.Assert(called, gc.Equals, 1)
	c.Assert(cfg, jc.DeepEquals, expectedConfig)
}
开发者ID:imoapps,项目名称:juju,代码行数:14,代码来源:instancepoller_test.go


示例11: TestMachineCallsLife

func (s *InstancePollerSuite) TestMachineCallsLife(c *gc.C) {
	// We have tested separately the Life method, here we just check
	// it's called internally.
	var called int
	expectedResults := params.LifeResults{
		Results: []params.LifeResult{{Life: "working"}},
	}
	apiCaller := successAPICaller(c, "Life", entitiesArgs, expectedResults, &called)
	api := instancepoller.NewAPI(apiCaller)
	m, err := api.Machine(names.NewMachineTag("42"))
	c.Assert(err, jc.ErrorIsNil)
	c.Assert(called, gc.Equals, 1)
	c.Assert(m.Life(), gc.Equals, params.Life("working"))
	c.Assert(m.Id(), gc.Equals, "42")
}
开发者ID:imoapps,项目名称:juju,代码行数:15,代码来源:instancepoller_test.go


示例12: InstancePoller

// InstancePoller returns access to the InstancePoller API
func (st *State) InstancePoller() *instancepoller.API {
	return instancepoller.NewAPI(st)
}
开发者ID:Pankov404,项目名称:juju,代码行数:4,代码来源:state.go


示例13: TestNewAPIWithNilCaller

func (s *InstancePollerSuite) TestNewAPIWithNilCaller(c *gc.C) {
	panicFunc := func() { instancepoller.NewAPI(nil) }
	c.Assert(panicFunc, gc.PanicMatches, "caller is nil")
}
开发者ID:imoapps,项目名称:juju,代码行数:4,代码来源:instancepoller_test.go



注:本文中的github.com/juju/juju/api/instancepoller.NewAPI函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang instancepoller.NewMachine函数代码示例发布时间:2022-05-23
下一篇:
Golang imagemetadata.NewClient函数代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap