@hotmeshio/hotmesh 0.0.1
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/LICENSE +214 -0
- package/README.md +241 -0
- package/build/index.d.ts +4 -0
- package/build/index.js +7 -0
- package/build/modules/errors.d.ts +28 -0
- package/build/modules/errors.js +50 -0
- package/build/modules/key.d.ts +75 -0
- package/build/modules/key.js +116 -0
- package/build/modules/utils.d.ts +34 -0
- package/build/modules/utils.js +173 -0
- package/build/package.json +73 -0
- package/build/services/activities/activity.d.ts +59 -0
- package/build/services/activities/activity.js +396 -0
- package/build/services/activities/await.d.ts +16 -0
- package/build/services/activities/await.js +143 -0
- package/build/services/activities/emit.d.ts +9 -0
- package/build/services/activities/emit.js +13 -0
- package/build/services/activities/index.d.ts +15 -0
- package/build/services/activities/index.js +16 -0
- package/build/services/activities/iterate.d.ts +9 -0
- package/build/services/activities/iterate.js +13 -0
- package/build/services/activities/trigger.d.ts +22 -0
- package/build/services/activities/trigger.js +161 -0
- package/build/services/activities/worker.d.ts +17 -0
- package/build/services/activities/worker.js +164 -0
- package/build/services/collator/index.d.ts +54 -0
- package/build/services/collator/index.js +171 -0
- package/build/services/compiler/deployer.d.ts +35 -0
- package/build/services/compiler/deployer.js +412 -0
- package/build/services/compiler/index.d.ts +30 -0
- package/build/services/compiler/index.js +111 -0
- package/build/services/compiler/validator.d.ts +32 -0
- package/build/services/compiler/validator.js +134 -0
- package/build/services/connector/clients/ioredis.d.ts +13 -0
- package/build/services/connector/clients/ioredis.js +50 -0
- package/build/services/connector/clients/redis.d.ts +13 -0
- package/build/services/connector/clients/redis.js +62 -0
- package/build/services/connector/index.d.ts +5 -0
- package/build/services/connector/index.js +31 -0
- package/build/services/dimension/index.d.ts +29 -0
- package/build/services/dimension/index.js +35 -0
- package/build/services/durable/asyncLocalStorage.d.ts +3 -0
- package/build/services/durable/asyncLocalStorage.js +5 -0
- package/build/services/durable/client.d.ts +15 -0
- package/build/services/durable/client.js +108 -0
- package/build/services/durable/connection.d.ts +4 -0
- package/build/services/durable/connection.js +51 -0
- package/build/services/durable/factory.d.ts +3 -0
- package/build/services/durable/factory.js +123 -0
- package/build/services/durable/handle.d.ts +8 -0
- package/build/services/durable/handle.js +38 -0
- package/build/services/durable/index.d.ts +57 -0
- package/build/services/durable/index.js +58 -0
- package/build/services/durable/native.d.ts +4 -0
- package/build/services/durable/native.js +47 -0
- package/build/services/durable/worker.d.ts +36 -0
- package/build/services/durable/worker.js +266 -0
- package/build/services/durable/workflow.d.ts +6 -0
- package/build/services/durable/workflow.js +135 -0
- package/build/services/engine/index.d.ts +82 -0
- package/build/services/engine/index.js +511 -0
- package/build/services/hotmesh/index.d.ts +45 -0
- package/build/services/hotmesh/index.js +134 -0
- package/build/services/logger/index.d.ts +17 -0
- package/build/services/logger/index.js +73 -0
- package/build/services/mapper/index.d.ts +24 -0
- package/build/services/mapper/index.js +72 -0
- package/build/services/pipe/functions/array.d.ts +24 -0
- package/build/services/pipe/functions/array.js +69 -0
- package/build/services/pipe/functions/bitwise.d.ts +9 -0
- package/build/services/pipe/functions/bitwise.js +24 -0
- package/build/services/pipe/functions/conditional.d.ts +10 -0
- package/build/services/pipe/functions/conditional.js +27 -0
- package/build/services/pipe/functions/date.d.ts +57 -0
- package/build/services/pipe/functions/date.js +167 -0
- package/build/services/pipe/functions/index.d.ts +25 -0
- package/build/services/pipe/functions/index.js +26 -0
- package/build/services/pipe/functions/json.d.ts +5 -0
- package/build/services/pipe/functions/json.js +12 -0
- package/build/services/pipe/functions/math.d.ts +38 -0
- package/build/services/pipe/functions/math.js +111 -0
- package/build/services/pipe/functions/number.d.ts +25 -0
- package/build/services/pipe/functions/number.js +133 -0
- package/build/services/pipe/functions/object.d.ts +22 -0
- package/build/services/pipe/functions/object.js +63 -0
- package/build/services/pipe/functions/string.d.ts +23 -0
- package/build/services/pipe/functions/string.js +69 -0
- package/build/services/pipe/functions/symbol.d.ts +12 -0
- package/build/services/pipe/functions/symbol.js +33 -0
- package/build/services/pipe/functions/unary.d.ts +7 -0
- package/build/services/pipe/functions/unary.js +18 -0
- package/build/services/pipe/index.d.ts +30 -0
- package/build/services/pipe/index.js +128 -0
- package/build/services/quorum/index.d.ts +34 -0
- package/build/services/quorum/index.js +147 -0
- package/build/services/reporter/index.d.ts +47 -0
- package/build/services/reporter/index.js +330 -0
- package/build/services/serializer/index.d.ts +36 -0
- package/build/services/serializer/index.js +222 -0
- package/build/services/signaler/store.d.ts +15 -0
- package/build/services/signaler/store.js +53 -0
- package/build/services/signaler/stream.d.ts +43 -0
- package/build/services/signaler/stream.js +317 -0
- package/build/services/store/cache.d.ts +66 -0
- package/build/services/store/cache.js +127 -0
- package/build/services/store/clients/ioredis.d.ts +27 -0
- package/build/services/store/clients/ioredis.js +96 -0
- package/build/services/store/clients/redis.d.ts +29 -0
- package/build/services/store/clients/redis.js +143 -0
- package/build/services/store/index.d.ts +88 -0
- package/build/services/store/index.js +657 -0
- package/build/services/stream/clients/ioredis.d.ts +23 -0
- package/build/services/stream/clients/ioredis.js +115 -0
- package/build/services/stream/clients/redis.d.ts +23 -0
- package/build/services/stream/clients/redis.js +119 -0
- package/build/services/stream/index.d.ts +21 -0
- package/build/services/stream/index.js +9 -0
- package/build/services/sub/clients/ioredis.d.ts +20 -0
- package/build/services/sub/clients/ioredis.js +72 -0
- package/build/services/sub/clients/redis.d.ts +20 -0
- package/build/services/sub/clients/redis.js +63 -0
- package/build/services/sub/index.d.ts +18 -0
- package/build/services/sub/index.js +9 -0
- package/build/services/task/index.d.ts +18 -0
- package/build/services/task/index.js +73 -0
- package/build/services/telemetry/index.d.ts +49 -0
- package/build/services/telemetry/index.js +223 -0
- package/build/services/worker/index.d.ts +30 -0
- package/build/services/worker/index.js +105 -0
- package/build/types/activity.d.ts +86 -0
- package/build/types/activity.js +2 -0
- package/build/types/app.d.ts +16 -0
- package/build/types/app.js +2 -0
- package/build/types/async.d.ts +5 -0
- package/build/types/async.js +2 -0
- package/build/types/cache.d.ts +1 -0
- package/build/types/cache.js +2 -0
- package/build/types/collator.d.ts +8 -0
- package/build/types/collator.js +11 -0
- package/build/types/durable.d.ts +59 -0
- package/build/types/durable.js +2 -0
- package/build/types/hook.d.ts +31 -0
- package/build/types/hook.js +9 -0
- package/build/types/hotmesh.d.ts +82 -0
- package/build/types/hotmesh.js +2 -0
- package/build/types/index.d.ts +20 -0
- package/build/types/index.js +21 -0
- package/build/types/ioredisclient.d.ts +5 -0
- package/build/types/ioredisclient.js +5 -0
- package/build/types/job.d.ts +50 -0
- package/build/types/job.js +2 -0
- package/build/types/logger.d.ts +6 -0
- package/build/types/logger.js +2 -0
- package/build/types/map.d.ts +4 -0
- package/build/types/map.js +2 -0
- package/build/types/pipe.d.ts +4 -0
- package/build/types/pipe.js +2 -0
- package/build/types/quorum.d.ts +46 -0
- package/build/types/quorum.js +2 -0
- package/build/types/redis.d.ts +8 -0
- package/build/types/redis.js +2 -0
- package/build/types/redisclient.d.ts +25 -0
- package/build/types/redisclient.js +2 -0
- package/build/types/serializer.d.ts +33 -0
- package/build/types/serializer.js +2 -0
- package/build/types/stats.d.ts +83 -0
- package/build/types/stats.js +2 -0
- package/build/types/stream.d.ts +67 -0
- package/build/types/stream.js +25 -0
- package/build/types/telemetry.d.ts +1 -0
- package/build/types/telemetry.js +11 -0
- package/build/types/transition.d.ts +17 -0
- package/build/types/transition.js +2 -0
- package/index.ts +5 -0
- package/modules/errors.ts +55 -0
- package/modules/key.ts +129 -0
- package/modules/utils.ts +170 -0
- package/package.json +73 -0
- package/services/activities/activity.ts +473 -0
- package/services/activities/await.ts +172 -0
- package/services/activities/emit.ts +25 -0
- package/services/activities/index.ts +15 -0
- package/services/activities/iterate.ts +26 -0
- package/services/activities/trigger.ts +196 -0
- package/services/activities/worker.ts +190 -0
- package/services/collator/README.md +102 -0
- package/services/collator/index.ts +182 -0
- package/services/compiler/deployer.ts +432 -0
- package/services/compiler/index.ts +98 -0
- package/services/compiler/validator.ts +154 -0
- package/services/connector/clients/ioredis.ts +57 -0
- package/services/connector/clients/redis.ts +72 -0
- package/services/connector/index.ts +44 -0
- package/services/dimension/README.md +73 -0
- package/services/dimension/index.ts +39 -0
- package/services/durable/asyncLocalStorage.ts +3 -0
- package/services/durable/client.ts +116 -0
- package/services/durable/connection.ts +50 -0
- package/services/durable/factory.ts +124 -0
- package/services/durable/handle.ts +43 -0
- package/services/durable/index.ts +60 -0
- package/services/durable/native.ts +46 -0
- package/services/durable/worker.ts +254 -0
- package/services/durable/workflow.ts +136 -0
- package/services/engine/index.ts +615 -0
- package/services/hotmesh/index.ts +182 -0
- package/services/logger/index.ts +79 -0
- package/services/mapper/index.ts +84 -0
- package/services/pipe/functions/array.ts +87 -0
- package/services/pipe/functions/bitwise.ts +27 -0
- package/services/pipe/functions/conditional.ts +31 -0
- package/services/pipe/functions/date.ts +214 -0
- package/services/pipe/functions/index.ts +25 -0
- package/services/pipe/functions/json.ts +11 -0
- package/services/pipe/functions/math.ts +143 -0
- package/services/pipe/functions/number.ts +150 -0
- package/services/pipe/functions/object.ts +79 -0
- package/services/pipe/functions/string.ts +86 -0
- package/services/pipe/functions/symbol.ts +39 -0
- package/services/pipe/functions/unary.ts +19 -0
- package/services/pipe/index.ts +138 -0
- package/services/quorum/index.ts +200 -0
- package/services/reporter/index.ts +379 -0
- package/services/serializer/README.md +10 -0
- package/services/serializer/index.ts +243 -0
- package/services/signaler/store.ts +61 -0
- package/services/signaler/stream.ts +354 -0
- package/services/store/cache.ts +172 -0
- package/services/store/clients/ioredis.ts +123 -0
- package/services/store/clients/redis.ts +169 -0
- package/services/store/index.ts +757 -0
- package/services/stream/clients/ioredis.ts +148 -0
- package/services/stream/clients/redis.ts +144 -0
- package/services/stream/index.ts +57 -0
- package/services/sub/clients/ioredis.ts +83 -0
- package/services/sub/clients/redis.ts +74 -0
- package/services/sub/index.ts +25 -0
- package/services/task/index.ts +86 -0
- package/services/telemetry/index.ts +267 -0
- package/services/worker/index.ts +165 -0
- package/types/activity.ts +115 -0
- package/types/app.ts +20 -0
- package/types/async.ts +7 -0
- package/types/cache.ts +1 -0
- package/types/collator.ts +9 -0
- package/types/durable.ts +81 -0
- package/types/hook.ts +32 -0
- package/types/hotmesh.ts +102 -0
- package/types/index.ts +138 -0
- package/types/ioredisclient.ts +10 -0
- package/types/job.ts +59 -0
- package/types/logger.ts +6 -0
- package/types/map.ts +5 -0
- package/types/ms.d.ts +7 -0
- package/types/pipe.ts +7 -0
- package/types/quorum.ts +59 -0
- package/types/redis.ts +27 -0
- package/types/redisclient.ts +29 -0
- package/types/serializer.ts +38 -0
- package/types/stats.ts +100 -0
- package/types/stream.ts +75 -0
- package/types/telemetry.ts +15 -0
- package/types/transition.ts +20 -0
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.IORedisStreamService = void 0;
|
|
4
|
+
const key_1 = require("../../../modules/key");
|
|
5
|
+
const index_1 = require("../index");
|
|
6
|
+
class IORedisStreamService extends index_1.StreamService {
|
|
7
|
+
constructor(redisClient) {
|
|
8
|
+
super(redisClient);
|
|
9
|
+
}
|
|
10
|
+
async init(namespace = key_1.PSNS, appId, logger) {
|
|
11
|
+
this.namespace = namespace;
|
|
12
|
+
this.logger = logger;
|
|
13
|
+
this.appId = appId;
|
|
14
|
+
}
|
|
15
|
+
getMulti() {
|
|
16
|
+
return this.redisClient.multi();
|
|
17
|
+
}
|
|
18
|
+
mintKey(type, params) {
|
|
19
|
+
if (!this.namespace)
|
|
20
|
+
throw new Error('namespace not set');
|
|
21
|
+
return key_1.KeyService.mintKey(this.namespace, type, params);
|
|
22
|
+
}
|
|
23
|
+
async xgroup(command, key, groupName, id, mkStream) {
|
|
24
|
+
if (mkStream === 'MKSTREAM') {
|
|
25
|
+
try {
|
|
26
|
+
return (await this.redisClient.xgroup(command, key, groupName, id, mkStream)) === 'OK';
|
|
27
|
+
}
|
|
28
|
+
catch (err) {
|
|
29
|
+
this.logger.info(`Consumer group not created with MKSTREAM for key: ${key} and group: ${groupName}`);
|
|
30
|
+
throw err;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
try {
|
|
35
|
+
return (await this.redisClient.xgroup(command, key, groupName, id)) === 'OK';
|
|
36
|
+
}
|
|
37
|
+
catch (err) {
|
|
38
|
+
this.logger.info(`Consumer group not created for key: ${key} and group: ${groupName}`);
|
|
39
|
+
throw err;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
async xadd(key, id, messageId, messageValue, multi) {
|
|
44
|
+
try {
|
|
45
|
+
return await (multi || this.redisClient).xadd(key, id, messageId, messageValue);
|
|
46
|
+
}
|
|
47
|
+
catch (err) {
|
|
48
|
+
this.logger.error(`Error publishing 'xadd'; key: ${key}`, err);
|
|
49
|
+
throw err;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
async xreadgroup(command, groupName, consumerName, blockOption, blockTime, streamsOption, streamName, id) {
|
|
53
|
+
try {
|
|
54
|
+
//@ts-ignore
|
|
55
|
+
return await this.redisClient.xreadgroup(command, groupName, consumerName,
|
|
56
|
+
// @ts-ignore
|
|
57
|
+
blockOption, blockTime, streamsOption, streamName, id);
|
|
58
|
+
}
|
|
59
|
+
catch (err) {
|
|
60
|
+
this.logger.error(`Error reading stream data [Stream ${streamName}] [Group ${groupName}]`, err);
|
|
61
|
+
throw err;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
async xpending(key, group, start, end, count, consumer) {
|
|
65
|
+
try {
|
|
66
|
+
const args = [key, group];
|
|
67
|
+
if (start)
|
|
68
|
+
args.push(start);
|
|
69
|
+
if (end)
|
|
70
|
+
args.push(end);
|
|
71
|
+
if (count !== undefined)
|
|
72
|
+
args.push(count.toString());
|
|
73
|
+
if (consumer)
|
|
74
|
+
args.push(consumer);
|
|
75
|
+
try {
|
|
76
|
+
return await this.redisClient.call('XPENDING', ...args);
|
|
77
|
+
}
|
|
78
|
+
catch (err) {
|
|
79
|
+
this.logger.error('err, args', err, args);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
catch (err) {
|
|
83
|
+
this.logger.error(`Error in retrieving pending messages for [stream ${key}], [group ${group}]`, err);
|
|
84
|
+
throw err;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
async xclaim(key, group, consumer, minIdleTime, id, ...args) {
|
|
88
|
+
try {
|
|
89
|
+
return await this.redisClient.xclaim(key, group, consumer, minIdleTime, id, ...args);
|
|
90
|
+
}
|
|
91
|
+
catch (err) {
|
|
92
|
+
this.logger.error(`Error in claiming message with id: ${id} in group: ${group} for key: ${key}`, err);
|
|
93
|
+
throw err;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
async xack(key, group, id, multi) {
|
|
97
|
+
try {
|
|
98
|
+
return await (multi || this.redisClient).xack(key, group, id);
|
|
99
|
+
}
|
|
100
|
+
catch (err) {
|
|
101
|
+
this.logger.error(`Error in acknowledging messages in group: ${group} for key: ${key}`, err);
|
|
102
|
+
throw err;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
async xdel(key, id, multi) {
|
|
106
|
+
try {
|
|
107
|
+
return await (multi || this.redisClient).xdel(key, id);
|
|
108
|
+
}
|
|
109
|
+
catch (err) {
|
|
110
|
+
this.logger.error(`Error in deleting messages with id: ${id} for key: ${key}`, err);
|
|
111
|
+
throw err;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
exports.IORedisStreamService = IORedisStreamService;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { KeyStoreParams, KeyType } from '../../../modules/key';
|
|
2
|
+
import { ILogger } from '../../logger';
|
|
3
|
+
import { StreamService } from '../index';
|
|
4
|
+
import { RedisClientType, RedisMultiType } from '../../../types/redisclient';
|
|
5
|
+
import { ReclaimedMessageType } from '../../../types/stream';
|
|
6
|
+
declare class RedisStreamService extends StreamService<RedisClientType, RedisMultiType> {
|
|
7
|
+
redisClient: RedisClientType;
|
|
8
|
+
namespace: string;
|
|
9
|
+
logger: ILogger;
|
|
10
|
+
appId: string;
|
|
11
|
+
constructor(redisClient: RedisClientType);
|
|
12
|
+
init(namespace: string, appId: string, logger: ILogger): Promise<void>;
|
|
13
|
+
getMulti(): RedisMultiType;
|
|
14
|
+
mintKey(type: KeyType, params: KeyStoreParams): string;
|
|
15
|
+
xgroup(command: 'CREATE', key: string, groupName: string, id: string, mkStream?: 'MKSTREAM'): Promise<boolean>;
|
|
16
|
+
xadd(key: string, id: string, ...args: any[]): Promise<string | RedisMultiType>;
|
|
17
|
+
xreadgroup(command: 'GROUP', groupName: string, consumerName: string, blockOption: 'BLOCK' | 'COUNT', blockTime: number | string, streamsOption: 'STREAMS', streamName: string, id: string): Promise<string[][][] | null>;
|
|
18
|
+
xpending(key: string, group: string, start?: string, end?: string, count?: number, consumer?: string): Promise<[string, string, number, [string, number][]][] | [string, string, number, number]>;
|
|
19
|
+
xclaim(key: string, group: string, consumer: string, minIdleTime: number, id: string, ...args: string[]): Promise<ReclaimedMessageType>;
|
|
20
|
+
xack(key: string, group: string, id: string, multi?: RedisMultiType): Promise<number | RedisMultiType>;
|
|
21
|
+
xdel(key: string, id: string, multi?: RedisMultiType): Promise<number | RedisMultiType>;
|
|
22
|
+
}
|
|
23
|
+
export { RedisStreamService };
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RedisStreamService = void 0;
|
|
4
|
+
const key_1 = require("../../../modules/key");
|
|
5
|
+
const index_1 = require("../index");
|
|
6
|
+
class RedisStreamService extends index_1.StreamService {
|
|
7
|
+
constructor(redisClient) {
|
|
8
|
+
super(redisClient);
|
|
9
|
+
}
|
|
10
|
+
async init(namespace = key_1.PSNS, appId, logger) {
|
|
11
|
+
this.namespace = namespace;
|
|
12
|
+
this.logger = logger;
|
|
13
|
+
this.appId = appId;
|
|
14
|
+
}
|
|
15
|
+
getMulti() {
|
|
16
|
+
return this.redisClient.MULTI();
|
|
17
|
+
}
|
|
18
|
+
mintKey(type, params) {
|
|
19
|
+
if (!this.namespace)
|
|
20
|
+
throw new Error('namespace not set');
|
|
21
|
+
return key_1.KeyService.mintKey(this.namespace, type, params);
|
|
22
|
+
}
|
|
23
|
+
async xgroup(command, key, groupName, id, mkStream) {
|
|
24
|
+
const args = mkStream === 'MKSTREAM' ? ['MKSTREAM'] : [];
|
|
25
|
+
try {
|
|
26
|
+
return (await this.redisClient.sendCommand(['XGROUP', 'CREATE', key, groupName, id, ...args])) === 1;
|
|
27
|
+
}
|
|
28
|
+
catch (err) {
|
|
29
|
+
const streamType = mkStream === 'MKSTREAM' ? 'with MKSTREAM' : 'without MKSTREAM';
|
|
30
|
+
this.logger.error(`x-group-error ${streamType} for key: ${key} and group: ${groupName}`, err);
|
|
31
|
+
throw err;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
async xadd(key, id, ...args) {
|
|
35
|
+
let multi;
|
|
36
|
+
if (typeof args[args.length - 1] !== 'string') {
|
|
37
|
+
multi = args.pop();
|
|
38
|
+
}
|
|
39
|
+
try {
|
|
40
|
+
return await (multi || this.redisClient).XADD(key, id, { [args[0]]: args[1] });
|
|
41
|
+
}
|
|
42
|
+
catch (err) {
|
|
43
|
+
this.logger.error(`Error publishing 'xadd'; key: ${key}`, err);
|
|
44
|
+
throw err;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
async xreadgroup(command, groupName, consumerName, blockOption, blockTime, streamsOption, streamName, id) {
|
|
48
|
+
try {
|
|
49
|
+
return await this.redisClient.sendCommand(['XREADGROUP', command, groupName, consumerName, blockOption, blockTime.toString(), streamsOption, streamName, id]);
|
|
50
|
+
}
|
|
51
|
+
catch (err) {
|
|
52
|
+
this.logger.error(`Error in reading data from group: ${groupName} in stream: ${streamName}`, err);
|
|
53
|
+
throw err;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
async xpending(key, group, start, end, count, consumer) {
|
|
57
|
+
try {
|
|
58
|
+
const args = [key, group];
|
|
59
|
+
if (start)
|
|
60
|
+
args.push(start);
|
|
61
|
+
if (end)
|
|
62
|
+
args.push(end);
|
|
63
|
+
if (count !== undefined)
|
|
64
|
+
args.push(count.toString());
|
|
65
|
+
if (consumer)
|
|
66
|
+
args.push(consumer);
|
|
67
|
+
try {
|
|
68
|
+
return await this.redisClient.sendCommand(['XPENDING', ...args]);
|
|
69
|
+
}
|
|
70
|
+
catch (err) {
|
|
71
|
+
this.logger.error('err, args', err, args);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
catch (err) {
|
|
75
|
+
this.logger.error(`Error in retrieving pending messages for group: ${group} in key: ${key}`, err);
|
|
76
|
+
throw err;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
async xclaim(key, group, consumer, minIdleTime, id, ...args) {
|
|
80
|
+
try {
|
|
81
|
+
return await this.redisClient.sendCommand(['XCLAIM', key, group, consumer, minIdleTime.toString(), id, ...args]);
|
|
82
|
+
}
|
|
83
|
+
catch (err) {
|
|
84
|
+
this.logger.error(`Error in claiming message with id: ${id} in group: ${group} for key: ${key}`, err);
|
|
85
|
+
throw err;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
async xack(key, group, id, multi) {
|
|
89
|
+
try {
|
|
90
|
+
if (multi) {
|
|
91
|
+
multi.XACK(key, group, id);
|
|
92
|
+
return multi;
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
return await this.redisClient.XACK(key, group, id);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
catch (err) {
|
|
99
|
+
this.logger.error(`Error in acknowledging messages in group: ${group} for key: ${key}`, err);
|
|
100
|
+
throw err;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
async xdel(key, id, multi) {
|
|
104
|
+
try {
|
|
105
|
+
if (multi) {
|
|
106
|
+
multi.XDEL(key, id);
|
|
107
|
+
return multi;
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
return await this.redisClient.XDEL(key, id);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
catch (err) {
|
|
114
|
+
this.logger.error(`Error in deleting messages with ids: ${id} for key: ${key}`, err);
|
|
115
|
+
throw err;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
exports.RedisStreamService = RedisStreamService;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { KeyStoreParams, KeyType } from '../../modules/key';
|
|
2
|
+
import { ReclaimedMessageType } from '../../types/stream';
|
|
3
|
+
import { ILogger } from '../logger';
|
|
4
|
+
declare abstract class StreamService<T, U> {
|
|
5
|
+
redisClient: T;
|
|
6
|
+
namespace: string;
|
|
7
|
+
logger: ILogger;
|
|
8
|
+
appId: string;
|
|
9
|
+
constructor(redisClient: T);
|
|
10
|
+
abstract init(namespace: string, appId: string, logger: ILogger): Promise<void>;
|
|
11
|
+
abstract getMulti(): U;
|
|
12
|
+
abstract mintKey(type: KeyType, params: KeyStoreParams): string;
|
|
13
|
+
abstract xgroup(command: 'CREATE', key: string, groupName: string, id: string, mkStream?: 'MKSTREAM'): Promise<boolean>;
|
|
14
|
+
abstract xadd(key: string, id: string, messageId: string, messageValue: string, multi?: U): Promise<string | U>;
|
|
15
|
+
abstract xreadgroup(command: 'GROUP', groupName: string, consumerName: string, blockOption: 'BLOCK' | 'COUNT', blockTime: number | string, streamsOption: 'STREAMS', streamName: string, id: string): Promise<string[][][] | null | unknown[]>;
|
|
16
|
+
abstract xpending(key: string, group: string, start?: string, end?: string, count?: number, consumer?: string): Promise<[string, string, number, [string, number][]][] | [string, string, number, number] | unknown[]>;
|
|
17
|
+
abstract xclaim(key: string, group: string, consumer: string, minIdleTime: number, id: string, ...args: string[]): Promise<ReclaimedMessageType>;
|
|
18
|
+
abstract xack(key: string, group: string, id: string, multi?: U): Promise<number | U>;
|
|
19
|
+
abstract xdel(key: string, id: string, multi?: U): Promise<number | U>;
|
|
20
|
+
}
|
|
21
|
+
export { StreamService };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { KeyStoreParams, KeyType } from '../../../modules/key';
|
|
2
|
+
import { ILogger } from '../../logger';
|
|
3
|
+
import { SubService } from '../index';
|
|
4
|
+
import { RedisClientType, RedisMultiType } from '../../../types/ioredisclient';
|
|
5
|
+
import { SubscriptionCallback } from '../../../types/quorum';
|
|
6
|
+
declare class IORedisSubService extends SubService<RedisClientType, RedisMultiType> {
|
|
7
|
+
redisClient: RedisClientType;
|
|
8
|
+
namespace: string;
|
|
9
|
+
logger: ILogger;
|
|
10
|
+
appId: string;
|
|
11
|
+
constructor(redisClient: RedisClientType);
|
|
12
|
+
init(namespace: string, appId: string, engineId: string, logger: ILogger): Promise<void>;
|
|
13
|
+
getMulti(): RedisMultiType;
|
|
14
|
+
mintKey(type: KeyType, params: KeyStoreParams): string;
|
|
15
|
+
subscribe(keyType: KeyType.QUORUM, callback: SubscriptionCallback, appId: string, engineId?: string): Promise<void>;
|
|
16
|
+
unsubscribe(keyType: KeyType.QUORUM, appId: string, engineId?: string): Promise<void>;
|
|
17
|
+
psubscribe(keyType: KeyType.QUORUM, callback: SubscriptionCallback, appId: string, engineId?: string): Promise<void>;
|
|
18
|
+
punsubscribe(keyType: KeyType.QUORUM, appId: string, engineId?: string): Promise<void>;
|
|
19
|
+
}
|
|
20
|
+
export { IORedisSubService };
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.IORedisSubService = void 0;
|
|
4
|
+
const key_1 = require("../../../modules/key");
|
|
5
|
+
const index_1 = require("../index");
|
|
6
|
+
class IORedisSubService extends index_1.SubService {
|
|
7
|
+
constructor(redisClient) {
|
|
8
|
+
super(redisClient);
|
|
9
|
+
}
|
|
10
|
+
async init(namespace = key_1.PSNS, appId, engineId, logger) {
|
|
11
|
+
this.namespace = namespace;
|
|
12
|
+
this.logger = logger;
|
|
13
|
+
this.appId = appId;
|
|
14
|
+
}
|
|
15
|
+
getMulti() {
|
|
16
|
+
return this.redisClient.multi();
|
|
17
|
+
}
|
|
18
|
+
mintKey(type, params) {
|
|
19
|
+
if (!this.namespace)
|
|
20
|
+
throw new Error('namespace not set');
|
|
21
|
+
return key_1.KeyService.mintKey(this.namespace, type, params);
|
|
22
|
+
}
|
|
23
|
+
async subscribe(keyType, callback, appId, engineId) {
|
|
24
|
+
const self = this;
|
|
25
|
+
const topic = this.mintKey(keyType, { appId, engineId });
|
|
26
|
+
await this.redisClient.subscribe(topic, (err) => {
|
|
27
|
+
if (err) {
|
|
28
|
+
self.logger.error(`Error subscribing to: ${topic}`, err);
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
this.redisClient.on('message', (channel, message) => {
|
|
32
|
+
if (channel === topic) {
|
|
33
|
+
try {
|
|
34
|
+
const payload = JSON.parse(message);
|
|
35
|
+
callback(topic, payload);
|
|
36
|
+
}
|
|
37
|
+
catch (e) {
|
|
38
|
+
self.logger.error(`Error parsing message: ${message}`, e);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
async unsubscribe(keyType, appId, engineId) {
|
|
44
|
+
const topic = this.mintKey(keyType, { appId, engineId });
|
|
45
|
+
await this.redisClient.unsubscribe(topic);
|
|
46
|
+
}
|
|
47
|
+
async psubscribe(keyType, callback, appId, engineId) {
|
|
48
|
+
const self = this;
|
|
49
|
+
const topic = this.mintKey(keyType, { appId, engineId });
|
|
50
|
+
await this.redisClient.psubscribe(topic, (err) => {
|
|
51
|
+
if (err) {
|
|
52
|
+
self.logger.error(`Error subscribing to: ${topic}`, err);
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
this.redisClient.on('pmessage', (pattern, channel, message) => {
|
|
56
|
+
if (pattern === topic) {
|
|
57
|
+
try {
|
|
58
|
+
const payload = JSON.parse(message);
|
|
59
|
+
callback(channel, payload);
|
|
60
|
+
}
|
|
61
|
+
catch (e) {
|
|
62
|
+
self.logger.error(`Error parsing message: ${message}`, e);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
async punsubscribe(keyType, appId, engineId) {
|
|
68
|
+
const topic = this.mintKey(keyType, { appId, engineId });
|
|
69
|
+
await this.redisClient.punsubscribe(topic);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
exports.IORedisSubService = IORedisSubService;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { KeyStoreParams, KeyType } from '../../../modules/key';
|
|
2
|
+
import { ILogger } from '../../logger';
|
|
3
|
+
import { SubService } from '../index';
|
|
4
|
+
import { RedisClientType, RedisMultiType } from '../../../types/redisclient';
|
|
5
|
+
import { SubscriptionCallback } from '../../../types/quorum';
|
|
6
|
+
declare class RedisSubService extends SubService<RedisClientType, RedisMultiType> {
|
|
7
|
+
redisClient: RedisClientType;
|
|
8
|
+
namespace: string;
|
|
9
|
+
logger: ILogger;
|
|
10
|
+
appId: string;
|
|
11
|
+
constructor(redisClient: RedisClientType);
|
|
12
|
+
init(namespace: string, appId: string, engineId: string, logger: ILogger): Promise<void>;
|
|
13
|
+
getMulti(): RedisMultiType;
|
|
14
|
+
mintKey(type: KeyType, params: KeyStoreParams): string;
|
|
15
|
+
subscribe(keyType: KeyType.QUORUM, callback: SubscriptionCallback, appId: string, engineId?: string): Promise<void>;
|
|
16
|
+
unsubscribe(keyType: KeyType.QUORUM, appId: string, engineId?: string): Promise<void>;
|
|
17
|
+
psubscribe(keyType: KeyType.QUORUM, callback: SubscriptionCallback, appId: string, engineId?: string): Promise<void>;
|
|
18
|
+
punsubscribe(keyType: KeyType.QUORUM, appId: string, engineId?: string): Promise<void>;
|
|
19
|
+
}
|
|
20
|
+
export { RedisSubService };
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RedisSubService = void 0;
|
|
4
|
+
const key_1 = require("../../../modules/key");
|
|
5
|
+
const index_1 = require("../index");
|
|
6
|
+
class RedisSubService extends index_1.SubService {
|
|
7
|
+
constructor(redisClient) {
|
|
8
|
+
super(redisClient);
|
|
9
|
+
}
|
|
10
|
+
async init(namespace = key_1.PSNS, appId, engineId, logger) {
|
|
11
|
+
this.namespace = namespace;
|
|
12
|
+
this.logger = logger;
|
|
13
|
+
this.appId = appId;
|
|
14
|
+
}
|
|
15
|
+
getMulti() {
|
|
16
|
+
const multi = this.redisClient.MULTI();
|
|
17
|
+
return multi;
|
|
18
|
+
}
|
|
19
|
+
mintKey(type, params) {
|
|
20
|
+
if (!this.namespace)
|
|
21
|
+
throw new Error('namespace not set');
|
|
22
|
+
return key_1.KeyService.mintKey(this.namespace, type, params);
|
|
23
|
+
}
|
|
24
|
+
async subscribe(keyType, callback, appId, engineId) {
|
|
25
|
+
if (this.redisClient) {
|
|
26
|
+
const self = this;
|
|
27
|
+
const topic = this.mintKey(keyType, { appId, engineId });
|
|
28
|
+
await this.redisClient.subscribe(topic, (message) => {
|
|
29
|
+
try {
|
|
30
|
+
const payload = JSON.parse(message);
|
|
31
|
+
callback(topic, payload);
|
|
32
|
+
}
|
|
33
|
+
catch (e) {
|
|
34
|
+
self.logger.error(`Error parsing message: ${message}`, e);
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
async unsubscribe(keyType, appId, engineId) {
|
|
40
|
+
const topic = this.mintKey(keyType, { appId, engineId });
|
|
41
|
+
await this.redisClient.unsubscribe(topic);
|
|
42
|
+
}
|
|
43
|
+
async psubscribe(keyType, callback, appId, engineId) {
|
|
44
|
+
if (this.redisClient) {
|
|
45
|
+
const self = this;
|
|
46
|
+
const topic = this.mintKey(keyType, { appId, engineId });
|
|
47
|
+
await this.redisClient.pSubscribe(topic, (message, channel) => {
|
|
48
|
+
try {
|
|
49
|
+
const payload = JSON.parse(message);
|
|
50
|
+
callback(channel, payload);
|
|
51
|
+
}
|
|
52
|
+
catch (e) {
|
|
53
|
+
self.logger.error(`Error parsing message: ${message}`, e);
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
async punsubscribe(keyType, appId, engineId) {
|
|
59
|
+
const topic = this.mintKey(keyType, { appId, engineId });
|
|
60
|
+
await this.redisClient.pUnsubscribe(topic);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
exports.RedisSubService = RedisSubService;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { KeyStoreParams, KeyType } from '../../modules/key';
|
|
2
|
+
import { ILogger } from '../logger';
|
|
3
|
+
import { SubscriptionCallback } from '../../types/quorum';
|
|
4
|
+
declare abstract class SubService<T, U> {
|
|
5
|
+
redisClient: T;
|
|
6
|
+
namespace: string;
|
|
7
|
+
logger: ILogger;
|
|
8
|
+
appId: string;
|
|
9
|
+
constructor(redisClient: T);
|
|
10
|
+
abstract init(namespace: string, appId: string, engineId: string, logger: ILogger): Promise<void>;
|
|
11
|
+
abstract getMulti(): U;
|
|
12
|
+
abstract mintKey(type: KeyType, params: KeyStoreParams): string;
|
|
13
|
+
abstract subscribe(keyType: KeyType.QUORUM, callback: SubscriptionCallback, appId: string, engineId?: string): Promise<void>;
|
|
14
|
+
abstract unsubscribe(keyType: KeyType.QUORUM, appId: string, engineId?: string): Promise<void>;
|
|
15
|
+
abstract psubscribe(keyType: KeyType.QUORUM, callback: SubscriptionCallback, appId: string, engineId?: string): Promise<void>;
|
|
16
|
+
abstract punsubscribe(keyType: KeyType.QUORUM, appId: string, engineId?: string): Promise<void>;
|
|
17
|
+
}
|
|
18
|
+
export { SubService };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { ILogger } from '../logger';
|
|
3
|
+
import { StoreService } from '../store';
|
|
4
|
+
import { RedisClient, RedisMulti } from '../../types/redis';
|
|
5
|
+
import { HookInterface } from '../../types/hook';
|
|
6
|
+
declare class TaskService {
|
|
7
|
+
store: StoreService<RedisClient, RedisMulti>;
|
|
8
|
+
logger: ILogger;
|
|
9
|
+
cleanupTimeout: NodeJS.Timeout | null;
|
|
10
|
+
constructor(store: StoreService<RedisClient, RedisMulti>, logger: ILogger);
|
|
11
|
+
processWebHooks(hookEventCallback: HookInterface): Promise<void>;
|
|
12
|
+
enqueueWorkItems(keys: string[]): Promise<void>;
|
|
13
|
+
registerJobForCleanup(jobId: string, inSeconds?: number): Promise<void>;
|
|
14
|
+
registerTimeHook(jobId: string, activityId: string, type: 'sleep' | 'expire' | 'cron', inSeconds?: number, multi?: RedisMulti): Promise<void>;
|
|
15
|
+
processTimeHooks(timeEventCallback: (jobId: string, activityId: string) => Promise<void>, listKey?: string): Promise<void>;
|
|
16
|
+
cancelCleanup(): void;
|
|
17
|
+
}
|
|
18
|
+
export { TaskService };
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TaskService = void 0;
|
|
4
|
+
const utils_1 = require("../../modules/utils");
|
|
5
|
+
//system timer granularity limit (task queues organize)
|
|
6
|
+
const FIDELITY_SECONDS = 15; //note: this can be reduced using 'watch' or scout role
|
|
7
|
+
//default resolution/fidelity when expiring
|
|
8
|
+
const EXPIRATION_FIDELITY_SECONDS = 60;
|
|
9
|
+
class TaskService {
|
|
10
|
+
constructor(store, logger) {
|
|
11
|
+
this.cleanupTimeout = null;
|
|
12
|
+
this.logger = logger;
|
|
13
|
+
this.store = store;
|
|
14
|
+
}
|
|
15
|
+
async processWebHooks(hookEventCallback) {
|
|
16
|
+
const workItemKey = await this.store.getActiveTaskQueue();
|
|
17
|
+
if (workItemKey) {
|
|
18
|
+
const [topic, sourceKey, ...sdata] = workItemKey.split('::');
|
|
19
|
+
const data = JSON.parse(sdata.join('::'));
|
|
20
|
+
const destinationKey = `${sourceKey}:processed`;
|
|
21
|
+
const jobId = await this.store.processTaskQueue(sourceKey, destinationKey);
|
|
22
|
+
if (jobId) {
|
|
23
|
+
await hookEventCallback(topic, { ...data, id: jobId });
|
|
24
|
+
//todo: do final checksum count (values are tracked in the stats hash)
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
await this.store.deleteProcessedTaskQueue(workItemKey, sourceKey, destinationKey);
|
|
28
|
+
}
|
|
29
|
+
setImmediate(() => this.processWebHooks(hookEventCallback));
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
async enqueueWorkItems(keys) {
|
|
33
|
+
await this.store.addTaskQueues(keys);
|
|
34
|
+
}
|
|
35
|
+
async registerJobForCleanup(jobId, inSeconds = EXPIRATION_FIDELITY_SECONDS) {
|
|
36
|
+
if (inSeconds > -1) {
|
|
37
|
+
await this.store.expireJob(jobId, inSeconds);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
async registerTimeHook(jobId, activityId, type, inSeconds = FIDELITY_SECONDS, multi) {
|
|
41
|
+
const awakenTimeSlot = Math.floor((Date.now() + inSeconds * 1000) / (FIDELITY_SECONDS * 1000)) * (FIDELITY_SECONDS * 1000); //n second awaken groups
|
|
42
|
+
await this.store.registerTimeHook(jobId, activityId, type, awakenTimeSlot, multi);
|
|
43
|
+
}
|
|
44
|
+
//todo: need 'scout' role in quorum to check for this and then alert the quorum to get to work
|
|
45
|
+
async processTimeHooks(timeEventCallback, listKey) {
|
|
46
|
+
try {
|
|
47
|
+
const job = await this.store.getNextTimeJob(listKey);
|
|
48
|
+
if (job) {
|
|
49
|
+
const [listKey, jobId, activityId] = job;
|
|
50
|
+
await timeEventCallback(jobId, activityId);
|
|
51
|
+
await (0, utils_1.sleepFor)(0);
|
|
52
|
+
this.processTimeHooks(timeEventCallback, listKey);
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
let sleep = (0, utils_1.XSleepFor)(FIDELITY_SECONDS * 1000);
|
|
56
|
+
this.cleanupTimeout = sleep.timerId;
|
|
57
|
+
await sleep.promise;
|
|
58
|
+
this.processTimeHooks(timeEventCallback);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
catch (err) {
|
|
62
|
+
//todo: retry connect to redis
|
|
63
|
+
this.logger.error('task-process-timehooks-error', err);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
cancelCleanup() {
|
|
67
|
+
if (this.cleanupTimeout !== undefined) {
|
|
68
|
+
clearTimeout(this.cleanupTimeout);
|
|
69
|
+
this.cleanupTimeout = undefined;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
exports.TaskService = TaskService;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { ActivityMetadata, ActivityType, Consumes } from '../../types/activity';
|
|
2
|
+
import { JobState } from '../../types/job';
|
|
3
|
+
import { StringAnyType, StringScalarType, StringStringType } from '../../types/serializer';
|
|
4
|
+
import { StreamData, StreamRole } from '../../types/stream';
|
|
5
|
+
import { Span, Context } from '../../types/telemetry';
|
|
6
|
+
declare class TelemetryService {
|
|
7
|
+
span: Span;
|
|
8
|
+
jobSpan: Span;
|
|
9
|
+
config: ActivityType;
|
|
10
|
+
traceId: string | null;
|
|
11
|
+
spanId: string | null;
|
|
12
|
+
appId: string;
|
|
13
|
+
metadata: ActivityMetadata;
|
|
14
|
+
context: JobState;
|
|
15
|
+
leg: number;
|
|
16
|
+
constructor(appId: string, config?: ActivityType, metadata?: ActivityMetadata, context?: JobState);
|
|
17
|
+
getJobParentSpanId(): string | undefined;
|
|
18
|
+
getActivityParentSpanId(leg: number): string | undefined;
|
|
19
|
+
getTraceId(): string | undefined;
|
|
20
|
+
startJobSpan(): TelemetryService;
|
|
21
|
+
startActivitySpan(leg?: number): TelemetryService;
|
|
22
|
+
startStreamSpan(data: StreamData, role: StreamRole): TelemetryService;
|
|
23
|
+
startSpan(traceId: string, spanId: string, spanName: string, attributes: StringScalarType): Span;
|
|
24
|
+
mapActivityAttributes(): void;
|
|
25
|
+
setActivityAttributes(attributes: StringScalarType): void;
|
|
26
|
+
setStreamAttributes(attributes: StringScalarType): void;
|
|
27
|
+
setJobAttributes(attributes: StringScalarType): void;
|
|
28
|
+
endJobSpan(): void;
|
|
29
|
+
endActivitySpan(): void;
|
|
30
|
+
endStreamSpan(): void;
|
|
31
|
+
endSpan(span: Span): void;
|
|
32
|
+
getParentSpanContext(): undefined | Context;
|
|
33
|
+
getSpanAttrs(leg: number): StringAnyType;
|
|
34
|
+
getStreamSpanAttrs(input: StreamData): StringAnyType;
|
|
35
|
+
setTelemetryContext(span: Span, leg: number): void;
|
|
36
|
+
setActivityError(message: string): void;
|
|
37
|
+
setStreamError(message: string): void;
|
|
38
|
+
/**
|
|
39
|
+
* Adds the paths (HGET) necessary to restore telemetry state for an activity
|
|
40
|
+
* @param consumes
|
|
41
|
+
* @param config
|
|
42
|
+
* @param metadata
|
|
43
|
+
* @param leg
|
|
44
|
+
*/
|
|
45
|
+
static addTargetTelemetryPaths(consumes: Consumes, config: ActivityType, metadata: ActivityMetadata, leg: number): void;
|
|
46
|
+
static bindJobTelemetryToState(state: StringStringType, config: ActivityType, context: JobState): void;
|
|
47
|
+
static bindActivityTelemetryToState(state: StringAnyType, config: ActivityType, metadata: ActivityMetadata, context: JobState, leg: number): void;
|
|
48
|
+
}
|
|
49
|
+
export { TelemetryService };
|