Skip to content
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

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

caichengw
Copy link

add gray routing predicate support based on request params(path,query,cookie or header), use consistent hashing other than random selection.

@caichengw caichengw changed the title add gray predicate support. add gray routing predicate support. Oct 16, 2023
import org.springframework.validation.annotation.Validated;
import org.springframework.web.server.ServerWebExchange;

/**

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.
@kimmking
Copy link

Why not use a percent value for gray, but use a specific range value now?

@caichengw
Copy link
Author

Why not use a percent value for gray, but use a specific range value now?
@kimmking
use an int value pair is more intuitive than a decimal value.
and sometimes we have to directly indicate a range value (with start value and end value) rather than a range must start from zero.

Copy link
Member

@spencergibb spencergibb left a 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) ;
Copy link
Member

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;
Copy link
Member

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>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change to test scope

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants