[Bugfix]修复mm2列表请求超时(#949)

调整代码结构
This commit is contained in:
wyb
2023-02-22 13:43:51 +08:00
committed by zengqiao
parent ec6f063450
commit 793c780015
2 changed files with 72 additions and 9 deletions

View File

@@ -0,0 +1,43 @@
package com.xiaojukeji.know.streaming.km.core.utils;
import com.xiaojukeji.know.streaming.km.common.utils.FutureWaitUtil;
import lombok.NoArgsConstructor;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import javax.annotation.PostConstruct;
import java.util.concurrent.Callable;
/**
* @author wyb
* @date 2023/2/22
*/
@Service
@NoArgsConstructor
public class ApiCallThreadPoolService {
@Value(value = "${thread-pool.api.thread-num:2}")
private Integer threadNum;
@Value(value = "${thread-pool.api.queue-size:500}")
private Integer queueSize;
private static FutureWaitUtil<Object> apiFutureUtil;
@PostConstruct
private void init() {
apiFutureUtil = FutureWaitUtil.init(
"ApiCallTP",
threadNum,
threadNum,
queueSize
);
}
public static void runnableTask(String taskName, Integer timeoutUnisMs, Callable<Object> callable) {
apiFutureUtil.runnableTask(taskName, timeoutUnisMs, callable);
}
public static void waitResult(Integer stepWaitTimeUnitMs) {
apiFutureUtil.waitResult(stepWaitTimeUnitMs);
}
}