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

Golang retrystrategy.Manifold函数代码示例

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

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



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

示例1: TestInputs

func (s *ManifoldSuite) TestInputs(c *gc.C) {
	manifold := retrystrategy.Manifold(retrystrategy.ManifoldConfig{
		AgentName:     "wut",
		APICallerName: "exactly",
	})
	c.Check(manifold.Inputs, jc.DeepEquals, []string{"wut", "exactly"})
}
开发者ID:makyo,项目名称:juju,代码行数:7,代码来源:manifold_test.go


示例2: TestStartFacadeValueError

func (s *ManifoldSuite) TestStartFacadeValueError(c *gc.C) {
	manifold := retrystrategy.Manifold(retrystrategy.ManifoldConfig{
		AgentApiManifoldConfig: s.stubAgentApiManifoldConfig,
		NewFacade:              s.newFacade(&fakeFacadeErr{err: errors.New("blop")}),
	})

	w, err := manifold.Start(s.getResource)
	c.Assert(errors.Cause(err), gc.ErrorMatches, "blop")
	c.Assert(w, gc.IsNil)
}
开发者ID:AlexisBruemmer,项目名称:juju,代码行数:10,代码来源:manifold_test.go


示例3: TestStartFacadeValueError

func (s *ManifoldSuite) TestStartFacadeValueError(c *gc.C) {
	manifold := retrystrategy.Manifold(retrystrategy.ManifoldConfig{
		AgentName:     "agent",
		APICallerName: "api-caller",
		NewFacade:     s.newFacade(&fakeFacadeErr{err: errors.New("blop")}),
	})

	w, err := manifold.Start(s.context)
	c.Assert(errors.Cause(err), gc.ErrorMatches, "blop")
	c.Assert(w, gc.IsNil)
}
开发者ID:makyo,项目名称:juju,代码行数:11,代码来源:manifold_test.go


示例4: TestStartWorkerError

func (s *ManifoldSuite) TestStartWorkerError(c *gc.C) {
	manifold := retrystrategy.Manifold(retrystrategy.ManifoldConfig{
		AgentApiManifoldConfig: s.stubAgentApiManifoldConfig,
		NewFacade:              s.newFacade(&fakeFacade{}),
		NewWorker:              s.newWorker(nil, errors.New("blam")),
	})

	w, err := manifold.Start(s.getResource)
	c.Assert(err, gc.ErrorMatches, "blam")
	c.Assert(w, gc.IsNil)
}
开发者ID:AlexisBruemmer,项目名称:juju,代码行数:11,代码来源:manifold_test.go


示例5: TestStartWorkerError

func (s *ManifoldSuite) TestStartWorkerError(c *gc.C) {
	manifold := retrystrategy.Manifold(retrystrategy.ManifoldConfig{
		AgentName:     "agent",
		APICallerName: "api-caller",
		NewFacade:     s.newFacade(&fakeFacade{}),
		NewWorker:     s.newWorker(nil, errors.New("blam")),
	})

	w, err := manifold.Start(s.context)
	c.Assert(err, gc.ErrorMatches, "blam")
	c.Assert(w, gc.IsNil)
}
开发者ID:makyo,项目名称:juju,代码行数:12,代码来源:manifold_test.go


示例6: TestStartMissingAgent

func (s *ManifoldSuite) TestStartMissingAgent(c *gc.C) {
	manifold := retrystrategy.Manifold(retrystrategy.ManifoldConfig{
		AgentApiManifoldConfig: s.stubAgentApiManifoldConfig,
	})
	getResource := dt.StubGetResource(dt.StubResources{
		"wut": dt.StubResource{Error: dependency.ErrMissing},
	})

	w, err := manifold.Start(getResource)
	c.Assert(errors.Cause(err), gc.Equals, dependency.ErrMissing)
	c.Assert(w, gc.IsNil)
}
开发者ID:AlexisBruemmer,项目名称:juju,代码行数:12,代码来源:manifold_test.go


示例7: TestStartSuccess

func (s *ManifoldSuite) TestStartSuccess(c *gc.C) {
	fakeWorker := &fakeWorker{}
	manifold := retrystrategy.Manifold(retrystrategy.ManifoldConfig{
		AgentApiManifoldConfig: s.stubAgentApiManifoldConfig,
		NewFacade:              s.newFacade(&fakeFacade{}),
		NewWorker:              s.newWorker(fakeWorker, nil),
	})

	w, err := manifold.Start(s.getResource)
	c.Assert(err, jc.ErrorIsNil)
	c.Assert(w, gc.Equals, fakeWorker)
}
开发者ID:AlexisBruemmer,项目名称:juju,代码行数:12,代码来源:manifold_test.go


示例8: TestStartSuccess

func (s *ManifoldSuite) TestStartSuccess(c *gc.C) {
	fakeWorker := &fakeWorker{}
	manifold := retrystrategy.Manifold(retrystrategy.ManifoldConfig{
		AgentName:     "agent",
		APICallerName: "api-caller",
		NewFacade:     s.newFacade(&fakeFacade{}),
		NewWorker:     s.newWorker(fakeWorker, nil),
	})

	w, err := manifold.Start(s.context)
	c.Assert(err, jc.ErrorIsNil)
	c.Assert(w, gc.Equals, fakeWorker)
}
开发者ID:makyo,项目名称:juju,代码行数:13,代码来源:manifold_test.go


