Skip to content

Commit c90fe07

Browse files
tzssangglasssamugi
authored andcommitted
Revert "feat(module): new method peer_conn.get_last_peer_connection_cached (#82)"
This reverts commit d1f8aaf. Signed-off-by: tzssangglass <[email protected]>
1 parent f9658b4 commit c90fe07

File tree

5 files changed

+0
-237
lines changed

5 files changed

+0
-237
lines changed

README.md

Lines changed: 0 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,7 @@ Table of Contents
3030
* [resty.kong.tag.get](#restykongtagget)
3131
* [resty.kong.log.set\_log\_level](#restykonglogset_log_level)
3232
* [resty.kong.log.get\_log\_level](#restykonglogget_log_level)
33-
* [resty.kong.peer_conn.get\_last\_peer\_connection\_cached](#restykongpeer_connget_last_peer_connection_cached)
3433
* [resty.kong.upstream.set\_next\_upstream](#restykongupstreamset_next_upstream)
35-
3634
* [License](#license)
3735

3836
Description
@@ -526,59 +524,6 @@ for the possible value of `level`.
526524

527525
[Back to TOC](#table-of-contents)
528526

529-
resty.kong.peer_conn.get\_last\_peer\_connection\_cached
530-
----------------------------------
531-
**syntax:** *res = resty.kong.peer_conn.get_last_peer_connection_cached()*
532-
533-
**context:** *balancer_by_lua*
534-
535-
**subsystems:** *http*
536-
537-
This function retrieves information about whether the connection used in the previous attempt came from the upstream connection pool when the next_upstream retrying mechanism is in action.
538-
539-
The possible results are as follows:
540-
- `false`: Indicates the connection was not reused from the upstream connection pool, meaning a new connection was created with the upstream in the previous attempt.
541-
- `true`: Indicates the connection was reused from the upstream connection pool, meaning no new connection was created with the upstream in the previous attempt.
542-
543-
After applying the [dynamic upstream keepalive patch](https://github.com/Kong/kong/blob/3.6.0/build/openresty/patches/ngx_lua-0.10.26_01-dyn_upstream_keepalive.patch),
544-
Nginx's upstream module attempts to retrieve connections from the upstream connection pool for each retry.
545-
If the obtained connection is deemed unusable, Nginx considers that retry invalid and performs a compensatory retry.
546-
547-
Since each retry triggers the `balancer_by_lua` phase, the number of retries logged in Lua land during this phase may exceed the maximum limit set by `set_more_tries`.
548-
549-
Using this function in the `balancer_by_lua` phase allows for determining if the connection used in the previous retry was taken from the connection pool.
550-
If the return value is `true`, it indicates that the connection from the pool used in the previous retry was unusable, rendering that retry void.
551-
552-
The value returned by this function helps in accurately assessing the actual number of new connections established with the upstream server during the retry process during the `balancer_by_lua phase`.
553-
554-
Example:
555-
```lua
556-
balancer_by_lua_block {
557-
local ctx = ngx.ctx
558-
559-
ctx.tries = ctx.tries or {}
560-
local tries = ctx.tries
561-
562-
-- update the number of tries
563-
local try_count = #tries + 1
564-
565-
-- fetch the last peer connection cached
566-
local peer_conn = require("resty.kong.peer_conn")
567-
local last_peer_connection_cached = peer_conn.get_last_peer_connection_cached()
568-
if try_count > 1 then
569-
local previous_try = tries[try_count - 1]
570-
previous_try.cached = peer_conn.get_last_peer_connection_cached()
571-
else
572-
tries[try_count].cached = false
573-
end
574-
575-
...
576-
}
577-
```
578-
579-
[Back to TOC](#table-of-contents)
580-
581-
582527
resty.kong.upstream.set\_next\_upstream
583528
----------------------------------
584529
**syntax:** *res = resty.kong.upstream.set_next_upstream("http_404")*
@@ -614,7 +559,6 @@ previous ones.
614559
[Back to TOC](#table-of-contents)
615560

616561

617-
618562
License
619563
=======
620564

config

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ ngx_module_srcs=" \
99
$ngx_addon_dir/src/ngx_http_lua_kong_log.c \
1010
$ngx_addon_dir/src/ngx_http_lua_kong_log_handler.c \
1111
$ngx_addon_dir/src/ngx_http_lua_kong_vars.c \
12-
$ngx_addon_dir/src/ngx_http_lua_kong_peer_connection.c \
1312
$ngx_addon_dir/src/ssl/ngx_lua_kong_ssl.c \
1413
"
1514

lualib/resty/kong/peer_conn.lua

Lines changed: 0 additions & 42 deletions
This file was deleted.

src/ngx_http_lua_kong_peer_connection.c

Lines changed: 0 additions & 33 deletions
This file was deleted.

t/011-get_last_peer_connection_cached.t

Lines changed: 0 additions & 105 deletions
This file was deleted.

0 commit comments

Comments
 (0)