package cn.reghao.devops.mgr.ws.event;

import cn.reghao.devops.mgr.machine.service.MachineService;
import cn.reghao.jutil.jdk.event.message.Event;
import cn.reghao.jutil.jdk.event.handler.Handler;
import cn.reghao.devops.common.msg.event.EvtAgentStart;
import org.springframework.stereotype.Service;

/**
 * @author reghao
 * @date 2022-05-05 17:26:47
 */
@Service
public class EvtAgentStartHandler extends Handler {
    private final MachineService machineService;

    public EvtAgentStartHandler(MachineService machineService) {
        this.machineService = machineService;
    }

    @Override
    public void handle(Event evt) {
        EvtAgentStart machineDetail = (EvtAgentStart) evt;
        machineService.addOrUpdateMachine(machineDetail);
    }
}
