From df7033819e0d3ed70b70e57f3a78ddb9eed4f907 Mon Sep 17 00:00:00 2001 From: Thibault Charbonnier Date: Fri, 15 Apr 2016 17:58:29 -0700 Subject: [PATCH] rename mashape-analytics to galileo --- kong-0.8.1-0.rockspec | 10 ++--- kong/constants.lua | 2 +- kong/dao/factory.lua | 2 +- .../{mashape-analytics => galileo}/alf.lua | 0 .../{mashape-analytics => galileo}/buffer.lua | 0 .../handler.lua | 0 kong/plugins/galileo/migrations/cassandra.lua | 31 ++++++++++++++ kong/plugins/galileo/migrations/postgres.lua | 31 ++++++++++++++ .../{mashape-analytics => galileo}/schema.lua | 4 +- .../migrations/cassandra.lua | 41 ------------------- 10 files changed, 71 insertions(+), 50 deletions(-) rename kong/plugins/{mashape-analytics => galileo}/alf.lua (100%) rename kong/plugins/{mashape-analytics => galileo}/buffer.lua (100%) rename kong/plugins/{mashape-analytics => galileo}/handler.lua (100%) create mode 100644 kong/plugins/galileo/migrations/cassandra.lua create mode 100644 kong/plugins/galileo/migrations/postgres.lua rename kong/plugins/{mashape-analytics => galileo}/schema.lua (82%) delete mode 100644 kong/plugins/mashape-analytics/migrations/cassandra.lua diff --git a/kong-0.8.1-0.rockspec b/kong-0.8.1-0.rockspec index 97e8d12d8b4..aee51de50ec 100644 --- a/kong-0.8.1-0.rockspec +++ b/kong-0.8.1-0.rockspec @@ -167,11 +167,11 @@ build = { ["kong.plugins.runscope.schema"] = "kong/plugins/runscope/schema.lua", ["kong.plugins.runscope.log"] = "kong/plugins/runscope/log.lua", - ["kong.plugins.mashape-analytics.migrations.cassandra"] = "kong/plugins/mashape-analytics/migrations/cassandra.lua", - ["kong.plugins.mashape-analytics.handler"] = "kong/plugins/mashape-analytics/handler.lua", - ["kong.plugins.mashape-analytics.schema"] = "kong/plugins/mashape-analytics/schema.lua", - ["kong.plugins.mashape-analytics.buffer"] = "kong/plugins/mashape-analytics/buffer.lua", - ["kong.plugins.mashape-analytics.alf"] = "kong/plugins/mashape-analytics/alf.lua", + ["kong.plugins.galileo.migrations.cassandra"] = "kong/plugins/galileo/migrations/cassandra.lua", + ["kong.plugins.galileo.handler"] = "kong/plugins/galileo/handler.lua", + ["kong.plugins.galileo.schema"] = "kong/plugins/galileo/schema.lua", + ["kong.plugins.galileo.buffer"] = "kong/plugins/galileo/buffer.lua", + ["kong.plugins.galileo.alf"] = "kong/plugins/galileo/alf.lua", ["kong.plugins.rate-limiting.migrations.cassandra"] = "kong/plugins/rate-limiting/migrations/cassandra.lua", ["kong.plugins.rate-limiting.migrations.postgres"] = "kong/plugins/rate-limiting/migrations/postgres.lua", diff --git a/kong/constants.lua b/kong/constants.lua index 35e0f5d15ea..dc1983b30a4 100644 --- a/kong/constants.lua +++ b/kong/constants.lua @@ -11,7 +11,7 @@ return { PLUGINS_AVAILABLE = { "ssl", "jwt", "acl", "correlation-id", "cors", "oauth2", "tcp-log", "udp-log", "file-log", "http-log", "key-auth", "hmac-auth", "basic-auth", "ip-restriction", - "mashape-analytics", "request-transformer", "response-transformer", + "galileo", "request-transformer", "response-transformer", "request-size-limiting", "rate-limiting", "response-ratelimiting", "syslog", "loggly", "datadog", "runscope", "ldap-auth", "statsd" }, diff --git a/kong/dao/factory.lua b/kong/dao/factory.lua index 9bc2b4a7b7f..bd1aea35ba1 100644 --- a/kong/dao/factory.lua +++ b/kong/dao/factory.lua @@ -201,7 +201,7 @@ local function migrate(self, identifier, migrations_modules, cur_migrations, on_ end -- record success - err = _db:record_migration(identifier, migration.name) + --err = _db:record_migration(identifier, migration.name) if err then return false, string.format("Error recording migration %s: %s", migration.name, err) end diff --git a/kong/plugins/mashape-analytics/alf.lua b/kong/plugins/galileo/alf.lua similarity index 100% rename from kong/plugins/mashape-analytics/alf.lua rename to kong/plugins/galileo/alf.lua diff --git a/kong/plugins/mashape-analytics/buffer.lua b/kong/plugins/galileo/buffer.lua similarity index 100% rename from kong/plugins/mashape-analytics/buffer.lua rename to kong/plugins/galileo/buffer.lua diff --git a/kong/plugins/mashape-analytics/handler.lua b/kong/plugins/galileo/handler.lua similarity index 100% rename from kong/plugins/mashape-analytics/handler.lua rename to kong/plugins/galileo/handler.lua diff --git a/kong/plugins/galileo/migrations/cassandra.lua b/kong/plugins/galileo/migrations/cassandra.lua new file mode 100644 index 00000000000..6f2f87bd59e --- /dev/null +++ b/kong/plugins/galileo/migrations/cassandra.lua @@ -0,0 +1,31 @@ +return { + { + name = "2016-04-15_galileo-import-mashape-analytics", + up = function(_, _, dao) + local rows, err = dao.plugins:find_all {name = "mashape-analytics"} + if err then return err end + + for i = 1, #rows do + local analytics = rows[i] + local _, err = dao.plugins:insert { + name = "galileo", + api_id = analytics.api_id, + enabled = analytics.enabled, + config = { + service_token = analytics.config.service_token, + environment = analytics.config.environment, + host = analytics.config.host, + port = analytics.config.port, + log_bodies = analytics.config.log_body, + queue_size = analytics.config.batch_size, + flush_timeout = analytics.config.delay + } + } + if err then return err end + + _, err = dao.plugins:delete(analytics) + if err then return err end + end + end + } +} diff --git a/kong/plugins/galileo/migrations/postgres.lua b/kong/plugins/galileo/migrations/postgres.lua new file mode 100644 index 00000000000..6f2f87bd59e --- /dev/null +++ b/kong/plugins/galileo/migrations/postgres.lua @@ -0,0 +1,31 @@ +return { + { + name = "2016-04-15_galileo-import-mashape-analytics", + up = function(_, _, dao) + local rows, err = dao.plugins:find_all {name = "mashape-analytics"} + if err then return err end + + for i = 1, #rows do + local analytics = rows[i] + local _, err = dao.plugins:insert { + name = "galileo", + api_id = analytics.api_id, + enabled = analytics.enabled, + config = { + service_token = analytics.config.service_token, + environment = analytics.config.environment, + host = analytics.config.host, + port = analytics.config.port, + log_bodies = analytics.config.log_body, + queue_size = analytics.config.batch_size, + flush_timeout = analytics.config.delay + } + } + if err then return err end + + _, err = dao.plugins:delete(analytics) + if err then return err end + end + end + } +} diff --git a/kong/plugins/mashape-analytics/schema.lua b/kong/plugins/galileo/schema.lua similarity index 82% rename from kong/plugins/mashape-analytics/schema.lua rename to kong/plugins/galileo/schema.lua index 5122193814a..7c0e4d13db0 100644 --- a/kong/plugins/mashape-analytics/schema.lua +++ b/kong/plugins/galileo/schema.lua @@ -1,8 +1,8 @@ return { fields = { environment = {type = "string"}, - retry_count = {type = "number", default = 0}, - queue_size = {type = "number", default = 500}, + retry_count = {type = "number", default = 10}, + queue_size = {type = "number", default = 1000}, flush_timeout = {type = "number", default = 2}, log_bodies = {type = "boolean", default = false}, service_token = {type = "string", required = true}, diff --git a/kong/plugins/mashape-analytics/migrations/cassandra.lua b/kong/plugins/mashape-analytics/migrations/cassandra.lua deleted file mode 100644 index 7a92f282bee..00000000000 --- a/kong/plugins/mashape-analytics/migrations/cassandra.lua +++ /dev/null @@ -1,41 +0,0 @@ -return { - { - name = "2015-12-03-161400_mashape-analytics-config", - up = function(_, _, factory) - local schema = require "kong.plugins.mashape-analytics.schema" - - local plugins, err = factory.plugins:find_all {name = "mashape-analytics"} - if err then - return err - end - - for _, plugin in ipairs(plugins) do - plugin.config.host = plugin.config.host or schema.fields.host.default - plugin.config.port = plugin.config.port or schema.fields.port.default - plugin.config.path = plugin.config.path or schema.fields.path.default - plugin.config.max_sending_queue_size = plugin.config.max_sending_queue_size or schema.fields.max_sending_queue_size.default - local _, err = factory.plugins:update(plugin, plugin, {full = true}) - if err then - return err - end - end - end, - down = function(_, _, factory) - local plugins, err = factory.plugins:find_all {name = "mashape-analytics"} - if err then - return err - end - - for _, plugin in ipairs(plugins) do - plugin.config.host = nil - plugin.config.port = nil - plugin.config.path = nil - plugin.config.max_sending_queue_size = nil - local _, err = factory.plugins:update(plugin, plugin, {full = true}) - if err then - return err - end - end - end - } -}