Skip to content
Rehan Iftikhar edited this page Dec 7, 2011 · 8 revisions

Documentation

Engine.js has a very simple public API. All default parameter values are designed to work together “out of the box”.

Client

Static Methods

engine.client.create({}) - Returns a new instance of engine.client.

Param Type Value Default Note
sending_endpoint String 0mq endpoint ipc:///tmp/intake-listener.ipc
listening_endpoint String 0mq endpoint ipc:///tmp/exhaust-publisher.ipc

Instance Methods

engine.client#createTask() - Returns a new instance of engine.task.

Task

A Task must be created through an instance of engine.client.

Instance Methods

engine.task#setContext(context) - Set a task’s context

Param Type Value Default Note
context String The context which the user’s code will be called against. none See creating your own contexts for more information.

engine.task#setCode(code) - Set a task’s code

Param Type Value Default Note
code String The user’s javascript code that will execute against the context none

engine.task#setLocals(locals) - Set a task’s local variable bindings

Param Type Value Default Note
locals Object literal A map of key/value pairs that will be available in the context none

engine.task#run() - Start executing a task

Events

A Task is an EventEmitter.

eval - When the task has finished evaluating. A result String object is passed to the callback function.

output - When the task has an output message (from the built-in console.log). A data String object is passed to the callback function.

Intake

Static Methods

engine.intake.create({}) - Returns a new instance of engine.intake

Param Type Value Default Note
sending_endpoint String 0mq endpoint (exclusive) ipc:///tmp/cylinder-listener.ipc
listening_endpoint String 0mq endpoint (exclusive) ipc:///tmp/intake-listener.ipc
logging_gateway logging_gateway instance Where log messages are sent Empty logging_gateway An Empty logging_gateway will accept log requests and do nothing with them

Cylinder

Static Methods

engine.cylinder.create({}) - Returns a new instance of engine.cylinder

Param Type Value Default Note
listening_endpoint String 0mq endpoint ipc:///tmp/cylinder-listener.ipc
exhaust_endpoint String 0mq endpoint ipc:///tmp/exhaust-listener.ipc
piston_script String File to run as the piston process ./script/piston.js
threshold Integer # of milliseconds a task can execute before its killed 5000
logging_gateway logging_gateway instance Where log messages are sent Empty logging_gateway An Empty logging_gateway will accept log requests and do nothing with them

Piston

Static Methods

engine.piston.create() - Returns a new instance of engine.piston

Param Type Value Default Note
console_endpoint String 0mq endpoint None. Kinda. The Cylinder will spawn a new process with node [piston_script] [cylinder_id] [console_endpoint]. Normally the value of console_endpoint is the same as the cylinder’s exhaust_endpoint

Exhaust

Static Methods

engine.exhaust.create({}) - Returns a new instance of engine.exhaust

Param Type Value Default Note
listening_endpoint String 0mq endpoint (exclusive) ipc:///tmp/exhaust-listener.ipc
publishing_endpoint String 0mq endpoint (exclusive) ipc:///tmp/exhaust-publisher.ipc
logging_gateway logging_gateway instance Where log messages are sent Empty logging_gateway An Empty logging_gateway will accept log requests and do nothing with them