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

Golang migrationflag.Manifold函数代码示例

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

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



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

示例1: TestOutputBadTarget

func (*ManifoldSuite) TestOutputBadTarget(c *gc.C) {
	manifold := migrationflag.Manifold(migrationflag.ManifoldConfig{})
	in := &migrationflag.Worker{}
	var out bool
	err := manifold.Output(in, &out)
	c.Check(err, gc.ErrorMatches, "expected out to be a \\*Flag; got a .*")
}
开发者ID:makyo,项目名称:juju,代码行数:7,代码来源:manifold_test.go


示例2: checkManifoldNotValid

// checkManifoldNotValid checks that the supplied ManifoldConfig creates
// a manifold that cannot be started.
func checkManifoldNotValid(c *gc.C, config migrationflag.ManifoldConfig, expect string) {
	manifold := migrationflag.Manifold(config)
	worker, err := manifold.Start(dt.StubContext(nil, nil))
	c.Check(worker, gc.IsNil)
	c.Check(err, gc.ErrorMatches, expect)
	c.Check(err, jc.Satisfies, errors.IsNotValid)
}
开发者ID:makyo,项目名称:juju,代码行数:9,代码来源:util_test.go


示例3: TestOutputBadWorker

func (*ManifoldSuite) TestOutputBadWorker(c *gc.C) {
	manifold := migrationflag.Manifold(migrationflag.ManifoldConfig{})
	in := &struct{ worker.Worker }{}
	var out util.Flag
	err := manifold.Output(in, &out)
	c.Check(err, gc.ErrorMatches, "expected in to implement Flag; got a .*")
}
开发者ID:makyo,项目名称:juju,代码行数:7,代码来源:manifold_test.go


示例4: TestOutputBadInput

func (*ManifoldSuite) TestOutputBadInput(c *gc.C) {
	manifold := migrationflag.Manifold(migrationflag.ManifoldConfig{})
	in := &migrationflag.Worker{}
	var out util.Flag
	err := manifold.Output(in, &out)
	c.Check(err, jc.ErrorIsNil)
	c.Check(out, gc.Equals, in)
}
开发者ID:makyo,项目名称:juju,代码行数:8,代码来源:manifold_test.go


示例5: TestStartMissingAPICaller

