Code Monkey home page Code Monkey logo

Comments (7)

esatterwhite avatar esatterwhite commented on August 12, 2024

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.

fffonion avatar fffonion commented on August 12, 2024

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.

esatterwhite avatar esatterwhite commented on August 12, 2024

@fffonion

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.

esatterwhite avatar esatterwhite commented on August 12, 2024

@fffonion

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.

esatterwhite avatar esatterwhite commented on August 12, 2024

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.

hanshuebner avatar hanshuebner commented on August 12, 2024

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.

esatterwhite avatar esatterwhite commented on August 12, 2024

I think this was done in #101

from kong-js-pdk.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.