-
-
Save mikz/ceb8f141de2e8f74206761abda231f70 to your computer and use it in GitHub Desktop.
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
-- purpose of this file is to have JUST ONE entrypoint to the module | |
-- so it can be required without any extra knowledge, | |
-- but also that the real file can have own name so it is easier to find | |
-- this file is loaded in a sandbox that has only APIcast load path and this policy available, | |
-- so there should be no namespace clash other than with APIcast itself. | |
return require('policy_name') |
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
local _M = required('apicast.policy').new() | |
local dep = require('vendor.dependency_name') | |
return _M |
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
1) must work both locally and when copied to a container | |
2) should NOT impose any naming rules for the source code | |
3) should have JUST ONE well-known entrypoint to load the code | |
4) should vendor all dependencies | |
5) must have a manifest file on well-known or guessable location | |
6) must be unique to each policy - policies are self contained and share nothing with other policies | |
7) must have unique policy_name | |
Example: | |
policy_name/ | |
policy_name/init.lua | |
policy_name/policy_name.lua | |
policy_name/vendor/dependency_name.lua | |
policy_name/apicast-policy.json | |
Would be installed like into folder : | |
./policies/policy_name/policy_version/ | |
so each {policy_name,policy_version} tuple has own directory. | |
And APIcast loader would take care of finding the proper policy based on the name and version in the chain: | |
[ { "name": "policy_name", "version": "policy_version" } ] | |
would call `policy_chain.load('policy_name', 'policy_version')` | |
which would require the policy code in sandbox and return the policy object. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment