From 79bddca3217b367648940d8deab87cf3260ed6a3 Mon Sep 17 00:00:00 2001 From: pfans Date: Mon, 4 Sep 2023 15:52:37 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BD=BF=E7=94=A8ip=E5=9C=B0=E5=9D=80=E4=BD=9C?= =?UTF-8?q?=E4=B8=BAHashingLoadBalancer=E7=9A=84hash=20key=20(#38)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pjs/http/forward.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pjs/http/forward.js b/pjs/http/forward.js index bd6b5d8..80d2d47 100644 --- a/pjs/http/forward.js +++ b/pjs/http/forward.js @@ -148,6 +148,7 @@ _unhealthCache: null, _healthCheckTarget: null, _targetResource: null, + _balancerKey: undefined, }) .import({ @@ -212,7 +213,8 @@ _cookieId ? ( __target = _cookieId ) : ( - (_targetResource = _targetBalancer?.borrow?.(undefined, undefined, _unhealthCache)) && ( + (__service?.Algorithm === 'HashingLoadBalancer') && (_balancerKey = __inbound.remoteAddress), + (_targetResource = _targetBalancer?.borrow?.(undefined, _balancerKey, _unhealthCache)) && ( __target = _targetResource?.id ) ),