-
Notifications
You must be signed in to change notification settings - Fork 3
Adds ability to target specific phase for serverless functions #21
Conversation
can't we specify the phase on a per-function basis? Now all the functions run in the same phase. It's harder to do backward compatible though. |
Much harder to do backwards compatibility. I like the idea though. |
Maybe not; if we add it as a second array in the config. Then all entries in the old array can be copied over to the new array under "access" entry. Mark the arrays in the schema as either one or the other can be provided. In some future version we drop support for the old array. |
@nijikokun if you'd like to give this a shot for Kong 2.0, now it's a window of opportunity for API changes if you think it's worth it for greater flexibility. |
Are you planning to merge this changes for kong 1.x? We need to execute custom Lua function in header_filter or body_filter phase |
dff3c24
to
78d46b0
Compare
@eskerda You mentioned you had a rebased version of this PR? Any chance you could incorporate the changes here? |
@hishamhm This is the rebased version. Trying to allocate some time to look at this CI failure. The other changes proposed are at https://github.com/Kong/kong-plugin-serverless-functions/tree/feat/multi-phase-take-two Probably we want to incorporate a nicer version of e7ff2d5 and most definitely we do not want aebc8b3 |
@nijikokun (cannot assign you for review it seems) cleaned up the changes from https://github.com/Kong/kong-plugin-serverless-functions/tree/feat/multi-phase-take-two
@Tieske since this is an old PR. Some context:
this new syntax I think is compatible with both old syntax and adds support for targeting multiple phases in the same config |
19a4975
to
2d50e58
Compare
2d50e58
to
6123d88
Compare
@Tieske :
I really didn't find a nicer (easy) way to rework the specs making sure that both old and new features work. Since we are going to deprecate |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can still cleanup the core of the handler to be cleaner code. Need to think about that.
True. I think I will give the handler core a few more spins |
82ebde3
to
f1fc937
Compare
there is a bigger underlying problem with the whole plugin. If a configured function does an early exit, then it will never be cached, which will make the plugin be recompiled and executed on every invocation. In case you use a plugin with upvalues, it means even that the upvalues will be lost. The way I see it there are 2 options:
The 2 cannot be combined properly, I think, but it's hard to reason about. |
there's no concept of plugin entity during init_worker
* default config.functions to access phase (as always) * make config.functions and config.access mutually exclusive * throw a deprecation warning when config.functions is used
f1fc937
to
6a9ecfe
Compare
see comment #21 (comment)
I added some config files and rebased it on master. Also fixed the bad test that displays the behaviour I described (bug in the test failed it to show). |
see #27 for the fix (complete rewrite btw) |
Because executing might do an early exit, we need to cache the function before executing it
Implements #20
Now you can specifically target and run functions in the
header_filter
orbody_filter
phase, or any other phase that Kong Plugins support.Usage:
Setup
Check for
server
headerSave as
custom-fn.lua
Add
pre-function
forheader_filter
phaseNo more
server
header