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

import cn.reghao.bnt.common.msg.event.EvtAgentHeartbeat;
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 2020-12-30 10:26:47
 */
@Service
public class EvtAgentHeartbeatHandler extends Handler {
    private final MachineService machineService;

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

    @Override
    public void handle(Event evt) {
        EvtAgentHeartbeat machineStat = (EvtAgentHeartbeat) evt;
        machineService.updateMachine(machineStat);
    }
}
