예제 #1
0
    def handle(self, process, element, status):
        # rerun mode
        if status.loop > 1:
            element.prepare_rerun_data()
            element.pipeline.context.recover_variable()
            process.top_pipeline.context.recover_variable()

        # set loop count
        element.data.outputs._loop = status.loop - 1

        # pre output extract
        process.top_pipeline.context.extract_output(element)

        # hydrate data
        hydrate_node_data(element)

        # context injection
        data = element.pipeline.data
        context = element.pipeline.context
        for k, v in data.get_inputs().items():
            context.set_global_var(k, v)

        hydrated = hydrate_data(context.variables)
        context.update_global_var(hydrated)

        sub_pipeline = element.pipeline
        process.push_pipeline(sub_pipeline, is_subprocess=True)
        return self.HandleResult(next_node=sub_pipeline.start_event, should_return=False, should_sleep=False)
예제 #2
0
def exclusive_gateway_handler(process, ex_gateway):
    try:
        hydrate_context = hydrate_data(
            process.top_pipeline.context().variables)
        next_node = ex_gateway.next(hydrate_context)
    except PipelineException as e:
        logger.error(traceback.format_exc(e))
        Status.objects.fail(ex_gateway, ex_data=e.message)
        return HandleResult(next_node=None,
                            should_return=True,
                            should_sleep=True)
    Status.objects.finish(ex_gateway)
    return HandleResult(next_node=next_node,
                        should_return=False,
                        should_sleep=False)
예제 #3
0
    def handle(self, process, element, status):
        if status.loop > 1:
            process.top_pipeline.context.recover_variable()

        try:
            hydrate_context = hydrate_data(
                process.top_pipeline.context.variables)
            next_node = element.next(hydrate_context)
        except PipelineException as e:
            logger.error(traceback.format_exc(e))
            Status.objects.fail(element, ex_data=e.message)
            return self.HandleResult(next_node=None,
                                     should_return=True,
                                     should_sleep=True)
        Status.objects.finish(element)
        return self.HandleResult(next_node=next_node,
                                 should_return=False,
                                 should_sleep=False)
예제 #4
0
def subprocess_handler(process, subprocess_act):
    # hydrate data
    hydrate_node_data(subprocess_act)

    # context injection
    data = subprocess_act.pipeline.data
    context = subprocess_act.pipeline.context()
    for k, v in data.get_inputs().items():
        context.set_global_var(k, v)

    hydrated = hydrate_data(context.variables)
    context.update_global_var(hydrated)

    sub_pipeline = subprocess_act.pipeline
    process.push_pipeline(sub_pipeline, is_subprocess=True)
    return HandleResult(next_node=sub_pipeline.start_event(),
                        should_return=False,
                        should_sleep=False)
예제 #5
0
    def handle(self, process, element, status):
        if status.loop > 1:
            process.top_pipeline.context.recover_variable()

        try:
            hydrate_context = hydrate_data(
                process.top_pipeline.context.variables)
            targets = element.targets_meet_condition(hydrate_context)
        except PipelineException as e:
            logger.error(traceback.format_exc(e))
            Status.objects.fail(element, ex_data=e.message)
            return self.HandleResult(next_node=None,
                                     should_return=True,
                                     should_sleep=True)

        children = []

        for target in targets:
            try:
                child = PipelineProcess.objects.fork_child(
                    parent=process,
                    current_node_id=target.id,
                    destination_id=element.converge_gateway_id)
            except PipelineException as e:
                logger.error(traceback.format_exc(e))
                Status.objects.fail(element, ex_data=e.message)
                return self.HandleResult(next_node=None,
                                         should_return=True,
                                         should_sleep=True)

            children.append(child)

        process.join(children)

        Status.objects.finish(element)

        return self.HandleResult(next_node=None,
                                 should_return=True,
                                 should_sleep=True)