유량제어 오류 메시지 개선 -> API 호출 한도 초과 [테스트 그룹1: 10req/MIN]

This commit is contained in:
yunjy-hp
2025-12-11 14:27:12 +09:00
parent 730cdd96fa
commit 6b71d4414c
5 changed files with 39 additions and 14 deletions
@@ -8,7 +8,8 @@ public interface Bucket {
public InflowTargetVO getInflowThreashold(String inter);
// 그룹 관련 메서드
public boolean isGroupPass(String groupId);
/** @return null이면 통과, "PER_SECOND" 또는 "THRESHOLD"면 해당 버킷에서 차단 */
public String isGroupPass(String groupId);
public InflowGroupVO getGroupInflowThreshold(String groupId);
public String getGroupIdByInterface(String interfaceId);
}
@@ -17,24 +17,31 @@ public class CustomGroupBucket {
this.groupVo = groupVo;
}
/** 소비 결과: 성공 */
public static final String RESULT_PASS = null;
/** 소비 결과: 초당 임계치 초과 */
public static final String RESULT_BLOCKED_PER_SECOND = "PER_SECOND";
/** 소비 결과: 추가 임계치 초과 */
public static final String RESULT_BLOCKED_THRESHOLD = "THRESHOLD";
/**
* 두 버킷 모두에서 토큰 소비 시도
* @return 모든 버킷에서 소비 성공 시 true
* @return null이면 성공, "PER_SECOND" 또는 "THRESHOLD"면 해당 버킷에서 차단
*/
public boolean tryConsume() {
public String tryConsume() {
boolean perSecondPass = (perSecondBucket == null) || perSecondBucket.tryConsume(1);
if (!perSecondPass) {
return false;
return RESULT_BLOCKED_PER_SECOND;
}
boolean thresholdPass = (thresholdBucket == null) || thresholdBucket.tryConsume(1);
if (!thresholdPass) {
// 초당 버킷에서 이미 소비했으므로 롤백은 불가 (Token Bucket 특성상)
// 하지만 초당 버킷은 빠르게 리필되므로 실질적 영향 미미
return false;
return RESULT_BLOCKED_THRESHOLD;
}
return true;
return RESULT_PASS;
}
/**
@@ -470,11 +470,11 @@ public class InflowControlManager implements Lifecycle, Bucket {
}
@Override
public boolean isGroupPass(String groupId) {
public String isGroupPass(String groupId) {
CustomGroupBucket b = groupBucketList.get(groupId);
if (b == null)
return true;
return null;
return b.tryConsume();
}
@@ -155,7 +155,7 @@ public class SessionManagerForEhcache extends SessionManager {
}
System.setProperty("net.sf.ehcache.skipUpdateCheck", "true");
String bootstrapAsynchronously = "false";
String bootstrapAsynchronously = "true";
Configuration cf = new Configuration();
FactoryConfiguration ppFactory = new FactoryConfiguration();