ENGAGE-549: Architecture: Determine the viability of server-side JavaScript using Jack and JSGI

Metadata

Source
ENGAGE-549
Type
Task
Priority
Major
Status
Closed
Resolution
Fixed
Assignee
Colin Clark
Reporter
Colin Clark
Created
2009-06-02T19:19:13.000-0400
Updated
2014-03-03T14:28:51.448-0500
Versions
N/A
Fixed Versions
N/A
Component
N/A

Description

We're interested in the possibility of building Infusion's services layer using JavaScript running on the server. This would allow us to use much of our existing infrastructure from Infusion while using a widely familiar language.

Biggest concerns come from the lack of infrastructure and potential speed issues. Since JSGI and Jack help to address the infrastructure issue, let's get a sense of how fast or slow this stuff will be running in Rhino on the JVM.

Comments

  • Colin Clark commented 2009-06-04T09:41:19.000-0400

    Here's a zip file containing a checkout of Narwhal and Jack, along with a simple hello world-type test. There's a directory called "perftest" in here that is intended for the performance test application. Things to figure out:

    1. Do we need to call setTimeout() in runTests()? If so, what alternative do we have in Rhino/Narwhal? Or do we need to use Env.js?
    2. Get the Renderer to work without the DOM. This should be easy:

    • Call parseTemplates() and renderTemplates() instead of selfRender. renderTemplates() will need a resourceSpec object, but it should be fairly easy to create, using the implementation in selfRender() as an example. Some documentation:

    http://wiki.fluidproject.org/display/fluid/Renderer+API#RendererAPI-fetchResources

    After that, it should be as simple as packaging up everything as a module and then running it, appending the results of the Renderer to the body of the response.

  • Michelle D'Souza commented 2009-06-04T16:13:16.000-0400

    Note that despite what the readme says, for the examples to run as is, jack needs to be inside the narwhal directory. This will make the symlinks to jackup incorrect so run the example from the jack directory like this:
    bin/jackup examples/example.js

  • Colin Clark commented 2009-06-05T00:31:56.000-0400

    Here's an updated zip file containing narwhal and jack, along with a SecureModules package for InfusionAll.js. Due to our heavy dependence on jQuery, I had to also include Envjs, which is automatically imported if you load Infusion via Narwhal's package loader like this:

    var fluid = require("infusion").fluid;

    I've also moved the perftests jack app to into the narwhal directory (not exactly sure why; it should be able to go anywhere) and updated the app to load our perftest.html template and return it as the text of the response.

    Next steps: feed the text of that template file to parseTemplates() and renderTemplates(), returning the response. Obviously the code from perftests.js will have to be moved into scope for the app.