當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。