本文整理匯總了Golang中github.com/wallyworld/core/agent.Config.Nonce方法的典型用法代碼示例。如果您正苦於以下問題:Golang Config.Nonce方法的具體用法?Golang Config.Nonce怎麽用?Golang Config.Nonce使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/wallyworld/core/agent.Config
的用法示例。
在下文中一共展示了Config.Nonce方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: openState
func openState(agentConfig agent.Config) (_ *state.State, _ *state.Machine, err error) {
info, ok := agentConfig.StateInfo()
if !ok {
return nil, nil, fmt.Errorf("no state info available")
}
st, err := state.Open(info, state.DialOpts{}, environs.NewStatePolicy())
if err != nil {
return nil, nil, err
}
defer func() {
if err != nil {
st.Close()
}
}()
m0, err := st.FindEntity(agentConfig.Tag())
if err != nil {
if errors.IsNotFound(err) {
err = worker.ErrTerminateAgent
}
return nil, nil, err
}
m := m0.(*state.Machine)
if m.Life() == state.Dead {
return nil, nil, worker.ErrTerminateAgent
}
// Check the machine nonce as provisioned matches the agent.Conf value.
if !m.CheckProvisioned(agentConfig.Nonce()) {
// The agent is running on a different machine to the one it
// should be according to state. It must stop immediately.
logger.Errorf("running machine %v agent on inappropriate instance", m)
return nil, nil, worker.ErrTerminateAgent
}
return st, m, nil
}