@hotmeshio/hotmesh 0.3.6 → 0.3.8
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.
- package/README.md +13 -1
- package/build/index.d.ts +3 -1
- package/build/index.js +10 -1
- package/build/modules/key.js +1 -62
- package/build/modules/utils.js +1 -267
- package/build/package.json +12 -8
- package/build/services/activities/activity.js +1 -495
- package/build/services/activities/await.js +1 -109
- package/build/services/activities/cycle.js +1 -96
- package/build/services/activities/hook.js +1 -154
- package/build/services/activities/index.js +1 -20
- package/build/services/activities/interrupt.js +1 -149
- package/build/services/activities/signal.js +1 -118
- package/build/services/activities/trigger.js +1 -237
- package/build/services/activities/worker.js +1 -101
- package/build/services/collator/index.js +1 -197
- package/build/services/compiler/deployer.d.ts +3 -1
- package/build/services/compiler/deployer.js +1 -455
- package/build/services/compiler/index.d.ts +3 -1
- package/build/services/compiler/index.js +1 -91
- package/build/services/compiler/validator.js +1 -122
- package/build/services/engine/index.d.ts +5 -2
- package/build/services/engine/index.js +1 -562
- package/build/services/exporter/index.js +1 -93
- package/build/services/mapper/index.js +1 -67
- package/build/services/meshdata/index.d.ts +0 -1
- package/build/services/meshdata/index.js +16 -24
- package/build/services/meshflow/client.js +4 -8
- package/build/services/meshflow/exporter.js +1 -186
- package/build/services/meshflow/index.d.ts +2 -0
- package/build/services/meshflow/index.js +2 -0
- package/build/services/meshflow/search.d.ts +4 -5
- package/build/services/meshflow/search.js +45 -35
- package/build/services/meshflow/workflow.d.ts +1 -1
- package/build/services/meshflow/workflow.js +3 -28
- package/build/services/pipe/functions/array.js +1 -74
- package/build/services/pipe/functions/bitwise.js +1 -24
- package/build/services/pipe/functions/conditional.js +1 -36
- package/build/services/pipe/functions/cron.js +1 -32
- package/build/services/pipe/functions/date.js +1 -164
- package/build/services/pipe/functions/index.js +1 -30
- package/build/services/pipe/functions/json.js +1 -12
- package/build/services/pipe/functions/logical.js +1 -12
- package/build/services/pipe/functions/math.js +1 -182
- package/build/services/pipe/functions/number.js +1 -60
- package/build/services/pipe/functions/object.js +1 -81
- package/build/services/pipe/functions/string.js +1 -69
- package/build/services/pipe/functions/symbol.js +1 -33
- package/build/services/pipe/functions/unary.js +1 -18
- package/build/services/pipe/index.js +1 -221
- package/build/services/quorum/index.d.ts +1 -1
- package/build/services/quorum/index.js +1 -219
- package/build/services/reporter/index.js +1 -331
- package/build/services/router/index.js +1 -420
- package/build/services/search/factory.d.ts +7 -0
- package/build/services/search/factory.js +20 -0
- package/build/services/search/index.d.ts +21 -0
- package/build/services/search/index.js +10 -0
- package/build/services/search/providers/redis/ioredis.d.ts +18 -0
- package/build/services/search/providers/redis/ioredis.js +1 -0
- package/build/services/search/providers/redis/redis.d.ts +18 -0
- package/build/services/search/providers/redis/redis.js +1 -0
- package/build/services/serializer/index.js +1 -265
- package/build/services/store/factory.d.ts +2 -1
- package/build/services/store/factory.js +2 -2
- package/build/services/store/index.d.ts +71 -97
- package/build/services/store/index.js +2 -939
- package/build/services/store/providers/postgres/postgres.d.ts +0 -0
- package/build/services/store/providers/postgres/postgres.js +0 -0
- package/build/services/store/providers/postgres/types/hash.d.ts +0 -0
- package/build/services/store/providers/postgres/types/hash.js +0 -0
- package/build/services/store/providers/postgres/types/list.d.ts +0 -0
- package/build/services/store/providers/postgres/types/list.js +0 -0
- package/build/services/store/providers/postgres/types/string.d.ts +0 -0
- package/build/services/store/providers/postgres/types/string.js +0 -0
- package/build/services/store/providers/postgres/types/zset.d.ts +0 -0
- package/build/services/store/providers/postgres/types/zset.js +0 -0
- package/build/services/store/providers/redis/_base.d.ts +98 -0
- package/build/services/store/providers/redis/_base.js +1 -0
- package/build/services/store/providers/redis/ioredis.d.ts +12 -0
- package/build/services/store/providers/redis/ioredis.js +1 -0
- package/build/services/store/providers/redis/redis.d.ts +13 -0
- package/build/services/store/providers/redis/redis.js +1 -0
- package/build/services/store/providers/store-initializable.d.ts +5 -0
- package/build/services/store/providers/store-initializable.js +1 -0
- package/build/services/stream/factory.d.ts +2 -1
- package/build/services/stream/factory.js +5 -5
- package/build/services/stream/index.d.ts +13 -14
- package/build/services/stream/index.js +3 -2
- package/build/services/stream/providers/postgres/_deploy.d.ts +4 -0
- package/build/services/stream/providers/postgres/_deploy.js +1 -0
- package/build/services/stream/providers/redis/ioredis.d.ts +21 -0
- package/build/services/stream/providers/redis/ioredis.js +1 -0
- package/build/services/stream/providers/redis/redis.d.ts +21 -0
- package/build/services/stream/providers/redis/redis.js +1 -0
- package/build/services/stream/providers/stream-initializable.d.ts +5 -0
- package/build/services/stream/providers/stream-initializable.js +1 -0
- package/build/services/sub/factory.d.ts +1 -1
- package/build/services/sub/factory.js +5 -5
- package/build/services/sub/index.d.ts +9 -7
- package/build/services/sub/index.js +3 -2
- package/build/services/sub/{clients → providers/redis}/ioredis.d.ts +7 -10
- package/build/services/sub/providers/redis/ioredis.js +1 -0
- package/build/services/sub/{clients → providers/redis}/redis.d.ts +7 -10
- package/build/services/sub/providers/redis/redis.js +1 -0
- package/build/services/task/index.js +1 -171
- package/build/services/telemetry/index.js +1 -225
- package/build/services/worker/index.d.ts +2 -2
- package/build/services/worker/index.js +1 -158
- package/build/types/redis.d.ts +5 -5
- package/index.ts +18 -1
- package/package.json +12 -8
- package/typedoc.json +2 -1
- package/types/redis.ts +5 -5
- package/build/services/store/clients/ioredis.d.ts +0 -30
- package/build/services/store/clients/ioredis.js +0 -220
- package/build/services/store/clients/redis.d.ts +0 -32
- package/build/services/store/clients/redis.js +0 -319
- package/build/services/stream/clients/ioredis.d.ts +0 -24
- package/build/services/stream/clients/ioredis.js +0 -121
- package/build/services/stream/clients/redis.d.ts +0 -24
- package/build/services/stream/clients/redis.js +0 -161
- package/build/services/sub/clients/ioredis.js +0 -72
- package/build/services/sub/clients/redis.js +0 -63
|
@@ -1,158 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.WorkerService = void 0;
|
|
4
|
-
const key_1 = require("../../modules/key");
|
|
5
|
-
const utils_1 = require("../../modules/utils");
|
|
6
|
-
const connector_1 = require("../connector");
|
|
7
|
-
const router_1 = require("../router");
|
|
8
|
-
const stream_1 = require("../../types/stream");
|
|
9
|
-
const enums_1 = require("../../modules/enums");
|
|
10
|
-
const factory_1 = require("../stream/factory");
|
|
11
|
-
const factory_2 = require("../sub/factory");
|
|
12
|
-
const factory_3 = require("../store/factory");
|
|
13
|
-
class WorkerService {
|
|
14
|
-
constructor() {
|
|
15
|
-
this.reporting = false;
|
|
16
|
-
}
|
|
17
|
-
static async init(namespace, appId, guid, config, logger) {
|
|
18
|
-
const services = [];
|
|
19
|
-
if (Array.isArray(config.workers)) {
|
|
20
|
-
for (const worker of config.workers) {
|
|
21
|
-
await connector_1.ConnectorService.initRedisClients(worker.redis?.class, worker.redis?.options, worker);
|
|
22
|
-
const service = new WorkerService();
|
|
23
|
-
service.verifyWorkerFields(worker);
|
|
24
|
-
service.namespace = namespace;
|
|
25
|
-
service.appId = appId;
|
|
26
|
-
service.guid = guid;
|
|
27
|
-
service.callback = worker.callback;
|
|
28
|
-
service.topic = worker.topic;
|
|
29
|
-
service.config = config;
|
|
30
|
-
service.logger = logger;
|
|
31
|
-
await service.initStoreChannel(service, worker.store);
|
|
32
|
-
await service.initSubChannel(service, worker.sub);
|
|
33
|
-
await service.subscribe.subscribe(key_1.KeyType.QUORUM, service.subscriptionHandler(), appId);
|
|
34
|
-
await service.subscribe.subscribe(key_1.KeyType.QUORUM, service.subscriptionHandler(), appId, service.topic);
|
|
35
|
-
await service.subscribe.subscribe(key_1.KeyType.QUORUM, service.subscriptionHandler(), appId, service.guid);
|
|
36
|
-
await service.initStreamChannel(service, worker.stream);
|
|
37
|
-
service.router = await service.initRouter(worker, logger);
|
|
38
|
-
const key = service.stream.mintKey(key_1.KeyType.STREAMS, {
|
|
39
|
-
appId: service.appId,
|
|
40
|
-
topic: worker.topic,
|
|
41
|
-
});
|
|
42
|
-
await service.router.consumeMessages(key, 'WORKER', service.guid, worker.callback);
|
|
43
|
-
service.inited = (0, utils_1.formatISODate)(new Date());
|
|
44
|
-
services.push(service);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
return services;
|
|
48
|
-
}
|
|
49
|
-
verifyWorkerFields(worker) {
|
|
50
|
-
if (!(0, utils_1.identifyRedisType)(worker.store) ||
|
|
51
|
-
!(0, utils_1.identifyRedisType)(worker.stream) ||
|
|
52
|
-
!(0, utils_1.identifyRedisType)(worker.sub) ||
|
|
53
|
-
!(worker.topic && worker.callback)) {
|
|
54
|
-
throw new Error('worker must include `store`, `stream`, and `sub` fields along with a callback function and topic.');
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
async initStoreChannel(service, store) {
|
|
58
|
-
service.store = await factory_3.StoreServiceFactory.init(store, service.namespace, service.appId, service.logger);
|
|
59
|
-
}
|
|
60
|
-
async initSubChannel(service, sub) {
|
|
61
|
-
service.subscribe = await factory_2.SubServiceFactory.init(sub, service.namespace, service.appId, service.guid, service.logger);
|
|
62
|
-
}
|
|
63
|
-
async initStreamChannel(service, stream) {
|
|
64
|
-
service.stream = await factory_1.StreamServiceFactory.init(stream, service.namespace, service.appId, service.logger);
|
|
65
|
-
}
|
|
66
|
-
async initRouter(worker, logger) {
|
|
67
|
-
const throttle = await this.store.getThrottleRate(worker.topic);
|
|
68
|
-
return new router_1.Router({
|
|
69
|
-
namespace: this.namespace,
|
|
70
|
-
appId: this.appId,
|
|
71
|
-
guid: this.guid,
|
|
72
|
-
role: stream_1.StreamRole.WORKER,
|
|
73
|
-
topic: worker.topic,
|
|
74
|
-
reclaimDelay: worker.reclaimDelay,
|
|
75
|
-
reclaimCount: worker.reclaimCount,
|
|
76
|
-
throttle,
|
|
77
|
-
}, this.stream, this.store, logger);
|
|
78
|
-
}
|
|
79
|
-
subscriptionHandler() {
|
|
80
|
-
const self = this;
|
|
81
|
-
return async (topic, message) => {
|
|
82
|
-
self.logger.debug('worker-event-received', { topic, type: message.type });
|
|
83
|
-
if (message.type === 'throttle') {
|
|
84
|
-
if (message.topic !== null) {
|
|
85
|
-
self.throttle(message.throttle);
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
else if (message.type === 'ping') {
|
|
89
|
-
self.sayPong(self.appId, self.guid, message.originator, message.details);
|
|
90
|
-
}
|
|
91
|
-
else if (message.type === 'rollcall') {
|
|
92
|
-
if (message.topic !== null) {
|
|
93
|
-
self.doRollCall(message);
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
};
|
|
97
|
-
}
|
|
98
|
-
async doRollCall(message) {
|
|
99
|
-
let iteration = 0;
|
|
100
|
-
const max = !isNaN(message.max) ? message.max : enums_1.HMSH_QUORUM_ROLLCALL_CYCLES;
|
|
101
|
-
if (this.rollCallInterval)
|
|
102
|
-
clearTimeout(this.rollCallInterval);
|
|
103
|
-
const base = message.interval / 2;
|
|
104
|
-
const amount = base + Math.ceil(Math.random() * base);
|
|
105
|
-
do {
|
|
106
|
-
await (0, utils_1.sleepFor)(Math.ceil(Math.random() * 1000));
|
|
107
|
-
await this.sayPong(this.appId, this.guid, null, true, message.signature);
|
|
108
|
-
if (!message.interval)
|
|
109
|
-
return;
|
|
110
|
-
const { promise, timerId } = (0, utils_1.XSleepFor)(amount * 1000);
|
|
111
|
-
this.rollCallInterval = timerId;
|
|
112
|
-
await promise;
|
|
113
|
-
} while (this.rollCallInterval && iteration++ < max - 1);
|
|
114
|
-
}
|
|
115
|
-
cancelRollCall() {
|
|
116
|
-
if (this.rollCallInterval) {
|
|
117
|
-
clearTimeout(this.rollCallInterval);
|
|
118
|
-
delete this.rollCallInterval;
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
stop() {
|
|
122
|
-
this.cancelRollCall();
|
|
123
|
-
}
|
|
124
|
-
async sayPong(appId, guid, originator, details = false, signature = false) {
|
|
125
|
-
let profile;
|
|
126
|
-
if (details) {
|
|
127
|
-
const params = {
|
|
128
|
-
appId: this.appId,
|
|
129
|
-
topic: this.topic,
|
|
130
|
-
};
|
|
131
|
-
profile = {
|
|
132
|
-
engine_id: this.guid,
|
|
133
|
-
namespace: this.namespace,
|
|
134
|
-
app_id: this.appId,
|
|
135
|
-
worker_topic: this.topic,
|
|
136
|
-
stream: this.stream.mintKey(key_1.KeyType.STREAMS, params),
|
|
137
|
-
counts: this.router.counts,
|
|
138
|
-
timestamp: (0, utils_1.formatISODate)(new Date()),
|
|
139
|
-
inited: this.inited,
|
|
140
|
-
throttle: this.router.throttle,
|
|
141
|
-
reclaimDelay: this.router.reclaimDelay,
|
|
142
|
-
reclaimCount: this.router.reclaimCount,
|
|
143
|
-
system: await (0, utils_1.getSystemHealth)(),
|
|
144
|
-
signature: signature ? this.callback.toString() : undefined,
|
|
145
|
-
};
|
|
146
|
-
}
|
|
147
|
-
this.store.publish(key_1.KeyType.QUORUM, {
|
|
148
|
-
type: 'pong',
|
|
149
|
-
guid,
|
|
150
|
-
originator,
|
|
151
|
-
profile,
|
|
152
|
-
}, appId);
|
|
153
|
-
}
|
|
154
|
-
async throttle(delayInMillis) {
|
|
155
|
-
this.router.setThrottle(delayInMillis);
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
exports.WorkerService = WorkerService;
|
|
1
|
+
'use strict';(function(_0x5c1b61,_0x3fe390){const _0x132c03=_0x4255,_0x39487b=_0x5c1b61();while(!![]){try{const _0x19710d=-parseInt(_0x132c03(0xf3))/0x1+parseInt(_0x132c03(0xf6))/0x2*(parseInt(_0x132c03(0xfa))/0x3)+-parseInt(_0x132c03(0xf7))/0x4*(-parseInt(_0x132c03(0xf8))/0x5)+parseInt(_0x132c03(0xf4))/0x6+-parseInt(_0x132c03(0xf9))/0x7+-parseInt(_0x132c03(0xf5))/0x8+-parseInt(_0x132c03(0xfb))/0x9;if(_0x19710d===_0x3fe390)break;else _0x39487b['push'](_0x39487b['shift']());}catch(_0x4a9471){_0x39487b['push'](_0x39487b['shift']());}}}(_0x28e4,0x44388));function _0x28e4(){const _0x17695b=['4MDFFxb','2554355jFphkd','1586256anlXvL','1397616MziPdZ','3313305IKzqdA','535132kPdYZB','3194634AuoXpy','798920HEpcNf','2LcOBVL'];_0x28e4=function(){return _0x17695b;};return _0x28e4();}function _0x4255(_0x1ebf8a,_0x29780e){const _0x28e4ae=_0x28e4();return _0x4255=function(_0x4255dc,_0x3d7b6c){_0x4255dc=_0x4255dc-0xf3;let _0x2fec92=_0x28e4ae[_0x4255dc];return _0x2fec92;},_0x4255(_0x1ebf8a,_0x29780e);}Object['defineProperty'](exports,'__esModule',{'value':!![]}),exports['WorkerService']=void 0x0;const key_1=require('../../modules/key'),utils_1=require('../../modules/utils'),connector_1=require('../connector'),router_1=require('../router'),stream_1=require('../../types/stream'),enums_1=require('../../modules/enums'),factory_1=require('../stream/factory'),factory_2=require('../sub/factory'),factory_3=require('../store/factory');class WorkerService{constructor(){this['reporting']=![];}static async['init'](_0x5405ea,_0x5cc2ef,_0x4e65f8,_0x56d166,_0x157b5e){const _0x38be5a=[];if(Array['isArray'](_0x56d166['workers']))for(const _0x5082d3 of _0x56d166['workers']){await connector_1['ConnectorService']['initRedisClients'](_0x5082d3['redis']?.['class'],_0x5082d3['redis']?.['options'],_0x5082d3);const _0x43f839=new WorkerService();_0x43f839['verifyWorkerFields'](_0x5082d3),_0x43f839['namespace']=_0x5405ea,_0x43f839['appId']=_0x5cc2ef,_0x43f839['guid']=_0x4e65f8,_0x43f839['callback']=_0x5082d3['callback'],_0x43f839['topic']=_0x5082d3['topic'],_0x43f839['config']=_0x56d166,_0x43f839['logger']=_0x157b5e,await _0x43f839['initStoreChannel'](_0x43f839,_0x5082d3['store']),await _0x43f839['initSubChannel'](_0x43f839,_0x5082d3['sub'],_0x5082d3['store']),await _0x43f839['subscribe']['subscribe'](key_1['KeyType']['QUORUM'],_0x43f839['subscriptionHandler'](),_0x5cc2ef),await _0x43f839['subscribe']['subscribe'](key_1['KeyType']['QUORUM'],_0x43f839['subscriptionHandler'](),_0x5cc2ef,_0x43f839['topic']),await _0x43f839['subscribe']['subscribe'](key_1['KeyType']['QUORUM'],_0x43f839['subscriptionHandler'](),_0x5cc2ef,_0x43f839['guid']),await _0x43f839['initStreamChannel'](_0x43f839,_0x5082d3['stream'],_0x5082d3['store']),_0x43f839['router']=await _0x43f839['initRouter'](_0x5082d3,_0x157b5e);const _0x3f27e6=_0x43f839['store']['mintKey'](key_1['KeyType']['STREAMS'],{'appId':_0x43f839['appId'],'topic':_0x5082d3['topic']});await _0x43f839['router']['consumeMessages'](_0x3f27e6,'WORKER',_0x43f839['guid'],_0x5082d3['callback']),_0x43f839['inited']=(0x0,utils_1['formatISODate'])(new Date()),_0x38be5a['push'](_0x43f839);}return _0x38be5a;}['verifyWorkerFields'](_0x53c8b5){if(!(0x0,utils_1['identifyRedisType'])(_0x53c8b5['store'])||!(0x0,utils_1['identifyRedisType'])(_0x53c8b5['stream'])||!(0x0,utils_1['identifyRedisType'])(_0x53c8b5['sub'])||!(_0x53c8b5['topic']&&_0x53c8b5['callback']))throw new Error('worker\x20must\x20include\x20`store`,\x20`stream`,\x20and\x20`sub`\x20fields\x20along\x20with\x20a\x20callback\x20function\x20and\x20topic.');}async['initStoreChannel'](_0x29ae74,_0x207b9e){_0x29ae74['store']=await factory_3['StoreServiceFactory']['init'](_0x207b9e,_0x29ae74['namespace'],_0x29ae74['appId'],_0x29ae74['logger']);}async['initSubChannel'](_0x1c1cbf,_0x2db7bd,_0x28bf19){_0x1c1cbf['subscribe']=await factory_2['SubServiceFactory']['init'](_0x2db7bd,_0x28bf19,_0x1c1cbf['namespace'],_0x1c1cbf['appId'],_0x1c1cbf['guid'],_0x1c1cbf['logger']);}async['initStreamChannel'](_0x540e04,_0x1651f3,_0x89568d){_0x540e04['stream']=await factory_1['StreamServiceFactory']['init'](_0x1651f3,_0x89568d,_0x540e04['namespace'],_0x540e04['appId'],_0x540e04['logger']);}async['initRouter'](_0x1db931,_0x1d6886){const _0x41ba4c=await this['store']['getThrottleRate'](_0x1db931['topic']);return new router_1['Router']({'namespace':this['namespace'],'appId':this['appId'],'guid':this['guid'],'role':stream_1['StreamRole']['WORKER'],'topic':_0x1db931['topic'],'reclaimDelay':_0x1db931['reclaimDelay'],'reclaimCount':_0x1db931['reclaimCount'],'throttle':_0x41ba4c},this['stream'],this['store'],_0x1d6886);}['subscriptionHandler'](){const _0x114f65=this;return async(_0x25cf2a,_0x5303ff)=>{_0x114f65['logger']['debug']('worker-event-received',{'topic':_0x25cf2a,'type':_0x5303ff['type']});if(_0x5303ff['type']==='throttle')_0x5303ff['topic']!==null&&_0x114f65['throttle'](_0x5303ff['throttle']);else{if(_0x5303ff['type']==='ping')_0x114f65['sayPong'](_0x114f65['appId'],_0x114f65['guid'],_0x5303ff['originator'],_0x5303ff['details']);else _0x5303ff['type']==='rollcall'&&(_0x5303ff['topic']!==null&&_0x114f65['doRollCall'](_0x5303ff));}};}async['doRollCall'](_0x150fef){let _0xf8b92e=0x0;const _0x282414=!isNaN(_0x150fef['max'])?_0x150fef['max']:enums_1['HMSH_QUORUM_ROLLCALL_CYCLES'];if(this['rollCallInterval'])clearTimeout(this['rollCallInterval']);const _0x381a2e=_0x150fef['interval']/0x2,_0x428da6=_0x381a2e+Math['ceil'](Math['random']()*_0x381a2e);do{await(0x0,utils_1['sleepFor'])(Math['ceil'](Math['random']()*0x3e8)),await this['sayPong'](this['appId'],this['guid'],null,!![],_0x150fef['signature']);if(!_0x150fef['interval'])return;const {promise:_0x1cfafb,timerId:_0xaa9484}=(0x0,utils_1['XSleepFor'])(_0x428da6*0x3e8);this['rollCallInterval']=_0xaa9484,await _0x1cfafb;}while(this['rollCallInterval']&&_0xf8b92e++<_0x282414-0x1);}['cancelRollCall'](){this['rollCallInterval']&&(clearTimeout(this['rollCallInterval']),delete this['rollCallInterval']);}['stop'](){this['cancelRollCall']();}async['sayPong'](_0x26c51e,_0xc6182b,_0x56748e,_0x4c27f1=![],_0x2b2624=![]){let _0x203a4e;if(_0x4c27f1){const _0x19ee76={'appId':this['appId'],'topic':this['topic']};_0x203a4e={'engine_id':this['guid'],'namespace':this['namespace'],'app_id':this['appId'],'worker_topic':this['topic'],'stream':this['store']['mintKey'](key_1['KeyType']['STREAMS'],_0x19ee76),'counts':this['router']['counts'],'timestamp':(0x0,utils_1['formatISODate'])(new Date()),'inited':this['inited'],'throttle':this['router']['throttle'],'reclaimDelay':this['router']['reclaimDelay'],'reclaimCount':this['router']['reclaimCount'],'system':await(0x0,utils_1['getSystemHealth'])(),'signature':_0x2b2624?this['callback']['toString']():undefined};}this['subscribe']['publish'](key_1['KeyType']['QUORUM'],{'type':'pong','guid':_0xc6182b,'originator':_0x56748e,'profile':_0x203a4e},_0x26c51e);}async['throttle'](_0x4519ed){this['router']['setThrottle'](_0x4519ed);}}exports['WorkerService']=WorkerService;
|
package/build/types/redis.d.ts
CHANGED
|
@@ -66,7 +66,7 @@ interface RedisRedisMultiType {
|
|
|
66
66
|
DEL(key: string): this;
|
|
67
67
|
EXISTS(key: string): this;
|
|
68
68
|
EXPIRE(key: string, seconds: number): this;
|
|
69
|
-
HDEL(key: string,
|
|
69
|
+
HDEL(key: string, fields: string[] | string): this;
|
|
70
70
|
HGET(key: string, itemId: string): this;
|
|
71
71
|
HGETALL(key: string): this;
|
|
72
72
|
HINCRBYFLOAT(key: string, itemId: string, value: number): this;
|
|
@@ -115,12 +115,12 @@ interface RedisRedisClientType {
|
|
|
115
115
|
XLEN(key: string): Promise<number>;
|
|
116
116
|
DEL(key: string): Promise<number>;
|
|
117
117
|
EXISTS(key: string): Promise<number>;
|
|
118
|
-
HDEL(key: string,
|
|
118
|
+
HDEL(key: string, fields: string[] | string): Promise<number>;
|
|
119
119
|
HGET(key: string, itemId: string): Promise<string | null>;
|
|
120
120
|
HGETALL(key: string): Promise<StringStringType>;
|
|
121
121
|
HINCRBYFLOAT(key: string, itemId: string, value: number): Promise<number>;
|
|
122
122
|
HMGET(key: string, itemIds: string[]): Promise<string[]>;
|
|
123
|
-
HSET(key: string, values: Record<string, string>):
|
|
123
|
+
HSET(key: string, values: Record<string, string>): Promise<number>;
|
|
124
124
|
LPUSH(key: string, items: string[]): Promise<number>;
|
|
125
125
|
LRANGE(key: string, start: number, end: number): Promise<string[]>;
|
|
126
126
|
RPUSH(key: string, items: string[]): Promise<number>;
|
|
@@ -185,12 +185,12 @@ interface IORedisClient {
|
|
|
185
185
|
del(key: string): Promise<number>;
|
|
186
186
|
exists(key: string): Promise<number>;
|
|
187
187
|
get(key: string): Promise<string | null>;
|
|
188
|
-
hdel(key: string,
|
|
188
|
+
hdel(key: string, ...fields: string[]): Promise<number>;
|
|
189
189
|
hget(key: string, itemId: string): Promise<string | null>;
|
|
190
190
|
hgetall(key: string): Promise<StringStringType>;
|
|
191
191
|
hincrbyfloat(key: string, itemId: string, value: number): Promise<number>;
|
|
192
192
|
hmget(key: string, itemIds: string[]): Promise<string[]>;
|
|
193
|
-
hset(key: string, values: Record<string, string>):
|
|
193
|
+
hset(key: string, values: Record<string, string>): Promise<number>;
|
|
194
194
|
lpush(key: string, ...args: string[]): Promise<number>;
|
|
195
195
|
lrange(key: string, start: number, end: number): Promise<string[]>;
|
|
196
196
|
on(event: string, callback: (...args: any[]) => void): void;
|
package/index.ts
CHANGED
|
@@ -4,7 +4,24 @@ import { MeshCall } from './services/meshcall';
|
|
|
4
4
|
import { MeshFlow } from './services/meshflow';
|
|
5
5
|
import { MeshData } from './services/meshdata';
|
|
6
6
|
import { MeshOS } from './services/meshos';
|
|
7
|
+
import * as Utils from './modules/utils';
|
|
7
8
|
|
|
8
|
-
|
|
9
|
+
const { Client, Connection, Handle, Search, Worker, workflow } = MeshFlow;
|
|
10
|
+
|
|
11
|
+
export {
|
|
12
|
+
HotMesh,
|
|
13
|
+
HotMeshConfig,
|
|
14
|
+
MeshCall,
|
|
15
|
+
MeshData,
|
|
16
|
+
MeshOS,
|
|
17
|
+
MeshFlow,
|
|
18
|
+
Client,
|
|
19
|
+
Connection,
|
|
20
|
+
Handle,
|
|
21
|
+
Search,
|
|
22
|
+
Utils,
|
|
23
|
+
Worker,
|
|
24
|
+
workflow,
|
|
25
|
+
};
|
|
9
26
|
|
|
10
27
|
export * as Types from './types';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hotmeshio/hotmesh",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.8",
|
|
4
4
|
"description": "Unbreakable Workflows",
|
|
5
5
|
"main": "./build/index.js",
|
|
6
6
|
"types": "./build/index.d.ts",
|
|
@@ -13,9 +13,11 @@
|
|
|
13
13
|
"access": "public"
|
|
14
14
|
},
|
|
15
15
|
"scripts": {
|
|
16
|
-
"build": "tsc --build tsconfig.json",
|
|
17
16
|
"clean": "rimraf ./build",
|
|
17
|
+
"build": "tsc --build tsconfig.json",
|
|
18
|
+
"obfuscate": "ts-node scripts/obfuscate.ts",
|
|
18
19
|
"clean-build": "npm run clean && npm run build",
|
|
20
|
+
"clean-build-obfuscate": "npm run clean-build && npm run obfuscate",
|
|
19
21
|
"lint": "eslint . --ext .ts",
|
|
20
22
|
"lint:fix": "eslint . --fix --ext .ts",
|
|
21
23
|
"start": "ts-node src/index.ts",
|
|
@@ -51,17 +53,18 @@
|
|
|
51
53
|
"test:quorum": "HMSH_IS_CLUSTER=true NODE_ENV=test jest ./tests/functional/quorum/index.test.ts --detectOpenHandles --forceExit --verbose",
|
|
52
54
|
"test:reclaim": "NODE_ENV=test jest ./tests/functional/reclaim/index.test.ts --detectOpenHandles --forceExit --verbose",
|
|
53
55
|
"test:redeploy": "NODE_ENV=test jest ./tests/functional/redeploy/index.test.ts --detectOpenHandles --forceExit --verbose",
|
|
56
|
+
"test:reporter": "NODE_ENV=test jest ./tests/unit/services/reporter/index.test.ts --detectOpenHandles --forceExit --verbose",
|
|
54
57
|
"test:reentrant": "NODE_ENV=test jest ./tests/functional/reentrant/index.test.ts --detectOpenHandles --forceExit --verbose",
|
|
55
58
|
"test:retry": "NODE_ENV=test jest ./tests/functional/retry/index.test.ts --detectOpenHandles --forceExit --verbose",
|
|
56
59
|
"test:sequence": "NODE_ENV=test jest ./tests/functional/sequence/index.test.ts --detectOpenHandles --forceExit --verbose",
|
|
57
60
|
"test:signal": "NODE_ENV=test jest ./tests/functional/signal/index.test.ts --detectOpenHandles --forceExit --verbose",
|
|
58
61
|
"test:status": "NODE_ENV=test jest ./tests/functional/status/index.test.ts --detectOpenHandles --forceExit --verbose",
|
|
59
|
-
"test:store:ioredis": "NODE_ENV=test jest ./tests/functional/store/
|
|
60
|
-
"test:store:redis": "NODE_ENV=test jest ./tests/functional/store/
|
|
61
|
-
"test:stream:ioredis": "NODE_ENV=test jest ./tests/functional/stream/
|
|
62
|
-
"test:stream:redis": "NODE_ENV=test jest ./tests/functional/stream/
|
|
63
|
-
"test:sub:ioredis": "NODE_ENV=test jest ./tests/functional/sub/
|
|
64
|
-
"test:sub:redis": "NODE_ENV=test jest ./tests/functional/sub/
|
|
62
|
+
"test:store:ioredis": "NODE_ENV=test jest ./tests/functional/store/providers/redis/ioredis.test.ts --detectOpenHandles --forceExit --verbose",
|
|
63
|
+
"test:store:redis": "NODE_ENV=test jest ./tests/functional/store/providers/redis/redis.test.ts --detectOpenHandles --forceExit --verbose",
|
|
64
|
+
"test:stream:ioredis": "NODE_ENV=test jest ./tests/functional/stream/providers/redis/ioredis.test.ts --detectOpenHandles --forceExit --verbose",
|
|
65
|
+
"test:stream:redis": "NODE_ENV=test jest ./tests/functional/stream/providers/redis/redis.test.ts --detectOpenHandles --forceExit --verbose",
|
|
66
|
+
"test:sub:ioredis": "NODE_ENV=test jest ./tests/functional/sub/providers/redis/ioredis.test.ts --detectOpenHandles --forceExit --verbose",
|
|
67
|
+
"test:sub:redis": "NODE_ENV=test jest ./tests/functional/sub/providers/redis/redis.test.ts --detectOpenHandles --forceExit --verbose",
|
|
65
68
|
"test:trigger": "NODE_ENV=test jest ./tests/unit/services/activities/trigger.test.ts --detectOpenHandles --forceExit --verbose",
|
|
66
69
|
"test:meshdata": "NODE_ENV=test HMSH_IS_CLUSTER=true jest ./tests/meshdata/index.test.ts --forceExit --verbose --detectOpenHandles",
|
|
67
70
|
"test:meshos": "NODE_ENV=test HMSH_IS_CLUSTER=true jest ./tests/meshos/index.test.ts --forceExit --verbose --detectOpenHandles",
|
|
@@ -100,6 +103,7 @@
|
|
|
100
103
|
"eslint-plugin-import": "^2.29.1",
|
|
101
104
|
"eslint-plugin-prettier": "^5.1.3",
|
|
102
105
|
"ioredis": "^5.3.2",
|
|
106
|
+
"javascript-obfuscator": "^4.1.1",
|
|
103
107
|
"jest": "^29.5.0",
|
|
104
108
|
"redis": "^4.6.13",
|
|
105
109
|
"rimraf": "^4.4.1",
|
package/typedoc.json
CHANGED
package/types/redis.ts
CHANGED
|
@@ -75,7 +75,7 @@ interface RedisRedisMultiType {
|
|
|
75
75
|
DEL(key: string): this;
|
|
76
76
|
EXISTS(key: string): this;
|
|
77
77
|
EXPIRE(key: string, seconds: number): this;
|
|
78
|
-
HDEL(key: string,
|
|
78
|
+
HDEL(key: string, fields: string[] | string): this;
|
|
79
79
|
HGET(key: string, itemId: string): this;
|
|
80
80
|
HGETALL(key: string): this;
|
|
81
81
|
HINCRBYFLOAT(key: string, itemId: string, value: number): this;
|
|
@@ -151,12 +151,12 @@ interface RedisRedisClientType {
|
|
|
151
151
|
XLEN(key: string): Promise<number>;
|
|
152
152
|
DEL(key: string): Promise<number>;
|
|
153
153
|
EXISTS(key: string): Promise<number>;
|
|
154
|
-
HDEL(key: string,
|
|
154
|
+
HDEL(key: string, fields: string[] | string): Promise<number>;
|
|
155
155
|
HGET(key: string, itemId: string): Promise<string | null>;
|
|
156
156
|
HGETALL(key: string): Promise<StringStringType>;
|
|
157
157
|
HINCRBYFLOAT(key: string, itemId: string, value: number): Promise<number>;
|
|
158
158
|
HMGET(key: string, itemIds: string[]): Promise<string[]>;
|
|
159
|
-
HSET(key: string, values: Record<string, string>):
|
|
159
|
+
HSET(key: string, values: Record<string, string>): Promise<number>;
|
|
160
160
|
LPUSH(key: string, items: string[]): Promise<number>;
|
|
161
161
|
LRANGE(key: string, start: number, end: number): Promise<string[]>;
|
|
162
162
|
RPUSH(key: string, items: string[]): Promise<number>;
|
|
@@ -250,12 +250,12 @@ interface IORedisClient {
|
|
|
250
250
|
del(key: string): Promise<number>;
|
|
251
251
|
exists(key: string): Promise<number>;
|
|
252
252
|
get(key: string): Promise<string | null>;
|
|
253
|
-
hdel(key: string,
|
|
253
|
+
hdel(key: string, ...fields: string[]): Promise<number>;
|
|
254
254
|
hget(key: string, itemId: string): Promise<string | null>;
|
|
255
255
|
hgetall(key: string): Promise<StringStringType>;
|
|
256
256
|
hincrbyfloat(key: string, itemId: string, value: number): Promise<number>;
|
|
257
257
|
hmget(key: string, itemIds: string[]): Promise<string[]>;
|
|
258
|
-
hset(key: string, values: Record<string, string>):
|
|
258
|
+
hset(key: string, values: Record<string, string>): Promise<number>;
|
|
259
259
|
lpush(key: string, ...args: string[]): Promise<number>;
|
|
260
260
|
lrange(key: string, start: number, end: number): Promise<string[]>;
|
|
261
261
|
on(event: string, callback: (...args: any[]) => void): void;
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { KeyType } from '../../../modules/key';
|
|
2
|
-
import { ILogger } from '../../logger';
|
|
3
|
-
import { SerializerService as Serializer } from '../../serializer';
|
|
4
|
-
import { Cache } from '../cache';
|
|
5
|
-
import { StoreService } from '../index';
|
|
6
|
-
import { IORedisClientType as RedisClientType, IORedisMultiType as RedisMultiType } from '../../../types/redis';
|
|
7
|
-
import { ReclaimedMessageType } from '../../../types/stream';
|
|
8
|
-
declare class IORedisStoreService extends StoreService<RedisClientType, RedisMultiType> {
|
|
9
|
-
redisClient: RedisClientType;
|
|
10
|
-
cache: Cache;
|
|
11
|
-
namespace: string;
|
|
12
|
-
appId: string;
|
|
13
|
-
logger: ILogger;
|
|
14
|
-
serializer: Serializer;
|
|
15
|
-
constructor(redisClient: RedisClientType);
|
|
16
|
-
getMulti(): RedisMultiType;
|
|
17
|
-
exec(...args: any[]): Promise<string | string[] | string[][]>;
|
|
18
|
-
setnxex(key: string, value: string, expireSeconds: number): Promise<boolean>;
|
|
19
|
-
hGetAllResult(result: any): any;
|
|
20
|
-
addTaskQueues(keys: string[]): Promise<void>;
|
|
21
|
-
publish(keyType: KeyType.QUORUM, message: Record<string, any>, appId: string, engineId?: string): Promise<boolean>;
|
|
22
|
-
xgroup(command: 'CREATE', key: string, groupName: string, id: string, mkStream?: 'MKSTREAM'): Promise<boolean>;
|
|
23
|
-
xadd(key: string, id: string, messageId: string, messageValue: string, multi?: RedisMultiType): Promise<string | RedisMultiType>;
|
|
24
|
-
xpending(key: string, group: string, start?: string, end?: string, count?: number, consumer?: string): Promise<[string, string, number, [string, number][]][] | [string, string, number, number] | unknown[]>;
|
|
25
|
-
xclaim(key: string, group: string, consumer: string, minIdleTime: number, id: string, ...args: string[]): Promise<ReclaimedMessageType>;
|
|
26
|
-
xack(key: string, group: string, id: string, multi?: RedisMultiType): Promise<number | RedisMultiType>;
|
|
27
|
-
xdel(key: string, id: string, multi?: RedisMultiType): Promise<number | RedisMultiType>;
|
|
28
|
-
xlen(key: string, multi?: RedisMultiType): Promise<number | RedisMultiType>;
|
|
29
|
-
}
|
|
30
|
-
export { IORedisStoreService };
|
|
@@ -1,220 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.IORedisStoreService = void 0;
|
|
4
|
-
const key_1 = require("../../../modules/key");
|
|
5
|
-
const index_1 = require("../index");
|
|
6
|
-
const enums_1 = require("../../../modules/enums");
|
|
7
|
-
class IORedisStoreService extends index_1.StoreService {
|
|
8
|
-
constructor(redisClient) {
|
|
9
|
-
super(redisClient);
|
|
10
|
-
}
|
|
11
|
-
getMulti() {
|
|
12
|
-
const my = this;
|
|
13
|
-
if (enums_1.HMSH_IS_CLUSTER) {
|
|
14
|
-
const commands = [];
|
|
15
|
-
const addCommand = (command, args) => {
|
|
16
|
-
commands.push({ command, args });
|
|
17
|
-
return multiInstance;
|
|
18
|
-
};
|
|
19
|
-
const multiInstance = {
|
|
20
|
-
sendCommand(command) {
|
|
21
|
-
return my.redisClient.sendCommand(command);
|
|
22
|
-
},
|
|
23
|
-
async exec() {
|
|
24
|
-
if (commands.length === 0)
|
|
25
|
-
return [];
|
|
26
|
-
const sameKey = commands.every((cmd) => {
|
|
27
|
-
return cmd.args[0] === commands[0].args[0];
|
|
28
|
-
});
|
|
29
|
-
if (sameKey) {
|
|
30
|
-
const multi = my.redisClient.multi();
|
|
31
|
-
commands.forEach((cmd) => multi[cmd.command](...cmd.args));
|
|
32
|
-
const results = await multi.exec();
|
|
33
|
-
return results.map((item) => item);
|
|
34
|
-
}
|
|
35
|
-
else {
|
|
36
|
-
return Promise.all(commands.map((cmd) => my.redisClient[cmd.command](...cmd.args)));
|
|
37
|
-
}
|
|
38
|
-
},
|
|
39
|
-
xadd(key, id, fields, message) {
|
|
40
|
-
return addCommand('xadd', [key, id, fields, message]);
|
|
41
|
-
},
|
|
42
|
-
xack(key, group, id) {
|
|
43
|
-
return addCommand('xack', [key, group, id]);
|
|
44
|
-
},
|
|
45
|
-
xdel(key, id) {
|
|
46
|
-
return addCommand('xdel', [key, id]);
|
|
47
|
-
},
|
|
48
|
-
xlen(key) {
|
|
49
|
-
return addCommand('xlen', [key]);
|
|
50
|
-
},
|
|
51
|
-
xpending(key, group, start, end, count, consumer) {
|
|
52
|
-
return addCommand('xpending', [
|
|
53
|
-
key,
|
|
54
|
-
group,
|
|
55
|
-
start,
|
|
56
|
-
end,
|
|
57
|
-
count,
|
|
58
|
-
consumer,
|
|
59
|
-
]);
|
|
60
|
-
},
|
|
61
|
-
xclaim(key, group, consumer, minIdleTime, id, ...args) {
|
|
62
|
-
return addCommand('xclaim', [
|
|
63
|
-
key,
|
|
64
|
-
group,
|
|
65
|
-
consumer,
|
|
66
|
-
minIdleTime,
|
|
67
|
-
id,
|
|
68
|
-
...args,
|
|
69
|
-
]);
|
|
70
|
-
},
|
|
71
|
-
del(key) {
|
|
72
|
-
return addCommand('del', [key]);
|
|
73
|
-
},
|
|
74
|
-
expire: function (key, seconds) {
|
|
75
|
-
return addCommand('expire', [key, seconds]);
|
|
76
|
-
},
|
|
77
|
-
hdel(key, itemId) {
|
|
78
|
-
return addCommand('hdel', [key, itemId]);
|
|
79
|
-
},
|
|
80
|
-
hget(key, itemId) {
|
|
81
|
-
return addCommand('hget', [key, itemId]);
|
|
82
|
-
},
|
|
83
|
-
hgetall(key) {
|
|
84
|
-
return addCommand('hgetall', [key]);
|
|
85
|
-
},
|
|
86
|
-
hincrbyfloat(key, itemId, value) {
|
|
87
|
-
return addCommand('hincrbyfloat', [key, itemId, value]);
|
|
88
|
-
},
|
|
89
|
-
hmget(key, itemIds) {
|
|
90
|
-
return addCommand('hmget', [key, itemIds]);
|
|
91
|
-
},
|
|
92
|
-
hset(key, values) {
|
|
93
|
-
return addCommand('hset', [key, values]);
|
|
94
|
-
},
|
|
95
|
-
lrange(key, start, end) {
|
|
96
|
-
return addCommand('lrange', [key, start, end]);
|
|
97
|
-
},
|
|
98
|
-
rpush(key, value) {
|
|
99
|
-
return addCommand('rpush', [key, value]);
|
|
100
|
-
},
|
|
101
|
-
zadd(...args) {
|
|
102
|
-
return addCommand('zadd', args);
|
|
103
|
-
},
|
|
104
|
-
xgroup(command, key, groupName, id, mkStream) {
|
|
105
|
-
return addCommand('xgroup', [command, key, groupName, id, mkStream]);
|
|
106
|
-
},
|
|
107
|
-
};
|
|
108
|
-
return multiInstance;
|
|
109
|
-
}
|
|
110
|
-
return this.redisClient.multi();
|
|
111
|
-
}
|
|
112
|
-
async exec(...args) {
|
|
113
|
-
const response = await this.redisClient.call.apply(this.redisClient, args);
|
|
114
|
-
if (typeof response === 'string') {
|
|
115
|
-
return response;
|
|
116
|
-
}
|
|
117
|
-
else if (Array.isArray(response)) {
|
|
118
|
-
if (Array.isArray(response[0])) {
|
|
119
|
-
return response;
|
|
120
|
-
}
|
|
121
|
-
return response;
|
|
122
|
-
}
|
|
123
|
-
return response;
|
|
124
|
-
}
|
|
125
|
-
async setnxex(key, value, expireSeconds) {
|
|
126
|
-
const status = await this.redisClient[this.commands.set](key, value, 'NX', 'EX', expireSeconds.toString());
|
|
127
|
-
return this.isSuccessful(status);
|
|
128
|
-
}
|
|
129
|
-
hGetAllResult(result) {
|
|
130
|
-
return result[1];
|
|
131
|
-
}
|
|
132
|
-
async addTaskQueues(keys) {
|
|
133
|
-
const multi = this.redisClient.multi();
|
|
134
|
-
const zsetKey = this.mintKey(key_1.KeyType.WORK_ITEMS, { appId: this.appId });
|
|
135
|
-
for (const key of keys) {
|
|
136
|
-
multi.zadd(zsetKey, 'NX', Date.now(), key);
|
|
137
|
-
}
|
|
138
|
-
await multi.exec();
|
|
139
|
-
}
|
|
140
|
-
async publish(keyType, message, appId, engineId) {
|
|
141
|
-
const topic = this.mintKey(keyType, { appId, engineId });
|
|
142
|
-
const status = await this.redisClient.publish(topic, JSON.stringify(message));
|
|
143
|
-
return status === 1;
|
|
144
|
-
}
|
|
145
|
-
async xgroup(command, key, groupName, id, mkStream) {
|
|
146
|
-
if (mkStream === 'MKSTREAM') {
|
|
147
|
-
try {
|
|
148
|
-
return ((await this.redisClient.xgroup(command, key, groupName, id, mkStream)) === 'OK');
|
|
149
|
-
}
|
|
150
|
-
catch (err) {
|
|
151
|
-
this.logger.debug('stream-mkstream-caught', { key, group: groupName });
|
|
152
|
-
throw err;
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
else {
|
|
156
|
-
try {
|
|
157
|
-
return ((await this.redisClient.xgroup(command, key, groupName, id)) === 'OK');
|
|
158
|
-
}
|
|
159
|
-
catch (err) {
|
|
160
|
-
this.logger.debug(`Consumer group not created for key: ${key} and group: ${groupName}`);
|
|
161
|
-
throw err;
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
async xadd(key, id, messageId, messageValue, multi) {
|
|
166
|
-
try {
|
|
167
|
-
return await (multi || this.redisClient).xadd(key, id, messageId, messageValue);
|
|
168
|
-
}
|
|
169
|
-
catch (error) {
|
|
170
|
-
this.logger.error(`Error publishing 'xadd'; key: ${key}`, { ...error });
|
|
171
|
-
throw error;
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
async xpending(key, group, start, end, count, consumer) {
|
|
175
|
-
try {
|
|
176
|
-
return await this.redisClient.xpending(key, group, start, end, count, consumer);
|
|
177
|
-
}
|
|
178
|
-
catch (error) {
|
|
179
|
-
this.logger.error(`Error in retrieving pending messages for [stream ${key}], [group ${group}]`, { ...error });
|
|
180
|
-
throw error;
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
async xclaim(key, group, consumer, minIdleTime, id, ...args) {
|
|
184
|
-
try {
|
|
185
|
-
return (await this.redisClient.xclaim(key, group, consumer, minIdleTime, id, ...args));
|
|
186
|
-
}
|
|
187
|
-
catch (error) {
|
|
188
|
-
this.logger.error(`Error in claiming message with id: ${id} in group: ${group} for key: ${key}`, { ...error });
|
|
189
|
-
throw error;
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
async xack(key, group, id, multi) {
|
|
193
|
-
try {
|
|
194
|
-
return await (multi || this.redisClient).xack(key, group, id);
|
|
195
|
-
}
|
|
196
|
-
catch (error) {
|
|
197
|
-
this.logger.error(`Error in acknowledging messages in group: ${group} for key: ${key}`, { ...error });
|
|
198
|
-
throw error;
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
async xdel(key, id, multi) {
|
|
202
|
-
try {
|
|
203
|
-
return await (multi || this.redisClient).xdel(key, id);
|
|
204
|
-
}
|
|
205
|
-
catch (error) {
|
|
206
|
-
this.logger.error(`Error in deleting messages with id: ${id} for key: ${key}`, { ...error });
|
|
207
|
-
throw error;
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
async xlen(key, multi) {
|
|
211
|
-
try {
|
|
212
|
-
return await (multi || this.redisClient).xlen(key);
|
|
213
|
-
}
|
|
214
|
-
catch (error) {
|
|
215
|
-
this.logger.error(`Error getting stream depth: ${key}`, { ...error });
|
|
216
|
-
throw error;
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
exports.IORedisStoreService = IORedisStoreService;
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { KeyType } from '../../../modules/key';
|
|
2
|
-
import { ILogger } from '../../logger';
|
|
3
|
-
import { SerializerService as Serializer } from '../../serializer';
|
|
4
|
-
import { Cache } from '../cache';
|
|
5
|
-
import { StoreService } from '../index';
|
|
6
|
-
import { RedisRedisClientType as RedisClientType, RedisRedisMultiType as RedisMultiType } from '../../../types/redis';
|
|
7
|
-
import { ReclaimedMessageType } from '../../../types/stream';
|
|
8
|
-
declare class RedisStoreService extends StoreService<RedisClientType, RedisMultiType> {
|
|
9
|
-
redisClient: RedisClientType;
|
|
10
|
-
cache: Cache;
|
|
11
|
-
namespace: string;
|
|
12
|
-
appId: string;
|
|
13
|
-
logger: ILogger;
|
|
14
|
-
serializer: Serializer;
|
|
15
|
-
commands: Record<string, string>;
|
|
16
|
-
constructor(redisClient: RedisClientType);
|
|
17
|
-
getMulti(): RedisMultiType;
|
|
18
|
-
exec(...args: any[]): Promise<string | string[] | string[][]>;
|
|
19
|
-
setnxex(key: string, value: string, expireSeconds: number): Promise<boolean>;
|
|
20
|
-
publish(keyType: KeyType.QUORUM, message: Record<string, any>, appId: string, engineId?: string): Promise<boolean>;
|
|
21
|
-
zAdd(key: string, score: number | string, value: string | number, redisMulti?: RedisMultiType): Promise<any>;
|
|
22
|
-
zRangeByScoreWithScores(key: string, score: number | string, value: string | number): Promise<string | null>;
|
|
23
|
-
zRangeByScore(key: string, score: number | string, value: string | number): Promise<string | null>;
|
|
24
|
-
xgroup(command: 'CREATE', key: string, groupName: string, id: string, mkStream?: 'MKSTREAM'): Promise<boolean>;
|
|
25
|
-
xadd(key: string, id: string, ...args: any[]): Promise<string | RedisMultiType>;
|
|
26
|
-
xpending(key: string, group: string, start?: string, end?: string, count?: number, consumer?: string): Promise<[string, string, number, [string, number][]][] | [string, string, number, number]>;
|
|
27
|
-
xclaim(key: string, group: string, consumer: string, minIdleTime: number, id: string, ...args: string[]): Promise<ReclaimedMessageType>;
|
|
28
|
-
xack(key: string, group: string, id: string, multi?: RedisMultiType): Promise<number | RedisMultiType>;
|
|
29
|
-
xdel(key: string, id: string, multi?: RedisMultiType): Promise<number | RedisMultiType>;
|
|
30
|
-
xlen(key: string, multi?: RedisMultiType): Promise<number | RedisMultiType>;
|
|
31
|
-
}
|
|
32
|
-
export { RedisStoreService };
|