tart-stepping-sandbox

Sandbox for tart-stepping

tart-stepping-sandbox

Stability: 1 - Experimental

Remotely controlled sandbox for controlling tart-stepping.

Remotely controlled sandbox for controlling tart-stepping. Familiarity with tart-stepping is assumed.

To run the below example run:

npm run readme
"use strict";
 
var sandbox = require('../index.js');
var tart = require('tart');
 
var sponsor = tart.minimal();
 
var create = sponsor(sandbox.createBeh);
 
var transport = sponsor(function transportBeh(message) {
    console.dir(message);
});
 
var ok = sponsor(function okBeh(message) {
    console.dir(message);
});
 
var fail = sponsor(function failBeh(message) {
    console.dir(message);
});
 
create({fail: fail, ok: ok, transport: transport});
npm test

Public API

Actor behavior that will create a new tart-stepping configuration and respond with capabilities allowing for remote control of that configuration.

Message format:

  • fail: Actor function (error) {} Fail actor to respond to if errors occur when creating.
  • ok: Actor function (sandboxCapabilities) {} Ok actor to respond to with created capabilities.
  • transport: Actor function (message) {} Transport actor capability that will be used for outbound traffic from the created sandbox.

The behavior creates two domains. The controlDomain, is the control surface for the tart-stepping configuration. The other created domain (domain) is the actual tart-stepping configuration which will accept commands from the controlDomain to dispatch, run the event loop, inspect last effect, destroy the configuration, or sponsor new actor behaviors.

sandbox.createBeh will return a response object to ok actor that contains the following:

  • controlDomain: String String name for the created control domain.
  • controlReceptionist: Actor function (message) {} Receptionist actor for the control domain to be registered with a transport for the given controlDomain name.
  • destroy: URI URI of the capability to destroy the created configuration.
  • dispatch: URI URI of the capability to dispatch the next event.
  • domain: String String name for the created domain to be controlled.
  • effect: URI URI of the capability to inspect the currently queued effects for the configuration.
  • eventLoop: URI URI of the capability to invoke the event loop on controlled configuration.
  • receptionist: Actor function (message) {} Receptionist actor for the domain under control to be registered with a transport for the given domain.
  • sponsor: URI URI of the capability to sponsor actor behaviors within the domain under control.

Destroys the sandboxed configuration.

Message format:

  • ok: Actor Optional actor to ack after destruction is complete.

Dispatch the next event. This is a wrapper around stepping.dispatch() using tart-adapter message format.

Return the value of stepping.effect (see tart-stepping).

Message format:

  • ok: Actor Actor to receive value of stepping.effect.

Dispatch events in a manner provided by control. This is a wrapper around stepping.eventLoop([control]) using tart-adapter message format.

Given a Node.js module that exports behaviors (see tart-vm), sponsor an actor for each behavior exported from the module.

Message format:

  • fail: Actor function (error) {} Fail actor to respond to if errors occur.
  • module: String Node.js module that exports behaviors that should be sponsored. The resulting actors will be sent to ok actor as a map of name-capability URI pairs, or a single capability URI.
  • ok: Actor function (response) {} Ok actor to respond to with sponsored capability URIs.