-
Notifications
You must be signed in to change notification settings - Fork 170
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
init and init_worker phases called on all policies #770
Conversation
Loading policy multiple times returns the same instance.
5a528fd
to
835ef42
Compare
The code was not taking into account that 'dir' is a table.
526ba5f
to
6783a06
Compare
Because it has to be executed for policies without configuration, it needs to be executed on the module level, not instance.
gateway/http.d/init.conf
Outdated
@@ -99,7 +99,7 @@ init_worker_by_lua_block { | |||
end) | |||
end | |||
|
|||
require('apicast.executor'):init_worker() | |||
require('apicast.executor').init_worker() |
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 one should be :
right? because it applies to an instance of Executor.
gateway/http.d/init.conf
Outdated
@@ -79,7 +79,7 @@ init_by_lua_block { | |||
package.loaded['apicast.executor'] = module | |||
end | |||
|
|||
module:init() | |||
module.init() |
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.
Same here
6783a06
to
ebc62e5
Compare
Now init() and init_worker() is run on service policies too.
7ed5ab8
to
096a9d4
Compare
executed[policy.init_worker] = true | ||
end | ||
|
||
for _, policy in ipairs(policies or policy_loader:get_all()) do |
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 caching complicates a lot testing this method. Depending on the execution the value will be cached or not and when it is, mocking policy_loader:get_all()
will have no effect.
The tests I added in my latest commit are affected by this.
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.
Are you ok with not caching this @mikz ?
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 see. It would make more sense to me to provide reset for the cache than not having it at all.
I think it is important to be correct and that init and init_worker should be executed on exactly the same lists. Loading the list for the second time could not ensure that.
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.
👍
… not in the chain
096a9d4
to
f8504bf
Compare
During master process boot all available policies are loaded
and get their
init
andinit_worker
phases executed.Increases initial memory use by about 800 kB (which is later shared between workers).