Skip to content

Commit b9f50bb

Browse files
authored
Merge pull request #667 from conductor-oss/rate_limit_policy
Added rate limit policy
2 parents 291867a + 72301d1 commit b9f50bb

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

common/src/main/java/com/netflix/conductor/common/metadata/workflow/RateLimitConfig.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,23 @@
1212
*/
1313
package com.netflix.conductor.common.metadata.workflow;
1414

15+
import com.netflix.conductor.annotations.protogen.ProtoEnum;
1516
import com.netflix.conductor.annotations.protogen.ProtoField;
1617
import com.netflix.conductor.annotations.protogen.ProtoMessage;
1718

1819
/** Rate limit configuration for workflows */
1920
@ProtoMessage
2021
public class RateLimitConfig {
22+
23+
/** Rate limit policy defining how to handle requests exceeding the limit */
24+
@ProtoEnum
25+
public enum RateLimitPolicy {
26+
/** Queue the request until capacity is available */
27+
QUEUE,
28+
/** Reject the request immediately */
29+
REJECT
30+
}
31+
2132
/**
2233
* Key that defines the rate limit. Rate limit key is a combination of workflow payload such as
2334
* name, or correlationId etc.
@@ -29,6 +40,10 @@ public class RateLimitConfig {
2940
@ProtoField(id = 2)
3041
private int concurrentExecLimit;
3142

43+
/** Policy to apply when rate limit is exceeded */
44+
@ProtoField(id = 3)
45+
private RateLimitPolicy policy = RateLimitPolicy.QUEUE;
46+
3247
public String getRateLimitKey() {
3348
return rateLimitKey;
3449
}
@@ -44,4 +59,12 @@ public int getConcurrentExecLimit() {
4459
public void setConcurrentExecLimit(int concurrentExecLimit) {
4560
this.concurrentExecLimit = concurrentExecLimit;
4661
}
62+
63+
public RateLimitPolicy getPolicy() {
64+
return policy;
65+
}
66+
67+
public void setPolicy(RateLimitPolicy policy) {
68+
this.policy = policy;
69+
}
4770
}

grpc/src/main/proto/model/ratelimitconfig.proto

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ option java_outer_classname = "RateLimitConfigPb";
77
option go_package = "github.com/netflix/conductor/client/gogrpc/conductor/model";
88

99
message RateLimitConfig {
10+
enum RateLimitPolicy {
11+
QUEUE = 0;
12+
REJECT = 1;
13+
}
1014
string rate_limit_key = 1;
1115
int32 concurrent_exec_limit = 2;
16+
RateLimitConfig.RateLimitPolicy policy = 3;
1217
}

0 commit comments

Comments
 (0)