package cc.smtweb.system.canal.deployer;

import cc.smtweb.framework.core.annotation.SwStartListener;
import cc.smtweb.framework.core.common.SwConsts;
import cc.smtweb.framework.core.mvc.controller.IStartListener;
import cc.smtweb.framework.core.systask.SysThreadPool;
import cc.smtweb.framework.core.systask.SysThreadWorker;
import lombok.extern.slf4j.Slf4j;

/**
 * @Author yaoq
 * @Date 2022年09月06日 10:31
 * @Description
 */
@Slf4j
@SwStartListener
public class CanalStartedListener implements IStartListener {

    @Override
    public int order() {
        return SwConsts.DEFAULT_ORDER + 90;
    }


    @Override
    public void init() {

    }

    @Override
    public void run() {
        if (!SwConsts.SysParam.enableCanal) return;
        SysThreadPool.getInstance().addTask(new SysThreadWorker("canal server") {
            @Override
            public void localWork() throws Exception {
                CanalLauncher.startServer();
            }
        });
    }
}
