File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -229,12 +229,25 @@ function _M.build_from_specs(policy_specs)
229229 return chain
230230end
231231
232+ local function build_default_policy_order_checker ()
233+ return PolicyOrderChecker .new (
234+ policy_manifests_loader .get_all ()
235+ )
236+ end
237+
238+ -- Cache for the PolicyOrderChecker instance (module-level, per-worker)
239+ -- Since manifests are static (only change on worker restart), we can safely
240+ -- cache the checker to avoid rebuilding OrderRestrictions on every call
241+ local default_order_checker = build_default_policy_order_checker ()
242+
232243-- Checks if there are any policies placed in the wrong place in the chain.
233244-- It doesn't return anything, it prints error messages when there's a problem.
234245function _M :check_order (manifests )
235- PolicyOrderChecker .new (
236- manifests or policy_manifests_loader .get_all ()
237- ):check (self )
246+ -- If manifests are explicitly provided, create a new checker
247+ if manifests then
248+ return PolicyOrderChecker .new (manifests ):check (self )
249+ end
250+ default_order_checker :check (self )
238251end
239252
240253local function call_chain (phase_name )
You can’t perform that action at this time.
0 commit comments