@hotmeshio/hotmesh 0.3.6 → 0.3.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (120) hide show
  1. package/build/index.d.ts +2 -1
  2. package/build/index.js +7 -1
  3. package/build/modules/key.js +1 -62
  4. package/build/modules/utils.js +1 -267
  5. package/build/package.json +12 -8
  6. package/build/services/activities/activity.js +1 -495
  7. package/build/services/activities/await.js +1 -109
  8. package/build/services/activities/cycle.js +1 -96
  9. package/build/services/activities/hook.js +1 -154
  10. package/build/services/activities/index.js +1 -20
  11. package/build/services/activities/interrupt.js +1 -149
  12. package/build/services/activities/signal.js +1 -118
  13. package/build/services/activities/trigger.js +1 -237
  14. package/build/services/activities/worker.js +1 -101
  15. package/build/services/collator/index.js +1 -197
  16. package/build/services/compiler/deployer.d.ts +3 -1
  17. package/build/services/compiler/deployer.js +1 -455
  18. package/build/services/compiler/index.d.ts +3 -1
  19. package/build/services/compiler/index.js +1 -91
  20. package/build/services/compiler/validator.js +1 -122
  21. package/build/services/engine/index.d.ts +5 -2
  22. package/build/services/engine/index.js +1 -562
  23. package/build/services/exporter/index.js +1 -93
  24. package/build/services/mapper/index.js +1 -67
  25. package/build/services/meshdata/index.d.ts +0 -1
  26. package/build/services/meshdata/index.js +16 -24
  27. package/build/services/meshflow/client.js +4 -8
  28. package/build/services/meshflow/exporter.js +1 -186
  29. package/build/services/meshflow/search.d.ts +4 -5
  30. package/build/services/meshflow/search.js +45 -35
  31. package/build/services/meshflow/workflow.d.ts +1 -1
  32. package/build/services/meshflow/workflow.js +3 -28
  33. package/build/services/pipe/functions/array.js +1 -74
  34. package/build/services/pipe/functions/bitwise.js +1 -24
  35. package/build/services/pipe/functions/conditional.js +1 -36
  36. package/build/services/pipe/functions/cron.js +1 -32
  37. package/build/services/pipe/functions/date.js +1 -164
  38. package/build/services/pipe/functions/index.js +1 -30
  39. package/build/services/pipe/functions/json.js +1 -12
  40. package/build/services/pipe/functions/logical.js +1 -12
  41. package/build/services/pipe/functions/math.js +1 -182
  42. package/build/services/pipe/functions/number.js +1 -60
  43. package/build/services/pipe/functions/object.js +1 -81
  44. package/build/services/pipe/functions/string.js +1 -69
  45. package/build/services/pipe/functions/symbol.js +1 -33
  46. package/build/services/pipe/functions/unary.js +1 -18
  47. package/build/services/pipe/index.js +1 -221
  48. package/build/services/quorum/index.d.ts +1 -1
  49. package/build/services/quorum/index.js +1 -219
  50. package/build/services/reporter/index.js +1 -331
  51. package/build/services/router/index.js +1 -420
  52. package/build/services/search/factory.d.ts +7 -0
  53. package/build/services/search/factory.js +20 -0
  54. package/build/services/search/index.d.ts +21 -0
  55. package/build/services/search/index.js +10 -0
  56. package/build/services/search/providers/redis/ioredis.d.ts +18 -0
  57. package/build/services/search/providers/redis/ioredis.js +1 -0
  58. package/build/services/search/providers/redis/redis.d.ts +18 -0
  59. package/build/services/search/providers/redis/redis.js +1 -0
  60. package/build/services/serializer/index.js +1 -265
  61. package/build/services/store/factory.d.ts +2 -1
  62. package/build/services/store/factory.js +2 -2
  63. package/build/services/store/index.d.ts +71 -97
  64. package/build/services/store/index.js +2 -939
  65. package/build/services/store/providers/postgres/postgres.d.ts +0 -0
  66. package/build/services/store/providers/postgres/postgres.js +0 -0
  67. package/build/services/store/providers/postgres/types/hash.d.ts +0 -0
  68. package/build/services/store/providers/postgres/types/hash.js +0 -0
  69. package/build/services/store/providers/postgres/types/list.d.ts +0 -0
  70. package/build/services/store/providers/postgres/types/list.js +0 -0
  71. package/build/services/store/providers/postgres/types/string.d.ts +0 -0
  72. package/build/services/store/providers/postgres/types/string.js +0 -0
  73. package/build/services/store/providers/postgres/types/zset.d.ts +0 -0
  74. package/build/services/store/providers/postgres/types/zset.js +0 -0
  75. package/build/services/store/providers/redis/_base.d.ts +98 -0
  76. package/build/services/store/providers/redis/_base.js +1 -0
  77. package/build/services/store/providers/redis/ioredis.d.ts +12 -0
  78. package/build/services/store/providers/redis/ioredis.js +1 -0
  79. package/build/services/store/providers/redis/redis.d.ts +13 -0
  80. package/build/services/store/providers/redis/redis.js +1 -0
  81. package/build/services/store/providers/store-initializable.d.ts +5 -0
  82. package/build/services/store/providers/store-initializable.js +1 -0
  83. package/build/services/stream/factory.d.ts +2 -1
  84. package/build/services/stream/factory.js +5 -5
  85. package/build/services/stream/index.d.ts +13 -14
  86. package/build/services/stream/index.js +3 -2
  87. package/build/services/stream/providers/postgres/_deploy.d.ts +4 -0
  88. package/build/services/stream/providers/postgres/_deploy.js +1 -0
  89. package/build/services/stream/providers/redis/ioredis.d.ts +21 -0
  90. package/build/services/stream/providers/redis/ioredis.js +1 -0
  91. package/build/services/stream/providers/redis/redis.d.ts +21 -0
  92. package/build/services/stream/providers/redis/redis.js +1 -0
  93. package/build/services/stream/providers/stream-initializable.d.ts +5 -0
  94. package/build/services/stream/providers/stream-initializable.js +1 -0
  95. package/build/services/sub/factory.d.ts +1 -1
  96. package/build/services/sub/factory.js +5 -5
  97. package/build/services/sub/index.d.ts +9 -7
  98. package/build/services/sub/index.js +3 -2
  99. package/build/services/sub/{clients → providers/redis}/ioredis.d.ts +7 -10
  100. package/build/services/sub/providers/redis/ioredis.js +1 -0
  101. package/build/services/sub/{clients → providers/redis}/redis.d.ts +7 -10
  102. package/build/services/sub/providers/redis/redis.js +1 -0
  103. package/build/services/task/index.js +1 -171
  104. package/build/services/telemetry/index.js +1 -225
  105. package/build/services/worker/index.d.ts +2 -2
  106. package/build/services/worker/index.js +1 -158
  107. package/build/types/redis.d.ts +5 -5
  108. package/index.ts +15 -1
  109. package/package.json +12 -8
  110. package/types/redis.ts +5 -5
  111. package/build/services/store/clients/ioredis.d.ts +0 -30
  112. package/build/services/store/clients/ioredis.js +0 -220
  113. package/build/services/store/clients/redis.d.ts +0 -32
  114. package/build/services/store/clients/redis.js +0 -319
  115. package/build/services/stream/clients/ioredis.d.ts +0 -24
  116. package/build/services/stream/clients/ioredis.js +0 -121
  117. package/build/services/stream/clients/redis.d.ts +0 -24
  118. package/build/services/stream/clients/redis.js +0 -161
  119. package/build/services/sub/clients/ioredis.js +0 -72
  120. package/build/services/sub/clients/redis.js +0 -63
