Skip to content

Commit

Permalink
chore(plugins/aws-lambda): adopt lua-resty-aws v1.6.0 to simplify code
Browse files Browse the repository at this point in the history
  • Loading branch information
DiscreteTom committed Jun 11, 2024
1 parent 54f8306 commit f655794
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 391 deletions.
195 changes: 0 additions & 195 deletions kong/plugins/aws-lambda/aws_stream.lua

This file was deleted.

166 changes: 0 additions & 166 deletions kong/plugins/aws-lambda/execute.lua

This file was deleted.

15 changes: 6 additions & 9 deletions kong/plugins/aws-lambda/handler.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ local VIA_HEADER = constants.HEADERS.VIA
local VIA_HEADER_VALUE = meta._NAME .. "/" .. meta._VERSION

local request_util = require "kong.plugins.aws-lambda.request-util"
local AWS_Stream = require("kong.plugins.aws-lambda.aws_stream")
local invokeWithResponseStream = require "kong.plugins.aws-lambda.execute"
local AWS_Stream = require("resty.aws.stream")
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
Expand Down Expand Up @@ -170,7 +169,7 @@ local function invoke_streaming(conf, lambda_service)
-- TRACING: set KONG_WAITING_TIME start
local kong_wait_time_start = get_now()

local res, err = invokeWithResponseStream(lambda_service, {
local res, err = lambda_service:invokeWithResponseStream({
FunctionName = conf.function_name,
InvocationType = conf.invocation_type,
LogType = conf.log_type,
Expand Down Expand Up @@ -263,12 +262,10 @@ local function invoke_streaming(conf, lambda_service)
end

-- print(require("pl.pretty").write(msg))
for _, header in ipairs(msg.headers) do
if header.key == ":event-type" and header.value == "PayloadChunk" then
-- print(msg.body)
ngx.print(msg.body)
ngx.flush(true)
end
if msg.headers[":event-type"] == "PayloadChunk" then
-- print(msg.body)
ngx.print(msg.body)
ngx.flush(true)
end
end
end
Expand Down
Loading

0 comments on commit f655794

Please sign in to comment.