-
Notifications
You must be signed in to change notification settings - Fork 74
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
enhance(load balance): add StickySession load balance strategy #673
Conversation
@@ -63,3 +80,195 @@ pub fn strategy_consistent_hashring() -> StrategyFn { | |||
))) | |||
}) | |||
} | |||
|
|||
#[cfg(test)] |
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.
can we move this into mod tests
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.
TEST_LRU_STATE is coupled with the strategy fn, so i guess not.
for better readability, the #[cfg(test)]
lines can be removed, but then there is basically no way to perform the unittest for the lru_cache state inside the closure.
index = jump_hash(key + timestamp(), buckets) as usize; | ||
} | ||
// TODO: if we should just remove the key from the cache? | ||
lru_cache_clone.lock().await.insert(key, 0); |
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.
if no proxy is alive maybe we can just remove the entry and build the cache next time?
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.
i think so, the current solution - use the first entry of proxies as fallback - is written by clash.meta.
it's basically ok, since the cached proxy will be checked before chosen as the return result
…q#673) * feat: add StickySession load balance strategy * move noopxxx to test_utils
🤔 This is a ...
🔗 Related issue link
enhancement in (#563)
💡 Background and solution
refer to clash.meta's solution
strategy details:
tests:
NoopResolver
andNoopOutboundHandler
to create ProxyManager freely (shall i separate it into another PR?)📝 Changelog
enhance(load balance): support sticky session strategy.
☑️ Self-Check before Merge
unitests in
loadbalance/helpers.rs