示例9: TestStartMissingAPI

func (s *ManifoldSuite) TestStartMissingAPI(c *gc.C) {
	manifold := retrystrategy.Manifold(retrystrategy.ManifoldConfig{
		AgentName:     "agent",
		APICallerName: "api-caller",
	})
	context := dt.StubContext(nil, map[string]interface{}{
		"agent":      s.fakeAgent,
		"api-caller": dependency.ErrMissing,
	})

	w, err := manifold.Start(context)
	c.Assert(errors.Cause(err), gc.Equals, dependency.ErrMissing)
	c.Assert(w, gc.IsNil)
}
开发者ID:makyo,项目名称:juju,代码行数:14,代码来源:manifold_test.go


示例10: TestOutputBadTarget

func (s *ManifoldSuite) TestOutputBadTarget(c *gc.C) {
	manifold := retrystrategy.Manifold(retrystrategy.ManifoldConfig{
		AgentApiManifoldConfig: s.stubAgentApiManifoldConfig,
		NewFacade:              s.newFacade(&fakeFacade{}),
		NewWorker:              retrystrategy.NewRetryStrategyWorker,
	})

	w, err := manifold.Start(s.getResource)
	s.AddCleanup(func(c *gc.C) { w.Kill() })
	c.Assert(err, jc.ErrorIsNil)

	var out interface{}
	err = manifold.Output(w, &out)
	c.Assert(err.Error(), gc.Equals, "out should be a *params.RetryStrategy; is *interface {}")
}
开发者ID:AlexisBruemmer,项目名称:juju,代码行数:15,代码来源:manifold_test.go


示例11: TestOutputBadInput

func (s *ManifoldSuite) TestOutputBadInput(c *gc.C) {
	manifold := retrystrategy.Manifold(retrystrategy.ManifoldConfig{
		AgentApiManifoldConfig: s.stubAgentApiManifoldConfig,
		NewFacade:              s.newFacade(&fakeFacade{}),
		NewWorker:              s.newWorker(&fakeWorker{}, nil),
	})

	w, err := manifold.Start(s.getResource)
	c.Assert(err, jc.ErrorIsNil)

	var out params.RetryStrategy
	err = manifold.Output(w, &out)
	c.Assert(out, gc.Equals, params.RetryStrategy{})
	c.Assert(err.Error(), gc.Equals, "in should be a *retryStrategyWorker; is *retrystrategy_test.fakeWorker")
}
开发者ID:AlexisBruemmer,项目名称:juju,代码行数:15,代码来源:manifold_test.go


示例12: TestOutputBadInput

func (s *ManifoldSuite) TestOutputBadInput(c *gc.C) {
	manifold := retrystrategy.Manifold(retrystrategy.ManifoldConfig{
		AgentName:     "agent",
		APICallerName: "api-caller",
		NewFacade:     s.newFacade(&fakeFacade{}),
		NewWorker:     s.newWorker(&fakeWorker{}, nil),
	})

	w, err := manifold.Start(s.context)
	c.Assert(err, jc.ErrorIsNil)

	var out params.RetryStrategy
	err = manifold.Output(w, &out)
	c.Assert(out, gc.Equals, params.RetryStrategy{})
	c.Assert(err.Error(), gc.Equals, "in should be a *retryStrategyWorker; is *retrystrategy_test.fakeWorker")
}
开发者ID:makyo,项目名称:juju,代码行数:16,代码来源:manifold_test.go


示例13: TestOutputSuccess

func (s *ManifoldSuite) TestOutputSuccess(c *gc.C) {
	manifold := retrystrategy.Manifold(retrystrategy.ManifoldConfig{
		AgentApiManifoldConfig: s.stubAgentApiManifoldConfig,
		NewFacade:              s.newFacade(&fakeFacade{}),
		NewWorker:              retrystrategy.NewRetryStrategyWorker,
	})

	w, err := manifold.Start(s.getResource)
	s.AddCleanup(func(c *gc.C) { w.Kill() })
	c.Assert(err, jc.ErrorIsNil)

	var out params.RetryStrategy
	err = manifold.Output(w, &out)
	c.Assert(err, jc.ErrorIsNil)
	c.Assert(out, gc.Equals, fakeStrategy)
}
开发者ID:AlexisBruemmer,项目名称:juju,代码行数:16,代码来源:manifold_test.go


示例14: TestOutputSuccess

func (s *ManifoldSuite) TestOutputSuccess(c *gc.C) {
	manifold := retrystrategy.Manifold(retrystrategy.ManifoldConfig{
		AgentName:     "agent",
		APICallerName: "api-caller",
		NewFacade:     s.newFacade(&fakeFacade{}),
		NewWorker:     retrystrategy.NewRetryStrategyWorker,
	})

	w, err := manifold.Start(s.context)
	s.AddCleanup(func(c *gc.C) { w.Kill() })
	c.Assert(err, jc.ErrorIsNil)

	var out params.RetryStrategy
	err = manifold.Output(w, &out)
	c.Assert(err, jc.ErrorIsNil)
	c.Assert(out, gc.Equals, fakeStrategy)
}
开发者ID:makyo,项目名称:juju,代码行数:17,代码来源:manifold_test.go


