当前位置: 首页>>代码示例>>Golang>>正文


Golang State.Machine方法代码示例

本文整理汇总了Golang中launchpad/net/juju-core/state.State.Machine方法的典型用法代码示例。如果您正苦于以下问题:Golang State.Machine方法的具体用法?Golang State.Machine怎么用?Golang State.Machine使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在launchpad/net/juju-core/state.State的用法示例。


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

示例1: getAllUnits

// getAllUnits returns a list of all principal and subordinate units
// assigned to the given machine.
func getAllUnits(st *state.State, machineTag string) ([]string, error) {
	machine, err := st.Machine(state.MachineIdFromTag(machineTag))
	if err != nil {
		return nil, err
	}
	// Start a watcher on machine's units, read the initial event and stop it.
	watch := machine.WatchUnits()
	defer watch.Stop()
	if units, ok := <-watch.Changes(); ok {
		return units, nil
	}
	return nil, fmt.Errorf("cannot obtain units of machine %q: %v", machineTag, watch.Err())
}
开发者ID:johnvilsack,项目名称:golang-stuff,代码行数:15,代码来源:deployer.go

示例2: Entity

func (a *MachineAgent) Entity(st *state.State) (AgentState, error) {
	m, err := st.Machine(a.MachineId)
	if err != nil {
		return nil, err
	}
	// Check the machine nonce as provisioned matches the agent.Conf value.
	if !m.CheckProvisioned(a.Conf.MachineNonce) {
		// The agent is running on a different machine to the one it
		// should be according to state. It must stop immediately.
		log.Errorf("running machine %v agent on inappropriate instance", m)
		return nil, worker.ErrTerminateAgent
	}
	return m, nil
}
开发者ID:rif,项目名称:golang-stuff,代码行数:14,代码来源:machine.go

示例3: Entity

func (a *MachineAgent) Entity(st *state.State) (AgentState, error) {
	return st.Machine(a.MachineId)
}
开发者ID:prabhakhar,项目名称:juju-core,代码行数:3,代码来源:machine.go


注:本文中的launchpad/net/juju-core/state.State.Machine方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。