Skip to content

Commit

Permalink
Handle special case
Browse files Browse the repository at this point in the history
  • Loading branch information
sergiitk committed Oct 1, 2024
1 parent b95a57a commit b49a7b0
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions xds/src/main/java/io/grpc/xds/internal/rlqs/RlqsEngine.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ public RlqsEngine(
public RlqsRateLimitResult rateLimit(HttpMatchInput input) {
RlqsBucketSettings bucketSettings = bucketMatchers.match(input);
RlqsBucketId bucketId = bucketSettings.toBucketId(input);

Check warning on line 58 in xds/src/main/java/io/grpc/xds/internal/rlqs/RlqsEngine.java

View check run for this annotation

Codecov / codecov/patch

xds/src/main/java/io/grpc/xds/internal/rlqs/RlqsEngine.java#L57-L58

Added lines #L57 - L58 were not covered by tests
// Special case when bucket id builder not set.
if (bucketId == null) {
return rateLimitWithoutReports(bucketSettings);

Check warning on line 61 in xds/src/main/java/io/grpc/xds/internal/rlqs/RlqsEngine.java

View check run for this annotation

Codecov / codecov/patch

xds/src/main/java/io/grpc/xds/internal/rlqs/RlqsEngine.java#L61

Added line #L61 was not covered by tests
}
RlqsBucket bucket = bucketCache.getOrCreate(bucketId, bucketSettings, newBucket -> {

Check warning on line 63 in xds/src/main/java/io/grpc/xds/internal/rlqs/RlqsEngine.java

View check run for this annotation

Codecov / codecov/patch

xds/src/main/java/io/grpc/xds/internal/rlqs/RlqsEngine.java#L63

Added line #L63 was not covered by tests
// Called if a new bucket was created.
scheduleImmediateReport(newBucket);
Expand All @@ -64,6 +68,13 @@ public RlqsRateLimitResult rateLimit(HttpMatchInput input) {
return bucket.rateLimit();

Check warning on line 68 in xds/src/main/java/io/grpc/xds/internal/rlqs/RlqsEngine.java

View check run for this annotation

Codecov / codecov/patch

xds/src/main/java/io/grpc/xds/internal/rlqs/RlqsEngine.java#L65-L68

Added lines #L65 - L68 were not covered by tests
}

private static RlqsRateLimitResult rateLimitWithoutReports(RlqsBucketSettings bucketSettings) {
if (bucketSettings.noAssignmentStrategy().rateLimit()) {
return RlqsRateLimitResult.deny(bucketSettings.denyResponse());

Check warning on line 73 in xds/src/main/java/io/grpc/xds/internal/rlqs/RlqsEngine.java

View check run for this annotation

Codecov / codecov/patch

xds/src/main/java/io/grpc/xds/internal/rlqs/RlqsEngine.java#L73

Added line #L73 was not covered by tests
}
return RlqsRateLimitResult.allow();

Check warning on line 75 in xds/src/main/java/io/grpc/xds/internal/rlqs/RlqsEngine.java

View check run for this annotation

Codecov / codecov/patch

xds/src/main/java/io/grpc/xds/internal/rlqs/RlqsEngine.java#L75

Added line #L75 was not covered by tests
}

private void onBucketsUpdate(List<RlqsUpdateBucketAction> bucketActions) {
// TODO(sergiitk): [impl] ensure no more than 1 update at a time.
for (RlqsUpdateBucketAction bucketAction : bucketActions) {
Expand Down

0 comments on commit b49a7b0

Please sign in to comment.