Skip to content

Commit

Permalink
apply comments
Browse files Browse the repository at this point in the history
Signed-off-by: tzssangglass <tzssangglass@gmail.com>
  • Loading branch information
tzssangglass committed Feb 29, 2024
1 parent 827c5a1 commit ed6cce1
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion config
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ ngx_module_srcs=" \
$ngx_addon_dir/src/ngx_http_lua_kong_log.c \
$ngx_addon_dir/src/ngx_http_lua_kong_log_handler.c \
$ngx_addon_dir/src/ngx_http_lua_kong_vars.c \
$ngx_addon_dir/src/ngx_http_lua_kong_peer_connection.c \
$ngx_addon_dir/src/ngx_http_lua_kong_peer_connection.c \
$ngx_addon_dir/src/ssl/ngx_lua_kong_ssl.c \
"

Expand Down
11 changes: 7 additions & 4 deletions lualib/resty/kong/peer_conn.lua
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
local ffi = require "ffi"
local C = ffi.C
local base = require "resty.core.base"
local ffi_str = ffi.string

local orig_get_request = base.get_request
local errmsg = base.get_errmsg_ptr()
local C = ffi.C
local ffi_str = ffi.string
local get_phase = ngx.get_phase
local error = error
local NGX_ERROR = ngx.ERROR

local error = error


ffi.cdef[[
int
ngx_http_lua_kong_ffi_get_last_peer_connection_cached(ngx_http_request_t *r,
char **err);
]]

local errmsg = base.get_errmsg_ptr()

local function get_request()
local r = orig_get_request()
Expand Down
3 changes: 3 additions & 0 deletions src/ngx_http_lua_kong_peer_connection.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

#include "ngx_http_lua_kong_common.h"


int
ngx_http_lua_kong_ffi_get_last_peer_connection_cached(ngx_http_request_t *r,
char **err)
Expand All @@ -26,5 +27,7 @@ ngx_http_lua_kong_ffi_get_last_peer_connection_cached(ngx_http_request_t *r,
return NGX_ERROR;
}

ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
"last_peer_connection_cached %d", r->upstream->peer.cached);
return r->upstream->peer.cached;
}
3 changes: 1 addition & 2 deletions t/011-get_last_peer_connection_cached.t
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
use Test::Nginx::Socket::Lua;
use Cwd qw(cwd);

log_level('info');
log_level('debug');
repeat_each(1);

plan tests => repeat_each() * (blocks() * 2);
Expand All @@ -26,7 +26,6 @@ __DATA__
balancer_by_lua_block {
local peer_conn = require("resty.kong.peer_conn")
local last_peer_connection_cached = peer_conn.get_last_peer_connection_cached()
ngx.log(ngx.INFO, "last_peer_connection_cached ", tostring(last_peer_connection_cached))

local balancer = require "ngx.balancer"
local host = "127.0.0.1"
Expand Down

0 comments on commit ed6cce1

Please sign in to comment.