Skip to content

feat: support _meta.pre_function to execute custom logic before execution of each phase#11793

Merged
Revolyssup merged 15 commits into
apache:masterfrom
Revolyssup:revolyssup/feat/pre-func
Jan 28, 2025
Merged

feat: support _meta.pre_function to execute custom logic before execution of each phase#11793
Revolyssup merged 15 commits into
apache:masterfrom
Revolyssup:revolyssup/feat/pre-func

Conversation

@Revolyssup

@Revolyssup Revolyssup commented Nov 29, 2024

Copy link
Copy Markdown
Contributor

Add pre_function to the meta of the plugin to allow some personalized code to run before all plugins run. For example, register personalized variables so that these temporary variables can be referenced and used in the plugin.

Description

Fixes # (issue)
Add pre_function to the meta of the plugin to allow some personalized code to run before all plugins run. For example, register personalized variables so that these temporary variables can be referenced and used in the plugin.

Checklist

  • I have explained the need for this PR and the problem it solves
  • I have explained the changes or the new features added to this PR
  • I have added tests corresponding to this change
  • I have updated the documentation to reflect this change
  • I have verified that this change is backward compatible (If not, please discuss on the APISIX mailing list first)

@dosubot dosubot Bot added size:L This PR changes 100-499 lines, ignoring generated files. enhancement New feature or request labels Nov 29, 2024
@Revolyssup Revolyssup changed the title feat: support _meta.pre_function to execute custom logic before execu… feat: support _meta.pre_function to execute custom logic before execution of each phase Nov 29, 2024
nic-6443
nic-6443 previously approved these changes Dec 3, 2024
@membphis

membphis commented Dec 5, 2024

Copy link
Copy Markdown
Member

@Revolyssup some CI test cases failed

image

@dosubot dosubot Bot added size:XL This PR changes 500-999 lines, ignoring generated files. and removed size:L This PR changes 100-499 lines, ignoring generated files. labels Dec 24, 2024
Comment thread utils/lj-releng Outdated
|os|print|tonumber|math|pcall|xpcall|unpack
|pairs|ipairs|assert|module|package
|coroutine|[gs]etfenv|next|rawget|rawset
|loadstring|dofile|collectgarbage|load

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

load is added here which is not present in original lj-relang causing lint check to fail

Comment thread utils/lj-releng Outdated
@@ -0,0 +1,228 @@
#!/usr/bin/env perl

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we update the tool utils/lj-releng in a separate PR?

one PR for one thing
small PR is easier to review

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done. here is the smaller pr #11862 @membphis

Comment thread apisix/plugin.lua
local local_plugins = core.table.new(32, 0)
local tostring = tostring
local error = error
-- make linter happy to avoid error: getting the Lua global "load"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this is no longer needed?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is needed. The lj-releng file just added to the keywords that can be used with the ignore comment.

@dosubot dosubot Bot added size:L This PR changes 100-499 lines, ignoring generated files. and removed size:XL This PR changes 500-999 lines, ignoring generated files. labels Dec 30, 2024
Signed-off-by: Ashish Tiwari <[email protected]>
Signed-off-by: Ashish Tiwari <[email protected]>
@Revolyssup
Revolyssup merged commit c2324a5 into apache:master Jan 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants