Checkpointing configuration implementation for Tiny Actor Run-Time in JavaScript.
Checkpointing configuration implementation for Tiny Actor Run-Time in JavaScript.
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');
npm test
Checkpoint objects are intended to be safely convertible to JSON and back again without loss of information.
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.
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.
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 ofevents
representing newly-sent messages.output
: Array (Default: []) An array of transport-encoded messages to remote actors.cause
: Object (Default: undefined) Theevent
that is the cause of thiseffect
, if any.update
: Function (Default: undefined) The new state and behavior of theactor
that caused thisevent
.exception
: Object (Default: undefined) If dispatching theevent
caused an exception, that exception is stored here.
Public API
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.