Skip to content
Rehan Iftikhar edited this page Nov 4, 2011 · 5 revisions

Engine.js overview

Components

  • Client: The Client is responsible for create new Task objects and sending them the Intake
  • Task: A Task is the central unit of work in Engine.js. A Task contains a context, user code, and run-time variable bindings.
  • Intake: The Intake is responsible for accepting incoming Task messages from many clients and forwarding them to many Cylinders
  • Cylinder: When a Cylinder is created it starts its own Piston (in a separate process). When a Cylinder receives a Task it starts an execution timer and sends the Task to its Piston for evaluation. When the Piston returns a result the Cylinder forwards it to the Exhaust
    • If the execution timer finishes before a response from the Piston is received, the Piston process is killed and an error is sent back to the Client (via the Exhaust).
  • Piston: The Piston is responsible for creating a code sandbox from the received Task message’s context and run-time variable bindings. The Piston then runs the user-code against the sandbox and returns the results to its parent Cylinder.
  • Exhaust: The Exhaust receives Task result messages from many Cylinders and forwards then back to the appropriate Client.

Diagram

                                                                            +------------+      +------------+
                                                                       -----|            |      |            |
+------+                                                               |    |  Cylinder  |<---->|   Piston   |
| Task +-+   +------------+                   +------------+           |    |            |      |            |
+------+ |   |            |                   |            |           |    +------------+      +------------+
         +---+   Client   +----+     +--->----|   Intake   |-->-+      |
+------+ |   |            |    |     |        |            |    |      |    +------------+      +------------+
| Task +-+   +------------+    |     |        +------------+    |      |    |            |      |            |
+------+                       |     |              (1)         +-->---+    |  Cylinder  |<---->+   Piston   |
   (n)                         +-----+                                 |    |            |      |            |
                               |     |                          +--<---+    +------------+      +------------+
             +------------+    |     |        +------------+    |      |
+------+     |            |    |     |        |            |    |      |    +------------+      +------------+
| Task +-----+   Client   +----+     +---<----|  Exhaust   +-<--+      |    |            |      |            |
+------+     |            |                   |            |           |    |  Cylinder  |<---->+   Piston   |
             +------------+                   +------------+           |    |            |      |            |
                  (n)                               (1)                |    +------------+      +------------+
                                                                       |
                                                                       |    +------------+      +------------+
                                                                       |    |            |      |            |
                                                                       +----|  Cylinder  |<---->|   Piston   |
                                                                            |            |      |            |
                                                                            +------------+      +------------+
                                                                                  (n)
Clone this wiki locally