示例15: Manifolds

// Manifolds returns a set of co-configured manifolds covering the various
// responsibilities of a standalone unit agent. It also accepts the logSource
// argument because we haven't figured out how to thread all the logging bits
// through a dependency engine yet.
//
// Thou Shalt Not Use String Literals In This Function. Or Else.
func Manifolds(config ManifoldsConfig) dependency.Manifolds {

	// connectFilter exists to let us retry api connections immediately
	// on password change, rather than causing the dependency engine to
	// wait for a while.
	connectFilter := func(err error) error {
		cause := errors.Cause(err)
		if cause == apicaller.ErrChangedPassword {
			return dependency.ErrBounce
		} else if cause == apicaller.ErrConnectImpossible {
			return worker.ErrTerminateAgent
		}
		return err
	}

	return dependency.Manifolds{

		// The agent manifold references the enclosing agent, and is the
		// foundation stone on which most other manifolds ultimately depend.
		// (Currently, that is "all manifolds", but consider a shared clock.)
		agentName: agent.Manifold(config.Agent),

		// The machine lock manifold is a thin concurrent wrapper around an
		// FSLock in an agreed location. We expect it to be replaced with an
		// in-memory lock when the unit agent moves into the machine agent.
		machineLockName: machinelock.Manifold(machinelock.ManifoldConfig{
			AgentName: agentName,
		}),

		// The api-config-watcher manifold monitors the API server
		// addresses in the agent config and bounces when they
		// change. It's required as part of model migrations.
		apiConfigWatcherName: apiconfigwatcher.Manifold(apiconfigwatcher.ManifoldConfig{
			AgentName:          agentName,
			AgentConfigChanged: config.AgentConfigChanged,
		}),

		// The api caller is a thin concurrent wrapper around a connection
		// to some API server. It's used by many other manifolds, which all
		// select their own desired facades. It will be interesting to see
		// how this works when we consolidate the agents; might be best to
		// handle the auth changes server-side..?
		apiCallerName: apicaller.Manifold(apicaller.ManifoldConfig{
			AgentName:            agentName,
			APIConfigWatcherName: apiConfigWatcherName,
			APIOpen:              apicaller.APIOpen,
			NewConnection:        apicaller.ScaryConnect,
			Filter:               connectFilter,
		}),

		// The log sender is a leaf worker that sends log messages to some
		// API server, when configured so to do. We should only need one of
		// these in a consolidated agent.
		logSenderName: logsender.Manifold(logsender.ManifoldConfig{
			APICallerName: apiCallerName,
			LogSource:     config.LogSource,
		}),

		// The upgrader is a leaf worker that returns a specific error type
		// recognised by the unit agent, causing other workers to be stopped
		// and the agent to be restarted running the new tools. We should only
		// need one of these in a consolidated agent, but we'll need to be
		// careful about behavioural differences, and interactions with the
		// upgradesteps worker.
		upgraderName: upgrader.Manifold(upgrader.ManifoldConfig{
			AgentName:     agentName,
			APICallerName: apiCallerName,
		}),

		migrationFortressName: fortress.Manifold(),

		// The migration minion handles the agent side aspects of model migrations.
		migrationMinionName: migrationminion.Manifold(migrationminion.ManifoldConfig{
			AgentName:     agentName,
			APICallerName: apiCallerName,
			FortressName:  migrationFortressName,

			NewFacade: migrationminion.NewFacade,
			NewWorker: migrationminion.NewWorker,
		}),

		// The logging config updater is a leaf worker that indirectly
		// controls the messages sent via the log sender according to
		// changes in environment config. We should only need one of
		// these in a consolidated agent.
		loggingConfigUpdaterName: logger.Manifold(logger.ManifoldConfig{
			AgentName:     agentName,
			APICallerName: apiCallerName,
		}),

		// The api address updater is a leaf worker that rewrites agent config
		// as the controller addresses change. We should only need one of
		// these in a consolidated agent.
		apiAddressUpdaterName: apiaddressupdater.Manifold(apiaddressupdater.ManifoldConfig{
//.........这里部分代码省略.........
开发者ID:makyo,项目名称:juju,代码行数:101,代码来源:manifolds.go


示例16: TestInputs

func (s *ManifoldSuite) TestInputs(c *gc.C) {
	manifold := retrystrategy.Manifold(retrystrategy.ManifoldConfig{
		AgentApiManifoldConfig: s.stubAgentApiManifoldConfig,
	})
	c.Check(manifold.Inputs, jc.DeepEquals, []string{"wut", "exactly"})
}
开发者ID:AlexisBruemmer,项目名称:juju,代码行数:6,代码来源:manifold_test.go



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Golang rsyslog.NewRsyslogConfigWorker函数代码示例发布时间:2022-05-23
下一篇:
Golang proxyupdater.New函数代码示例发布时间: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