@arque/core
Advanced tools
Comparing version 0.8.0-alpha.1 to 0.8.1
@@ -0,1 +1,2 @@ | ||
/** build=1x */ | ||
export * from './libs/event-id'; | ||
@@ -2,0 +3,0 @@ export * from './libs/types'; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const tslib_1 = require("tslib"); | ||
/** build=1x */ | ||
tslib_1.__exportStar(require("./libs/event-id"), exports); | ||
@@ -5,0 +6,0 @@ tslib_1.__exportStar(require("./libs/types"), exports); |
@@ -15,2 +15,3 @@ import { ConfigAdapter, StoreAdapter, StreamAdapter } from './adapters'; | ||
verbose: any; | ||
debug: any; | ||
}; | ||
@@ -17,0 +18,0 @@ private readonly eventHandlers; |
@@ -7,2 +7,3 @@ "use strict"; | ||
const debug_1 = tslib_1.__importDefault(require("debug")); | ||
const util_1 = require("util"); | ||
class Projection { | ||
@@ -17,6 +18,7 @@ constructor(store, stream, config, eventHandlers, _id, _state, opts) { | ||
this.logger = { | ||
info: (0, debug_1.default)('broker:info'), | ||
error: (0, debug_1.default)('broker:error'), | ||
warn: (0, debug_1.default)('broker:warn'), | ||
verbose: (0, debug_1.default)('broker:verbose'), | ||
info: (0, debug_1.default)('info:Projection'), | ||
error: (0, debug_1.default)('error:Projection'), | ||
warn: (0, debug_1.default)('warn:Projection'), | ||
verbose: (0, debug_1.default)('verbose:Projection'), | ||
debug: (0, debug_1.default)('debug:Projection'), | ||
}; | ||
@@ -34,2 +36,3 @@ this.subscriber = null; | ||
async handleEvent(event) { | ||
const timestamp = new Date(); | ||
this.timestampLastEventReceived = Date.now(); | ||
@@ -40,3 +43,15 @@ const handler = this.eventHandlers.get(event.type); | ||
if (await this.store.checkProjectionCheckpoint({ projection: this.id, aggregate: event.aggregate })) { | ||
await handle({ state: this._state }, event); | ||
try { | ||
await handle({ state: this._state }, event); | ||
} | ||
catch (err) { | ||
this.logger.error(`error occured while handling event: error="${err.message}" event="${(0, util_1.inspect)({ | ||
id: event.id.toString(), | ||
type: event.type, | ||
}, { | ||
breakLength: Infinity, | ||
compact: true, | ||
})}"`); | ||
throw err; | ||
} | ||
await this.store.saveProjectionCheckpoint({ | ||
@@ -46,2 +61,9 @@ projection: this.id, | ||
}); | ||
this.logger.verbose(`event handled: event="${(0, util_1.inspect)({ | ||
id: event.id.toString(), | ||
type: event.type, | ||
}, { | ||
breakLength: Infinity, | ||
compact: true, | ||
})}" duration=${Date.now() - timestamp.getTime()}ms`); | ||
} | ||
@@ -48,0 +70,0 @@ } |
{ | ||
"name": "@arque/core", | ||
"version": "0.8.0-alpha.1", | ||
"version": "0.8.1", | ||
"description": "`arque` core library", | ||
@@ -27,3 +27,3 @@ "author": "ScaleForge", | ||
"bs58": "5.0.0", | ||
"debug": "4.3.4", | ||
"debug": "4.3.5", | ||
"exponential-backoff": "3.1.1", | ||
@@ -35,3 +35,3 @@ "lru-cache": "10.2.2" | ||
}, | ||
"gitHead": "d0c2157a87c2de6b2d7ec558e0eb8b0c6c9d966f" | ||
"gitHead": "c1fa319a90f93a8ea5d22f62e941f1c0b78740bf" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
50531
819
+ Addeddebug@4.3.5(transitive)
- Removeddebug@4.3.4(transitive)
Updateddebug@4.3.5