package cn.reghao.bnt.web.ws.event;

import cn.reghao.bnt.common.msg.event.EvtAgentStart;
import cn.reghao.bnt.web.devops.machine.service.MachineService;
import cn.reghao.jutil.jdk.event.handler.Handler;
import cn.reghao.jutil.jdk.event.message.Event;
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);
    }
}
