-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
feat(balancer) implement consistent hashing #2875
Conversation
The check function could verify that hash_header{1,2} are only non-empty when their corresponding enum is set to "hash". As for the schema interface, instead of hash_header1 and hash_header2 I'd use names matching the enum fields they are arguments of: hash_on_header and hash_fallback_header (or else it might seem that both headers are matched), but that's a matter of taste. |
cbf709e
to
2160d44
Compare
Minor changes to adhere to the coding rules.
2160d44
to
c5a5a99
Compare
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.
Approved, with minor style changes applied!
One can define 2 keys to hash on, if the first key returns nil, the fallback is used (for example if a header is not present). The options for the keys are: 1. `none`: do not use a hash, just do (weighted) round-robin. This is the default. 2. `consumer`: use the consumer_id, or if not found the credential_id. (later is for external auth like oauth2 or ldap) 3. `ip`: use the originating ip address 4. `header`: use the header specified in the additional header option. If there are multiple headers by this name, then all entries are used (concatenated) The hash value is created from the resulting string-value, and is calculated as a numerical crc32. PR #2875
One can define 2 keys to hash on, if the first key returns nil, the fallback is used (for example if a header is not present). The options for the keys are: 1. `none`: do not use a hash, just do (weighted) round-robin. This is the default. 2. `consumer`: use the consumer_id, or if not found the credential_id. (later is for external auth like oauth2 or ldap) 3. `ip`: use the originating ip address 4. `header`: use the header specified in the additional header option. If there are multiple headers by this name, then all entries are used (concatenated) The hash value is created from the resulting string-value, and is calculated as a numerical crc32. PR #2875
One can define 2 keys to hash on, if the first key returns
nil
, the fallback is used (for example if a header is not present). The options for the keys are:none
: do not use a hash, just do (weighted) round-robin. This is the default.consumer
: use theconsumer_id
, or if not found thecredential_id
. (later is for external auth likeoauth2
orldap
)ip
: use the originating ip addressheader
: use the header specified in the additional header option. If there are multiple headers by this name, then all entries are used (concatenated)The hash value is created from the resulting string-value, and is calculated as a numerical
crc32
.