Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[hotfix/galileo] Galileo custom host, port configuration #721

Merged
merged 1 commit into from
Nov 16, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 5 additions & 8 deletions kong/plugins/mashape-analytics/buffer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,6 @@ local setmetatable = setmetatable
local MB = 1024 * 1024
local MAX_BUFFER_SIZE = 1 * MB
local EMPTY_ARRAY_PLACEHOLDER = "__empty_array_placeholder__"
-- Mashape Analytics socket server properties
local ANALYTICS_SOCKET = {
host = "socket.analytics.mashape.com",
port = 80,
path = "/1.0.0/batch"
}

local buffer_mt = {}
buffer_mt.__index = buffer_mt
Expand Down Expand Up @@ -73,6 +67,9 @@ function buffer_mt.new(conf)
MAX_ENTRIES = conf.batch_size,
MAX_SIZE = MAX_BUFFER_SIZE,
AUTO_FLUSH_DELAY = conf.delay,
HOST = conf.host,
PORT = conf.port,
PATH = conf.path,
entries = {}, -- current buffer as an array of strings (serialized ALFs)
entries_size = 0, -- current buffer size in bytes
sending_queue = {}, -- array of constructed payloads (batches of ALFs) to be sent
Expand Down Expand Up @@ -177,9 +174,9 @@ function buffer_mt.send_batch(premature, self)
local client = http:new()
client:set_timeout(50000) -- 5 sec

local ok, err = client:connect(ANALYTICS_SOCKET.host, ANALYTICS_SOCKET.port)
local ok, err = client:connect(self.HOST, self.PORT)
if ok then
local res, err = client:request({path = ANALYTICS_SOCKET.path, body = batch_to_send.payload})
local res, err = client:request({path = self.PATH, body = batch_to_send.payload})
if not res then
ngx_log(ngx_log_ERR, string_format("[mashape-analytics] failed to send batch (%s ALFs %s bytes): %s",
batch_to_send.n_entries, batch_to_send.size, err))
Expand Down
5 changes: 4 additions & 1 deletion kong/plugins/mashape-analytics/schema.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ return {
environment = { type = "string" },
batch_size = { type = "number", default = 100 },
log_body = { type = "boolean", default = false },
delay = { type = "number", default = 2 }
delay = { type = "number", default = 2 },
host = { required = true, type = "string", default = "socket.analytics.mashape.com" },
port = { required = true, type = "number", default = 80 },
host = { required = true, type = "string", default = "/1.0.0/batch" }
}
}