APIcast
APIcast copied to clipboard
1316: support resilient redis mode for cache util
This resolves #1316 and make it useful to use the cache without fail in case of network disconnect, etc.
Tests passing:
(results included in commit message)
Thanks @eloycoto and @unleashed .. Just covered both scenarios and made sure to keep backward compatibility as the default.
Tests run is passing:
$ make busted-util
EXTRA_CFLAGS="-DHAVE_EVP_KDF_CTX=1" /usr/local/openresty/luajit/bin/rover install --roverfile=gateway/Roverfile > /dev/null
/usr/local/openresty/luajit/bin/rover exec bin/busted "spec/threescale_utils_spec.lua"
●●●
3 successes / 0 failures / 0 errors / 0 pending : 0.022514 seconds
Guys I thought again about current implementation and think it's better to keep _M.error()
signature intact and introduce a new function (e.g. _M.silent_error()
) using same signature ...
and without nginx exit call.
This way will make the redis connect use either based on the resilient
flag and without impacting original function usage.
Shared chunk in the function will be reused without duplication.
What do you think @unleashed @eloycoto @kevprice83 ?
Update: New implementation is done and re-based all commits.
bash-4.4$ make busted-util
EXTRA_CFLAGS="-DHAVE_EVP_KDF_CTX=1" /usr/local/openresty/luajit/bin/rover install --roverfile=gateway/Roverfile > /dev/null
/usr/local/openresty/luajit/bin/rover exec bin/busted "spec/threescale_utils_spec.lua"
●●●
3 successes / 0 failures / 0 errors / 0 pending : 0.02537 seconds
In general I think this is fine and adds a useful option. We could probably look at extending error_handler in the future to map the same auth caching modes we support in the auth caching policy: allow
, none
, strict
& resilient
. That might also be of interest to you @abarrak in case you wanted more granular control over the auth caching decisions when using redis as a shared cache.
@kevprice83 please review this PR and we decide to merge or close it
Hi @eguzki @kevprice83, could you decide on this PR clousre? It was originally approved but got new changes after review.