Skip to content

Commit

Permalink
Added interop feature
Browse files Browse the repository at this point in the history
  • Loading branch information
ncthbrt committed Apr 13, 2018
1 parent e2aacff commit 06319ed
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 9 deletions.
1 change: 0 additions & 1 deletion .bsb.lock

This file was deleted.

1 change: 0 additions & 1 deletion bsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"name": "reason-nact",
"version": "1.4.4",
"sources": [
{
"dir": "src"
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "reason-nact",
"version": "3.0.1",
"version": "3.1.0",
"description": "let reason-nact = (node.js, reason, actors) ⇒ your µ services have never been so typed",
"repository": "https://github.com/ncthbrt/reason-nact",
"author": "Nick Cuthbert (https://github.com/ncthbrt)",
Expand Down Expand Up @@ -46,4 +46,4 @@
"dependencies": {
"nact": "^6.0.4"
}
}
}
30 changes: 25 additions & 5 deletions src/Nact.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,25 @@ function defaultTo($$default, opt) {
}
}

function fromUntypedRef(reference) {
return /* ActorRef */[reference];
}

function toUntypedRef(param) {
return param[0];
}

function dispatch(prim, prim$1) {
Nact.dispatch(prim, prim$1);
return /* () */0;
}

var Interop = /* module */[
/* fromUntypedRef */fromUntypedRef,
/* toUntypedRef */toUntypedRef,
/* dispatch */dispatch
];

function fromReference(param) {
return /* ActorPath */[param[0].path];
}
Expand Down Expand Up @@ -366,7 +385,7 @@ function stop(param) {
return /* () */0;
}

function dispatch(param, msg) {
function dispatch$1(param, msg) {
Nact.dispatch(param[0], msg);
return /* () */0;
}
Expand All @@ -377,7 +396,7 @@ function nobody() {

function spawnAdapter(parent, mapping) {
return spawnStateless(/* None */0, /* None */0, /* None */0, parent, (function (msg, _) {
return Promise.resolve(dispatch(parent, Curry._1(mapping, msg)));
return Promise.resolve(dispatch$1(parent, Curry._1(mapping, msg)));
}));
}

Expand Down Expand Up @@ -450,10 +469,10 @@ var minutes = Caml_int32.imul(60, seconds);

var hours = Caml_int32.imul(60, minutes);

var $less$neg$less = dispatch;
var $less$neg$less = dispatch$1;

function $great$neg$great(msg, actorRef) {
return dispatch(actorRef, msg);
return dispatch$1(actorRef, msg);
}

function $less$unknown(actor, param) {
Expand Down Expand Up @@ -491,6 +510,7 @@ var messages = 1;

var message = 1;

exports.Interop = Interop;
exports.ActorPath = ActorPath;
exports.Log = Log;
exports.useStatefulSupervisionPolicy = useStatefulSupervisionPolicy;
Expand All @@ -500,7 +520,7 @@ exports.spawnPersistent = spawnPersistent;
exports.spawnAdapter = spawnAdapter;
exports.start = start;
exports.stop = stop;
exports.dispatch = dispatch;
exports.dispatch = dispatch$1;
exports.nobody = nobody;
exports.QueryTimeout = QueryTimeout;
exports.query = query;
Expand Down
8 changes: 8 additions & 0 deletions src/Nact.re
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,17 @@ let defaultTo = (default, opt) =>

type persistenceEngine = Nact_bindings.persistenceEngine;

type untypedRef = Nact_bindings.actorRef;

type actorRef('msg) =
| ActorRef(Nact_bindings.actorRef);

module Interop = {
let fromUntypedRef = reference => ActorRef(reference);
let toUntypedRef = (ActorRef(reference)) => reference;
let dispatch = Nact_bindings.dispatch;
};

type actorPath =
| ActorPath(Nact_bindings.actorPath);

Expand Down
8 changes: 8 additions & 0 deletions src/Nact.rei
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,16 @@ type systemMsg;

type actorRef('msg);

type untypedRef;

type actorPath;

module Interop: {
let fromUntypedRef: untypedRef => actorRef('msg);
let toUntypedRef: actorRef('msg) => untypedRef;
let dispatch: (untypedRef, 'msg) => unit;
};

module ActorPath: {
let fromReference: actorRef(_) => actorPath;
let systemName: actorPath => string;
Expand Down

0 comments on commit 06319ed

Please sign in to comment.