0.1.0 • Published 11 years ago
tart-checkpoint v0.1.0
tart-checkpoint
Checkpointing configuration implementation for Tiny Actor Run-Time in JavaScript.
Contributors
Overview
Checkpointing configuration implementation for Tiny Actor Run-Time in JavaScript.
Usage
To run the below example run:
npm run readme"use strict";
var tart = require('../index.js');
var checkpoint = tart.checkpoint();
var oneTimeBeh = (function oneTimeBeh(message) {
console.log('oneTimeBeh:', message);
var becomeBeh = (function becomeBeh(message) {}).toString();
var actor = this.sponsor((function createdBeh(message) {
console.log('createdBeh:', message);
}).toString()); // create
actor(this.state.label); // send
this.behavior = becomeBeh; // become
}).toString();
var actor = checkpoint.sponsor(oneTimeBeh, { label:'foo' });
actor('bar');Tests
npm testDocumentation
Checkpoint objects are intended to be safely convertible to JSON and back again without loss of information.
Events
An event is an Object that represents a message sent to an actor.
An event has the following attributes:
domain: String URI identifying the domain that generated the event.time: NumberDate.now()timestamp when the event was generated.seq: Number event sequence number, monotonically increasing withintime.message: String Transport-encoded message to be delivered.token: String Transport token identifying the target actor.
Actors
An actor is an Object that represents a unique entity with state and behavior.
An actor has the following attributes:
state: String Transport-encoded object representing the actor's state.behavior: String The actor's behavior function in source form.token: String Transport token uniquely identifying this actor.
Effects
An effect is an Object that represents the result of processing an event.
An effect has the following attributes:
created: Object (Default: {}) A map from tokens to newly-createdactors.sent: Array (Default: []) An array ofeventsrepresenting newly-sent messages.output: Array (Default: []) An array of transport-encoded messages to remote actors.cause: Object (Default: undefined) Theeventthat is the cause of thiseffect, if any.update: Function (Default: undefined) The new state and behavior of theactorthat caused thisevent.exception: Object (Default: undefined) If dispatching theeventcaused an exception, that exception is stored here.
Public API
tart.checkpoint(options)
options: Object (Default: undefined) Optional overrides.logEffect: Functionfunction (effect, callback) {}Recordeffect, then callcallback(error).
- Return: Object The checkpoint control object.
domain: Object Marshal domain.router: Object Router for marshal domain.sponsor: Functionfunction (behavior[, state[, token]]) {}A capability to create new actors with persistent state and optional identity.
Create a checkpoint control object.
Sources
0.1.0
11 years ago