status-update jar 로직 추가
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
package com.kamco.cd.kamcoback.config;
|
||||
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.Semaphore;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class ApiCallLimiter {
|
||||
// 동시에 허용할 외부 API 호출 수
|
||||
private final Semaphore semaphore = new Semaphore(5);
|
||||
|
||||
public <T> T call(Callable<T> fn) {
|
||||
try {
|
||||
semaphore.acquire();
|
||||
return fn.call();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
} finally {
|
||||
semaphore.release();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user