@@ -1,14 +1,10 @@
1
- import { KeyStoreParams, KeyType } from '../../../modules/key';
2
- import { ILogger } from '../../logger';
3
- import { SubService } from '../index';
4
- import { IORedisClientType as RedisClientType, IORedisMultiType as RedisMultiType } from '../../../types/redis';
5
- import { SubscriptionCallback } from '../../../types/quorum';
1
+ import { KeyStoreParams, KeyType } from '../../../../modules/key';
2
+ import { ILogger } from '../../../logger';
3
+ import { SubService } from '../../index';
4
+ import { IORedisClientType as RedisClientType, IORedisMultiType as RedisMultiType } from '../../../../types/redis';
5
+ import { SubscriptionCallback } from '../../../../types/quorum';
6
6
  declare class IORedisSubService extends SubService<RedisClientType, RedisMultiType> {
7
- redisClient: RedisClientType;
8
- namespace: string;
9
- logger: ILogger;
10
- appId: string;
11
- constructor(redisClient: RedisClientType);
7
+ constructor(eventClient: RedisClientType, storeClient: RedisClientType);
12
8
  init(namespace: string, appId: string, engineId: string, logger: ILogger): Promise<void>;
13
9
  getMulti(): RedisMultiType;
14
10
  mintKey(type: KeyType, params: KeyStoreParams): string;
@@ -16,5 +12,6 @@ declare class IORedisSubService extends SubService<RedisClientType, RedisMultiTy
16
12
  unsubscribe(keyType: KeyType.QUORUM, appId: string, engineId?: string): Promise<void>;
17
13
  psubscribe(keyType: KeyType.QUORUM, callback: SubscriptionCallback, appId: string, engineId?: string): Promise<void>;
18
14
  punsubscribe(keyType: KeyType.QUORUM, appId: string, engineId?: string): Promise<void>;
15
+ publish(keyType: KeyType.QUORUM, message: Record<string, any>, appId: string, engineId?: string): Promise<boolean>;
19
16
  }
20
17
  export { IORedisSubService };
@@ -0,0 +1 @@
1
+ 'use strict';(function(_0x2c1587,_0x3436fd){const _0x1b6696=_0x1e53,_0x4ffbf8=_0x2c1587();while(!![]){try{const _0x1bd43f=-parseInt(_0x1b6696(0x1b7))/0x1*(parseInt(_0x1b6696(0x1b2))/0x2)+parseInt(_0x1b6696(0x1b8))/0x3+-parseInt(_0x1b6696(0x1b5))/0x4*(parseInt(_0x1b6696(0x1b6))/0x5)+-parseInt(_0x1b6696(0x1b0))/0x6+parseInt(_0x1b6696(0x1b4))/0x7+parseInt(_0x1b6696(0x1b1))/0x8+parseInt(_0x1b6696(0x1b3))/0x9;if(_0x1bd43f===_0x3436fd)break;else _0x4ffbf8['push'](_0x4ffbf8['shift']());}catch(_0x5e6f54){_0x4ffbf8['push'](_0x4ffbf8['shift']());}}}(_0x47f9,0x37ce7));Object['defineProperty'](exports,'__esModule',{'value':!![]}),exports['IORedisSubService']=void 0x0;const key_1=require('../../../../modules/key'),index_1=require('../../index');function _0x1e53(_0x28a45a,_0x1cd91a){const _0x47f984=_0x47f9();return _0x1e53=function(_0x1e53e1,_0x182c8c){_0x1e53e1=_0x1e53e1-0x1b0;let _0x4d4305=_0x47f984[_0x1e53e1];return _0x4d4305;},_0x1e53(_0x28a45a,_0x1cd91a);}function _0x47f9(){const _0x317dbc=['2609526txTyLb','949112ffJaut','2vTSZfK','5011659ZUWHHD','1696303SCvzFK','3812WkzCUn','455itFBCG','204880mIXpgP','111864btAzim'];_0x47f9=function(){return _0x317dbc;};return _0x47f9();}class IORedisSubService extends index_1['SubService']{constructor(_0x53ef1e,_0xcc4763){super(_0x53ef1e,_0xcc4763);}async['init'](_0x1a06bf=key_1['HMNS'],_0x22e284,_0x4420f4,_0x4683e7){this['namespace']=_0x1a06bf,this['logger']=_0x4683e7,this['appId']=_0x22e284;}['getMulti'](){return this['eventClient']['multi']();}['mintKey'](_0x2dfb44,_0x56bfbd){if(!this['namespace'])throw new Error('namespace\x20not\x20set');return key_1['KeyService']['mintKey'](this['namespace'],_0x2dfb44,_0x56bfbd);}async['subscribe'](_0x9e1e52,_0x8f9f,_0x47e434,_0x3339f7){const _0x346ae3=this,_0x343090=this['mintKey'](_0x9e1e52,{'appId':_0x47e434,'engineId':_0x3339f7});await this['eventClient']['subscribe'](_0x343090,_0x1fa2a6=>{_0x1fa2a6&&_0x346ae3['logger']['error']('Error\x20subscribing\x20to:\x20'+_0x343090,_0x1fa2a6);}),this['eventClient']['on']('message',(_0x188154,_0x53c82b)=>{if(_0x188154===_0x343090)try{const _0x921522=JSON['parse'](_0x53c82b);_0x8f9f(_0x343090,_0x921522);}catch(_0x2bde53){_0x346ae3['logger']['error']('Error\x20parsing\x20message:\x20'+_0x53c82b,_0x2bde53);}});}async['unsubscribe'](_0x4d316f,_0x56d641,_0x4c2fbb){const _0x47a5ee=this['mintKey'](_0x4d316f,{'appId':_0x56d641,'engineId':_0x4c2fbb});await this['eventClient']['unsubscribe'](_0x47a5ee);}async['psubscribe'](_0x3080fe,_0x58de9c,_0x1f1662,_0x57c8a0){const _0x477e6a=this,_0x4f0249=this['mintKey'](_0x3080fe,{'appId':_0x1f1662,'engineId':_0x57c8a0});await this['eventClient']['psubscribe'](_0x4f0249,_0x5cf3fc=>{_0x5cf3fc&&_0x477e6a['logger']['error']('Error\x20subscribing\x20to:\x20'+_0x4f0249,_0x5cf3fc);}),this['eventClient']['on']('pmessage',(_0xfea79b,_0x3bf9e7,_0x3892ae)=>{if(_0xfea79b===_0x4f0249)try{const _0x4251fc=JSON['parse'](_0x3892ae);_0x58de9c(_0x3bf9e7,_0x4251fc);}catch(_0x353254){_0x477e6a['logger']['error']('Error\x20parsing\x20message:\x20'+_0x3892ae,_0x353254);}});}async['punsubscribe'](_0xe49e61,_0x232bc1,_0x10f7aa){const _0x53b9a2=this['mintKey'](_0xe49e61,{'appId':_0x232bc1,'engineId':_0x10f7aa});await this['eventClient']['punsubscribe'](_0x53b9a2);}async['publish'](_0x469140,_0x4d9787,_0x1bc189,_0xdcd21c){const _0x51dca3=this['mintKey'](_0x469140,{'appId':_0x1bc189,'engineId':_0xdcd21c}),_0x59fa09=await this['storeClient']['publish'](_0x51dca3,JSON['stringify'](_0x4d9787));return _0x59fa09===0x1;}}exports['IORedisSubService']=IORedisSubService;
@@ -1,14 +1,10 @@
1
- import { KeyStoreParams, KeyType } from '../../../modules/key';
2
- import { ILogger } from '../../logger';
3
- import { SubService } from '../index';
4
- import { RedisRedisClientType as RedisClientType, RedisRedisMultiType as RedisMultiType } from '../../../types/redis';
5
- import { SubscriptionCallback } from '../../../types/quorum';
1
+ import { KeyStoreParams, KeyType } from '../../../../modules/key';
2
+ import { ILogger } from '../../../logger';
3
+ import { SubService } from '../../index';
4
+ import { RedisRedisClientType as RedisClientType, RedisRedisMultiType as RedisMultiType } from '../../../../types/redis';
5
+ import { SubscriptionCallback } from '../../../../types/quorum';
6
6
  declare class RedisSubService extends SubService<RedisClientType, RedisMultiType> {
7
- redisClient: RedisClientType;
8
- namespace: string;
9
- logger: ILogger;
10
- appId: string;
11
- constructor(redisClient: RedisClientType);
7
+ constructor(eventClient: RedisClientType, storeClient: RedisClientType);
12
8
  init(namespace: string, appId: string, engineId: string, logger: ILogger): Promise<void>;
13
9
  getMulti(): RedisMultiType;
14
10
  mintKey(type: KeyType, params: KeyStoreParams): string;
@@ -16,5 +12,6 @@ declare class RedisSubService extends SubService<RedisClientType, RedisMultiType
16
12
  unsubscribe(keyType: KeyType.QUORUM, appId: string, engineId?: string): Promise<void>;
17
13
  psubscribe(keyType: KeyType.QUORUM, callback: SubscriptionCallback, appId: string, engineId?: string): Promise<void>;
18
14
  punsubscribe(keyType: KeyType.QUORUM, appId: string, engineId?: string): Promise<void>;
15
+ publish(keyType: KeyType.QUORUM, message: Record<string, any>, appId: string, engineId?: string): Promise<boolean>;
19
16
  }
