package cn.axzo.msg.center;

import com.taobao.api.internal.util.NamedThreadFactory;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

import static cn.axzo.msg.center.MsgCenterConfig.IM_CENTER;
import static cn.axzo.msg.center.MsgCenterConfig.WORKSPACE;
import static cn.axzo.msg.center.MsgCenterConfig.PUDGE;

/**
 * @author cn
 * @version 1.0
 * @description
 * @date 2023/5/30 11:33
 */
@Configuration
@EnableFeignClients(basePackages = {IM_CENTER, WORKSPACE, PUDGE})
public class MsgCenterConfig {

    public static final String IM_CENTER = "cn.axzo.im.center.api.feign";
    public static final String WORKSPACE = "cn.axzo.apollo.workspace";
    public static final String PUDGE = "cn.axzo.basics.profiles.api";

    @Bean @Primary
    public ExecutorService defaultExecutor() {
        return new ThreadPoolExecutor(5, 30,
                60L, TimeUnit.SECONDS,
                new ArrayBlockingQueue<>(1000),
                new NamedThreadFactory("defaultAsyncExecutor"));
    }

}