nats-hemera
Advanced tools
Comparing version 0.1.43 to 0.1.44
@@ -42,3 +42,2 @@ /*! | ||
msg.request$ = {} | ||
//Pass span name | ||
msg.request$.pattern = Util.pattern(pattern) | ||
@@ -51,3 +50,2 @@ msg.request$.endTime = Util.nowHrTime() | ||
msg.request$.endTime = Util.nowHrTime() | ||
//Pass span name | ||
msg.request$.pattern = Util.pattern(pattern) | ||
@@ -74,15 +72,13 @@ msg.request$.transportLatency = msg.response$.startTime - msg.request$.startTime | ||
//Set context by pattern or current configuration | ||
//Set context by pattern or current context$ | ||
ctx.context$ = pattern.context$ || prevCtx.context$ | ||
//Set metadata by pattern or previous context | ||
//Set metadata by passed pattern or previous context | ||
ctx.meta$ = (pattern.meta$ || ctx.meta$) || {} | ||
//Span | ||
ctx.meta$.span = ctx.meta$.span ? ++ctx.meta$.span : 1 | ||
//Trace id | ||
ctx.meta$.traceId = ctx.meta$.traceId || Util.createUniqueId() | ||
//Parent id | ||
//Expose to current act handler | ||
ctx.parentId$ = ctx.requestId$; | ||
//Create unique reqeuest id | ||
ctx.requestId$ = pattern.requestId$ || Util.createUniqueId() | ||
} | ||
@@ -89,0 +85,0 @@ |
@@ -31,3 +31,2 @@ /*! | ||
ctx.delegationData.response$.startTime = Util.nowHrTime() | ||
} | ||
@@ -45,23 +44,28 @@ /** | ||
//Pass metadata to response | ||
msg.pattern.meta$ = msg.meta$ | ||
msg.pattern.request$ = msg.request$ | ||
msg = msg.pattern | ||
//Pass metadata to request payload | ||
let result = msg.pattern | ||
result.meta$ = msg.meta$ | ||
result.request$ = msg.request$ | ||
//Pass parent id from previous request | ||
//Pass parentId$, requestId$ from previous request to current add handler context to preserve chain | ||
ctx.parentId$ = msg.request$.id | ||
//Append to response | ||
ctx.requestId$ = msg.request$.id | ||
//Append to response to transfer metadata to the next | ||
ctx.delegationData.meta$ = msg.meta$ || {} | ||
//Increment span id | ||
ctx.delegationData.meta$.span = ctx.delegationData.meta$.span ? ++ctx.delegationData.meta$.span : 1 | ||
ctx.delegationData.request$ = msg.request$ | ||
return msg | ||
return result | ||
} | ||
static after() { | ||
/** | ||
* | ||
* | ||
* @static | ||
* | ||
* @memberOf AddContext | ||
*/ | ||
static after() {} | ||
} | ||
} | ||
module.exports = AddContext |
{ | ||
"name": "nats-hemera", | ||
"author": "Dustin Deus (https://github.com/StarpTech)", | ||
"version": "0.1.43", | ||
"version": "0.1.44", | ||
"main": "index.js", | ||
@@ -6,0 +6,0 @@ "homepage": "https://hemerajs.github.io/hemera/", |
41962