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


Golang Action.GetValue方法代碼示例

本文整理匯總了Golang中github.com/cloudfoundry-incubator/bbs/models.Action.GetValue方法的典型用法代碼示例。如果您正苦於以下問題:Golang Action.GetValue方法的具體用法?Golang Action.GetValue怎麽用?Golang Action.GetValue使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/cloudfoundry-incubator/bbs/models.Action的用法示例。


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

示例1: updateTimeoutInAction

func updateTimeoutInAction(logger lager.Logger, action *models.Action) {
	if action == nil {
		logger.Debug("no-action-to-convert")
		return
	}

	a := action.GetValue()
	switch actionModel := a.(type) {
	case *models.RunAction, *models.DownloadAction, *models.UploadAction:
		return

	case *models.TimeoutAction:
		timeoutAction := actionModel
		timeoutAction.TimeoutMs = timeoutAction.DeprecatedTimeoutNs / 1000000

	case *models.EmitProgressAction:
		updateTimeoutInAction(logger, actionModel.Action)

	case *models.TryAction:
		updateTimeoutInAction(logger, actionModel.Action)

	case *models.ParallelAction:
		for _, subaction := range actionModel.Actions {
			updateTimeoutInAction(logger, subaction)
		}

	case *models.SerialAction:
		for _, subaction := range actionModel.Actions {
			updateTimeoutInAction(logger, subaction)
		}

	case *models.CodependentAction:
		for _, subaction := range actionModel.Actions {
			updateTimeoutInAction(logger, subaction)
		}
	}
}
開發者ID:timani,項目名稱:bbs,代碼行數:37,代碼來源:1451635200_timeouts_to_milliseconds.go

示例2: StepFor

func (transformer *Transformer) StepFor(
	logStreamer log_streamer.LogStreamer,
	action *models.Action,
	container garden.Container,
	externalIP string,
	ports []executor.PortMapping,
	logger lager.Logger,
) steps.Step {

	a := action.GetValue()
	switch actionModel := a.(type) {
	case *models.RunAction:
		return steps.NewRun(
			container,
			*actionModel,
			logStreamer.WithSource(actionModel.LogSource),
			logger,
			externalIP,
			ports,
			transformer.exportNetworkEnvVars,
			transformer.clock,
		)

	case *models.DownloadAction:
		return steps.NewDownload(
			container,
			*actionModel,
			transformer.cachedDownloader,
			transformer.downloadLimiter,
			logStreamer.WithSource(actionModel.LogSource),
			logger,
		)

	case *models.UploadAction:
		return steps.NewUpload(
			container,
			*actionModel,
			transformer.uploader,
			transformer.compressor,
			transformer.tempDir,
			logStreamer.WithSource(actionModel.LogSource),
			transformer.uploadLimiter,
			logger,
		)

	case *models.EmitProgressAction:
		return steps.NewEmitProgress(
			transformer.StepFor(
				logStreamer,
				actionModel.Action,
				container,
				externalIP,
				ports,
				logger,
			),
			actionModel.StartMessage,
			actionModel.SuccessMessage,
			actionModel.FailureMessagePrefix,
			logStreamer.WithSource(actionModel.LogSource),
			logger,
		)

	case *models.TimeoutAction:
		return steps.NewTimeout(
			transformer.StepFor(
				logStreamer.WithSource(actionModel.LogSource),
				actionModel.Action,
				container,
				externalIP,
				ports,
				logger,
			),
			time.Duration(actionModel.Timeout),
			logger,
		)

	case *models.TryAction:
		return steps.NewTry(
			transformer.StepFor(
				logStreamer.WithSource(actionModel.LogSource),
				actionModel.Action,
				container,
				externalIP,
				ports,
				logger,
			),
			logger,
		)

	case *models.ParallelAction:
		subSteps := make([]steps.Step, len(actionModel.Actions))
		for i, action := range actionModel.Actions {
			subSteps[i] = transformer.StepFor(
				logStreamer.WithSource(actionModel.LogSource),
				action,
				container,
				externalIP,
				ports,
				logger,
			)
//.........這裏部分代碼省略.........
開發者ID:snowsnail,項目名稱:executor,代碼行數:101,代碼來源:transformer.go


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