-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding cache API - CLI Rewrite - Serf integration - Hooks/Events - In…
…validations
- Loading branch information
1 parent
b5330ad
commit 067aad4
Showing
109 changed files
with
3,849 additions
and
979 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
#!/bin/bash | ||
|
||
KONG_VERSION=0.5.0 | ||
KONG_VERSION=0.5.2 | ||
|
||
sudo apt-get update | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -146,4 +146,4 @@ function _M.delete(where_t, dao_collection) | |
end | ||
end | ||
|
||
return _M | ||
return _M |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
local responses = require "kong.tools.responses" | ||
local cache = require "kong.tools.database_cache" | ||
|
||
return { | ||
["/cache/"] = { | ||
DELETE = function(self, dao_factory) | ||
cache.delete_all() | ||
return responses.send_HTTP_OK() | ||
end | ||
}, | ||
|
||
["/cache/:key"] = { | ||
GET = function(self, dao_factory) | ||
if self.params.key then | ||
local cached_item = cache.get(self.params.key) | ||
if cached_item then | ||
return responses.send_HTTP_OK(cached_item) | ||
end | ||
end | ||
|
||
return responses.send_HTTP_NOT_FOUND() | ||
end, | ||
|
||
DELETE = function(self, dao_factory) | ||
if self.params.key then | ||
cache.delete(self.params.key) | ||
return responses.send_HTTP_OK() | ||
else | ||
return responses.send_HTTP_NOT_FOUND() | ||
end | ||
end | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
local responses = require "kong.tools.responses" | ||
local cjson = require "cjson" | ||
|
||
return { | ||
["/cluster/"] = { | ||
GET = function(self, dao_factory) | ||
local serf = require("kong.cli.services.serf")(configuration) | ||
local res, err = serf:invoke_signal("members", { ["-format"] = "json" }) | ||
if err then | ||
return responses.send_HTTP_INTERNAL_SERVER_ERROR(err) | ||
else | ||
local members = cjson.decode(res).members | ||
for _, v in ipairs(members) do | ||
v.tags = nil | ||
v.protocol = nil | ||
end | ||
return responses.send_HTTP_OK(members) | ||
end | ||
end, | ||
|
||
POST = function(self, dao_factory) | ||
local serf = require("kong.cli.services.serf")(configuration) | ||
if self.params.address then | ||
local _, err = serf:invoke_signal("join", { self.params.address }) | ||
if err then | ||
return responses.send_HTTP_BAD_REQUEST(err) | ||
else | ||
return responses.send_HTTP_OK() | ||
end | ||
else | ||
return responses.send_HTTP_BAD_REQUEST("Missing \"address\"") | ||
end | ||
end | ||
}, | ||
["/cluster/events/"] = { | ||
POST = function(self, dao_factory) | ||
ngx.log(ngx.DEBUG, " received cluster event "..(self.params.type and self.params.type or "UNKNOWN")) | ||
|
||
local message_t = self.params | ||
|
||
-- If it's an update, load the new entity too so it's available in the hooks | ||
if message_t.type == events.TYPES.ENTITY_UPDATED then | ||
message_t.old_entity = message_t.entity | ||
message_t.entity = dao[message_t.collection]:find_by_primary_key({id=message_t.old_entity.id}) | ||
if not message_t.entity then | ||
-- This means that the entity has been deleted immediately after an update in the meanwhile that | ||
-- the system was still processing the update. A delete invalidation will come immediately after | ||
-- so we can ignore this event | ||
return responses.send_HTTP_OK() | ||
end | ||
end | ||
|
||
-- Trigger event in the node | ||
events:publish(message_t.type, message_t) | ||
return responses.send_HTTP_OK() | ||
end | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.