Skip to content

tristanls/tart-stepping-sandbox

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

tart-stepping-sandbox

Stability: 1 - Experimental

NPM version

Remotely controlled sandbox for controlling tart-stepping.

Overview

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

Usage

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});

Tests

npm test

Documentation

Public API

sandbox.createBeh

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.

sandboxCapabilities.destroy

Destroys the sandboxed configuration.

Message format:

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

sandboxCapabilities.dispatch

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

sandboxCapabilities.effect

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

Message format:

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

sandboxCapabilities.eventLoop

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

sandboxCapabilities.sponsor

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.

Sources

About

Remotely controlled sandbox for tart-stepping.

Resources

License

Stars

Watchers

Forks

Packages

No packages published