-
Notifications
You must be signed in to change notification settings - Fork 3.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add gray routing predicate support. #3101
base: main
Are you sure you want to change the base?
Conversation
.../java/org/springframework/cloud/gateway/handler/predicate/OpenGrayRoutePredicateFactory.java
Outdated
Show resolved
Hide resolved
.../java/org/springframework/cloud/gateway/handler/predicate/OpenGrayRoutePredicateFactory.java
Outdated
Show resolved
Hide resolved
import org.springframework.validation.annotation.Validated; | ||
import org.springframework.web.server.ServerWebExchange; | ||
|
||
/** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add some details for describing this gray filter?
…rayRoutePredicateFactory when hash value equals int.min_value.
…rayRoutePredicateFactory when hash value equals int.min_value.
Why not use a percent value for gray, but use a specific range value now? |
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See comments. Also missing tests.
} | ||
|
||
|
||
int hash = Math.abs(MurmurHash3.hash32x86(patternValue.getBytes(StandardCharsets.UTF_8))% MAX_WEIGHT_RANGE) ; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's create an interface that extends Function<byte[], int>
and require a bean of that type for this to work. That way the use of apache commons doesn't leak here.
import java.util.Objects; | ||
import java.util.Optional; | ||
import java.util.function.Predicate; | ||
import org.apache.commons.codec.digest.MurmurHash3; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove hard dependency on apache commons
<groupId>commons-codec</groupId> | ||
<artifactId>commons-codec</artifactId> | ||
<version>1.16.0</version> | ||
<scope>compile</scope> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
change to test
scope
add gray routing predicate support based on request params(path,query,cookie or header), use consistent hashing other than random selection.