use of com.tencent.polaris.ratelimit.client.pb.RatelimitV2.QuotaLeft in project polaris-java by polarismesh.
the class StreamCounterSet method handleRateLimitReportResponse.
/**
* 处理acquire的回包
*
* @param rateLimitReportResponse report的回包
*/
void handleRateLimitReportResponse(RateLimitReportResponse rateLimitReportResponse) {
LOG.debug("[handleRateLimitReportRequest] response:{}", rateLimitReportResponse);
if (rateLimitReportResponse.getCode() != RateLimitConstants.SUCCESS) {
LOG.error("[handleRateLimitReportRequest] failed. code is {}", rateLimitReportResponse.getCode());
return;
}
long serverTimeMilli = rateLimitReportResponse.getTimestamp();
List<QuotaLeft> quotaLeftsList = rateLimitReportResponse.getQuotaLeftsList();
if (CollectionUtils.isEmpty(quotaLeftsList)) {
LOG.error("[handleRateLimitReportRequest] quotaLefts is empty.");
return;
}
quotaLeftsList.forEach(quotaLeft -> {
DurationBaseCallback callback = getCounters().get(quotaLeft.getCounterKey());
RemoteQuotaInfo remoteQuotaInfo = new RemoteQuotaInfo(quotaLeft.getLeft(), quotaLeft.getClientCount(), serverTimeMilli, callback.getDuration() * 1000);
callback.getRateLimitWindow().getAllocatingBucket().onRemoteUpdate(remoteQuotaInfo);
});
}
Aggregations