當前位置: 首頁>>代碼示例>>Golang>>正文


Golang names.ActionTag類代碼示例

本文整理匯總了Golang中github.com/juju/names.ActionTag的典型用法代碼示例。如果您正苦於以下問題:Golang ActionTag類的具體用法?Golang ActionTag怎麽用?Golang ActionTag使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了ActionTag類的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: actionIdFromTag

// actionIdFromTag converts an ActionTag to an actionId
func actionIdFromTag(tag names.ActionTag) string {
	ptag := tag.PrefixTag()
	if ptag == nil {
		return ""
	}
	return fmt.Sprintf("%s%d", ensureActionMarker(ptag.Id()), tag.Sequence())
}
開發者ID:kapilt,項目名稱:juju,代碼行數:8,代碼來源:action.go

示例2: ActionFinish

// ActionFinish captures the structured output of an action.
func (st *State) ActionFinish(tag names.ActionTag, status string, results map[string]interface{}, message string) error {
	var outcome params.ErrorResults

	args := params.ActionExecutionResults{
		Results: []params.ActionExecutionResult{
			{
				ActionTag: tag.String(),
				Status:    status,
				Results:   results,
				Message:   message,
			},
		},
	}

	err := st.facade.FacadeCall("FinishActions", args, &outcome)
	if err != nil {
		return err
	}
	if len(outcome.Results) != 1 {
		return fmt.Errorf("expected 1 result, got %d", len(outcome.Results))
	}
	result := outcome.Results[0]
	if result.Error != nil {
		return result.Error
	}
	return nil
}
開發者ID:pmatulis,項目名稱:juju,代碼行數:28,代碼來源:uniter.go

示例3: getOneAction

// getOneAction retrieves a single Action from the state server.
func (st *State) getOneAction(tag *names.ActionTag) (params.ActionsQueryResult, error) {
	nothing := params.ActionsQueryResult{}

	args := params.Entities{
		Entities: []params.Entity{
			{Tag: tag.String()},
		},
	}

	var results params.ActionsQueryResults
	err := st.facade.FacadeCall("Actions", args, &results)
	if err != nil {
		return nothing, err
	}

	if len(results.Results) > 1 {
		return nothing, fmt.Errorf("expected only 1 action query result, got %d", len(results.Results))
	}

	// handle server errors
	result := results.Results[0]
	if err := result.Error; err != nil {
		return nothing, err
	}

	return result, nil
}
開發者ID:pmatulis,項目名稱:juju,代碼行數:28,代碼來源:uniter.go

示例4: ActionBegin

// ActionBegin marks an action as running.
func (c *Client) ActionBegin(tag names.ActionTag) error {
	var results params.ErrorResults

	args := params.Entities{
		Entities: []params.Entity{{Tag: tag.String()}},
	}

	err := c.facade.FacadeCall("BeginActions", args, &results)
	if err != nil {
		return errors.Trace(err)
	}

	return results.OneError()
}
開發者ID:AlexisBruemmer,項目名稱:juju,代碼行數:15,代碼來源:machineactions.go

示例5: ActionFinish

// ActionFinish captures the structured output of an action.
func (c *Client) ActionFinish(tag names.ActionTag, status string, actionResults map[string]interface{}, message string) error {
	var results params.ErrorResults

	args := params.ActionExecutionResults{
		Results: []params.ActionExecutionResult{{
			ActionTag: tag.String(),
			Status:    status,
			Results:   actionResults,
			Message:   message,
		}},
	}

	err := c.facade.FacadeCall("FinishActions", args, &results)
	if err != nil {
		return errors.Trace(err)
	}

	return results.OneError()
}
開發者ID:AlexisBruemmer,項目名稱:juju,代碼行數:20,代碼來源:machineactions.go

示例6: ActionBegin

// ActionBegin marks an action as running.
func (st *State) ActionBegin(tag names.ActionTag) error {
	var outcome params.ErrorResults

	args := params.Entities{
		Entities: []params.Entity{
			{Tag: tag.String()},
		},
	}

	err := st.facade.FacadeCall("BeginActions", args, &outcome)
	if err != nil {
		return err
	}
	if len(outcome.Results) != 1 {
		return fmt.Errorf("expected 1 result, got %d", len(outcome.Results))
	}
	result := outcome.Results[0]
	if result.Error != nil {
		return result.Error
	}
	return nil
}
開發者ID:pmatulis,項目名稱:juju,代碼行數:23,代碼來源:uniter.go

示例7: getOneAction

func (c *Client) getOneAction(tag names.ActionTag) (params.ActionResult, error) {
	nothing := params.ActionResult{}

	args := params.Entities{
		Entities: []params.Entity{{Tag: tag.String()}},
	}

	var results params.ActionResults
	err := c.facade.FacadeCall("Actions", args, &results)
	if err != nil {
		return nothing, errors.Trace(err)
	}

	if len(results.Results) > 1 {
		return nothing, errors.Errorf("expected only 1 action query result, got %d", len(results.Results))
	}

	result := results.Results[0]
	if result.Error != nil {
		return nothing, errors.Trace(result.Error)
	}

	return result, nil
}
開發者ID:AlexisBruemmer,項目名稱:juju,代碼行數:24,代碼來源:machineactions.go

示例8: ActionFail

// ActionFail captures the action tag and error of a failed action.
func (st *State) ActionFail(tag names.ActionTag, err string) error {
	var result params.BoolResult
	args := params.ActionResult{ActionTag: tag.String(), Message: err, Failed: true}
	return st.facade.FacadeCall("ActionFinish", args, &result)
}
開發者ID:kapilt,項目名稱:juju,代碼行數:6,代碼來源:uniter.go

示例9: ActionComplete

// ActionComplete captures the structured output of an action.
func (st *State) ActionComplete(tag names.ActionTag, results map[string]interface{}) error {
	var result params.BoolResult
	args := params.ActionResult{ActionTag: tag.String(), Results: results}
	return st.facade.FacadeCall("ActionFinish", args, &result)
}
開發者ID:kapilt,項目名稱:juju,代碼行數:6,代碼來源:uniter.go

示例10: ActionFail

func (st *State) ActionFail(tag names.ActionTag, errorMessage string) error {
	var result params.BoolResult
	args := params.ActionResult{ActionTag: tag.String(), Output: errorMessage}
	return st.call("ActionFail", args, &result)
}
開發者ID:jiasir,項目名稱:juju,代碼行數:5,代碼來源:uniter.go

示例11: ActionComplete

func (st *State) ActionComplete(tag names.ActionTag, output string) error {
	var result params.BoolResult
	args := params.ActionResult{ActionTag: tag.String(), Output: output}
	return st.call("ActionComplete", args, &result)
}
開發者ID:jiasir,項目名稱:juju,代碼行數:5,代碼來源:uniter.go

示例12: ActionByTag

// ActionByTag returns an Action given an ActionTag.
func (st *State) ActionByTag(tag names.ActionTag) (Action, error) {
	return st.Action(tag.Id())
}
開發者ID:AlexisBruemmer,項目名稱:juju,代碼行數:4,代碼來源:action.go

示例13: actionIdFromTag

// actionIdFromTag converts an ActionTag to an actionId
func actionIdFromTag(tag names.ActionTag) string {
	prefix := actionPrefixFromUnitId(tag.UnitTag().Id())
	return actionId(prefix, tag.Sequence())
}
開發者ID:,項目名稱:,代碼行數:5,代碼來源:


注:本文中的github.com/juju/names.ActionTag類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。