Skip to content

Commit

Permalink
hotfix(galileo) use cache shm for retry policy
Browse files Browse the repository at this point in the history
4720b7b renamed the previous 'locks' shm and broke the galileo retry
policy relying on it. To avoid users to modify their nginx config if
they use a custom one, this makes galileo use the already present (and
huge) 'cache' shm.
  • Loading branch information
thibaultcha committed Feb 3, 2016
1 parent 9b7c7f9 commit c417407
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion kong/plugins/mashape-analytics/buffer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ local EMPTY_ARRAY_PLACEHOLDER = "__empty_array_placeholder__"
-- The policy will give a delay that grows everytime
-- Galileo fails to respond. As soon as Galileo responds,
-- the delay is reset to its base.
local dict = ngx.shared.locks
local dict = ngx.shared.cache
local RETRY_INDEX_KEY = "mashape_analytics_retry_index"
local RETRY_BASE_DELAY = 1 -- seconds
local RETRY_MAX_DELAY = 60 -- seconds
Expand Down
6 changes: 4 additions & 2 deletions kong/plugins/mashape-analytics/handler.lua
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,12 @@ end
function AnalyticsHandler:body_filter(conf)
AnalyticsHandler.super.body_filter(self)

local chunk = ngx.arg[1]
-- concatenate response chunks for ALF's `response.content.text`
if conf.log_body then
ngx.ctx.analytics.res_body = ngx.ctx.analytics.res_body..chunk
local chunk = ngx.arg[1]
local analytics_data = ngx.ctx.analytics or {res_body = ""} -- minimize the number of calls to ngx.ctx while fallbacking on default value
analytics_data.res_body = analytics_data.res_body..chunk
ngx.ctx.analytics = analytics_data
end
end

Expand Down

0 comments on commit c417407

Please sign in to comment.