20
17
  export { RedisSubService };
@@ -0,0 +1 @@
1
+ 'use strict';function _0x24b2(_0x1a7d5f,_0x2e2262){const _0x5ea4dd=_0x5ea4();return _0x24b2=function(_0x24b23d,_0x154a85){_0x24b23d=_0x24b23d-0x191;let _0x439784=_0x5ea4dd[_0x24b23d];return _0x439784;},_0x24b2(_0x1a7d5f,_0x2e2262);}(function(_0x120590,_0x4e1403){const _0x56db43=_0x24b2,_0x3f3fca=_0x120590();while(!![]){try{const _0x21ae04=parseInt(_0x56db43(0x196))/0x1*(-parseInt(_0x56db43(0x19a))/0x2)+parseInt(_0x56db43(0x195))/0x3+parseInt(_0x56db43(0x198))/0x4*(parseInt(_0x56db43(0x192))/0x5)+parseInt(_0x56db43(0x197))/0x6+-parseInt(_0x56db43(0x194))/0x7+-parseInt(_0x56db43(0x193))/0x8*(parseInt(_0x56db43(0x199))/0x9)+-parseInt(_0x56db43(0x191))/0xa;if(_0x21ae04===_0x4e1403)break;else _0x3f3fca['push'](_0x3f3fca['shift']());}catch(_0x477b3c){_0x3f3fca['push'](_0x3f3fca['shift']());}}}(_0x5ea4,0x28b10));function _0x5ea4(){const _0x14e1f8=['962549YaxOFp','369384KXsRZM','33638yDntTP','1580898nsUIwo','24HsszAN','9GyblJj','12fJTREb','1510730iUzozk','270425ZWzAID','432328IpmDWw'];_0x5ea4=function(){return _0x14e1f8;};return _0x5ea4();}Object['defineProperty'](exports,'__esModule',{'value':!![]}),exports['RedisSubService']=void 0x0;const key_1=require('../../../../modules/key'),index_1=require('../../index');class RedisSubService extends index_1['SubService']{constructor(_0x16004c,_0x1c4363){super(_0x16004c,_0x1c4363);}async['init'](_0x4b6516=key_1['HMNS'],_0x3b35dc,_0x421e95,_0x21d9fe){this['namespace']=_0x4b6516,this['logger']=_0x21d9fe,this['appId']=_0x3b35dc;}['getMulti'](){const _0xbb07=this['eventClient']['multi']();return _0xbb07;}['mintKey'](_0x25389b,_0x4b16ce){if(!this['namespace'])throw new Error('namespace\x20not\x20set');return key_1['KeyService']['mintKey'](this['namespace'],_0x25389b,_0x4b16ce);}async['subscribe'](_0x34a92c,_0x5ad9b3,_0x439dcc,_0x324fe4){if(this['eventClient']){const _0x48a018=this,_0x31de35=this['mintKey'](_0x34a92c,{'appId':_0x439dcc,'engineId':_0x324fe4});await this['eventClient']['subscribe'](_0x31de35,_0x254f02=>{try{const _0x38efe6=JSON['parse'](_0x254f02);_0x5ad9b3(_0x31de35,_0x38efe6);}catch(_0x463423){_0x48a018['logger']['error']('Error\x20parsing\x20message:\x20'+_0x254f02,_0x463423);}});}}async['unsubscribe'](_0x4f9745,_0x6bad7d,_0x10a9b7){const _0x1d212f=this['mintKey'](_0x4f9745,{'appId':_0x6bad7d,'engineId':_0x10a9b7});await this['eventClient']['unsubscribe'](_0x1d212f);}async['psubscribe'](_0x31df6a,_0x525a5d,_0x3e9221,_0x4559d5){if(this['eventClient']){const _0x3feee0=this,_0x54d4c6=this['mintKey'](_0x31df6a,{'appId':_0x3e9221,'engineId':_0x4559d5});await this['eventClient']['pSubscribe'](_0x54d4c6,(_0x1be9d3,_0x3e02ec)=>{try{const _0x21f5a0=JSON['parse'](_0x1be9d3);_0x525a5d(_0x3e02ec,_0x21f5a0);}catch(_0x1dc59d){_0x3feee0['logger']['error']('Error\x20parsing\x20message:\x20'+_0x1be9d3,_0x1dc59d);}});}}async['punsubscribe'](_0x22a3b0,_0x29c639,_0x1c3279){const _0x41c904=this['mintKey'](_0x22a3b0,{'appId':_0x29c639,'engineId':_0x1c3279});await this['eventClient']['pUnsubscribe'](_0x41c904);}async['publish'](_0x450f37,_0x2b12e1,_0x9f85eb,_0x42a462){const _0x39d7e6=this['mintKey'](_0x450f37,{'appId':_0x9f85eb,'engineId':_0x42a462}),_0x34a930=await this['storeClient']['publish'](_0x39d7e6,JSON['stringify'](_0x2b12e1));return _0x34a930>0x0;}}exports['RedisSubService']=RedisSubService;
@@ -1,171 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TaskService = void 0;
4
- const enums_1 = require("../../modules/enums");
5
- const utils_1 = require("../../modules/utils");
6
- const pipe_1 = require("../pipe");
7
- const hotmesh_1 = require("../../types/hotmesh");
8
- const key_1 = require("../../modules/key");
9
- class TaskService {
10
- constructor(store, logger) {
11
- this.cleanupTimeout = null;
12
- this.isScout = false;
13
- this.errorCount = 0;
14
- this.logger = logger;
15
- this.store = store;
16
- }
17
- async processWebHooks(hookEventCallback) {
18
- const workItemKey = await this.store.getActiveTaskQueue();
19
- if (workItemKey) {
20
- const [topic, sourceKey, scrub, ...sdata] = workItemKey.split(key_1.WEBSEP);
21
- const data = JSON.parse(sdata.join(key_1.WEBSEP));
22
- const destinationKey = `${sourceKey}:processed`;
23
- const jobId = await this.store.processTaskQueue(sourceKey, destinationKey);
24
- if (jobId) {
25
- await hookEventCallback(topic, { ...data, id: jobId });
26
- }
27
- else {
28
- await this.store.deleteProcessedTaskQueue(workItemKey, sourceKey, destinationKey, scrub === 'true');
29
- }
30
- setImmediate(() => this.processWebHooks(hookEventCallback));
31
- }
32
- }
33
- async enqueueWorkItems(keys) {
34
- await this.store.addTaskQueues(keys);
35
- }
36
- async registerJobForCleanup(jobId, inSeconds = enums_1.HMSH_EXPIRE_DURATION, options) {
37
- if (inSeconds > 0) {
38
- await this.store.expireJob(jobId, inSeconds);
39
- }
40
- }
41
- async registerTimeHook(jobId, gId, activityId, type, inSeconds = enums_1.HMSH_FIDELITY_SECONDS, dad, multi) {
42
- const fromNow = Date.now() + inSeconds * 1000;
43
- const fidelityMS = enums_1.HMSH_FIDELITY_SECONDS * 1000;
44
- const awakenTimeSlot = Math.floor(fromNow / fidelityMS) * fidelityMS;
45
- await this.store.registerTimeHook(jobId, gId, activityId, type, awakenTimeSlot, dad, multi);
46
- }
47
- async shouldScout() {
48
- const wasScout = this.isScout;
49
- const isScout = wasScout || (this.isScout = await this.store.reserveScoutRole('time'));
50
- if (isScout) {
51
- if (!wasScout) {
52
- setTimeout(() => {
53
- this.isScout = false;
54
- }, enums_1.HMSH_SCOUT_INTERVAL_SECONDS * 1000);
55
- }
56
- return true;
57
- }
58
- return false;
59
- }
60
- async processTimeHooks(timeEventCallback, listKey) {
61
- if (await this.shouldScout()) {
62
- try {
63
- const workListTask = await this.store.getNextTask(listKey);
64
- if (Array.isArray(workListTask)) {
65
- const [listKey, target, gId, activityId, type] = workListTask;
66
- if (type === 'child') {
67
- }
68
- else if (type === 'delist') {
69
- const key = this.store.mintKey(hotmesh_1.KeyType.SIGNALS, {
70
- appId: this.store.appId,
71
- });
72
- await this.store.redisClient[this.store.commands.del](`${key}:${target}`);
73
- }
74
- else {
75
- await timeEventCallback(target, gId, activityId, type);
76
- }
77
- await (0, utils_1.sleepFor)(0);
78
- this.errorCount = 0;
79
- this.processTimeHooks(timeEventCallback, listKey);
80
- }
81
- else if (workListTask) {
82
- await (0, utils_1.sleepFor)(0);
83
- this.errorCount = 0;
84
- this.processTimeHooks(timeEventCallback);
85
- }
86
- else {
87
- const sleep = (0, utils_1.XSleepFor)(enums_1.HMSH_FIDELITY_SECONDS * 1000);
88
- this.cleanupTimeout = sleep.timerId;
89
- await sleep.promise;
90
- this.errorCount = 0;
91
- this.processTimeHooks(timeEventCallback);
92
- }
93
- }
94
- catch (err) {
95
- this.logger.warn('task-process-timehooks-error', err);
96
- await (0, utils_1.sleepFor)(1000 * this.errorCount++);
97
- if (this.errorCount < 5) {
98
- this.processTimeHooks(timeEventCallback);
99
- }
100
- }
101
- }
102
- else {
103
- const sleep = (0, utils_1.XSleepFor)(enums_1.HMSH_SCOUT_INTERVAL_SECONDS * 1000 * 2 * Math.random());
104
- this.cleanupTimeout = sleep.timerId;
105
- await sleep.promise;
106
- this.processTimeHooks(timeEventCallback);
107
- }
108
- }
109
- cancelCleanup() {
110
- if (this.cleanupTimeout !== undefined) {
111
- clearTimeout(this.cleanupTimeout);
112
- this.cleanupTimeout = undefined;
113
- }
114
- }
115
- async getHookRule(topic) {
116
- const rules = await this.store.getHookRules();
117
- return rules?.[topic]?.[0];
118
- }
119
- async registerWebHook(topic, context, dad, expire, multi) {
120
- const hookRule = await this.getHookRule(topic);
121
- if (hookRule) {
122
- const mapExpression = hookRule.conditions.match[0].expected;
123
- const resolved = pipe_1.Pipe.resolve(mapExpression, context);
124
- const jobId = context.metadata.jid;
125
- const gId = context.metadata.gid;
126
- const activityId = hookRule.to;
127
- const compositeJobKey = [activityId, dad, gId, jobId].join(key_1.WEBSEP);
128
- const hook = {
129
- topic,
130
- resolved,
131
- jobId: compositeJobKey,
132
- expire,
133
- };
134
- await this.store.setHookSignal(hook, multi);
135
- return jobId;
136
- }
137
- else {
138
- throw new Error('signaler.registerWebHook:error: hook rule not found');
139
- }
140
- }
141
- async processWebHookSignal(topic, data) {
142
- const hookRule = await this.getHookRule(topic);
143
- if (hookRule) {
144
- const context = { $self: { hook: { data } }, $hook: { data } };
145
- const mapExpression = hookRule.conditions.match[0].actual;
146
- const resolved = pipe_1.Pipe.resolve(mapExpression, context);
147
- const hookSignalId = await this.store.getHookSignal(topic, resolved);
148
- if (!hookSignalId) {
149
- return undefined;
150
- }
151
- const [_aid, dad, gid, ...jid] = hookSignalId.split(key_1.WEBSEP);
152
- return [jid.join(key_1.WEBSEP), hookRule.to, dad, gid];
153
- }
154
- else {
155
- throw new Error('signal-not-found');
156
- }
157
- }
158
- async deleteWebHookSignal(topic, data) {
159
- const hookRule = await this.getHookRule(topic);
160
- if (hookRule) {
161
- const context = { $self: { hook: { data } }, $hook: { data } };
162
- const mapExpression = hookRule.conditions.match[0].actual;
163
- const resolved = pipe_1.Pipe.resolve(mapExpression, context);
164
- return await this.store.deleteHookSignal(topic, resolved);
165
- }
166
- else {
167
- throw new Error('signaler.process:error: hook rule not found');
168
- }
169
- }
170
- }
171
- exports.TaskService = TaskService;
1
+ 'use strict';function _0x508b(_0x3f4edc,_0x20f5bf){const _0x315ab9=_0x315a();return _0x508b=function(_0x508bf8,_0x455352){_0x508bf8=_0x508bf8-0x158;let _0x1b771c=_0x315ab9[_0x508bf8];return _0x1b771c;},_0x508b(_0x3f4edc,_0x20f5bf);}(function(_0x3ac7e7,_0x40222a){const _0x2de3eb=_0x508b,_0x32f57d=_0x3ac7e7();while(!![]){try{const _0x5a7642=-parseInt(_0x2de3eb(0x15e))/0x1+parseInt(_0x2de3eb(0x158))/0x2+-parseInt(_0x2de3eb(0x15b))/0x3+parseInt(_0x2de3eb(0x159))/0x4+-parseInt(_0x2de3eb(0x15f))/0x5*(parseInt(_0x2de3eb(0x15a))/0x6)+-parseInt(_0x2de3eb(0x15d))/0x7*(parseInt(_0x2de3eb(0x160))/0x8)+parseInt(_0x2de3eb(0x15c))/0x9;if(_0x5a7642===_0x40222a)break;else _0x32f57d['push'](_0x32f57d['shift']());}catch(_0x5084b4){_0x32f57d['push'](_0x32f57d['shift']());}}}(_0x315a,0xba900));function _0x315a(){const _0x446ef2=['1421gXWdVH','176338hJgXZu','6490qpWkDr','49792pbJlIi','761502AoFmGY','5257400BXRxyh','3966fsXKtQ','2279970ABYKPv','19141533xjoKDx'];_0x315a=function(){return _0x446ef2;};return _0x315a();}Object['defineProperty'](exports,'__esModule',{'value':!![]}),exports['TaskService']=void 0x0;const enums_1=require('../../modules/enums'),utils_1=require('../../modules/utils'),pipe_1=require('../pipe'),hotmesh_1=require('../../types/hotmesh'),key_1=require('../../modules/key');class TaskService{constructor(_0x404d61,_0x368e05){this['cleanupTimeout']=null,this['isScout']=![],this['errorCount']=0x0,this['logger']=_0x368e05,this['store']=_0x404d61;}async['processWebHooks'](_0x431226){const _0x4ec2d9=await this['store']['getActiveTaskQueue']();if(_0x4ec2d9){const [_0x493133,_0x490b2f,_0x446088,..._0x58de83]=_0x4ec2d9['split'](key_1['WEBSEP']),_0x47a61d=JSON['parse'](_0x58de83['join'](key_1['WEBSEP'])),_0x4e0bcb=_0x490b2f+':processed',_0x51d4ca=await this['store']['processTaskQueue'](_0x490b2f,_0x4e0bcb);_0x51d4ca?await _0x431226(_0x493133,{..._0x47a61d,'id':_0x51d4ca}):await this['store']['deleteProcessedTaskQueue'](_0x4ec2d9,_0x490b2f,_0x4e0bcb,_0x446088==='true'),setImmediate(()=>this['processWebHooks'](_0x431226));}}async['enqueueWorkItems'](_0xe87799){await this['store']['addTaskQueues'](_0xe87799);}async['registerJobForCleanup'](_0x4df570,_0x1f2147=enums_1['HMSH_EXPIRE_DURATION'],_0xd8e453){_0x1f2147>0x0&&await this['store']['expireJob'](_0x4df570,_0x1f2147);}async['registerTimeHook'](_0x457cf7,_0x314134,_0x13da99,_0x2d7a21,_0x37f298=enums_1['HMSH_FIDELITY_SECONDS'],_0x3368ac,_0x14d7d5){const _0x437250=Date['now']()+_0x37f298*0x3e8,_0x5277ae=enums_1['HMSH_FIDELITY_SECONDS']*0x3e8,_0xb41ee9=Math['floor'](_0x437250/_0x5277ae)*_0x5277ae;await this['store']['registerTimeHook'](_0x457cf7,_0x314134,_0x13da99,_0x2d7a21,_0xb41ee9,_0x3368ac,_0x14d7d5);}async['shouldScout'](){const _0x1fe813=this['isScout'],_0x3f1112=_0x1fe813||(this['isScout']=await this['store']['reserveScoutRole']('time'));if(_0x3f1112)return!_0x1fe813&&setTimeout(()=>{this['isScout']=![];},enums_1['HMSH_SCOUT_INTERVAL_SECONDS']*0x3e8),!![];return![];}async['processTimeHooks'](_0x1ed338,_0x435d8a){if(await this['shouldScout']())try{const _0x463ded=await this['store']['getNextTask'](_0x435d8a);if(Array['isArray'](_0x463ded)){const [_0x2de765,_0x1845a4,_0x42da2b,_0x23ed81,_0x303857]=_0x463ded;if(_0x303857==='child'){}else{if(_0x303857==='delist'){const _0x4e0582=this['store']['mintKey'](hotmesh_1['KeyType']['SIGNALS'],{'appId':this['store']['appId']});await this['store']['delistSignalKey'](_0x4e0582,_0x1845a4);}else await _0x1ed338(_0x1845a4,_0x42da2b,_0x23ed81,_0x303857);}await(0x0,utils_1['sleepFor'])(0x0),this['errorCount']=0x0,this['processTimeHooks'](_0x1ed338,_0x2de765);}else{if(_0x463ded)await(0x0,utils_1['sleepFor'])(0x0),this['errorCount']=0x0,this['processTimeHooks'](_0x1ed338);else{const _0x50a78a=(0x0,utils_1['XSleepFor'])(enums_1['HMSH_FIDELITY_SECONDS']*0x3e8);this['cleanupTimeout']=_0x50a78a['timerId'],await _0x50a78a['promise'],this['errorCount']=0x0,this['processTimeHooks'](_0x1ed338);}}}catch(_0x19b642){this['logger']['warn']('task-process-timehooks-error',_0x19b642),await(0x0,utils_1['sleepFor'])(0x3e8*this['errorCount']++),this['errorCount']<0x5&&this['processTimeHooks'](_0x1ed338);}else{const _0x43f7e5=(0x0,utils_1['XSleepFor'])(enums_1['HMSH_SCOUT_INTERVAL_SECONDS']*0x3e8*0x2*Math['random']());this['cleanupTimeout']=_0x43f7e5['timerId'],await _0x43f7e5['promise'],this['processTimeHooks'](_0x1ed338);}}['cancelCleanup'](){this['cleanupTimeout']!==undefined&&(clearTimeout(this['cleanupTimeout']),this['cleanupTimeout']=undefined);}async['getHookRule'](_0x1e8b5c){const _0x42f7a4=await this['store']['getHookRules']();return _0x42f7a4?.[_0x1e8b5c]?.[0x0];}async['registerWebHook'](_0x21d73a,_0x7a6d83,_0x209c60,_0x1dec4c,_0x25442f){const _0xb613b2=await this['getHookRule'](_0x21d73a);if(_0xb613b2){const _0x90d389=_0xb613b2['conditions']['match'][0x0]['expected'],_0x8a68fe=pipe_1['Pipe']['resolve'](_0x90d389,_0x7a6d83),_0x3d0781=_0x7a6d83['metadata']['jid'],_0x54ecfc=_0x7a6d83['metadata']['gid'],_0x2db1f2=_0xb613b2['to'],_0x21d7b9=[_0x2db1f2,_0x209c60,_0x54ecfc,_0x3d0781]['join'](key_1['WEBSEP']),_0x42e12a={'topic':_0x21d73a,'resolved':_0x8a68fe,'jobId':_0x21d7b9,'expire':_0x1dec4c};return await this['store']['setHookSignal'](_0x42e12a,_0x25442f),_0x3d0781;}else throw new Error('signaler.registerWebHook:error:\x20hook\x20rule\x20not\x20found');}async['processWebHookSignal'](_0x2c63d0,_0x2d4879){const _0x5b1fd6=await this['getHookRule'](_0x2c63d0);if(_0x5b1fd6){const _0x4c7291={'$self':{'hook':{'data':_0x2d4879}},'$hook':{'data':_0x2d4879}},_0xd417d6=_0x5b1fd6['conditions']['match'][0x0]['actual'],_0x412327=pipe_1['Pipe']['resolve'](_0xd417d6,_0x4c7291),_0x1047e3=await this['store']['getHookSignal'](_0x2c63d0,_0x412327);if(!_0x1047e3)return undefined;const [_0x3e6ace,_0x14e34,_0x221446,..._0x4f9f40]=_0x1047e3['split'](key_1['WEBSEP']);return[_0x4f9f40['join'](key_1['WEBSEP']),_0x5b1fd6['to'],_0x14e34,_0x221446];}else throw new Error('signal-not-found');}async['deleteWebHookSignal'](_0x2ccfe4,_0x5a2c4f){const _0x292b9=await this['getHookRule'](_0x2ccfe4);if(_0x292b9){const _0xefeb62={'$self':{'hook':{'data':_0x5a2c4f}},'$hook':{'data':_0x5a2c4f}},_0x3d2dd5=_0x292b9['conditions']['match'][0x0]['actual'],_0x234e8b=pipe_1['Pipe']['resolve'](_0x3d2dd5,_0xefeb62);return await this['store']['deleteHookSignal'](_0x2ccfe4,_0x234e8b);}else throw new Error('signaler.process:error:\x20hook\x20rule\x20not\x20found');}}exports['TaskService']=TaskService;
@@ -1,225 +1 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.TelemetryService = void 0;
7
- const package_json_1 = __importDefault(require("../../package.json"));
8
- const mapper_1 = require("../mapper");
9
- const stream_1 = require("../../types/stream");
10
- const telemetry_1 = require("../../types/telemetry");
11
- const utils_1 = require("../../modules/utils");
12
- class TelemetryService {
13
- constructor(appId, config, metadata, context) {
14
- this.leg = 1;
15
- this.appId = appId;
16
- this.config = config;
17
- this.metadata = metadata;
18
- this.context = context;
19
- }
20
- getJobParentSpanId() {
21
- return this.context.metadata.spn;
22
- }
23
- getActivityParentSpanId(leg) {
24
- if (leg === 1) {
25
- return this.context[this.config.parent].output?.metadata?.l2s;
26
- }
27
- else {
28
- return this.context['$self'].output?.metadata?.l1s;
29
- }
30
- }
31
- getTraceId() {
32
- return this.context.metadata.trc;
33
- }
34
- startJobSpan() {
35
- const spanName = `JOB/${this.appId}/${this.config.subscribes}/1`;
36
- const traceId = this.getTraceId();
37
- const spanId = this.getJobParentSpanId();
38
- const attributes = this.getSpanAttrs(1);
39
- const span = this.startSpan(traceId, spanId, spanName, attributes);
40
- this.jobSpan = span;
41
- this.setTelemetryContext(span, 1);
42
- return this;
43
- }
44
- startActivitySpan(leg = this.leg) {
45
- const spanName = `${this.config.type.toUpperCase()}/${this.appId}/${this.metadata.aid}/${leg}`;
46
- const traceId = this.getTraceId();
47
- const spanId = this.getActivityParentSpanId(leg);
48
- const attributes = this.getSpanAttrs(leg);
49
- const span = this.startSpan(traceId, spanId, spanName, attributes);
50
- this.setTelemetryContext(span, leg);
51
- this.span = span;
52
- return this;
53
- }
54
- startStreamSpan(data, role) {
55
- let type;
56
- if (role === stream_1.StreamRole.SYSTEM) {
57
- type = 'SYSTEM';
58
- }
59
- else if (role === stream_1.StreamRole.WORKER) {
60
- type = 'EXECUTE';
61
- }
62
- else if (data.type === stream_1.StreamDataType.RESULT ||
63
- data.type === stream_1.StreamDataType.RESPONSE) {
64
- type = 'FANIN';
65
- }
66
- else {
67
- type = 'FANOUT';
68
- }
69
- const topic = data.metadata.topic ? `/${data.metadata.topic}` : '';
70
- const spanName = `${type}/${this.appId}/${data.metadata.aid}${topic}`;
71
- const attributes = this.getStreamSpanAttrs(data);
72
- const span = this.startSpan(data.metadata.trc, data.metadata.spn, spanName, attributes);
73
- this.span = span;
74
- return this;
75
- }
76
- startSpan(traceId, spanId, spanName, attributes) {
77
- this.traceId = traceId;
78
- this.spanId = spanId;
79
- const tracer = telemetry_1.trace.getTracer(package_json_1.default.name, package_json_1.default.version);
80
- const parentContext = this.getParentSpanContext();
81
- const span = tracer.startSpan(spanName, { kind: telemetry_1.SpanKind.CLIENT, attributes, root: !parentContext }, parentContext);
82
- return span;
83
- }
84
- mapActivityAttributes() {
85
- if (this.config.telemetry) {
86
- const telemetryAtts = new mapper_1.MapperService(this.config.telemetry, this.context).mapRules();
87
- const namespacedAtts = {
88
- ...Object.keys(telemetryAtts).reduce((result, key) => {
89
- if (['string', 'boolean', 'number'].includes(typeof telemetryAtts[key])) {
90
- result[`app.activity.data.${key}`] = telemetryAtts[key];
91
- }
92
- return result;
93
- }, {}),
94
- };
95
- this.span?.setAttributes(namespacedAtts);
96
- }
97
- }
98
- setActivityAttributes(attributes) {
99
- this.span?.setAttributes(attributes);
100
- }
101
- setStreamAttributes(attributes) {
102
- this.span?.setAttributes(attributes);
103
- }
104
- setJobAttributes(attributes) {
105
- this.jobSpan?.setAttributes(attributes);
106
- }
107
- endJobSpan() {
108
- this.endSpan(this.jobSpan);
109
- }
110
- endActivitySpan() {
111
- this.endSpan(this.span);
112
- }
113
- endStreamSpan() {
114
- this.endSpan(this.span);
115
- }
116
- endSpan(span) {
117
- span && span.end();
118
- }
119
- getParentSpanContext() {
120
- if (this.traceId && this.spanId) {
121
- const restoredSpanContext = {
122
- traceId: this.traceId,
123
- spanId: this.spanId,
124
- isRemote: true,
125
- traceFlags: 1,
126
- };
127
- const parentContext = telemetry_1.trace.setSpanContext(telemetry_1.context.active(), restoredSpanContext);
128
- return parentContext;
129
- }
130
- }
131
- getSpanAttrs(leg) {
132
- return {
133
- ...Object.keys(this.context.metadata).reduce((result, key) => {
134
- if (key !== 'trc') {
135
- result[`app.job.${key}`] = this.context.metadata[key];
136
- }
137
- return result;
138
- }, {}),
139
- ...Object.keys(this.metadata).reduce((result, key) => {
140
- result[`app.activity.${key}`] = this.metadata[key];
141
- return result;
142
- }, {}),
143
- 'app.activity.leg': leg,
144
- };
145
- }
146
- getStreamSpanAttrs(input) {
147
- return {
148
- ...Object.keys(input.metadata).reduce((result, key) => {
149
- if (key !== 'trc' && key !== 'spn') {
150
- result[`app.stream.${key}`] = input.metadata[key];
151
- }
152
- return result;
153
- }, {}),
154
- };
155
- }
156
- setTelemetryContext(span, leg) {
157
- if (!this.context.metadata.trc) {
158
- this.context.metadata.trc = span.spanContext().traceId;
159
- }
160
- if (leg === 1) {
161
- if (!this.context['$self'].output.metadata) {
162
- this.context['$self'].output.metadata = {};
163
- }
164
- this.context['$self'].output.metadata.l1s = span.spanContext().spanId;
165
- }
166
- else {
167
- if (!this.context['$self'].output.metadata) {
168
- this.context['$self'].output.metadata = {};
169
- }
170
- this.context['$self'].output.metadata.l2s = span.spanContext().spanId;
171
- }
172
- }
173
- setActivityError(message) {
174
- this.span?.setStatus({ code: telemetry_1.SpanStatusCode.ERROR, message });
175
- }
176
- setStreamError(message) {
177
- this.span?.setStatus({ code: telemetry_1.SpanStatusCode.ERROR, message });
178
- }
179
- static addTargetTelemetryPaths(consumes, config, metadata, leg) {
180
- if (leg === 1) {
181
- if (!(config.parent in consumes)) {
182
- consumes[config.parent] = [];
183
- }
184
- consumes[config.parent].push(`${config.parent}/output/metadata/l2s`);
185
- }
186
- else {
187
- if (!(metadata.aid in consumes)) {
188
- consumes[metadata.aid] = [];
189
- }
190
- consumes[metadata.aid].push(`${metadata.aid}/output/metadata/l1s`);
191
- }
192
- }
193
- static bindJobTelemetryToState(state, config, context) {
194
- if (config.type === 'trigger') {
195
- state['metadata/trc'] = context.metadata.trc;
196
- }
197
- }
198
- static bindActivityTelemetryToState(state, config, metadata, context, leg) {
199
- if (config.type === 'trigger') {
200
- state[`${metadata.aid}/output/metadata/l1s`] =
201
- context['$self'].output.metadata.l1s;
202
- state[`${metadata.aid}/output/metadata/l2s`] =
203
- context['$self'].output.metadata.l2s;
204
- }
205
- else if (utils_1.polyfill.resolveActivityType(config.type) === 'hook' &&
206
- leg === 1) {
207
- state[`${metadata.aid}/output/metadata/l1s`] =
208
- context['$self'].output.metadata.l1s;
209
- state[`${metadata.aid}/output/metadata/l2s`] =
210
- context['$self'].output.metadata.l1s;
211
- }
212
- else if (config.type === 'signal' && leg === 1) {
213
- state[`${metadata.aid}/output/metadata/l1s`] =
214
- context['$self'].output.metadata.l1s;
215
- state[`${metadata.aid}/output/metadata/l2s`] =
216
- context['$self'].output.metadata.l1s;
217
- }
218
- else {
219
- const target = `l${leg}s`;
220
- state[`${metadata.aid}/output/metadata/${target}`] =
221
- context['$self'].output.metadata[target];
222
- }
223
- }
224
- }
225
- exports.TelemetryService = TelemetryService;
1
+ 'use strict';(function(_0x5b1599,_0x35b4aa){const _0x44b384=_0x2611,_0x283bc2=_0x5b1599();while(!![]){try{const _0x567a2e=-parseInt(_0x44b384(0x172))/0x1*(-parseInt(_0x44b384(0x174))/0x2)+parseInt(_0x44b384(0x16f))/0x3+-parseInt(_0x44b384(0x175))/0x4+-parseInt(_0x44b384(0x170))/0x5*(-parseInt(_0x44b384(0x176))/0x6)+parseInt(_0x44b384(0x173))/0x7+-parseInt(_0x44b384(0x171))/0x8*(-parseInt(_0x44b384(0x178))/0x9)+-parseInt(_0x44b384(0x177))/0xa;if(_0x567a2e===_0x35b4aa)break;else _0x283bc2['push'](_0x283bc2['shift']());}catch(_0x13c51e){_0x283bc2['push'](_0x283bc2['shift']());}}}(_0x2101,0xbe074));var __importDefault=this&&this['__importDefault']||function(_0x3998cd){return _0x3998cd&&_0x3998cd['__esModule']?_0x3998cd:{'default':_0x3998cd};};Object['defineProperty'](exports,'__esModule',{'value':!![]}),exports['TelemetryService']=void 0x0;const package_json_1=__importDefault(require('../../package.json')),mapper_1=require('../mapper'),stream_1=require('../../types/stream'),telemetry_1=require('../../types/telemetry'),utils_1=require('../../modules/utils');class TelemetryService{constructor(_0x4bfc09,_0x486276,_0x42e4f2,_0x45e2cc){this['leg']=0x1,this['appId']=_0x4bfc09,this['config']=_0x486276,this['metadata']=_0x42e4f2,this['context']=_0x45e2cc;}['getJobParentSpanId'](){return this['context']['metadata']['spn'];}['getActivityParentSpanId'](_0x21ebd2){return _0x21ebd2===0x1?this['context'][this['config']['parent']]['output']?.['metadata']?.['l2s']:this['context']['$self']['output']?.['metadata']?.['l1s'];}['getTraceId'](){return this['context']['metadata']['trc'];}['startJobSpan'](){const _0x1bf4e3='JOB/'+this['appId']+'/'+this['config']['subscribes']+'/1',_0x4d5e3d=this['getTraceId'](),_0x4ac9b7=this['getJobParentSpanId'](),_0xadc2b5=this['getSpanAttrs'](0x1),_0xf104d3=this['startSpan'](_0x4d5e3d,_0x4ac9b7,_0x1bf4e3,_0xadc2b5);return this['jobSpan']=_0xf104d3,this['setTelemetryContext'](_0xf104d3,0x1),this;}['startActivitySpan'](_0x4b4a9f=this['leg']){const _0x5048e2=this['config']['type']['toUpperCase']()+'/'+this['appId']+'/'+this['metadata']['aid']+'/'+_0x4b4a9f,_0x132d8c=this['getTraceId'](),_0x520e6b=this['getActivityParentSpanId'](_0x4b4a9f),_0x356e03=this['getSpanAttrs'](_0x4b4a9f),_0xdf51b3=this['startSpan'](_0x132d8c,_0x520e6b,_0x5048e2,_0x356e03);return this['setTelemetryContext'](_0xdf51b3,_0x4b4a9f),this['span']=_0xdf51b3,this;}['startStreamSpan'](_0x39bf44,_0x4103c4){let _0x4bdb26;if(_0x4103c4===stream_1['StreamRole']['SYSTEM'])_0x4bdb26='SYSTEM';else{if(_0x4103c4===stream_1['StreamRole']['WORKER'])_0x4bdb26='EXECUTE';else _0x39bf44['type']===stream_1['StreamDataType']['RESULT']||_0x39bf44['type']===stream_1['StreamDataType']['RESPONSE']?_0x4bdb26='FANIN':_0x4bdb26='FANOUT';}const _0x45547c=_0x39bf44['metadata']['topic']?'/'+_0x39bf44['metadata']['topic']:'',_0x1b4f3e=_0x4bdb26+'/'+this['appId']+'/'+_0x39bf44['metadata']['aid']+_0x45547c,_0x380ee5=this['getStreamSpanAttrs'](_0x39bf44),_0x568cd5=this['startSpan'](_0x39bf44['metadata']['trc'],_0x39bf44['metadata']['spn'],_0x1b4f3e,_0x380ee5);return this['span']=_0x568cd5,this;}['startSpan'](_0x58c6d3,_0xa122f0,_0x3c24bc,_0x166a9a){this['traceId']=_0x58c6d3,this['spanId']=_0xa122f0;const _0x5b961b=telemetry_1['trace']['getTracer'](package_json_1['default']['name'],package_json_1['default']['version']),_0x14c2b4=this['getParentSpanContext'](),_0x32fa43=_0x5b961b['startSpan'](_0x3c24bc,{'kind':telemetry_1['SpanKind']['CLIENT'],'attributes':_0x166a9a,'root':!_0x14c2b4},_0x14c2b4);return _0x32fa43;}['mapActivityAttributes'](){if(this['config']['telemetry']){const _0x3f0c9f=new mapper_1['MapperService'](this['config']['telemetry'],this['context'])['mapRules'](),_0x1ea13d={...Object['keys'](_0x3f0c9f)['reduce']((_0x49e4c7,_0x2a4534)=>{return['string','boolean','number']['includes'](typeof _0x3f0c9f[_0x2a4534])&&(_0x49e4c7['app.activity.data.'+_0x2a4534]=_0x3f0c9f[_0x2a4534]),_0x49e4c7;},{})};this['span']?.['setAttributes'](_0x1ea13d);}}['setActivityAttributes'](_0x4424d4){this['span']?.['setAttributes'](_0x4424d4);}['setStreamAttributes'](_0x595dc0){this['span']?.['setAttributes'](_0x595dc0);}['setJobAttributes'](_0x421b00){this['jobSpan']?.['setAttributes'](_0x421b00);}['endJobSpan'](){this['endSpan'](this['jobSpan']);}['endActivitySpan'](){this['endSpan'](this['span']);}['endStreamSpan'](){this['endSpan'](this['span']);}['endSpan'](_0x4aca7e){_0x4aca7e&&_0x4aca7e['end']();}['getParentSpanContext'](){if(this['traceId']&&this['spanId']){const _0x40aa13={'traceId':this['traceId'],'spanId':this['spanId'],'isRemote':!![],'traceFlags':0x1},_0x277e1c=telemetry_1['trace']['setSpanContext'](telemetry_1['context']['active'](),_0x40aa13);return _0x277e1c;}}['getSpanAttrs'](_0x4e5820){return{...Object['keys'](this['context']['metadata'])['reduce']((_0x35d1cf,_0x266fa6)=>{return _0x266fa6!=='trc'&&(_0x35d1cf['app.job.'+_0x266fa6]=this['context']['metadata'][_0x266fa6]),_0x35d1cf;},{}),...Object['keys'](this['metadata'])['reduce']((_0x2eaadd,_0x3e114b)=>{return _0x2eaadd['app.activity.'+_0x3e114b]=this['metadata'][_0x3e114b],_0x2eaadd;},{}),'app.activity.leg':_0x4e5820};}['getStreamSpanAttrs'](_0x53aaa2){return{...Object['keys'](_0x53aaa2['metadata'])['reduce']((_0x22a39f,_0x494c92)=>{return _0x494c92!=='trc'&&_0x494c92!=='spn'&&(_0x22a39f['app.stream.'+_0x494c92]=_0x53aaa2['metadata'][_0x494c92]),_0x22a39f;},{})};}['setTelemetryContext'](_0x1df869,_0x5cdb38){!this['context']['metadata']['trc']&&(this['context']['metadata']['trc']=_0x1df869['spanContext']()['traceId']),_0x5cdb38===0x1?(!this['context']['$self']['output']['metadata']&&(this['context']['$self']['output']['metadata']={}),this['context']['$self']['output']['metadata']['l1s']=_0x1df869['spanContext']()['spanId']):(!this['context']['$self']['output']['metadata']&&(this['context']['$self']['output']['metadata']={}),this['context']['$self']['output']['metadata']['l2s']=_0x1df869['spanContext']()['spanId']);}['setActivityError'](_0x144ef0){this['span']?.['setStatus']({'code':telemetry_1['SpanStatusCode']['ERROR'],'message':_0x144ef0});}['setStreamError'](_0x2b98f5){this['span']?.['setStatus']({'code':telemetry_1['SpanStatusCode']['ERROR'],'message':_0x2b98f5});}static['addTargetTelemetryPaths'](_0x1f1e1c,_0x258aea,_0x3d4021,_0x5b31ee){_0x5b31ee===0x1?(!(_0x258aea['parent']in _0x1f1e1c)&&(_0x1f1e1c[_0x258aea['parent']]=[]),_0x1f1e1c[_0x258aea['parent']]['push'](_0x258aea['parent']+'/output/metadata/l2s')):(!(_0x3d4021['aid']in _0x1f1e1c)&&(_0x1f1e1c[_0x3d4021['aid']]=[]),_0x1f1e1c[_0x3d4021['aid']]['push'](_0x3d4021['aid']+'/output/metadata/l1s'));}static['bindJobTelemetryToState'](_0x5c4d5e,_0x4c0b16,_0x344323){_0x4c0b16['type']==='trigger'&&(_0x5c4d5e['metadata/trc']=_0x344323['metadata']['trc']);}static['bindActivityTelemetryToState'](_0x371298,_0x4444c4,_0x340dc9,_0x5e5a4b,_0x4ac4fe){if(_0x4444c4['type']==='trigger')_0x371298[_0x340dc9['aid']+'/output/metadata/l1s']=_0x5e5a4b['$self']['output']['metadata']['l1s'],_0x371298[_0x340dc9['aid']+'/output/metadata/l2s']=_0x5e5a4b['$self']['output']['metadata']['l2s'];else{if(utils_1['polyfill']['resolveActivityType'](_0x4444c4['type'])==='hook'&&_0x4ac4fe===0x1)_0x371298[_0x340dc9['aid']+'/output/metadata/l1s']=_0x5e5a4b['$self']['output']['metadata']['l1s'],_0x371298[_0x340dc9['aid']+'/output/metadata/l2s']=_0x5e5a4b['$self']['output']['metadata']['l1s'];else{if(_0x4444c4['type']==='signal'&&_0x4ac4fe===0x1)_0x371298[_0x340dc9['aid']+'/output/metadata/l1s']=_0x5e5a4b['$self']['output']['metadata']['l1s'],_0x371298[_0x340dc9['aid']+'/output/metadata/l2s']=_0x5e5a4b['$self']['output']['metadata']['l1s'];else{const _0x4d8a1e='l'+_0x4ac4fe+'s';_0x371298[_0x340dc9['aid']+'/output/metadata/'+_0x4d8a1e]=_0x5e5a4b['$self']['output']['metadata'][_0x4d8a1e];}}}}}exports['TelemetryService']=TelemetryService;function _0x2611(_0x2ac1bf,_0x345b60){const _0x2101b0=_0x2101();return _0x2611=function(_0x2611cc,_0x214cc0){_0x2611cc=_0x2611cc-0x16f;let _0x1c5dae=_0x2101b0[_0x2611cc];return _0x1c5dae;},_0x2611(_0x2ac1bf,_0x345b60);}function _0x2101(){const _0x41678e=['26415kFLvqc','438060qaueVd','2423170SxWfWG','3864FHtRgC','206qfLFtS','685160xjeIht','458NNUCji','1334980PRkHVJ','18WFWrfw','20504800lJqbTL'];_0x2101=function(){return _0x41678e;};return _0x2101();}
@@ -27,8 +27,8 @@ declare class WorkerService {
27
27
  static init(namespace: string, appId: string, guid: string, config: HotMeshConfig, logger: ILogger): Promise<WorkerService[]>;
28
28
  verifyWorkerFields(worker: HotMeshWorker): void;
29
29
  initStoreChannel(service: WorkerService, store: RedisClient): Promise<void>;
30
- initSubChannel(service: WorkerService, sub: RedisClient): Promise<void>;
31
- initStreamChannel(service: WorkerService, stream: RedisClient): Promise<void>;
30
+ initSubChannel(service: WorkerService, sub: RedisClient, store: RedisClient): Promise<void>;
31
+ initStreamChannel(service: WorkerService, stream: RedisClient, store: RedisClient): Promise<void>;
32
32
  initRouter(worker: HotMeshWorker, logger: ILogger): Promise<Router>;
33
33
  subscriptionHandler(): SubscriptionCallback;
34
34
  doRollCall(message: RollCallMessage): Promise<void>;