@levrbet/shared 0.3.41 → 0.4.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/dist/core/config/urls.js +1 -1
- package/dist/server/index.d.ts +1 -0
- package/dist/server/index.js +1 -0
- package/dist/server/index.js.map +1 -1
- package/dist/server/redis/index.d.ts +6 -0
- package/dist/server/redis/index.js +23 -0
- package/dist/server/redis/index.js.map +1 -0
- package/dist/server/redis/queue-management/constants.d.ts +62 -0
- package/dist/server/redis/queue-management/constants.js +70 -0
- package/dist/server/redis/queue-management/constants.js.map +1 -0
- package/dist/server/redis/queue-management/index.d.ts +20 -0
- package/dist/server/redis/queue-management/index.js +32 -0
- package/dist/server/redis/queue-management/index.js.map +1 -0
- package/dist/server/redis/queue-management/keys.d.ts +97 -0
- package/dist/server/redis/queue-management/keys.js +113 -0
- package/dist/server/redis/queue-management/keys.js.map +1 -0
- package/dist/server/redis/queue-management/types.d.ts +111 -0
- package/dist/server/redis/queue-management/types.js +28 -0
- package/dist/server/redis/queue-management/types.js.map +1 -0
- package/package.json +1 -1
package/dist/core/config/urls.js
CHANGED
|
@@ -33,7 +33,7 @@ exports.allUrls = {
|
|
|
33
33
|
leaderboard: "https://leaderboard.dev.levr.bet",
|
|
34
34
|
indexers: {
|
|
35
35
|
[types_1.LevrChain.MONAD_TESTNET]: [
|
|
36
|
-
{ type: indexers_types_1.LevrIndexer.ENVIO, url: "https://indexer.dev.hyperindex.xyz/
|
|
36
|
+
{ type: indexers_types_1.LevrIndexer.ENVIO, url: "https://indexer.dev.hyperindex.xyz/79ae9a8/v1/graphql" },
|
|
37
37
|
{ type: indexers_types_1.LevrIndexer.SUBSQUID, url: "https://levrbet.squids.live/v1-levr-dev@v3/api/graphql" },
|
|
38
38
|
],
|
|
39
39
|
},
|
package/dist/server/index.d.ts
CHANGED
package/dist/server/index.js
CHANGED
|
@@ -26,6 +26,7 @@ __exportStar(require("./contracts"), exports);
|
|
|
26
26
|
__exportStar(require("./liquidation-engine"), exports);
|
|
27
27
|
__exportStar(require("./middleware"), exports);
|
|
28
28
|
__exportStar(require("./oracle"), exports);
|
|
29
|
+
__exportStar(require("./redis"), exports);
|
|
29
30
|
__exportStar(require("./repositories"), exports);
|
|
30
31
|
__exportStar(require("./services"), exports);
|
|
31
32
|
__exportStar(require("./types"), exports);
|
package/dist/server/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,iFAAiF;AACjF,IAAI,OAAQ,UAAkB,CAAC,MAAM,KAAK,WAAW,EAAE,CAAC;IACpD,MAAM,IAAI,KAAK,CACX,0EAA0E;QACtE,0GAA0G;QAC1G,kFAAkF,CACzF,CAAA;AACL,CAAC;AAED,0CAAuB;AACvB,2CAAwB;AACxB,8CAA2B;AAC3B,uDAAoC;AACpC,+CAA4B;AAC5B,2CAAwB;AACxB,iDAA8B;AAC9B,6CAA0B;AAC1B,0CAAuB;AACvB,0CAAuB;AAEvB,0CAA0C;AAC1C,6DAA6D"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,iFAAiF;AACjF,IAAI,OAAQ,UAAkB,CAAC,MAAM,KAAK,WAAW,EAAE,CAAC;IACpD,MAAM,IAAI,KAAK,CACX,0EAA0E;QACtE,0GAA0G;QAC1G,kFAAkF,CACzF,CAAA;AACL,CAAC;AAED,0CAAuB;AACvB,2CAAwB;AACxB,8CAA2B;AAC3B,uDAAoC;AACpC,+CAA4B;AAC5B,2CAAwB;AACxB,0CAAuB;AACvB,iDAA8B;AAC9B,6CAA0B;AAC1B,0CAAuB;AACvB,0CAAuB;AAEvB,0CAA0C;AAC1C,6DAA6D"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Redis Module
|
|
4
|
+
*
|
|
5
|
+
* Redis-related utilities, keys, and service interfaces.
|
|
6
|
+
*/
|
|
7
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
8
|
+
if (k2 === undefined) k2 = k;
|
|
9
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
10
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
11
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
12
|
+
}
|
|
13
|
+
Object.defineProperty(o, k2, desc);
|
|
14
|
+
}) : (function(o, m, k, k2) {
|
|
15
|
+
if (k2 === undefined) k2 = k;
|
|
16
|
+
o[k2] = m[k];
|
|
17
|
+
}));
|
|
18
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
19
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
20
|
+
};
|
|
21
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
+
__exportStar(require("./queue-management"), exports);
|
|
23
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/server/redis/index.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;;;;;;;;AAEH,qDAAkC"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Queue Management Configuration Constants
|
|
3
|
+
*
|
|
4
|
+
* Configuration values and thresholds for the Queue Management System.
|
|
5
|
+
*/
|
|
6
|
+
export declare const QUEUE_MANAGEMENT_CONFIG: {
|
|
7
|
+
/**
|
|
8
|
+
* TTLs in seconds for various Redis keys
|
|
9
|
+
*/
|
|
10
|
+
readonly TTL: {
|
|
11
|
+
/** DLQ stats cache refresh interval */
|
|
12
|
+
readonly DLQ_STATS_CACHE: 60;
|
|
13
|
+
/** Escalation history retention */
|
|
14
|
+
readonly ESCALATION_HISTORY: 604800;
|
|
15
|
+
/** DLQ alert debounce period */
|
|
16
|
+
readonly DLQ_ALERT_DEBOUNCE: 3600;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Circuit breaker configuration
|
|
20
|
+
*/
|
|
21
|
+
readonly CIRCUIT_BREAKER: {
|
|
22
|
+
/** Number of consecutive failures before opening circuit */
|
|
23
|
+
readonly FAILURE_THRESHOLD: 3;
|
|
24
|
+
/** Initial backoff duration in milliseconds */
|
|
25
|
+
readonly INITIAL_BACKOFF_MS: 30000;
|
|
26
|
+
/** Maximum backoff duration in milliseconds */
|
|
27
|
+
readonly MAX_BACKOFF_MS: 600000;
|
|
28
|
+
/** Multiplier for exponential backoff */
|
|
29
|
+
readonly BACKOFF_MULTIPLIER: 2;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* DLQ thresholds for auto-escalation
|
|
33
|
+
*/
|
|
34
|
+
readonly DLQ_THRESHOLDS: {
|
|
35
|
+
/** Message count to trigger WARNING escalation */
|
|
36
|
+
readonly WARNING: 50;
|
|
37
|
+
/** Message count to trigger CRITICAL escalation */
|
|
38
|
+
readonly CRITICAL: 100;
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Escalation history retention
|
|
42
|
+
*/
|
|
43
|
+
readonly ESCALATION_HISTORY_MAX: 1000;
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* Redis key patterns for documentation purposes
|
|
47
|
+
* (Not used in runtime, just for reference)
|
|
48
|
+
*/
|
|
49
|
+
export declare const KEY_PATTERNS: {
|
|
50
|
+
readonly QUEUE_PAUSE_GLOBAL: "queue:pause:global";
|
|
51
|
+
readonly QUEUE_PAUSE_TYPE: "queue:pause:type:{type}";
|
|
52
|
+
readonly QUEUE_PAUSE_QUEUE: "queue:pause:queue:{queueName}";
|
|
53
|
+
readonly QUEUE_PAUSE_ACTIVE: "queue:pause:active";
|
|
54
|
+
readonly QUEUE_ESCALATION: "queue:escalation:{queueName}";
|
|
55
|
+
readonly QUEUE_ESCALATION_HISTORY: "queue:escalation:history:{queueName}";
|
|
56
|
+
readonly QUEUE_ESCALATION_ACTIVE: "queue:escalation:active";
|
|
57
|
+
readonly CIRCUIT_BREAKER_STATE: "circuit_breaker:{queueName}";
|
|
58
|
+
readonly CIRCUIT_BREAKER_OPEN: "circuit_breaker:open";
|
|
59
|
+
readonly DLQ_STATS: "dlq:stats:{dlqName}";
|
|
60
|
+
readonly DLQ_REPROCESS_COUNT: "dlq:reprocessed:{dlqName}";
|
|
61
|
+
readonly DLQ_ALERT_SENT: "dlq:alert:{dlqName}:{alertType}";
|
|
62
|
+
};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Queue Management Configuration Constants
|
|
4
|
+
*
|
|
5
|
+
* Configuration values and thresholds for the Queue Management System.
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.KEY_PATTERNS = exports.QUEUE_MANAGEMENT_CONFIG = void 0;
|
|
9
|
+
exports.QUEUE_MANAGEMENT_CONFIG = {
|
|
10
|
+
/**
|
|
11
|
+
* TTLs in seconds for various Redis keys
|
|
12
|
+
*/
|
|
13
|
+
TTL: {
|
|
14
|
+
/** DLQ stats cache refresh interval */
|
|
15
|
+
DLQ_STATS_CACHE: 60, // 1 minute
|
|
16
|
+
/** Escalation history retention */
|
|
17
|
+
ESCALATION_HISTORY: 604800, // 7 days
|
|
18
|
+
/** DLQ alert debounce period */
|
|
19
|
+
DLQ_ALERT_DEBOUNCE: 3600, // 1 hour
|
|
20
|
+
},
|
|
21
|
+
/**
|
|
22
|
+
* Circuit breaker configuration
|
|
23
|
+
*/
|
|
24
|
+
CIRCUIT_BREAKER: {
|
|
25
|
+
/** Number of consecutive failures before opening circuit */
|
|
26
|
+
FAILURE_THRESHOLD: 3,
|
|
27
|
+
/** Initial backoff duration in milliseconds */
|
|
28
|
+
INITIAL_BACKOFF_MS: 30000, // 30 seconds
|
|
29
|
+
/** Maximum backoff duration in milliseconds */
|
|
30
|
+
MAX_BACKOFF_MS: 600000, // 10 minutes
|
|
31
|
+
/** Multiplier for exponential backoff */
|
|
32
|
+
BACKOFF_MULTIPLIER: 2,
|
|
33
|
+
},
|
|
34
|
+
/**
|
|
35
|
+
* DLQ thresholds for auto-escalation
|
|
36
|
+
*/
|
|
37
|
+
DLQ_THRESHOLDS: {
|
|
38
|
+
/** Message count to trigger WARNING escalation */
|
|
39
|
+
WARNING: 50,
|
|
40
|
+
/** Message count to trigger CRITICAL escalation */
|
|
41
|
+
CRITICAL: 100,
|
|
42
|
+
},
|
|
43
|
+
/**
|
|
44
|
+
* Escalation history retention
|
|
45
|
+
*/
|
|
46
|
+
ESCALATION_HISTORY_MAX: 1000,
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* Redis key patterns for documentation purposes
|
|
50
|
+
* (Not used in runtime, just for reference)
|
|
51
|
+
*/
|
|
52
|
+
exports.KEY_PATTERNS = {
|
|
53
|
+
// Operational pause keys (NEW)
|
|
54
|
+
QUEUE_PAUSE_GLOBAL: "queue:pause:global",
|
|
55
|
+
QUEUE_PAUSE_TYPE: "queue:pause:type:{type}",
|
|
56
|
+
QUEUE_PAUSE_QUEUE: "queue:pause:queue:{queueName}",
|
|
57
|
+
QUEUE_PAUSE_ACTIVE: "queue:pause:active",
|
|
58
|
+
// Escalation keys
|
|
59
|
+
QUEUE_ESCALATION: "queue:escalation:{queueName}",
|
|
60
|
+
QUEUE_ESCALATION_HISTORY: "queue:escalation:history:{queueName}",
|
|
61
|
+
QUEUE_ESCALATION_ACTIVE: "queue:escalation:active",
|
|
62
|
+
// Circuit breaker keys
|
|
63
|
+
CIRCUIT_BREAKER_STATE: "circuit_breaker:{queueName}",
|
|
64
|
+
CIRCUIT_BREAKER_OPEN: "circuit_breaker:open",
|
|
65
|
+
// DLQ keys
|
|
66
|
+
DLQ_STATS: "dlq:stats:{dlqName}",
|
|
67
|
+
DLQ_REPROCESS_COUNT: "dlq:reprocessed:{dlqName}",
|
|
68
|
+
DLQ_ALERT_SENT: "dlq:alert:{dlqName}:{alertType}",
|
|
69
|
+
};
|
|
70
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../src/server/redis/queue-management/constants.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAEU,QAAA,uBAAuB,GAAG;IACnC;;OAEG;IACH,GAAG,EAAE;QACD,uCAAuC;QACvC,eAAe,EAAE,EAAE,EAAE,WAAW;QAEhC,mCAAmC;QACnC,kBAAkB,EAAE,MAAM,EAAE,SAAS;QAErC,gCAAgC;QAChC,kBAAkB,EAAE,IAAI,EAAE,SAAS;KACtC;IAED;;OAEG;IACH,eAAe,EAAE;QACb,4DAA4D;QAC5D,iBAAiB,EAAE,CAAC;QAEpB,+CAA+C;QAC/C,kBAAkB,EAAE,KAAK,EAAE,aAAa;QAExC,+CAA+C;QAC/C,cAAc,EAAE,MAAM,EAAE,aAAa;QAErC,yCAAyC;QACzC,kBAAkB,EAAE,CAAC;KACxB;IAED;;OAEG;IACH,cAAc,EAAE;QACZ,kDAAkD;QAClD,OAAO,EAAE,EAAE;QAEX,mDAAmD;QACnD,QAAQ,EAAE,GAAG;KAChB;IAED;;OAEG;IACH,sBAAsB,EAAE,IAAI;CACtB,CAAA;AAEV;;;GAGG;AACU,QAAA,YAAY,GAAG;IACxB,+BAA+B;IAC/B,kBAAkB,EAAE,oBAAoB;IACxC,gBAAgB,EAAE,yBAAyB;IAC3C,iBAAiB,EAAE,+BAA+B;IAClD,kBAAkB,EAAE,oBAAoB;IAExC,kBAAkB;IAClB,gBAAgB,EAAE,8BAA8B;IAChD,wBAAwB,EAAE,sCAAsC;IAChE,uBAAuB,EAAE,yBAAyB;IAElD,uBAAuB;IACvB,qBAAqB,EAAE,6BAA6B;IACpD,oBAAoB,EAAE,sBAAsB;IAE5C,WAAW;IACX,SAAS,EAAE,qBAAqB;IAChC,mBAAmB,EAAE,2BAA2B;IAChD,cAAc,EAAE,iCAAiC;CAC3C,CAAA"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Queue Management Redis Module
|
|
3
|
+
*
|
|
4
|
+
* Provides Redis keys, types, and constants for the Queue Management System.
|
|
5
|
+
* Used by oracle/core, oracle/processors, liquidation-engine, and other services.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* import { QueueManagementKeys, EscalationLevel } from '@levrbet/shared/server'
|
|
10
|
+
*
|
|
11
|
+
* // Get key for global pause
|
|
12
|
+
* const key = QueueManagementKeys.pause.global()
|
|
13
|
+
*
|
|
14
|
+
* // Get key for specific queue pause
|
|
15
|
+
* const queueKey = QueueManagementKeys.pause.queue('mkt.abc.xyz')
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export { QueueManagementKeys } from "./keys";
|
|
19
|
+
export { CircuitState, EscalationLevel, type CircuitBreakerState, type DLQStats, type EscalationHistoryEntry, type EscalationState, type GlobalPauseState, type OperationalPauseState, type PauseCheckResult, type QueueContext, type QueuePauseState, type QueueType, type TypePauseState, } from "./types";
|
|
20
|
+
export { KEY_PATTERNS, QUEUE_MANAGEMENT_CONFIG } from "./constants";
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Queue Management Redis Module
|
|
4
|
+
*
|
|
5
|
+
* Provides Redis keys, types, and constants for the Queue Management System.
|
|
6
|
+
* Used by oracle/core, oracle/processors, liquidation-engine, and other services.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* import { QueueManagementKeys, EscalationLevel } from '@levrbet/shared/server'
|
|
11
|
+
*
|
|
12
|
+
* // Get key for global pause
|
|
13
|
+
* const key = QueueManagementKeys.pause.global()
|
|
14
|
+
*
|
|
15
|
+
* // Get key for specific queue pause
|
|
16
|
+
* const queueKey = QueueManagementKeys.pause.queue('mkt.abc.xyz')
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
+
exports.QUEUE_MANAGEMENT_CONFIG = exports.KEY_PATTERNS = exports.EscalationLevel = exports.CircuitState = exports.QueueManagementKeys = void 0;
|
|
21
|
+
// Key builders
|
|
22
|
+
var keys_1 = require("./keys");
|
|
23
|
+
Object.defineProperty(exports, "QueueManagementKeys", { enumerable: true, get: function () { return keys_1.QueueManagementKeys; } });
|
|
24
|
+
// Types and enums
|
|
25
|
+
var types_1 = require("./types");
|
|
26
|
+
Object.defineProperty(exports, "CircuitState", { enumerable: true, get: function () { return types_1.CircuitState; } });
|
|
27
|
+
Object.defineProperty(exports, "EscalationLevel", { enumerable: true, get: function () { return types_1.EscalationLevel; } });
|
|
28
|
+
// Constants
|
|
29
|
+
var constants_1 = require("./constants");
|
|
30
|
+
Object.defineProperty(exports, "KEY_PATTERNS", { enumerable: true, get: function () { return constants_1.KEY_PATTERNS; } });
|
|
31
|
+
Object.defineProperty(exports, "QUEUE_MANAGEMENT_CONFIG", { enumerable: true, get: function () { return constants_1.QUEUE_MANAGEMENT_CONFIG; } });
|
|
32
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/server/redis/queue-management/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;GAgBG;;;AAEH,eAAe;AACf,+BAA4C;AAAnC,2GAAA,mBAAmB,OAAA;AAE5B,kBAAkB;AAClB,iCAcgB;AAbZ,qGAAA,YAAY,OAAA;AACZ,wGAAA,eAAe,OAAA;AAcnB,YAAY;AACZ,yCAAmE;AAA1D,yGAAA,YAAY,OAAA;AAAE,oHAAA,uBAAuB,OAAA"}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Queue Management Redis Keys
|
|
3
|
+
*
|
|
4
|
+
* Key builder functions for the Queue Management System.
|
|
5
|
+
* These are ONLY for operational queue control.
|
|
6
|
+
*
|
|
7
|
+
* NOTE: Game/market pause is checked via existing searchGames()/searchMarkets()
|
|
8
|
+
* which return game.paused/market.paused from Redis Search cache.
|
|
9
|
+
* DO NOT create separate pause keys for games/markets.
|
|
10
|
+
*/
|
|
11
|
+
import type { QueueType } from "./types";
|
|
12
|
+
export declare const QueueManagementKeys: {
|
|
13
|
+
readonly pause: {
|
|
14
|
+
/**
|
|
15
|
+
* Global pause key - stops ALL queue processing
|
|
16
|
+
* Type: STRING (JSON)
|
|
17
|
+
* @example 'queue:pause:global'
|
|
18
|
+
*/
|
|
19
|
+
readonly global: () => "queue:pause:global";
|
|
20
|
+
/**
|
|
21
|
+
* Queue type pause key - stops all queues of a specific type
|
|
22
|
+
* Type: STRING (JSON)
|
|
23
|
+
* @example 'queue:pause:type:market'
|
|
24
|
+
*/
|
|
25
|
+
readonly type: (type: QueueType) => "queue:pause:type:market" | "queue:pause:type:game" | "queue:pause:type:game_time" | "queue:pause:type:liquidation";
|
|
26
|
+
/**
|
|
27
|
+
* Individual queue pause key - stops a specific queue
|
|
28
|
+
* Type: STRING (JSON)
|
|
29
|
+
* Use for operational control without touching game/market state
|
|
30
|
+
* @example 'queue:pause:queue:mkt.507f1f77bcf86cd799439011.507f1f77bcf86cd799439012'
|
|
31
|
+
*/
|
|
32
|
+
readonly queue: (queueName: string) => `queue:pause:queue:${string}`;
|
|
33
|
+
/**
|
|
34
|
+
* Active operational pauses index
|
|
35
|
+
* Type: SET
|
|
36
|
+
* Members: All currently paused key names (only operational pauses)
|
|
37
|
+
* @example 'queue:pause:active'
|
|
38
|
+
*/
|
|
39
|
+
readonly activeIndex: () => "queue:pause:active";
|
|
40
|
+
};
|
|
41
|
+
readonly escalation: {
|
|
42
|
+
/**
|
|
43
|
+
* Queue escalation state
|
|
44
|
+
* Type: HASH
|
|
45
|
+
* @example 'queue:escalation:mkt.abc.xyz'
|
|
46
|
+
*/
|
|
47
|
+
readonly state: (queueName: string) => `queue:escalation:${string}`;
|
|
48
|
+
/**
|
|
49
|
+
* Queue escalation history
|
|
50
|
+
* Type: LIST (LPUSH, most recent first)
|
|
51
|
+
* @example 'queue:escalation:history:mkt.abc.xyz'
|
|
52
|
+
*/
|
|
53
|
+
readonly history: (queueName: string) => `queue:escalation:history:${string}`;
|
|
54
|
+
/**
|
|
55
|
+
* Active escalations index (sorted by level)
|
|
56
|
+
* Type: SORTED SET (score = escalation level)
|
|
57
|
+
* @example 'queue:escalation:active'
|
|
58
|
+
*/
|
|
59
|
+
readonly activeIndex: () => "queue:escalation:active";
|
|
60
|
+
};
|
|
61
|
+
readonly circuitBreaker: {
|
|
62
|
+
/**
|
|
63
|
+
* Circuit breaker state for a queue
|
|
64
|
+
* Type: HASH
|
|
65
|
+
* @example 'circuit_breaker:mkt.abc.xyz'
|
|
66
|
+
*/
|
|
67
|
+
readonly state: (queueName: string) => `circuit_breaker:${string}`;
|
|
68
|
+
/**
|
|
69
|
+
* Index of open circuit breakers
|
|
70
|
+
* Type: SET
|
|
71
|
+
* @example 'circuit_breaker:open'
|
|
72
|
+
*/
|
|
73
|
+
readonly openIndex: () => "circuit_breaker:open";
|
|
74
|
+
};
|
|
75
|
+
readonly dlq: {
|
|
76
|
+
/**
|
|
77
|
+
* DLQ statistics cache
|
|
78
|
+
* Type: HASH
|
|
79
|
+
* TTL: 60 seconds
|
|
80
|
+
* @example 'dlq:stats:dlq.market'
|
|
81
|
+
*/
|
|
82
|
+
readonly stats: (dlqName: string) => `dlq:stats:${string}`;
|
|
83
|
+
/**
|
|
84
|
+
* DLQ reprocess counter
|
|
85
|
+
* Type: STRING (integer)
|
|
86
|
+
* @example 'dlq:reprocessed:dlq.market'
|
|
87
|
+
*/
|
|
88
|
+
readonly reprocessCount: (dlqName: string) => `dlq:reprocessed:${string}`;
|
|
89
|
+
/**
|
|
90
|
+
* DLQ alert sent flag (for debouncing)
|
|
91
|
+
* Type: STRING
|
|
92
|
+
* TTL: 3600 seconds (1 hour)
|
|
93
|
+
* @example 'dlq:alert:dlq.market:threshold_exceeded'
|
|
94
|
+
*/
|
|
95
|
+
readonly alertSent: (dlqName: string, alertType: string) => `dlq:alert:${string}:${string}`;
|
|
96
|
+
};
|
|
97
|
+
};
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Queue Management Redis Keys
|
|
4
|
+
*
|
|
5
|
+
* Key builder functions for the Queue Management System.
|
|
6
|
+
* These are ONLY for operational queue control.
|
|
7
|
+
*
|
|
8
|
+
* NOTE: Game/market pause is checked via existing searchGames()/searchMarkets()
|
|
9
|
+
* which return game.paused/market.paused from Redis Search cache.
|
|
10
|
+
* DO NOT create separate pause keys for games/markets.
|
|
11
|
+
*/
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.QueueManagementKeys = void 0;
|
|
14
|
+
exports.QueueManagementKeys = {
|
|
15
|
+
// =========================================================================
|
|
16
|
+
// Operational Pause Keys (NEW)
|
|
17
|
+
// For pausing message PROCESSING without changing game/market business state
|
|
18
|
+
// =========================================================================
|
|
19
|
+
pause: {
|
|
20
|
+
/**
|
|
21
|
+
* Global pause key - stops ALL queue processing
|
|
22
|
+
* Type: STRING (JSON)
|
|
23
|
+
* @example 'queue:pause:global'
|
|
24
|
+
*/
|
|
25
|
+
global: () => "queue:pause:global",
|
|
26
|
+
/**
|
|
27
|
+
* Queue type pause key - stops all queues of a specific type
|
|
28
|
+
* Type: STRING (JSON)
|
|
29
|
+
* @example 'queue:pause:type:market'
|
|
30
|
+
*/
|
|
31
|
+
type: (type) => `queue:pause:type:${type}`,
|
|
32
|
+
/**
|
|
33
|
+
* Individual queue pause key - stops a specific queue
|
|
34
|
+
* Type: STRING (JSON)
|
|
35
|
+
* Use for operational control without touching game/market state
|
|
36
|
+
* @example 'queue:pause:queue:mkt.507f1f77bcf86cd799439011.507f1f77bcf86cd799439012'
|
|
37
|
+
*/
|
|
38
|
+
queue: (queueName) => `queue:pause:queue:${queueName}`,
|
|
39
|
+
/**
|
|
40
|
+
* Active operational pauses index
|
|
41
|
+
* Type: SET
|
|
42
|
+
* Members: All currently paused key names (only operational pauses)
|
|
43
|
+
* @example 'queue:pause:active'
|
|
44
|
+
*/
|
|
45
|
+
activeIndex: () => "queue:pause:active",
|
|
46
|
+
},
|
|
47
|
+
// =========================================================================
|
|
48
|
+
// Escalation Keys
|
|
49
|
+
// =========================================================================
|
|
50
|
+
escalation: {
|
|
51
|
+
/**
|
|
52
|
+
* Queue escalation state
|
|
53
|
+
* Type: HASH
|
|
54
|
+
* @example 'queue:escalation:mkt.abc.xyz'
|
|
55
|
+
*/
|
|
56
|
+
state: (queueName) => `queue:escalation:${queueName}`,
|
|
57
|
+
/**
|
|
58
|
+
* Queue escalation history
|
|
59
|
+
* Type: LIST (LPUSH, most recent first)
|
|
60
|
+
* @example 'queue:escalation:history:mkt.abc.xyz'
|
|
61
|
+
*/
|
|
62
|
+
history: (queueName) => `queue:escalation:history:${queueName}`,
|
|
63
|
+
/**
|
|
64
|
+
* Active escalations index (sorted by level)
|
|
65
|
+
* Type: SORTED SET (score = escalation level)
|
|
66
|
+
* @example 'queue:escalation:active'
|
|
67
|
+
*/
|
|
68
|
+
activeIndex: () => "queue:escalation:active",
|
|
69
|
+
},
|
|
70
|
+
// =========================================================================
|
|
71
|
+
// Circuit Breaker Keys (Existing - Standardized)
|
|
72
|
+
// =========================================================================
|
|
73
|
+
circuitBreaker: {
|
|
74
|
+
/**
|
|
75
|
+
* Circuit breaker state for a queue
|
|
76
|
+
* Type: HASH
|
|
77
|
+
* @example 'circuit_breaker:mkt.abc.xyz'
|
|
78
|
+
*/
|
|
79
|
+
state: (queueName) => `circuit_breaker:${queueName}`,
|
|
80
|
+
/**
|
|
81
|
+
* Index of open circuit breakers
|
|
82
|
+
* Type: SET
|
|
83
|
+
* @example 'circuit_breaker:open'
|
|
84
|
+
*/
|
|
85
|
+
openIndex: () => "circuit_breaker:open",
|
|
86
|
+
},
|
|
87
|
+
// =========================================================================
|
|
88
|
+
// DLQ Management Keys
|
|
89
|
+
// =========================================================================
|
|
90
|
+
dlq: {
|
|
91
|
+
/**
|
|
92
|
+
* DLQ statistics cache
|
|
93
|
+
* Type: HASH
|
|
94
|
+
* TTL: 60 seconds
|
|
95
|
+
* @example 'dlq:stats:dlq.market'
|
|
96
|
+
*/
|
|
97
|
+
stats: (dlqName) => `dlq:stats:${dlqName}`,
|
|
98
|
+
/**
|
|
99
|
+
* DLQ reprocess counter
|
|
100
|
+
* Type: STRING (integer)
|
|
101
|
+
* @example 'dlq:reprocessed:dlq.market'
|
|
102
|
+
*/
|
|
103
|
+
reprocessCount: (dlqName) => `dlq:reprocessed:${dlqName}`,
|
|
104
|
+
/**
|
|
105
|
+
* DLQ alert sent flag (for debouncing)
|
|
106
|
+
* Type: STRING
|
|
107
|
+
* TTL: 3600 seconds (1 hour)
|
|
108
|
+
* @example 'dlq:alert:dlq.market:threshold_exceeded'
|
|
109
|
+
*/
|
|
110
|
+
alertSent: (dlqName, alertType) => `dlq:alert:${dlqName}:${alertType}`,
|
|
111
|
+
},
|
|
112
|
+
};
|
|
113
|
+
//# sourceMappingURL=keys.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"keys.js","sourceRoot":"","sources":["../../../../src/server/redis/queue-management/keys.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;;AAIU,QAAA,mBAAmB,GAAG;IAC/B,4EAA4E;IAC5E,+BAA+B;IAC/B,6EAA6E;IAC7E,4EAA4E;IAE5E,KAAK,EAAE;QACH;;;;WAIG;QACH,MAAM,EAAE,GAAG,EAAE,CAAC,oBAA6B;QAE3C;;;;WAIG;QACH,IAAI,EAAE,CAAC,IAAe,EAAE,EAAE,CAAC,oBAAoB,IAAI,EAAW;QAE9D;;;;;WAKG;QACH,KAAK,EAAE,CAAC,SAAiB,EAAE,EAAE,CAAC,qBAAqB,SAAS,EAAW;QAEvE;;;;;WAKG;QACH,WAAW,EAAE,GAAG,EAAE,CAAC,oBAA6B;KACnD;IAED,4EAA4E;IAC5E,kBAAkB;IAClB,4EAA4E;IAE5E,UAAU,EAAE;QACR;;;;WAIG;QACH,KAAK,EAAE,CAAC,SAAiB,EAAE,EAAE,CAAC,oBAAoB,SAAS,EAAW;QAEtE;;;;WAIG;QACH,OAAO,EAAE,CAAC,SAAiB,EAAE,EAAE,CAAC,4BAA4B,SAAS,EAAW;QAEhF;;;;WAIG;QACH,WAAW,EAAE,GAAG,EAAE,CAAC,yBAAkC;KACxD;IAED,4EAA4E;IAC5E,iDAAiD;IACjD,4EAA4E;IAE5E,cAAc,EAAE;QACZ;;;;WAIG;QACH,KAAK,EAAE,CAAC,SAAiB,EAAE,EAAE,CAAC,mBAAmB,SAAS,EAAW;QAErE;;;;WAIG;QACH,SAAS,EAAE,GAAG,EAAE,CAAC,sBAA+B;KACnD;IAED,4EAA4E;IAC5E,sBAAsB;IACtB,4EAA4E;IAE5E,GAAG,EAAE;QACD;;;;;WAKG;QACH,KAAK,EAAE,CAAC,OAAe,EAAE,EAAE,CAAC,aAAa,OAAO,EAAW;QAE3D;;;;WAIG;QACH,cAAc,EAAE,CAAC,OAAe,EAAE,EAAE,CAAC,mBAAmB,OAAO,EAAW;QAE1E;;;;;WAKG;QACH,SAAS,EAAE,CAAC,OAAe,EAAE,SAAiB,EAAE,EAAE,CAAC,aAAa,OAAO,IAAI,SAAS,EAAW;KAClG;CACK,CAAA"}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Queue Management Redis Types
|
|
3
|
+
*
|
|
4
|
+
* Type definitions for the Queue Management System Redis keys.
|
|
5
|
+
* These keys handle operational queue control - NOT game/market business state.
|
|
6
|
+
*
|
|
7
|
+
* For game/market pause state, use existing Redis Search cache:
|
|
8
|
+
* - searchGames(redis, { objectId }) → game.paused
|
|
9
|
+
* - searchMarkets(redis, { objectId }) → market.paused
|
|
10
|
+
*/
|
|
11
|
+
export declare enum EscalationLevel {
|
|
12
|
+
NORMAL = 0,
|
|
13
|
+
WATCH = 1,
|
|
14
|
+
WARNING = 2,
|
|
15
|
+
CRITICAL = 3,
|
|
16
|
+
EMERGENCY = 4
|
|
17
|
+
}
|
|
18
|
+
export declare enum CircuitState {
|
|
19
|
+
CLOSED = "CLOSED",
|
|
20
|
+
OPEN = "OPEN",
|
|
21
|
+
HALF_OPEN = "HALF_OPEN"
|
|
22
|
+
}
|
|
23
|
+
export type QueueType = "market" | "game" | "game_time" | "liquidation";
|
|
24
|
+
/**
|
|
25
|
+
* Base pause state for operational pauses
|
|
26
|
+
*/
|
|
27
|
+
export interface OperationalPauseState {
|
|
28
|
+
paused: boolean;
|
|
29
|
+
pausedAt: number;
|
|
30
|
+
pausedBy: string;
|
|
31
|
+
reason: string;
|
|
32
|
+
resumeAt?: number;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Global pause state - stops ALL queue processing
|
|
36
|
+
*/
|
|
37
|
+
export interface GlobalPauseState extends OperationalPauseState {
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Type pause state - stops all queues of a specific type
|
|
41
|
+
*/
|
|
42
|
+
export interface TypePauseState extends OperationalPauseState {
|
|
43
|
+
queueType: QueueType;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Individual queue pause state - stops a specific queue
|
|
47
|
+
* Use for operational control without touching game/market state
|
|
48
|
+
*/
|
|
49
|
+
export interface QueuePauseState extends OperationalPauseState {
|
|
50
|
+
queueName: string;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Current escalation state for a queue
|
|
54
|
+
*/
|
|
55
|
+
export interface EscalationState {
|
|
56
|
+
queueName: string;
|
|
57
|
+
level: EscalationLevel;
|
|
58
|
+
escalatedAt: number;
|
|
59
|
+
reason: string;
|
|
60
|
+
escalatedBy: "auto" | string;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Historical escalation entry
|
|
64
|
+
*/
|
|
65
|
+
export interface EscalationHistoryEntry {
|
|
66
|
+
level: EscalationLevel;
|
|
67
|
+
timestamp: number;
|
|
68
|
+
reason: string;
|
|
69
|
+
escalatedBy: string;
|
|
70
|
+
resolvedAt?: number;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Circuit breaker state for a queue
|
|
74
|
+
*/
|
|
75
|
+
export interface CircuitBreakerState {
|
|
76
|
+
state: CircuitState;
|
|
77
|
+
consecutiveFailures: number;
|
|
78
|
+
lastFailureTime: number;
|
|
79
|
+
lastSuccessTime: number;
|
|
80
|
+
lastError: string;
|
|
81
|
+
nextRetryTime: number;
|
|
82
|
+
backoffMs: number;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* DLQ statistics cache
|
|
86
|
+
*/
|
|
87
|
+
export interface DLQStats {
|
|
88
|
+
totalMessages: number;
|
|
89
|
+
oldestMessageAt: number;
|
|
90
|
+
newestMessageAt: number;
|
|
91
|
+
lastUpdated: number;
|
|
92
|
+
byQueue: Record<string, number>;
|
|
93
|
+
byReason: Record<string, number>;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Queue context for pause checking
|
|
97
|
+
*/
|
|
98
|
+
export interface QueueContext {
|
|
99
|
+
queueName: string;
|
|
100
|
+
queueType: QueueType;
|
|
101
|
+
gameObjectId: string;
|
|
102
|
+
marketObjectId?: string;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Result of pause check operation
|
|
106
|
+
*/
|
|
107
|
+
export interface PauseCheckResult {
|
|
108
|
+
canProcess: boolean;
|
|
109
|
+
reason?: string;
|
|
110
|
+
pauseLevel?: "global" | "type" | "game" | "market" | "queue";
|
|
111
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Queue Management Redis Types
|
|
4
|
+
*
|
|
5
|
+
* Type definitions for the Queue Management System Redis keys.
|
|
6
|
+
* These keys handle operational queue control - NOT game/market business state.
|
|
7
|
+
*
|
|
8
|
+
* For game/market pause state, use existing Redis Search cache:
|
|
9
|
+
* - searchGames(redis, { objectId }) → game.paused
|
|
10
|
+
* - searchMarkets(redis, { objectId }) → market.paused
|
|
11
|
+
*/
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.CircuitState = exports.EscalationLevel = void 0;
|
|
14
|
+
var EscalationLevel;
|
|
15
|
+
(function (EscalationLevel) {
|
|
16
|
+
EscalationLevel[EscalationLevel["NORMAL"] = 0] = "NORMAL";
|
|
17
|
+
EscalationLevel[EscalationLevel["WATCH"] = 1] = "WATCH";
|
|
18
|
+
EscalationLevel[EscalationLevel["WARNING"] = 2] = "WARNING";
|
|
19
|
+
EscalationLevel[EscalationLevel["CRITICAL"] = 3] = "CRITICAL";
|
|
20
|
+
EscalationLevel[EscalationLevel["EMERGENCY"] = 4] = "EMERGENCY";
|
|
21
|
+
})(EscalationLevel || (exports.EscalationLevel = EscalationLevel = {}));
|
|
22
|
+
var CircuitState;
|
|
23
|
+
(function (CircuitState) {
|
|
24
|
+
CircuitState["CLOSED"] = "CLOSED";
|
|
25
|
+
CircuitState["OPEN"] = "OPEN";
|
|
26
|
+
CircuitState["HALF_OPEN"] = "HALF_OPEN";
|
|
27
|
+
})(CircuitState || (exports.CircuitState = CircuitState = {}));
|
|
28
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/server/redis/queue-management/types.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;;AAEH,IAAY,eAMX;AAND,WAAY,eAAe;IACvB,yDAAU,CAAA;IACV,uDAAS,CAAA;IACT,2DAAW,CAAA;IACX,6DAAY,CAAA;IACZ,+DAAa,CAAA;AACjB,CAAC,EANW,eAAe,+BAAf,eAAe,QAM1B;AAED,IAAY,YAIX;AAJD,WAAY,YAAY;IACpB,iCAAiB,CAAA;IACjB,6BAAa,CAAA;IACb,uCAAuB,CAAA;AAC3B,CAAC,EAJW,YAAY,4BAAZ,YAAY,QAIvB"}
|