@hotmeshio/hotmesh 0.3.8 → 0.3.10
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 +7 -13
- package/build/index.d.ts +5 -2
- package/build/index.js +8 -3
- package/build/modules/key.js +1 -1
- package/build/modules/utils.d.ts +12 -4
- package/build/modules/utils.js +1 -1
- package/build/package.json +15 -8
- package/build/services/activities/activity.d.ts +9 -9
- package/build/services/activities/activity.js +1 -1
- package/build/services/activities/await.d.ts +2 -2
- package/build/services/activities/await.js +1 -1
- package/build/services/activities/cycle.d.ts +2 -2
- package/build/services/activities/cycle.js +1 -1
- package/build/services/activities/hook.d.ts +2 -2
- package/build/services/activities/hook.js +1 -1
- package/build/services/activities/index.js +1 -1
- package/build/services/activities/interrupt.js +1 -1
- package/build/services/activities/signal.js +1 -1
- package/build/services/activities/trigger.d.ts +3 -3
- package/build/services/activities/trigger.js +1 -1
- package/build/services/activities/worker.d.ts +2 -2
- package/build/services/activities/worker.js +1 -1
- package/build/services/collator/index.d.ts +9 -9
- package/build/services/collator/index.js +1 -1
- package/build/services/compiler/deployer.d.ts +4 -4
- package/build/services/compiler/deployer.js +1 -1
- package/build/services/compiler/index.d.ts +4 -4
- package/build/services/compiler/index.js +1 -1
- package/build/services/compiler/validator.d.ts +3 -3
- package/build/services/compiler/validator.js +1 -1
- package/build/services/connector/factory.d.ts +7 -0
- package/build/services/connector/factory.js +65 -0
- package/build/services/connector/index.d.ts +13 -4
- package/build/services/connector/index.js +30 -23
- package/build/services/connector/providers/ioredis.d.ts +9 -0
- package/build/services/connector/providers/ioredis.js +26 -0
- package/build/services/connector/providers/nats.d.ts +9 -0
- package/build/services/connector/providers/nats.js +26 -0
- package/build/services/connector/providers/postgres.d.ts +9 -0
- package/build/services/connector/providers/postgres.js +44 -0
- package/build/services/connector/providers/redis.d.ts +9 -0
- package/build/services/connector/providers/redis.js +38 -0
- package/build/services/engine/index.d.ts +12 -12
- package/build/services/engine/index.js +1 -1
- package/build/services/exporter/index.d.ts +3 -3
- package/build/services/exporter/index.js +1 -1
- package/build/services/hotmesh/index.js +4 -4
- package/build/services/mapper/index.js +1 -1
- package/build/services/meshcall/index.d.ts +5 -4
- package/build/services/meshcall/index.js +31 -14
- package/build/services/meshdata/index.d.ts +6 -6
- package/build/services/meshdata/index.js +7 -15
- package/build/services/meshflow/connection.d.ts +3 -2
- package/build/services/meshflow/exporter.d.ts +3 -3
- package/build/services/meshflow/exporter.js +1 -1
- package/build/services/meshflow/search.js +12 -4
- package/build/services/meshflow/worker.js +7 -7
- package/build/services/meshos/index.d.ts +1 -4
- package/build/services/meshos/index.js +11 -44
- package/build/services/pipe/functions/array.js +1 -1
- package/build/services/pipe/functions/bitwise.js +1 -1
- package/build/services/pipe/functions/conditional.js +1 -1
- package/build/services/pipe/functions/cron.d.ts +2 -0
- package/build/services/pipe/functions/cron.js +1 -1
- package/build/services/pipe/functions/date.js +1 -1
- package/build/services/pipe/functions/index.js +1 -1
- package/build/services/pipe/functions/json.js +1 -1
- package/build/services/pipe/functions/logical.js +1 -1
- package/build/services/pipe/functions/math.js +1 -1
- package/build/services/pipe/functions/number.js +1 -1
- package/build/services/pipe/functions/object.js +1 -1
- package/build/services/pipe/functions/string.js +1 -1
- package/build/services/pipe/functions/symbol.js +1 -1
- package/build/services/pipe/functions/unary.js +1 -1
- package/build/services/pipe/index.js +1 -1
- package/build/services/quorum/index.d.ts +5 -5
- package/build/services/quorum/index.js +1 -1
- package/build/services/reporter/index.d.ts +2 -2
- package/build/services/reporter/index.js +1 -1
- package/build/services/router/index.d.ts +8 -13
- package/build/services/router/index.js +1 -1
- package/build/services/search/factory.d.ts +2 -2
- package/build/services/search/factory.js +1 -1
- package/build/services/search/index.d.ts +5 -4
- package/build/services/search/providers/redis/ioredis.js +1 -1
- package/build/services/search/providers/redis/redis.js +1 -1
- package/build/services/serializer/index.js +1 -1
- package/build/services/store/factory.d.ts +3 -3
- package/build/services/store/factory.js +1 -1
- package/build/services/store/index.d.ts +18 -17
- package/build/services/store/providers/redis/_base.d.ts +13 -15
- package/build/services/store/providers/redis/_base.js +1 -1
- package/build/services/store/providers/redis/ioredis.d.ts +2 -2
- package/build/services/store/providers/redis/ioredis.js +1 -1
- package/build/services/store/providers/redis/redis.d.ts +2 -2
- package/build/services/store/providers/redis/redis.js +1 -1
- package/build/services/store/providers/store-initializable.js +1 -1
- package/build/services/stream/factory.d.ts +3 -3
- package/build/services/stream/factory.js +16 -4
- package/build/services/stream/index.d.ts +57 -18
- package/build/services/stream/index.js +2 -1
- package/build/services/stream/providers/nats/nats.d.ts +59 -0
- package/build/services/stream/providers/nats/nats.js +1 -0
- package/build/services/stream/providers/postgres/postgres.d.ts +68 -0
- package/build/services/stream/providers/postgres/postgres.js +1 -0
- package/build/services/stream/providers/redis/ioredis.d.ts +53 -14
- package/build/services/stream/providers/redis/ioredis.js +1 -1
- package/build/services/stream/providers/redis/redis.d.ts +54 -15
- package/build/services/stream/providers/redis/redis.js +1 -1
- package/build/services/stream/providers/stream-initializable.d.ts +1 -2
- package/build/services/stream/providers/stream-initializable.js +1 -1
- package/build/services/sub/factory.d.ts +2 -2
- package/build/services/sub/factory.js +1 -1
- package/build/services/sub/index.d.ts +6 -5
- package/build/services/sub/providers/redis/ioredis.d.ts +1 -1
- package/build/services/sub/providers/redis/ioredis.js +1 -1
- package/build/services/sub/providers/redis/redis.d.ts +4 -4
- package/build/services/sub/providers/redis/redis.js +1 -1
- package/build/services/task/index.d.ts +5 -5
- package/build/services/task/index.js +1 -1
- package/build/services/telemetry/index.js +1 -1
- package/build/services/worker/index.d.ts +9 -9
- package/build/services/worker/index.js +1 -1
- package/build/types/hotmesh.d.ts +26 -14
- package/build/types/index.d.ts +8 -5
- package/build/types/manifest.d.ts +1 -9
- package/build/types/meshcall.d.ts +12 -7
- package/build/types/meshflow.d.ts +3 -7
- package/build/types/nats.d.ts +150 -0
- package/build/types/nats.js +2 -0
- package/build/types/postgres.d.ts +70 -0
- package/build/types/postgres.js +2 -0
- package/build/types/provider.d.ts +26 -0
- package/build/types/provider.js +2 -0
- package/build/types/redis.d.ts +33 -15
- package/build/types/stream.d.ts +65 -1
- package/index.ts +10 -5
- package/package.json +15 -8
- package/typedoc.json +6 -0
- package/types/hotmesh.ts +139 -22
- package/types/index.ts +80 -17
- package/types/manifest.ts +1 -10
- package/types/meshcall.ts +38 -13
- package/types/meshflow.ts +2 -7
- package/types/nats.ts +236 -0
- package/types/postgres.ts +85 -0
- package/types/provider.ts +71 -0
- package/types/redis.ts +63 -18
- package/types/stream.ts +85 -1
- package/build/services/connector/clients/ioredis.d.ts +0 -13
- package/build/services/connector/clients/ioredis.js +0 -48
- package/build/services/connector/clients/redis.d.ts +0 -13
- package/build/services/connector/clients/redis.js +0 -60
- package/build/services/stream/providers/postgres/_deploy.d.ts +0 -4
- package/build/services/stream/providers/postgres/_deploy.js +0 -1
package/types/redis.ts
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ProviderClient,
|
|
3
|
+
ProviderConfig,
|
|
4
|
+
ProviderTransaction,
|
|
5
|
+
} from './provider';
|
|
1
6
|
import { StringStringType } from './serializer';
|
|
2
7
|
import { ReclaimedMessageType } from './stream';
|
|
3
8
|
|
|
4
|
-
type MultiResponseFlags = (string | number)[]; // e.g., [3, 2, '0']
|
|
5
|
-
|
|
6
9
|
/**
|
|
7
10
|
* Redis types
|
|
8
11
|
*/
|
|
@@ -64,14 +67,10 @@ interface RedisRedisClientOptions {
|
|
|
64
67
|
stringNumbers?: boolean;
|
|
65
68
|
}
|
|
66
69
|
|
|
67
|
-
interface RedisRedisMultiType {
|
|
70
|
+
interface RedisRedisMultiType extends ProviderTransaction {
|
|
68
71
|
sendCommand(command: string, ...args: string[]): Promise<any>;
|
|
69
72
|
exec: () => Promise<unknown[]>;
|
|
70
73
|
|
|
71
|
-
XADD(key: string, id: string, fields: any): this;
|
|
72
|
-
XACK(key: string, group: string, id: string): this;
|
|
73
|
-
XDEL(key: string, id: string): this;
|
|
74
|
-
XLEN(key: string): this;
|
|
75
74
|
DEL(key: string): this;
|
|
76
75
|
EXISTS(key: string): this;
|
|
77
76
|
EXPIRE(key: string, seconds: number): this;
|
|
@@ -87,6 +86,11 @@ interface RedisRedisMultiType {
|
|
|
87
86
|
LRANGE(key: string, start: number, end: number): this;
|
|
88
87
|
RPUSH(key: string, items: string[]): this;
|
|
89
88
|
SET(key: string, value: string): this;
|
|
89
|
+
XADD(key: string, id: string, fields: any): this;
|
|
90
|
+
XACK(key: string, group: string, id: string): this;
|
|
91
|
+
XACK(key: string, group: string, ...ids: string[]): this;
|
|
92
|
+
XDEL(key: string, id: string): this;
|
|
93
|
+
XDEL(key: string, ...ids: string[]): this;
|
|
90
94
|
XCLAIM(
|
|
91
95
|
key: string,
|
|
92
96
|
group: string,
|
|
@@ -95,6 +99,7 @@ interface RedisRedisMultiType {
|
|
|
95
99
|
id: string,
|
|
96
100
|
...args: string[]
|
|
97
101
|
): this;
|
|
102
|
+
XLEN(key: string): this;
|
|
98
103
|
XGROUP(
|
|
99
104
|
command: 'CREATE' | string,
|
|
100
105
|
key: string,
|
|
@@ -120,7 +125,7 @@ interface RedisRedisMultiType {
|
|
|
120
125
|
ZSCORE(key: string, value: string): this;
|
|
121
126
|
}
|
|
122
127
|
|
|
123
|
-
interface RedisRedisClientType {
|
|
128
|
+
interface RedisRedisClientType extends ProviderClient {
|
|
124
129
|
multi(): Partial<RedisRedisMultiType>;
|
|
125
130
|
connect(): Promise<void>;
|
|
126
131
|
sendCommand(args: any[]): Promise<any>;
|
|
@@ -145,10 +150,6 @@ interface RedisRedisClientType {
|
|
|
145
150
|
get(key: string): Promise<string | null>;
|
|
146
151
|
set(key: string, value: string): Promise<string>;
|
|
147
152
|
|
|
148
|
-
XADD(key: string, id: string, fields: any): Promise<string>;
|
|
149
|
-
XACK(key: string, group: string, id: string): Promise<number>;
|
|
150
|
-
XDEL(key: string, id: string): Promise<number>;
|
|
151
|
-
XLEN(key: string): Promise<number>;
|
|
152
153
|
DEL(key: string): Promise<number>;
|
|
153
154
|
EXISTS(key: string): Promise<number>;
|
|
154
155
|
HDEL(key: string, fields: string[] | string): Promise<number>;
|
|
@@ -161,6 +162,31 @@ interface RedisRedisClientType {
|
|
|
161
162
|
LRANGE(key: string, start: number, end: number): Promise<string[]>;
|
|
162
163
|
RPUSH(key: string, items: string[]): Promise<number>;
|
|
163
164
|
SET(key: string, value: string): Promise<string>;
|
|
165
|
+
XADD(key: string, id: string, fields: any): Promise<string>;
|
|
166
|
+
XACK(key: string, group: string, ...ids: string[]): Promise<number>;
|
|
167
|
+
XACK(key: string, group: string, id: string): Promise<number>;
|
|
168
|
+
XCLAIM(
|
|
169
|
+
key: string,
|
|
170
|
+
group: string,
|
|
171
|
+
consumer: string,
|
|
172
|
+
minIdleTime: number,
|
|
173
|
+
id: string,
|
|
174
|
+
...args: string[]
|
|
175
|
+
): Promise<ReclaimedMessageType>;
|
|
176
|
+
XDEL(key: string, id: string): Promise<number>;
|
|
177
|
+
XDEL(key: string, ...ids: string[]): Promise<number>;
|
|
178
|
+
xGroupDestroy(key: string, groupName: string): Promise<boolean>;
|
|
179
|
+
XINFO(command: 'GROUPS' | string, key: string): Promise<unknown>;
|
|
180
|
+
XINFO_GROUPS(key: string): Promise<unknown>;
|
|
181
|
+
XLEN(key: string): Promise<number>;
|
|
182
|
+
XPENDING(
|
|
183
|
+
key: string,
|
|
184
|
+
group: string,
|
|
185
|
+
start?: string,
|
|
186
|
+
end?: string,
|
|
187
|
+
count?: number,
|
|
188
|
+
consumer?: string,
|
|
189
|
+
): this;
|
|
164
190
|
ZADD(
|
|
165
191
|
key: string,
|
|
166
192
|
values: { score: string; value: string },
|
|
@@ -200,7 +226,7 @@ interface IORedisClientOptions {
|
|
|
200
226
|
reconnectOnError?: (err: Error) => boolean;
|
|
201
227
|
}
|
|
202
228
|
|
|
203
|
-
interface IORedisClient {
|
|
229
|
+
interface IORedisClient extends ProviderClient {
|
|
204
230
|
multi(): IORedisMultiType;
|
|
205
231
|
exec(): Promise<unknown[]>;
|
|
206
232
|
sendCommand(args: any[]): Promise<any>;
|
|
@@ -223,7 +249,9 @@ interface IORedisClient {
|
|
|
223
249
|
|
|
224
250
|
xadd(key: string, id: string, fields: any, message?: string): Promise<string>;
|
|
225
251
|
xack(key: string, group: string, id: string): Promise<number>;
|
|
252
|
+
xack(key: string, group: string, ...ids: string[]): Promise<number>;
|
|
226
253
|
xdel(key: string, id: string): Promise<number>;
|
|
254
|
+
xdel(key: string, ...ids: string[]): Promise<number>;
|
|
227
255
|
xlen(key: string): Promise<number>;
|
|
228
256
|
xpending(
|
|
229
257
|
key: string,
|
|
@@ -247,6 +275,16 @@ interface IORedisClient {
|
|
|
247
275
|
): Promise<ReclaimedMessageType>;
|
|
248
276
|
xinfo(command: 'GROUPS' | string, key: string): Promise<unknown>;
|
|
249
277
|
xrange(key: string, start: string, end: string): Promise<string[][]>;
|
|
278
|
+
xreadgroup(
|
|
279
|
+
command: 'GROUP',
|
|
280
|
+
groupName: string,
|
|
281
|
+
consumerName: string,
|
|
282
|
+
blockOption: string,
|
|
283
|
+
blockTime: number,
|
|
284
|
+
streamsOption: string,
|
|
285
|
+
streamName: string,
|
|
286
|
+
key: string,
|
|
287
|
+
): Promise<string[][]>;
|
|
250
288
|
del(key: string): Promise<number>;
|
|
251
289
|
exists(key: string): Promise<number>;
|
|
252
290
|
get(key: string): Promise<string | null>;
|
|
@@ -271,22 +309,24 @@ interface IORedisClient {
|
|
|
271
309
|
zrank(key: string, member: string): Promise<number>;
|
|
272
310
|
zscore(key: string, value: string): Promise<number>;
|
|
273
311
|
xgroup(
|
|
274
|
-
command: 'CREATE' | string,
|
|
312
|
+
command: 'CREATE' | 'DESTROY' | string,
|
|
275
313
|
key: string,
|
|
276
314
|
groupName: string,
|
|
277
|
-
id
|
|
315
|
+
id?: string,
|
|
278
316
|
mkStream?: 'MKSTREAM',
|
|
279
|
-
): Promise<string>;
|
|
317
|
+
): Promise<string | number>;
|
|
280
318
|
}
|
|
281
319
|
|
|
282
320
|
type IORedisClassType = new (
|
|
283
321
|
options: IORedisClientOptions,
|
|
284
322
|
...args: any[]
|
|
285
323
|
) => IORedisClient;
|
|
286
|
-
interface IORedisMultiType {
|
|
324
|
+
interface IORedisMultiType extends ProviderTransaction {
|
|
287
325
|
xadd(key: string, id: string, fields: any, message?: string): this;
|
|
288
326
|
xack(key: string, group: string, id: string): this;
|
|
327
|
+
xack(key: string, group: string, ...ids: string[]): this;
|
|
289
328
|
xdel(key: string, id: string): this;
|
|
329
|
+
xdel(key: string, ...ids: string[]): this;
|
|
290
330
|
xlen(key: string): this;
|
|
291
331
|
xpending(
|
|
292
332
|
key: string,
|
|
@@ -340,8 +380,14 @@ function isIORedisClient(client: RedisClient): client is IORedisClient {
|
|
|
340
380
|
return 'pipeline' in client;
|
|
341
381
|
}
|
|
342
382
|
|
|
383
|
+
interface RedisConfig extends ProviderConfig {
|
|
384
|
+
class: Partial<RedisClass>;
|
|
385
|
+
options: Partial<RedisOptions>;
|
|
386
|
+
}
|
|
387
|
+
|
|
343
388
|
export {
|
|
344
389
|
RedisClass,
|
|
390
|
+
RedisConfig,
|
|
345
391
|
RedisRedisClientType,
|
|
346
392
|
RedisRedisClientOptions,
|
|
347
393
|
RedisRedisClassType,
|
|
@@ -353,7 +399,6 @@ export {
|
|
|
353
399
|
IORedisClassType,
|
|
354
400
|
IORedisMultiType,
|
|
355
401
|
RedisOptions,
|
|
356
|
-
MultiResponseFlags,
|
|
357
402
|
isRedisClient,
|
|
358
403
|
isIORedisClient,
|
|
359
404
|
};
|
package/types/stream.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { ProviderTransaction } from './provider';
|
|
2
|
+
|
|
1
3
|
/** Represents a policy for retrying stream operations based on error codes */
|
|
2
4
|
export interface StreamRetryPolicy {
|
|
3
5
|
/**
|
|
@@ -121,7 +123,7 @@ export type ReclaimedMessageType = [
|
|
|
121
123
|
][];
|
|
122
124
|
|
|
123
125
|
/** Configuration parameters for a stream */
|
|
124
|
-
export type
|
|
126
|
+
export type RouterConfig = {
|
|
125
127
|
/** Namespace under which the stream operates */
|
|
126
128
|
namespace: string;
|
|
127
129
|
/** Application identifier */
|
|
@@ -141,3 +143,85 @@ export type StreamConfig = {
|
|
|
141
143
|
/** if true, will not process stream messages; default true */
|
|
142
144
|
readonly?: boolean;
|
|
143
145
|
};
|
|
146
|
+
|
|
147
|
+
export type StreamProviderType =
|
|
148
|
+
| 'redis'
|
|
149
|
+
| 'ioredis'
|
|
150
|
+
| 'postgres'
|
|
151
|
+
| 'nats'
|
|
152
|
+
| 'sqs';
|
|
153
|
+
|
|
154
|
+
export interface StreamConfig {
|
|
155
|
+
// Common configuration
|
|
156
|
+
provider?: StreamProviderType;
|
|
157
|
+
namespace?: string;
|
|
158
|
+
appId?: string;
|
|
159
|
+
maxRetries?: number;
|
|
160
|
+
batchSize?: number;
|
|
161
|
+
timeout?: number;
|
|
162
|
+
|
|
163
|
+
// Provider-specific configurations
|
|
164
|
+
redis?: {
|
|
165
|
+
claimTimeout?: number;
|
|
166
|
+
blockingTimeout?: number;
|
|
167
|
+
minIdleTime?: number;
|
|
168
|
+
};
|
|
169
|
+
postgres?: {
|
|
170
|
+
pollInterval?: number;
|
|
171
|
+
vacuumInterval?: number;
|
|
172
|
+
partitionInterval?: 'daily' | 'weekly' | 'monthly';
|
|
173
|
+
cleanupInterval?: number;
|
|
174
|
+
};
|
|
175
|
+
nats?: {
|
|
176
|
+
jetstream?: boolean;
|
|
177
|
+
durableName?: string;
|
|
178
|
+
deliverPolicy?: 'all' | 'last' | 'new' | 'byStartSequence' | 'byStartTime';
|
|
179
|
+
ackWait?: number;
|
|
180
|
+
};
|
|
181
|
+
sqs?: {
|
|
182
|
+
deadLetterQueue?: string;
|
|
183
|
+
visibilityTimeout?: number;
|
|
184
|
+
waitTimeSeconds?: number;
|
|
185
|
+
messageRetentionPeriod?: number;
|
|
186
|
+
dlqArn?: string;
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
export interface StreamMessage {
|
|
191
|
+
id: string;
|
|
192
|
+
data: StreamData;
|
|
193
|
+
metadata?: StreamMessageMetadata;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
export interface StreamMessageMetadata {
|
|
197
|
+
timestamp?: number;
|
|
198
|
+
stream?: string;
|
|
199
|
+
groupName?: string;
|
|
200
|
+
consumerName?: string;
|
|
201
|
+
retryCount?: number;
|
|
202
|
+
deliveryTime?: number;
|
|
203
|
+
originalMessageId?: string;
|
|
204
|
+
[key: string]: any; // For provider-specific metadata
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
export interface StreamStats {
|
|
208
|
+
messageCount: number;
|
|
209
|
+
consumerCount?: number;
|
|
210
|
+
bytesInMemory?: number;
|
|
211
|
+
oldestMessageTimestamp?: number;
|
|
212
|
+
pendingMessages?: number;
|
|
213
|
+
deadLetterQueueMessageCount?: number;
|
|
214
|
+
averageProcessingTime?: number;
|
|
215
|
+
lastErrorTimestamp?: number;
|
|
216
|
+
lastErrorMessage?: string;
|
|
217
|
+
[key: string]: any; // For provider-specific stats
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* When publishing a message to the stream, the configuration
|
|
222
|
+
* can include a transaction object to execute the operation
|
|
223
|
+
* atomically.
|
|
224
|
+
*/
|
|
225
|
+
export interface PublishMessageConfig {
|
|
226
|
+
transaction?: ProviderTransaction;
|
|
227
|
+
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { IORedisClientOptions as RedisClientOptions, IORedisClassType as RedisClassType, IORedisClientType as RedisClientType } from '../../../types/redis';
|
|
2
|
-
declare class RedisConnection {
|
|
3
|
-
private connection;
|
|
4
|
-
private static instances;
|
|
5
|
-
private id;
|
|
6
|
-
private static clientOptions;
|
|
7
|
-
private createConnection;
|
|
8
|
-
getClient(): RedisClientType;
|
|
9
|
-
disconnect(): Promise<void>;
|
|
10
|
-
static connect(id: string, Redis: Partial<RedisClassType>, options?: RedisClientOptions): Promise<RedisConnection>;
|
|
11
|
-
static disconnectAll(): Promise<void>;
|
|
12
|
-
}
|
|
13
|
-
export { RedisConnection };
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.RedisConnection = void 0;
|
|
4
|
-
class RedisConnection {
|
|
5
|
-
constructor() {
|
|
6
|
-
this.connection = null;
|
|
7
|
-
this.id = null;
|
|
8
|
-
}
|
|
9
|
-
async createConnection(Redis, options) {
|
|
10
|
-
return new Redis(options);
|
|
11
|
-
}
|
|
12
|
-
getClient() {
|
|
13
|
-
if (!this.connection) {
|
|
14
|
-
throw new Error('Redis client is not connected');
|
|
15
|
-
}
|
|
16
|
-
return this.connection;
|
|
17
|
-
}
|
|
18
|
-
async disconnect() {
|
|
19
|
-
if (this.connection) {
|
|
20
|
-
await this.connection.quit();
|
|
21
|
-
this.connection = null;
|
|
22
|
-
}
|
|
23
|
-
if (this.id) {
|
|
24
|
-
RedisConnection.instances.delete(this.id);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
static async connect(id, Redis, options) {
|
|
28
|
-
if (this.instances.has(id)) {
|
|
29
|
-
return this.instances.get(id);
|
|
30
|
-
}
|
|
31
|
-
const instance = new RedisConnection();
|
|
32
|
-
const opts = options ? { ...options } : { ...this.clientOptions };
|
|
33
|
-
instance.connection = await instance.createConnection(Redis, opts);
|
|
34
|
-
instance.id = id;
|
|
35
|
-
this.instances.set(id, instance);
|
|
36
|
-
return instance;
|
|
37
|
-
}
|
|
38
|
-
static async disconnectAll() {
|
|
39
|
-
await Promise.all(Array.from(this.instances.values()).map((instance) => instance.disconnect()));
|
|
40
|
-
this.instances.clear();
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
exports.RedisConnection = RedisConnection;
|
|
44
|
-
RedisConnection.instances = new Map();
|
|
45
|
-
RedisConnection.clientOptions = {
|
|
46
|
-
host: 'localhost',
|
|
47
|
-
port: 6379,
|
|
48
|
-
};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { RedisRedisClassType, RedisRedisClientType, RedisRedisClientOptions } from '../../../types/redis';
|
|
2
|
-
declare class RedisConnection {
|
|
3
|
-
private connection;
|
|
4
|
-
private static instances;
|
|
5
|
-
private id;
|
|
6
|
-
private static clientOptions;
|
|
7
|
-
private createConnection;
|
|
8
|
-
getClient(): RedisRedisClientType;
|
|
9
|
-
disconnect(): Promise<void>;
|
|
10
|
-
static connect(id: string, Redis: Partial<RedisRedisClassType>, options?: RedisRedisClientOptions): Promise<RedisConnection>;
|
|
11
|
-
static disconnectAll(): Promise<void>;
|
|
12
|
-
}
|
|
13
|
-
export { RedisConnection, RedisRedisClientType };
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.RedisConnection = void 0;
|
|
4
|
-
class RedisConnection {
|
|
5
|
-
constructor() {
|
|
6
|
-
this.connection = null;
|
|
7
|
-
this.id = null;
|
|
8
|
-
}
|
|
9
|
-
async createConnection(Redis, options) {
|
|
10
|
-
return new Promise((resolve, reject) => {
|
|
11
|
-
const client = Redis.createClient(options);
|
|
12
|
-
client.on('error', (error) => {
|
|
13
|
-
reject(error);
|
|
14
|
-
});
|
|
15
|
-
client.on('ready', () => {
|
|
16
|
-
resolve(client);
|
|
17
|
-
});
|
|
18
|
-
client.connect();
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
getClient() {
|
|
22
|
-
if (!this.connection) {
|
|
23
|
-
throw new Error('Redis client is not connected');
|
|
24
|
-
}
|
|
25
|
-
return this.connection;
|
|
26
|
-
}
|
|
27
|
-
async disconnect() {
|
|
28
|
-
if (this.connection) {
|
|
29
|
-
await this.connection.quit();
|
|
30
|
-
this.connection = null;
|
|
31
|
-
}
|
|
32
|
-
if (this.id) {
|
|
33
|
-
RedisConnection.instances.delete(this.id);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
static async connect(id, Redis, options) {
|
|
37
|
-
if (this.instances.has(id)) {
|
|
38
|
-
return this.instances.get(id);
|
|
39
|
-
}
|
|
40
|
-
const instance = new RedisConnection();
|
|
41
|
-
const opts = options ? { ...options } : { ...this.clientOptions };
|
|
42
|
-
instance.connection = (await instance.createConnection(Redis, opts));
|
|
43
|
-
instance.id = id;
|
|
44
|
-
this.instances.set(id, instance);
|
|
45
|
-
return instance;
|
|
46
|
-
}
|
|
47
|
-
static async disconnectAll() {
|
|
48
|
-
await Promise.all(Array.from(this.instances.values()).map((instance) => instance.disconnect()));
|
|
49
|
-
this.instances.clear();
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
exports.RedisConnection = RedisConnection;
|
|
53
|
-
RedisConnection.instances = new Map();
|
|
54
|
-
RedisConnection.clientOptions = {
|
|
55
|
-
socket: {
|
|
56
|
-
host: 'localhost',
|
|
57
|
-
port: 6379,
|
|
58
|
-
tls: false,
|
|
59
|
-
},
|
|
60
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
'use strict';(function(_0x1f8d0e,_0x2d0f77){const _0x5ae236=_0x3116,_0x1a2ab9=_0x1f8d0e();while(!![]){try{const _0x26a10f=parseInt(_0x5ae236(0x1b8))/0x1+parseInt(_0x5ae236(0x1bd))/0x2+parseInt(_0x5ae236(0x1c0))/0x3*(parseInt(_0x5ae236(0x1bb))/0x4)+parseInt(_0x5ae236(0x1c1))/0x5+parseInt(_0x5ae236(0x1ba))/0x6*(parseInt(_0x5ae236(0x1be))/0x7)+parseInt(_0x5ae236(0x1b9))/0x8*(parseInt(_0x5ae236(0x1bc))/0x9)+-parseInt(_0x5ae236(0x1bf))/0xa;if(_0x26a10f===_0x2d0f77)break;else _0x1a2ab9['push'](_0x1a2ab9['shift']());}catch(_0x9b34ce){_0x1a2ab9['push'](_0x1a2ab9['shift']());}}}(_0x3e02,0xb7835));Object['defineProperty'](exports,'__esModule',{'value':!![]}),exports['DeployService']=void 0x0;class DeployService{constructor(){}async['deploy'](){const _0x1e618f='\x0a--\x20messages\x20table\x0aCREATE\x20TABLE\x20IF\x20NOT\x20EXISTS\x20messages\x20(\x0a\x20\x20\x20\x20stream\x20VARCHAR(255)\x20NOT\x20NULL,\x0a\x20\x20\x20\x20message_id\x20BIGSERIAL\x20PRIMARY\x20KEY,\x0a\x20\x20\x20\x20message\x20JSONB\x20NOT\x20NULL,\x0a\x20\x20\x20\x20created_at\x20TIMESTAMPTZ\x20DEFAULT\x20NOW()\x0a);\x0a\x0aCREATE\x20INDEX\x20IF\x20NOT\x20EXISTS\x20idx_messages_stream_message_id\x20ON\x20messages\x20(stream,\x20message_id);\x0a\x0a--\x20consumer_groups\x20table\x0aCREATE\x20TABLE\x20IF\x20NOT\x20EXISTS\x20consumer_groups\x20(\x0a\x20\x20\x20\x20stream\x20VARCHAR(255)\x20NOT\x20NULL,\x0a\x20\x20\x20\x20group_name\x20VARCHAR(255)\x20NOT\x20NULL,\x0a\x20\x20\x20\x20last_message_id\x20BIGINT\x20DEFAULT\x200,\x0a\x20\x20\x20\x20PRIMARY\x20KEY\x20(stream,\x20group_name)\x0a);\x0a\x0aCREATE\x20INDEX\x20IF\x20NOT\x20EXISTS\x20idx_consumer_groups_stream_group\x20ON\x20consumer_groups\x20(stream,\x20group_name);\x0a\x0a--\x20pending_messages\x20table\x0aCREATE\x20TABLE\x20IF\x20NOT\x20EXISTS\x20pending_messages\x20(\x0a\x20\x20\x20\x20stream\x20VARCHAR(255)\x20NOT\x20NULL,\x0a\x20\x20\x20\x20group_name\x20VARCHAR(255)\x20NOT\x20NULL,\x0a\x20\x20\x20\x20consumer_name\x20VARCHAR(255)\x20NOT\x20NULL,\x0a\x20\x20\x20\x20message_id\x20BIGINT\x20NOT\x20NULL,\x0a\x20\x20\x20\x20delivered_at\x20TIMESTAMPTZ\x20DEFAULT\x20NOW(),\x0a\x20\x20\x20\x20delivery_count\x20INTEGER\x20DEFAULT\x201,\x0a\x20\x20\x20\x20PRIMARY\x20KEY\x20(stream,\x20group_name,\x20message_id)\x0a);\x0a\x0aCREATE\x20INDEX\x20IF\x20NOT\x20EXISTS\x20idx_pending_messages_consumer\x20ON\x20pending_messages\x20(stream,\x20group_name,\x20consumer_name);\x0aCREATE\x20INDEX\x20IF\x20NOT\x20EXISTS\x20idx_pending_messages_message_id\x20ON\x20pending_messages\x20(stream,\x20group_name,\x20message_id);\x0a';}}function _0x3116(_0x13f367,_0x114c61){const _0x3e02cb=_0x3e02();return _0x3116=function(_0x311699,_0x2c2b26){_0x311699=_0x311699-0x1b8;let _0x591dd6=_0x3e02cb[_0x311699];return _0x591dd6;},_0x3116(_0x13f367,_0x114c61);}function _0x3e02(){const _0x14e956=['9BilSbu','5833660mCyXff','1490868nWFIpj','42552wSNLyu','6kjCltx','441236RhAMdP','9ZdfdIU','339704WUTRvb','183302aaATAg','24382150DGVuyX'];_0x3e02=function(){return _0x14e956;};return _0x3e02();}exports['DeployService']=DeployService;
|