Comments (7)
And if mtime
isn't something used by the kong server for something specific, that could probably just be Date.now()
from kong-js-pdk.
Hi @esatterwhite , thanks for your interest and taking a deep dive into the project! I agree that the logic of loading
a module from file can be simplified, it mostly come from I can't make the require
magic just work. That being said,
PRs are welcomed if you can find a simper and cleaner way to do it.
On the other hand, with complicated module layout, the ideal way to do it by having them running in embedded server mode. Normally, you don't want to run multiple different js projects in a same process and expect they don't fight
with each other.
Plugin loading is very disk intensive
I assume the disk consuming conclusion comes from the fact that starting js-pluginserver take several seconds, and
that isn't because those stat or require calls, but comes from loading ts-node
. Node does tons lots of other fs operation
when you load from node_modules and those calls doens't really add to noticable overhead.
from kong-js-pdk.
On the other hand, with complicated module layout, the ideal way to do it by having them running in embedded server mode. Normally, you don't want to run multiple different js projects in a same process and expect they don't fight
with each other.
The modules aren't / don't need to be separate plugin servers. There is still a single plugin server in this case. The plugins are just independant modules. Nothing has changed in this setup aside from the fact that they can be a directory which require
can still load.
This still works:
pluginserver_names = js
pluginserver_js_one_socket = /usr/local/kong/js_pluginserver.sock
pluginserver_js_one_start_cmd = /usr/local/bin/kong-js-pluginserver --plugin-dir /my/plugins
pluginserver_js_one_query_cmd = /usr/local/bin/kong-js-pluginserver --plugin-dir /my/plugins --dump-all-plugins
from kong-js-pdk.
I agree that the logic of loading a module from file can be simplified, it mostly come from I can't make the require magic just work.
Can you elaborate on this? what did/wouldn't work
from kong-js-pdk.
Normally, you don't want to run multiple different js projects in a same process and expect they don't fight
with each other.
Thats how everything in Node.js works. Every user land npm module is a different project in the same process. This set up isn't particularly any different than that, or referencing globally installed modules. Same thing
from kong-js-pdk.
We don't currently have plans to rework the JS module loading logic. A pull request would be welcome if anyone has interest and time.
from kong-js-pdk.
I think this was done in #101
from kong-js-pdk.
Related Issues (20)
- How to convert the response obtained from getRawBody() to a readable format ? HOT 2
- package.json no longer includes files for plugin_test.js HOT 1
- Incorrect assignment of mocked log functions in plugin_test.js
- Server tries to load all files in the folder as a plugin and fails to start HOT 3
- Problem reading gzipped kong.service.response.get_raw_body() HOT 11
- Modifying response body (no body_filter phase?) HOT 3
- Question: How to wrote Unit tests using plugin_test.js HOT 1
- How to cache stuff? HOT 1
- Issues running tests HOT 4
- Question: How to see plugin error inside docker container logs HOT 2
- Missing plugin socket HOT 2
- Critical severity alert on msgpack dependency HOT 2
- Accessing Binary Files in plugin HOT 3
- How to add X-Kong-Upstream-Status header to response HOT 4
- Share Data between Plugins in Kong JS PDK HOT 2
- How to set no_consumer flag with kong-js-pdk Schema HOT 4
- Reference to a incorrect module functions HOT 3
- Kong unable to load js plugin HOT 10
- Plugin Test Case - Cannot use import statement outside a module error HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from kong-js-pdk.