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


TypeScript DecisionTask.startChildWorkflow方法代码示例

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


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

示例1: decide

  decide(parameters: TaskGraphParameters, decisionTask: DecisionTask) {
    const graph = parameters.graph
    const groupedEvents = decisionTask.getGroupedEvents()
    let next = this.getNextNodes(graph, groupedEvents)
    let startCountByHandler = {}
    let startCountSubWorkflows = 0
    for (let node of next.nodes) {
      if (node.type === 'decision') {
        // TODO: somehow hand off to a child? need to make this more generic but just hard code for now...
        if (node.handler === 'taskGraph') {
          let tgNode = node as TaskGraphGraphNode
          const shouldThrottle = this.throttleWorkflows(tgNode, graph, groupedEvents, startCountSubWorkflows)
          if (!shouldThrottle) {
            startCountSubWorkflows++
            const maxRetry = tgNode.maxRetry || this.ftlConfig.getOpt('maxRetry')
            decisionTask.startChildWorkflow(tgNode.id, tgNode, {maxRetry: maxRetry})
          }
        }
        else if (node.handler === 'recordMarker') {
          decisionTask.addMarker(node.id, node.parameters.status)
        }
        else {
          this.logger.warn('couldn\'t find hander for child node', node)
        }
      }
      else {
        const shouldThrottle = this.throttle(node, graph, groupedEvents, startCountByHandler)
        if (!shouldThrottle) {
          startCountByHandler[node.handler] = startCountByHandler[node.handler] || 0
          startCountByHandler[node.handler]++
          const handlerActType = this.activities.getModule(node.handler)
          if (!handlerActType) throw new Error('missing activity type ' + node.handler)
          let opts = this.buildOpts(node)
          opts['maxRetry'] = node.maxRetry || handlerActType.getMaxRetry() || this.ftlConfig.getOpt('maxRetry')
          decisionTask.scheduleTask(node.id, node, handlerActType, opts)
        }
      }
    }
    const failedToReFail = decisionTask.rescheduleFailedEvents()
    const failedToReTimeOut = decisionTask.rescheduleTimedOutEvents()
    const failedToReStart = decisionTask.rescheduleFailedToSchedule()
    const failedToReschedule = failedToReFail
    .concat(failedToReTimeOut)
    .concat(failedToReStart)
    if (failedToReschedule.length > 0) {
      this.logger.warn('failed to reschedule all previously failed events')
      decisionTask.failWorkflow('failed to reschedule previously failed events', JSON.stringify(failedToReschedule).slice(0, 250))
    }
    else if (next.finished) {
      // TODO: better results
      decisionTask.completeWorkflow({status: 'success'})
    }

  }
开发者ID:instructure,项目名称:ftl-engine,代码行数:54,代码来源:TaskGraph.ts


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