package com.cmvr.test.flow.runtime.dispatcher;

import com.cmvr.test.flow.runtime.message.TaskNodeExecuteMessage;
import com.cmvr.test.flow.runtime.message.TaskNodeExecuteResult;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

@Slf4j
@Component("STOP_LOOP")
@RequiredArgsConstructor
public class FlowStopLoopNodeHandler implements FlowNodeTypeHandler {

    @Override
    public TaskNodeExecuteResult handle(TaskNodeExecuteMessage message) {
        message.getGraph().setStopLoop(true);
        log.info("STOP_LOOP 节点执行，设置跳出标志：instId={}, nodeId={}", message.getInstId(), message.getNodeId());

        return TaskNodeExecuteResult.success();
    }
}
