Skip to content

tristanls/tart-revocable

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

tart-revocable

Stability: 1 - Experimental

NPM version

Implementation of a revocable proxy for Tiny Actor Run-Time in JavaScript.

Contributors

@dalnefre, @tristanls

Overview

An implementation of a revocable proxy.

Usage

To run the below example run:

npm run readme
"use strict";

var revocable = require('../index.js'),
    tart = require('tart');

var sponsor = tart.minimal();

var actorBeh = function actorBeh(message) {
    console.log(message);
};

var actor = sponsor(actorBeh);

var capabilities = revocable.proxy(actor);

var proxy = sponsor(capabilities.proxyBeh);
proxy('hello');
proxy('revocable');
proxy('world');

var revoke = sponsor(capabilities.revokeBeh);
var ackCustomer = sponsor(function ackCustomerBeh() {
    console.log('revoke acked');
    proxy('this');
    proxy('does not get through');
});
revoke(ackCustomer);

Tests

npm test

Documentation

Public API

revocable.proxy(actor)

  • actor: Actor function (message) {} Actor to create a revocable proxies for.
  • Return: Object An object containing behaviors for revocable proxies and a revoke capabilities for the proxies.
    • proxyBeh: Actor function (message) {} Actor behavior that will forward all messages to the actor it is a proxy for.
    • revokeBeh: Actor function (customer) {} Actor behavior that upon receipt of a message will revoke all proxies for the actor.
      • customer: Actor function () {} An ack will be sent to the customer upon revocation.

Sources

About

Tart implementation of a revocable proxy.

Resources

License

Stars

Watchers

Forks

Packages

No packages published