func (*ManifoldSuite) TestStartMissingAPICaller(c *gc.C) {
	context := dt.StubContext(nil, map[string]interface{}{
		"api-caller": dependency.ErrMissing,
	})
	manifold := migrationflag.Manifold(validManifoldConfig())

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


示例6: TestStartNewFacadeError

func (*ManifoldSuite) TestStartNewFacadeError(c *gc.C) {
	expectCaller := &stubCaller{}
	context := dt.StubContext(nil, map[string]interface{}{
		"api-caller": expectCaller,
	})
	config := validManifoldConfig()
	config.NewFacade = func(caller base.APICaller) (migrationflag.Facade, error) {
		c.Check(caller, gc.Equals, expectCaller)
		return nil, errors.New("bort")
	}
	manifold := migrationflag.Manifold(config)

	worker, err := manifold.Start(context)
	c.Check(worker, gc.IsNil)
	c.Check(err, gc.ErrorMatches, "bort")
}
开发者ID:makyo,项目名称:juju,代码行数:16,代码来源:manifold_test.go


示例7: TestStartSuccess

func (*ManifoldSuite) TestStartSuccess(c *gc.C) {
	context := dt.StubContext(nil, map[string]interface{}{
		"api-caller": &stubCaller{},
	})
	expectWorker := &struct{ worker.Worker }{}
	config := validManifoldConfig()
	config.NewFacade = func(base.APICaller) (migrationflag.Facade, error) {
		return &struct{ migrationflag.Facade }{}, nil
	}
	config.NewWorker = func(migrationflag.Config) (worker.Worker, error) {
		return expectWorker, nil
	}
	manifold := migrationflag.Manifold(config)

	worker, err := manifold.Start(context)
	c.Check(err, jc.ErrorIsNil)
	c.Check(worker, gc.Equals, expectWorker)
}
开发者ID:makyo,项目名称:juju,代码行数:18,代码来源:manifold_test.go


示例8: TestStartNewWorkerError

func (*ManifoldSuite) TestStartNewWorkerError(c *gc.C) {
	context := dt.StubContext(nil, map[string]interface{}{
		"api-caller": &stubCaller{},
	})
	expectFacade := &struct{ migrationflag.Facade }{}
	config := validManifoldConfig()
	config.NewFacade = func(base.APICaller) (migrationflag.Facade, error) {
		return expectFacade, nil
	}
	config.NewWorker = func(workerConfig migrationflag.Config) (worker.Worker, error) {
		c.Check(workerConfig.Facade, gc.Equals, expectFacade)
		c.Check(workerConfig.Model, gc.Equals, validUUID)
		c.Check(workerConfig.Check, gc.NotNil) // uncomparable
		return nil, errors.New("snerk")
	}
	manifold := migrationflag.Manifold(config)

	worker, err := manifold.Start(context)
	c.Check(worker, gc.IsNil)
	c.Check(err, gc.ErrorMatches, "snerk")
}
开发者ID:makyo,项目名称:juju,代码行数:21,代码来源:manifold_test.go


示例9: TestFilterOther

func (*ManifoldSuite) TestFilterOther(c *gc.C) {
	manifold := migrationflag.Manifold(migrationflag.ManifoldConfig{})
	expect := errors.New("whatever")
	actual := manifold.Filter(expect)
	c.Check(actual, gc.Equals, expect)
}
开发者ID:makyo,项目名称:juju,代码行数:6,代码来源:manifold_test.go


示例10: TestFilterErrChanged

func (*ManifoldSuite) TestFilterErrChanged(c *gc.C) {
	manifold := migrationflag.Manifold(migrationflag.ManifoldConfig{})
	err := manifold.Filter(migrationflag.ErrChanged)
	c.Check(err, gc.Equals, dependency.ErrBounce)
}
开发者ID:makyo,项目名称:juju,代码行数:5,代码来源:manifold_test.go


示例11: TestFilterNil

func (*ManifoldSuite) TestFilterNil(c *gc.C) {
	manifold := migrationflag.Manifold(migrationflag.ManifoldConfig{})
	err := manifold.Filter(nil)
	c.Check(err, jc.ErrorIsNil)
}
开发者ID:makyo,项目名称:juju,代码行数:5,代码来源:manifold_test.go


示例12: TestInputs

func (*ManifoldSuite) TestInputs(c *gc.C) {
	manifold := migrationflag.Manifold(validManifoldConfig())
	c.Check(manifold.Inputs, jc.DeepEquals, []string{"api-caller"})
}
开发者ID:makyo,项目名称:juju,代码行数:4,代码来源:manifold_test.go


示例13: Manifolds

// Manifolds returns a set of co-configured manifolds covering the
// various responsibilities of a machine agent.
//
// Thou Shalt Not Use String Literals In This Function. Or Else.
func Manifolds(config ManifoldsConfig) dependency.Manifolds {

	// connectFilter exists:
	//  1) to let us retry api connections immediately on password change,
	//     rather than causing the dependency engine to wait for a while;
	//  2) to ensure that certain connection failures correctly trigger
	//     complete agent removal. (It's not safe to let any agent other
	//     than the machine mess around with SetCanUninstall).
	connectFilter := func(err error) error {
		cause := errors.Cause(err)
		if cause == apicaller.ErrConnectImpossible {
			err2 := coreagent.SetCanUninstall(config.Agent)
			if err2 != nil {
				return errors.Trace(err2)
			}
			return worker.ErrTerminateAgent
		} else if cause == apicaller.ErrChangedPassword {
			return dependency.ErrBounce
		}
		return err
	}
	var externalUpdateProxyFunc func(proxy.Settings) error
	if runtime.GOOS == "linux" {
		externalUpdateProxyFunc = lxd.ConfigureLXDProxies
	}

	return dependency.Manifolds{
		// The agent manifold references the enclosing agent, and is the
		// foundation stone on which most other manifolds ultimately depend.
		agentName: agent.Manifold(config.Agent),

		// The termination worker returns ErrTerminateAgent if a
		// termination signal is received by the process it's running
		// in. It has no inputs and its only output is the error it
		// returns. It depends on the uninstall file having been
		// written *by the manual provider* at install time; it would
		// be Very Wrong Indeed to use SetCanUninstall in conjunction
		// with this code.
		terminationName: terminationworker.Manifold(),

		// The stateconfigwatcher manifold watches the machine agent's
		// configuration and reports if state serving info is
		// present. It will bounce itself if state serving info is
		// added or removed. It is intended as a dependency just for
		// the state manifold.
		stateConfigWatcherName: stateconfigwatcher.Manifold(stateconfigwatcher.ManifoldConfig{
			AgentName:          agentName,
			AgentConfigChanged: config.AgentConfigChanged,
		}),

		// The state manifold creates a *state.State and makes it
		// available to other manifolds. It pings the mongodb session
		// regularly and will die if pings fail.
		stateName: workerstate.Manifold(workerstate.ManifoldConfig{
			AgentName:              agentName,
			StateConfigWatcherName: stateConfigWatcherName,
			OpenState:              config.OpenState,
		}),

		// The stateworkers manifold starts workers which rely on a
		// *state.State but which haven't been converted to run
		// directly under the dependency engine yet. This manifold
		// will be removed once all such workers have been converted;
		// until then, the workers are expected to handle their own
		// checks for upgrades etc, rather than blocking this whole
		// worker on upgrade completion.
		stateWorkersName: StateWorkersManifold(StateWorkersConfig{
			StateName:         stateName,
			StartStateWorkers: config.StartStateWorkers,
		}),

		// 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:              api.Open,
			NewConnection:        apicaller.ScaryConnect,
			Filter:               connectFilter,
		}),

		// The upgrade steps gate is used to coordinate workers which
		// shouldn't do anything until the upgrade-steps worker has
		// finished running any required upgrade steps. The flag of
		// similar name is used to implement the isFullyUpgraded func
//.........这里部分代码省略.........
开发者ID:bac,项目名称:juju,代码行数:101,代码来源:manifolds.go



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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