-
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/Clustering - Hooks/…
…Events - Invalidations
- Loading branch information
1 parent
f4b9be2
commit 2193fe4
Showing
117 changed files
with
4,260 additions
and
983 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,52 @@ | ||
local crud = require "kong.api.crud_helpers" | ||
local responses = require "kong.tools.responses" | ||
|
||
return { | ||
["/cluster/"] = { | ||
GET = function(self, dao_factory) | ||
crud.paginated_set(self, dao_factory.nodes) | ||
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 | ||
|
||
-- The type is always upper case | ||
if message_t.type then | ||
message_t.type = string.upper(message_t.type) | ||
end | ||
|
||
-- 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.