Skip to content

Commit

Permalink
Fixed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ncthbrt committed May 10, 2018
1 parent 02cf186 commit a340d99
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 10 deletions.
10 changes: 2 additions & 8 deletions lib/actor.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class Actor {
this.path = parent.path.createChildPath(this.name);
this.system = system;
this.reference = new ActorReference(this.system.name, this.parent.reference, this.path, this.name);
this.log = this.system.createLogger || this.system.createLogger(this.reference);
this.log = this.system.createLogger(this.reference);
this.f = f;
this.state = undefined;
this.stopped = false;
Expand Down Expand Up @@ -202,13 +202,7 @@ const spawn = (parent, f, name, properties) =>
systemMap.applyOrThrowIfStopped(parent, p => p.assertNotStopped() && new Actor(p, name, p.system, f, properties).reference);

const spawnStateless = (parent, f, name, properties) =>
spawn(parent, function (state, msg, ctx) {
try {
return f.call(ctx, msg, ctx);
} catch (e) {
console.error(e);
}
}, name, properties);
spawn(parent, (state, msg, ctx) => f.call(ctx, msg, ctx), name, { onCrash: (_, __, ctx) => ctx.resume, ...properties });

module.exports.spawn = spawn;
module.exports.spawnStateless = spawnStateless;
Expand Down
2 changes: 1 addition & 1 deletion lib/monitoring/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const { logToConsole } = require('./console-engine');
const configureLogging = (engine) => (system) => {
const loggingActor = engine(system.reference);
if (loggingActor) {
return Object.assign(system, { createLogger: (reference) => new LoggingFacade(loggingActor, reference) });
system.createLogger = (reference) => new LoggingFacade(loggingActor, reference);
} else {
throw new Error('Logging engine is not defined');
}
Expand Down
1 change: 1 addition & 0 deletions lib/system.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class ActorSystem {
constructor (extensions) {
let [hd, ...tail] = extensions;
this.children = new Map();
this.createLogger = () => undefined;
this.name = (typeof (hd) === 'object' && hd.name) || generateSystemId();
this.path = ActorPath.root(this.name);
this.reference = new ActorSystemReference(this.name, this.path);
Expand Down
3 changes: 2 additions & 1 deletion test/actor.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const children = (reference) => {
}
};

const ignore = () => { };
const ignore = () => {};

const retry = async (assertion, remainingAttempts, retryInterval = 0) => {
if (remainingAttempts <= 1) {
Expand All @@ -55,6 +55,7 @@ describe('ActorReference', function () {
it('should have name, path, parent, properties', function () {
let child = spawnStateless(system, ignore);
let grandchild = spawnStateless(child, ignore);
console.error(child.parent);
child.parent.should.equal(system);
grandchild.parent.should.equal(child);
child.name.should.be.a('string');
Expand Down

0 comments on commit a340d99

Please sign in to comment.