Skip to content

Commit f05d097

Browse files
committed
Adress review comments on rate limiter
1 parent fa9aac4 commit f05d097

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

Runtime/Client/LootLockerServerRequest.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -153,11 +153,11 @@ public class LootLockerResponseFactory
153153
}
154154

155155
/// <summary>
156-
/// Construct an error response because an rate limit has been hit
156+
/// Construct an error response because the rate limit has been hit
157157
/// </summary>
158158
public static T RateLimitExceeded<T>(string method, int secondsLeftOfRateLimit) where T : LootLockerResponse, new()
159159
{
160-
return Error<T>(string.Format("You are sending too many requests and are being rate limited for %d seconds. Call was to endpoint %s", secondsLeftOfRateLimit, method));
160+
return Error<T>(string.Format("Your request to %s was not sent. You are sending too many requests and are being rate limited for %d seconds", method, secondsLeftOfRateLimit));
161161
}
162162
}
163163

@@ -170,7 +170,7 @@ public class RateLimiter
170170
/* -- Configurable constants -- */
171171
// Tripwire settings, allow for a max total of n requests per x seconds
172172
protected const int TripWireTimeFrameSeconds = 60;
173-
protected const int MaxRequestsPerTripWireTimeFrame = 280; // The backend rate limit is 300 requests per minute so we'll limit it slightly before that
173+
protected const int MaxRequestsPerTripWireTimeFrame = 280;
174174
protected const int SecondsPerBucket = 5; // Needs to evenly divide the time frame
175175

176176
// Moving average settings, allow for a max average of n requests per x seconds
@@ -253,8 +253,8 @@ public virtual bool AddRequestAndCheckIfRateLimitHit()
253253
isRateLimited |= _totalRequestsInBucketsInTripWireTimeFrame >= MaxRequestsPerTripWireTimeFrame; // If the request count for the time frame is greater than the max requests per time frame, set isRateLimited to true
254254
isRateLimited |= _totalRequestsInBuckets / RateLimitMovingAverageBucketCount > MaxRequestsPerBucketOnMovingAverage; // If the average number of requests per bucket is greater than the max requests on moving average, set isRateLimited to true
255255
#if UNITY_EDITOR
256-
if (_totalRequestsInBucketsInTripWireTimeFrame >= MaxRequestsPerTripWireTimeFrame) Debug.Log("Rate Limit Hit due to Trip Wire, count = " + _totalRequestsInBucketsInTripWireTimeFrame + " out of allowed " + MaxRequestsPerTripWireTimeFrame);
257-
if (_totalRequestsInBuckets / RateLimitMovingAverageBucketCount > MaxRequestsPerBucketOnMovingAverage) Debug.Log("Rate Limit Hit due to Moving Average, count = " + _totalRequestsInBuckets / RateLimitMovingAverageBucketCount + " out of allowed " + MaxRequestsPerBucketOnMovingAverage);
256+
if (_totalRequestsInBucketsInTripWireTimeFrame >= MaxRequestsPerTripWireTimeFrame) LootLockerLogger.GetForLogLevel()("Rate Limit Hit due to Trip Wire, count = " + _totalRequestsInBucketsInTripWireTimeFrame + " out of allowed " + MaxRequestsPerTripWireTimeFrame);
257+
if (_totalRequestsInBuckets / RateLimitMovingAverageBucketCount > MaxRequestsPerBucketOnMovingAverage) LootLockerLogger.GetForLogLevel()("Rate Limit Hit due to Moving Average, count = " + _totalRequestsInBuckets / RateLimitMovingAverageBucketCount + " out of allowed " + MaxRequestsPerBucketOnMovingAverage);
258258
#endif
259259
if (isRateLimited)
260260
{

0 commit comments

Comments
 (0)