-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace globals
configuration
, dao
with module variables.
- Loading branch information
Showing
24 changed files
with
111 additions
and
84 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
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
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
Oops, something went wrong.
f59c849
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.
This is interesting for a short-term approach.
My current, long-term idea is to leave those tables as Lua upvalues in the
kong.lua
"main" file, responsible for the plugins event loop. The event loop would be updated to allow more granularity in the number of hooks proposed since Kong plugins need more granularity than OpenResty modules:The event loop would then execute those contexts for each plugin, and plugins would ultimately be built in a much more FP-oriented way (ditching out the current verbose, not-so-useful OOP pattern):
This approach would make the plugins much more unit-testable than the current ones, would allow for more granularity for developers, and one could imagine 2 plugins that are executed in the same hook could be triggered in any order, since the FP paradigm simply provides us with much more robust handlers.
Of course, on a short-term timeline, your approach has the benefit of cleaning the global namespace (and local accesses are much faster than global ones too). I would not be opposed to discuss it and include this in Kong if you want to submit it.
f59c849
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.
@thibaultcha The more FP (function programming) style the better, especially for these granular plugin hooks.
It's understandable that
ngx
is inherently mutable with the request contexts. That little identifier is so overloaded with functionality & data structures, it seems we're stuck with it. Ideally the design would avoid any other side effects, though.Great to hear about the vision for this aspect of Kong. Let's continue discussion in the PR.