Remove subscribe to redis function
diff --git a/api-gateway-config/scripts/lua/lib/redis.lua b/api-gateway-config/scripts/lua/lib/redis.lua
index 2007b14..37491ca 100644
--- a/api-gateway-config/scripts/lua/lib/redis.lua
+++ b/api-gateway-config/scripts/lua/lib/redis.lua
@@ -352,50 +352,7 @@
end
end
------------------------------------
-------- Pub/Sub with Redis --------
------------------------------------
-
---- Subscribe to redis
--- @param redisSubClient the redis client that is listening for the redis key changes
--- @param redisGetClient the redis client that gets the changed resource to update the conf file
-function _M.subscribe(redisSubClient, redisGetClient)
- logger.info("Subscribed to redis and listening for key changes...")
- -- Subscribe to redis using psubscribe
- local ok, err = redisSubClient:config("set", "notify-keyspace-events", "KEA")
- if not ok then
- request.err(500, utils.concatStrings({"Failed to subscribe to redis: ", err}))
- end
- ok, err = redisSubClient:psubscribe("__keyspace@0__:resources:*:*")
- if not ok then
- request.err(500, utils.concatStrings({"Failed to subscribe to redis: ", err}))
- end
- while true do
- local res, err = redisSubClient:read_reply()
- if not res then
- if err ~= "timeout" then
- request.err(500, utils.concatStrings({"Failed to read from redis: ", err}))
- end
- else
- -- res[3] format is "__keyspace@0__:resources:<tenantId>:<gatewayPath>"
- local keyspacePrefix, resourcePrefix, tenant, gatewayPath = res[3]:match("([^,]+):([^,]+):([^,]+):([^,]+)")
- local redisKey = utils.concatStrings({resourcePrefix, ":", tenant, ":", gatewayPath})
- -- Don't allow single quotes in the gateway path
- if string.match(gatewayPath, "'") then
- logger.info(utils.concatStrings({"Redis key \"", redisKey, "\" contains illegal character \"'\"."}))
- else
- local resourceObj = _M.getResource(redisGetClient, redisKey, REDIS_FIELD)
- if resourceObj == nil then
- logger.info(utils.concatStrings({"Redis key deleted: ", redisKey}))
- else
- logger.info(utils.concatStrings({"Redis key updated: ", redisKey}))
- end
- end
- end
- end
-end
-
---- Get gateway sync status
+--- Check health of gateway
function _M.healthCheck()
request.success(200, "Status: Gateway ready.")
end
diff --git a/api-gateway-config/scripts/lua/management.lua b/api-gateway-config/scripts/lua/management.lua
index 8108598..ad87c0b 100644
--- a/api-gateway-config/scripts/lua/management.lua
+++ b/api-gateway-config/scripts/lua/management.lua
@@ -520,25 +520,20 @@
----- Pub/Sub with Redis -----
------------------------------
---- Sync with redis
--- GET /v1/sync
-function _M.sync()
- local red = redis.init(REDIS_HOST, REDIS_PORT, REDIS_PASS, 10000)
- redis.syncWithRedis(red)
- ngx.exit(200)
-end
-
--- Subscribe to redis
-- GET /v1/subscribe
function _M.subscribe()
- local redisGetClient = redis.init(REDIS_HOST, REDIS_PORT, REDIS_PASS, 10000)
- local redisSubClient = redis.init(REDIS_HOST, REDIS_PORT, REDIS_PASS, 1000)
+ redis.init(REDIS_HOST, REDIS_PORT, REDIS_PASS)
logger.info(utils.concatStrings({"Connected to redis at ", REDIS_HOST, ":", REDIS_PORT}))
- redis.subscribe(redisSubClient, redisGetClient)
+ while true do end
ngx.exit(200)
end
---- Get gateway sync status
+----------------------------
+------- Health Check -------
+----------------------------
+
+--- Check health of gateway
function _M.healthCheck()
redis.healthCheck()
end
diff --git a/api-gateway-config/scripts/lua/routing.lua b/api-gateway-config/scripts/lua/routing.lua
index 1b896dd..005e35e 100644
--- a/api-gateway-config/scripts/lua/routing.lua
+++ b/api-gateway-config/scripts/lua/routing.lua
@@ -49,7 +49,7 @@
if obj == nil then
obj = checkForPathParams(red)
if obj == nil then
- return request.err(404, 'API doesn\'t exist.')
+ return request.err(404, 'Not found.')
end
end
obj = cjson.decode(obj)