@live-change/framework
Advanced tools
Comparing version 0.3.34 to 0.4.0
@@ -271,2 +271,6 @@ const ReactiveDao = require("@live-change/dao") | ||
async waitForEvents(reportId, events, timeout) { | ||
if(events.length == 0) { | ||
console.log("no events, no need to wait", reportId) | ||
return | ||
} | ||
return new Promise((resolve, reject) => { | ||
@@ -330,2 +334,11 @@ let done = false | ||
async assertTime(taskName, duration, task, ...data) { | ||
const taskTimeout = setTimeout(() => { | ||
console.log(`TASK ${taskName} TIMEOUT`, ...data) | ||
}, duration) | ||
const result = await task() | ||
clearTimeout(taskTimeout) | ||
return result | ||
} | ||
async close() { | ||
@@ -332,0 +345,0 @@ this.dao.dispose() |
@@ -11,3 +11,5 @@ const Model = require("./Model.js") | ||
const eventSourcing = require('@live-change/event-sourcing') | ||
const EventSourcing = require('../utils/EventSourcing.js') | ||
const CommandQueue = require('../utils/CommandQueue.js') | ||
const KeyBasedExecutionQueues = require('../utils/KeyBasedExecutionQueues.js') | ||
@@ -100,7 +102,7 @@ class Service { | ||
if(this.app.splitEvents) { | ||
this.eventSourcing = new eventSourcing.EventSourcing(this.dao, this.databaseName, | ||
this.eventSourcing = new EventSourcing(this.dao, this.databaseName, | ||
'events_'+this.name, this.name, | ||
{ filter: (event) => event.service == this.name }) | ||
} else { | ||
this.eventSourcing = new eventSourcing.EventSourcing(this.dao, this.databaseName, | ||
this.eventSourcing = new EventSourcing(this.dao, this.databaseName, | ||
'events', this.name, | ||
@@ -129,6 +131,5 @@ { filter: (event) => event.service == this.name }) | ||
async startCommandExecutor() { | ||
this.commandQueue = new eventSourcing.CommandQueue(this.dao, this.databaseName, | ||
this.app.splitCommands ? `${this.name}_commands` : 'commands', | ||
{ filter: (command) => command.service == this.name } ) | ||
this.keyBasedCommandQueues = new eventSourcing.KeyBasedExecutionQueues(r => r.key) | ||
this.commandQueue = new CommandQueue(this.dao, this.databaseName, | ||
this.app.splitCommands ? `${this.name}_commands` : 'commands', this.name) | ||
this.keyBasedCommandQueues = new KeyBasedExecutionQueues(r => r.key) | ||
for (let actionName in this.actions) { | ||
@@ -148,3 +149,4 @@ const action = this.actions[actionName] | ||
const routine = async () => { | ||
const result = await action.runCommand(command, (...args) => emit.emit(...args)) | ||
const result = await this.app.assertTime('command '+action.definition.name, 10000, | ||
() => action.runCommand(command, (...args) => emit.emit(...args)), command) | ||
const events = await emit.commit() | ||
@@ -165,3 +167,4 @@ if(action.definition.waitForEvents) | ||
: new SingleEmitQueue(this, flags) | ||
const result = await action.runCommand(command, (...args) => emit.emit(...args)) | ||
const result = await this.app.assertTime('command '+action.definition.name, 10000, | ||
() => action.runCommand(command, (...args) => emit.emit(...args)), command) | ||
const events = await emit.commit() | ||
@@ -177,6 +180,5 @@ if(action.definition.waitForEvents) | ||
this.triggerQueue = new eventSourcing.CommandQueue(this.dao, this.databaseName, | ||
this.app.splitTriggers ? `${this.name}_triggers` : 'triggers', | ||
{ filter: (trigger) => trigger.service == this.name } ) | ||
this.keyBasedTriggerQueues = new eventSourcing.KeyBasedExecutionQueues(r => r.key) | ||
this.triggerQueue = new CommandQueue(this.dao, this.databaseName, | ||
this.app.splitTriggers ? `${this.name}_triggers` : 'triggers', this.name ) | ||
this.keyBasedTriggerQueues = new KeyBasedExecutionQueues(r => r.key) | ||
for (let triggerName in this.triggers) { | ||
@@ -201,4 +203,6 @@ const trigger = this.triggers[triggerName] | ||
try { | ||
console.log("TRIGGERED!!") | ||
result = await trigger.execute(trig, (...args) => emit.emit(...args)) | ||
console.log("TRIGGERED!!", trig) | ||
result = await this.app.assertTime('trigger '+trigger.definition.name, 10000, | ||
() => trigger.execute(trig, (...args) => emit.emit(...args)), trig) | ||
console.log("TRIGGER DONE!", trig) | ||
} catch (e) { | ||
@@ -230,3 +234,4 @@ console.error(`TRIGGER ${triggerName} ERROR`, e.stack) | ||
try { | ||
result = await trigger.execute(trig, (...args) => emit.emit(...args)) | ||
result = await this.app.assertTime('trigger '+trigger.definition.name, 10000, | ||
() => trigger.execute(trig, (...args) => emit.emit(...args)), trig) | ||
} catch (e) { | ||
@@ -233,0 +238,0 @@ console.error(`TRIGGER ${triggerName} ERROR`, e.stack) |
{ | ||
"name": "@live-change/framework", | ||
"version": "0.3.34", | ||
"version": "0.4.0", | ||
"description": "Live Change Framework - ultimate solution for real time mobile/web apps", | ||
@@ -46,5 +46,4 @@ "main": "index.js", | ||
"@elastic/elasticsearch": "^7.7.1", | ||
"@live-change/dao": "^0.2.18", | ||
"@live-change/event-sourcing": "^0.1.8" | ||
"@live-change/dao": "^0.2.18" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
146804
2
50
4060
40
316
61
143
- Removed@live-change/event-sourcing@^0.1.8
- Removed@live-change/event-sourcing@0.1.8(transitive)