From 551e3e149924c18aac51bf9667f463301c3322fc Mon Sep 17 00:00:00 2001 From: chronolaw Date: Tue, 23 Jul 2024 15:54:02 +0800 Subject: [PATCH 1/2] refactor(plugins/aws-lambda): simplify code with tools.time utility --- kong/plugins/aws-lambda/handler.lua | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/kong/plugins/aws-lambda/handler.lua b/kong/plugins/aws-lambda/handler.lua index febd326024fe..d546e6fda6bb 100644 --- a/kong/plugins/aws-lambda/handler.lua +++ b/kong/plugins/aws-lambda/handler.lua @@ -17,6 +17,7 @@ local VIA_HEADER = constants.HEADERS.VIA local server_tokens = meta._SERVER_TOKENS local request_util = require "kong.plugins.aws-lambda.request-util" +local get_now = require("kong.tools.time").get_updated_now_ms local build_request_payload = request_util.build_request_payload local extract_proxy_response = request_util.extract_proxy_response local remove_array_mt_for_empty_table = request_util.remove_array_mt_for_empty_table @@ -30,12 +31,6 @@ local AWS local LAMBDA_SERVICE_CACHE -local function get_now() - ngx_update_time() - return ngx_now() * 1000 -- time is kept in seconds with millisecond resolution. -end - - local function initialize() LAMBDA_SERVICE_CACHE = lrucache.new(1000) AWS_GLOBAL_CONFIG = aws_config.global From 2fe3b4bd322fbc24c7ff27810f6bdf82bba9b1f4 Mon Sep 17 00:00:00 2001 From: chronolaw Date: Tue, 23 Jul 2024 15:56:58 +0800 Subject: [PATCH 2/2] lint fix --- kong/plugins/aws-lambda/handler.lua | 2 -- 1 file changed, 2 deletions(-) diff --git a/kong/plugins/aws-lambda/handler.lua b/kong/plugins/aws-lambda/handler.lua index d546e6fda6bb..5e590fb90bc0 100644 --- a/kong/plugins/aws-lambda/handler.lua +++ b/kong/plugins/aws-lambda/handler.lua @@ -1,8 +1,6 @@ -- Copyright (C) Kong Inc. local ngx_var = ngx.var -local ngx_now = ngx.now -local ngx_update_time = ngx.update_time local md5_bin = ngx.md5_bin local re_match = ngx.re.match local fmt = string.format