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.EvtAgentHeartbeat;
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);
    }
}
