@zorionapp/gg-core 5.0.14 → 5.0.15
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/package.json +2 -3
- package/src/gg-cache/gg-cache.module.js +9 -26
- package/src/gg-cache/gg-cache.module.js.map +1 -1
- package/src/gg-cache/index.d.ts +1 -1
- package/src/gg-cache/index.js +3 -1
- package/src/gg-cache/index.js.map +1 -1
- package/src/gg-core/gg-core.module.js +2 -2
- package/src/gg-redis/index.d.ts +2 -0
- package/src/gg-redis/index.js +8 -0
- package/src/gg-redis/index.js.map +1 -0
- package/src/gg-redis/redis-client.factory.d.ts +6 -0
- package/src/gg-redis/redis-client.factory.js +31 -0
- package/src/gg-redis/redis-client.factory.js.map +1 -0
- package/src/{gg-cache → gg-redis}/redis.config.d.ts +4 -0
- package/src/gg-redis/redis.config.js +46 -0
- package/src/gg-redis/redis.config.js.map +1 -0
- package/src/gg-redlock/index.d.ts +1 -0
- package/src/gg-redlock/redlock.module.d.ts +3 -2
- package/src/gg-redlock/redlock.module.js +34 -6
- package/src/gg-redlock/redlock.module.js.map +1 -1
- package/src/gg-redlock/redlock.options.d.ts +1 -8
- package/src/gg-redlock/redlock.options.js +2 -10
- package/src/gg-redlock/redlock.options.js.map +1 -1
- package/src/gg-redlock/redlock.service.d.ts +11 -17
- package/src/gg-redlock/redlock.service.js +16 -35
- package/src/gg-redlock/redlock.service.js.map +1 -1
- package/src/index.d.ts +1 -0
- package/src/index.js +1 -0
- package/src/index.js.map +1 -1
- package/src/gg-cache/redis.config.js +0 -23
- package/src/gg-cache/redis.config.js.map +0 -1
- package/src/gg-redlock/redlock.config.d.ts +0 -5
- package/src/gg-redlock/redlock.config.js +0 -22
- package/src/gg-redlock/redlock.config.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zorionapp/gg-core",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.15",
|
|
4
4
|
"type": "commonjs",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"cache-manager": "5.2.4",
|
|
@@ -9,10 +9,9 @@
|
|
|
9
9
|
"@google-cloud/trace-agent": "7.1.2"
|
|
10
10
|
},
|
|
11
11
|
"peerDependencies": {
|
|
12
|
-
"cache-manager-
|
|
12
|
+
"cache-manager-ioredis-yet": "^2.0.0",
|
|
13
13
|
"amqp-connection-manager": "^4.1.14",
|
|
14
14
|
"amqplib": "^0.10.3",
|
|
15
|
-
"redis": "^4.6.10",
|
|
16
15
|
"helmet": "^7.1.0",
|
|
17
16
|
"pino-http": "^8.5.0",
|
|
18
17
|
"@google-cloud/error-reporting": "^3.0.5",
|
|
@@ -5,13 +5,10 @@ exports.GgCacheModule = void 0;
|
|
|
5
5
|
const tslib_1 = require("tslib");
|
|
6
6
|
const cache_manager_1 = require("@nestjs/cache-manager");
|
|
7
7
|
const common_1 = require("@nestjs/common");
|
|
8
|
-
const
|
|
9
|
-
const cache_manager_redis_yet_1 = require("cache-manager-redis-yet");
|
|
8
|
+
const cache_manager_ioredis_yet_1 = require("cache-manager-ioredis-yet");
|
|
10
9
|
const luxon_1 = require("luxon");
|
|
11
|
-
const
|
|
10
|
+
const gg_redis_1 = require("../gg-redis");
|
|
12
11
|
const gg_cache_service_1 = require("./gg-cache.service");
|
|
13
|
-
const redis_config_1 = require("./redis.config");
|
|
14
|
-
const PING_INTERVAL_SECONDS = 60;
|
|
15
12
|
let GgCacheModule = GgCacheModule_1 = class GgCacheModule {
|
|
16
13
|
static forRoot() {
|
|
17
14
|
return {
|
|
@@ -21,29 +18,15 @@ let GgCacheModule = GgCacheModule_1 = class GgCacheModule {
|
|
|
21
18
|
exports: [gg_cache_service_1.GgCacheService],
|
|
22
19
|
imports: [
|
|
23
20
|
cache_manager_1.CacheModule.registerAsync({
|
|
24
|
-
inject: [
|
|
21
|
+
inject: [gg_redis_1.redisConfig.KEY],
|
|
25
22
|
isGlobal: true,
|
|
26
|
-
useFactory:
|
|
27
|
-
const client = (0,
|
|
28
|
-
|
|
29
|
-
pingInterval: luxon_1.Duration.fromObject({ second: PING_INTERVAL_SECONDS }).as('milliseconds'),
|
|
30
|
-
});
|
|
31
|
-
client.on('error', (err) => {
|
|
32
|
-
console.error('Redis Client Error', err);
|
|
33
|
-
});
|
|
34
|
-
try {
|
|
35
|
-
await client.connect();
|
|
36
|
-
}
|
|
37
|
-
catch (error) {
|
|
38
|
-
console.error('Redis connecting Error', error);
|
|
39
|
-
throw new exceptions_1.RuntimeException('Error connecting to Redis');
|
|
40
|
-
}
|
|
23
|
+
useFactory: (redisConf) => {
|
|
24
|
+
const client = (0, gg_redis_1.createRedisClient)(redisConf, { keepAlive: 1 });
|
|
25
|
+
client.on('error', (err) => console.error('Redis cache client error', err));
|
|
41
26
|
return {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
ttl: luxon_1.Duration.fromObject({ minute: 1 }).as('milliseconds'),
|
|
46
|
-
pingInterval: luxon_1.Duration.fromObject({ second: PING_INTERVAL_SECONDS }).as('milliseconds'),
|
|
27
|
+
store: (0, cache_manager_ioredis_yet_1.redisInsStore)(client, {
|
|
28
|
+
ttl: luxon_1.Duration.fromObject({ minute: 1 }).as('milliseconds'),
|
|
29
|
+
}),
|
|
47
30
|
};
|
|
48
31
|
},
|
|
49
32
|
}),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gg-cache.module.js","sourceRoot":"","sources":["../../../../../libs/gg-core/src/gg-cache/gg-cache.module.ts"],"names":[],"mappings":";;;;;AAAA,yDAAoD;AACpD,2CAAuD;AAEvD
|
|
1
|
+
{"version":3,"file":"gg-cache.module.js","sourceRoot":"","sources":["../../../../../libs/gg-core/src/gg-cache/gg-cache.module.ts"],"names":[],"mappings":";;;;;AAAA,yDAAoD;AACpD,2CAAuD;AAEvD,yEAA0D;AAC1D,iCAAiC;AACjC,0CAA6D;AAC7D,yDAAoD;AAG7C,IAAM,aAAa,qBAAnB,MAAM,aAAa;IACjB,MAAM,CAAC,OAAO;QACnB,OAAO;YACL,MAAM,EAAE,eAAa;YACrB,MAAM,EAAE,IAAI;YACZ,SAAS,EAAE,CAAC,iCAAc,CAAC;YAC3B,OAAO,EAAE,CAAC,iCAAc,CAAC;YACzB,OAAO,EAAE;gBACP,2BAAW,CAAC,aAAa,CAAC;oBACxB,MAAM,EAAE,CAAC,sBAAW,CAAC,GAAG,CAAC;oBACzB,QAAQ,EAAE,IAAI;oBACd,UAAU,EAAE,CAAC,SAAyC,EAAE,EAAE;wBACxD,MAAM,MAAM,GAAG,IAAA,4BAAiB,EAAC,SAAS,EAAE,EAAE,SAAS,EAAE,CAAC,EAAE,CAAC,CAAC;wBAC9D,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,0BAA0B,EAAE,GAAG,CAAC,CAAC,CAAC;wBAC5E,OAAO;4BACL,KAAK,EAAE,IAAA,yCAAa,EAAC,MAAM,EAAE;gCAC3B,GAAG,EAAE,gBAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,cAAc,CAAC;6BAC3D,CAAC;yBACH,CAAC;oBACJ,CAAC;iBACF,CAAC;aACH;SACF,CAAC;IACJ,CAAC;CACF,CAAA;AAxBY,sCAAa;wBAAb,aAAa;IADzB,IAAA,eAAM,EAAC,EAAE,CAAC;GACE,aAAa,CAwBzB"}
|
package/src/gg-cache/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export * from './gg-cache.service';
|
|
2
|
-
export
|
|
2
|
+
export { redisConfig } from '../gg-redis';
|
package/src/gg-cache/index.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.redisConfig = void 0;
|
|
3
4
|
const tslib_1 = require("tslib");
|
|
4
5
|
tslib_1.__exportStar(require("./gg-cache.service"), exports);
|
|
5
|
-
|
|
6
|
+
var gg_redis_1 = require("../gg-redis");
|
|
7
|
+
Object.defineProperty(exports, "redisConfig", { enumerable: true, get: function () { return gg_redis_1.redisConfig; } });
|
|
6
8
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../libs/gg-core/src/gg-cache/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../libs/gg-core/src/gg-cache/index.ts"],"names":[],"mappings":";;;;AAAA,6DAAmC;AACnC,wCAA0C;AAAjC,uGAAA,WAAW,OAAA"}
|
|
@@ -5,7 +5,7 @@ exports.GgCoreModule = void 0;
|
|
|
5
5
|
const tslib_1 = require("tslib");
|
|
6
6
|
const common_1 = require("@nestjs/common");
|
|
7
7
|
const gg_auth_module_1 = require("../gg-auth/gg-auth.module");
|
|
8
|
-
const
|
|
8
|
+
const gg_redis_1 = require("../gg-redis");
|
|
9
9
|
const gg_cache_module_1 = require("../gg-cache/gg-cache.module");
|
|
10
10
|
const gg_cls_1 = require("../gg-cls");
|
|
11
11
|
const gg_config_1 = require("../gg-config");
|
|
@@ -23,7 +23,7 @@ let GgCoreModule = GgCoreModule_1 = class GgCoreModule {
|
|
|
23
23
|
static forRootAsync(options) {
|
|
24
24
|
const imports = [
|
|
25
25
|
/** Config module with basic app configurations */
|
|
26
|
-
gg_config_1.GgConfigModule.forRoot({ configs: [gg_config_1.appConfig,
|
|
26
|
+
gg_config_1.GgConfigModule.forRoot({ configs: [gg_config_1.appConfig, gg_redis_1.redisConfig, gg_micro_1.rmqConfig, ...(options.loadConfigs ?? [])] }),
|
|
27
27
|
/** AsyncContext module to avoid DI three rebuilding */
|
|
28
28
|
gg_cls_1.GgClsModule.forRoot(),
|
|
29
29
|
/** Pino logger module */
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createRedisClient = exports.redisConfig = void 0;
|
|
4
|
+
var redis_config_1 = require("./redis.config");
|
|
5
|
+
Object.defineProperty(exports, "redisConfig", { enumerable: true, get: function () { return redis_config_1.redisConfig; } });
|
|
6
|
+
var redis_client_factory_1 = require("./redis-client.factory");
|
|
7
|
+
Object.defineProperty(exports, "createRedisClient", { enumerable: true, get: function () { return redis_client_factory_1.createRedisClient; } });
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../libs/gg-core/src/gg-redis/index.ts"],"names":[],"mappings":";;;AAAA,+CAA6D;AAApD,2GAAA,WAAW,OAAA;AACpB,+DAA2D;AAAlD,yHAAA,iBAAiB,OAAA"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ConfigType } from '@nestjs/config';
|
|
2
|
+
import { default as Redis, RedisOptions } from 'ioredis';
|
|
3
|
+
import { redisConfig } from './redis.config';
|
|
4
|
+
type RedisConfigType = ConfigType<typeof redisConfig>;
|
|
5
|
+
export declare function createRedisClient(config: RedisConfigType, options?: Partial<RedisOptions>): Redis;
|
|
6
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createRedisClient = void 0;
|
|
4
|
+
const ioredis_1 = require("ioredis");
|
|
5
|
+
function createRedisClient(config, options) {
|
|
6
|
+
if (config.mode === 'sentinel') {
|
|
7
|
+
const sentinels = config.sentinelHosts
|
|
8
|
+
.split(';')
|
|
9
|
+
.map((entry) => entry.trim())
|
|
10
|
+
.filter(Boolean)
|
|
11
|
+
.map((entry) => {
|
|
12
|
+
const [host, port] = entry.split(':');
|
|
13
|
+
return { host, port: Number(port) || 26379 };
|
|
14
|
+
});
|
|
15
|
+
if (sentinels.length === 0) {
|
|
16
|
+
throw new Error('REDIS_SENTINEL_HOSTS is empty or invalid after parsing');
|
|
17
|
+
}
|
|
18
|
+
return new ioredis_1.default({
|
|
19
|
+
sentinels,
|
|
20
|
+
name: config.sentinelMaster,
|
|
21
|
+
...options,
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
return new ioredis_1.default({
|
|
25
|
+
host: config.host,
|
|
26
|
+
port: config.port,
|
|
27
|
+
...options,
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
exports.createRedisClient = createRedisClient;
|
|
31
|
+
//# sourceMappingURL=redis-client.factory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"redis-client.factory.js","sourceRoot":"","sources":["../../../../../libs/gg-core/src/gg-redis/redis-client.factory.ts"],"names":[],"mappings":";;;AACA,qCAAyD;AAKzD,SAAgB,iBAAiB,CAAC,MAAuB,EAAE,OAA+B;IACxF,IAAI,MAAM,CAAC,IAAI,KAAK,UAAU,EAAE,CAAC;QAC/B,MAAM,SAAS,GAAG,MAAM,CAAC,aAAa;aACnC,KAAK,CAAC,GAAG,CAAC;aACV,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC;aAC5B,MAAM,CAAC,OAAO,CAAC;aACf,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE;YACb,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YACtC,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,IAAI,KAAK,EAAE,CAAC;QAC/C,CAAC,CAAC,CAAC;QAEL,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC3B,MAAM,IAAI,KAAK,CAAC,wDAAwD,CAAC,CAAC;QAC5E,CAAC;QAED,OAAO,IAAI,iBAAK,CAAC;YACf,SAAS;YACT,IAAI,EAAE,MAAM,CAAC,cAAc;YAC3B,GAAG,OAAO;SACX,CAAC,CAAC;IACL,CAAC;IAED,OAAO,IAAI,iBAAK,CAAC;QACf,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,GAAG,OAAO;KACX,CAAC,CAAC;AACL,CAAC;AA3BD,8CA2BC"}
|
|
@@ -1,6 +1,10 @@
|
|
|
1
|
+
export type RedisMode = 'standalone' | 'sentinel';
|
|
1
2
|
declare class RedisConfig {
|
|
3
|
+
readonly mode: RedisMode;
|
|
2
4
|
readonly host: string;
|
|
3
5
|
readonly port: number;
|
|
6
|
+
readonly sentinelHosts: string;
|
|
7
|
+
readonly sentinelMaster: string;
|
|
4
8
|
}
|
|
5
9
|
export declare const redisConfig: (() => Promise<RedisConfig>) & import("@nestjs/config").ConfigFactoryKeyHost<Promise<RedisConfig>>;
|
|
6
10
|
export {};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.redisConfig = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const class_validator_1 = require("class-validator");
|
|
6
|
+
const lodash_1 = require("lodash");
|
|
7
|
+
const gg_config_1 = require("../gg-config");
|
|
8
|
+
class RedisConfig {
|
|
9
|
+
constructor() {
|
|
10
|
+
this.mode = (0, lodash_1.get)(process.env, 'REDIS_MODE', 'standalone');
|
|
11
|
+
this.host = (0, lodash_1.get)(process.env, 'REDIS_HOST');
|
|
12
|
+
this.port = Number((0, lodash_1.get)(process.env, 'REDIS_PORT', 6379));
|
|
13
|
+
this.sentinelHosts = (0, lodash_1.get)(process.env, 'REDIS_SENTINEL_HOSTS');
|
|
14
|
+
this.sentinelMaster = (0, lodash_1.get)(process.env, 'REDIS_SENTINEL_MASTER');
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
tslib_1.__decorate([
|
|
18
|
+
(0, class_validator_1.IsOptional)(),
|
|
19
|
+
(0, class_validator_1.IsIn)(['standalone', 'sentinel']),
|
|
20
|
+
tslib_1.__metadata("design:type", String)
|
|
21
|
+
], RedisConfig.prototype, "mode", void 0);
|
|
22
|
+
tslib_1.__decorate([
|
|
23
|
+
(0, class_validator_1.ValidateIf)((o) => o.mode === 'standalone'),
|
|
24
|
+
(0, class_validator_1.IsNotEmpty)(),
|
|
25
|
+
(0, class_validator_1.IsString)(),
|
|
26
|
+
tslib_1.__metadata("design:type", String)
|
|
27
|
+
], RedisConfig.prototype, "host", void 0);
|
|
28
|
+
tslib_1.__decorate([
|
|
29
|
+
(0, class_validator_1.ValidateIf)((o) => o.mode === 'standalone'),
|
|
30
|
+
(0, class_validator_1.IsNotEmpty)(),
|
|
31
|
+
tslib_1.__metadata("design:type", Number)
|
|
32
|
+
], RedisConfig.prototype, "port", void 0);
|
|
33
|
+
tslib_1.__decorate([
|
|
34
|
+
(0, class_validator_1.ValidateIf)((o) => o.mode === 'sentinel'),
|
|
35
|
+
(0, class_validator_1.IsNotEmpty)(),
|
|
36
|
+
(0, class_validator_1.IsString)(),
|
|
37
|
+
tslib_1.__metadata("design:type", String)
|
|
38
|
+
], RedisConfig.prototype, "sentinelHosts", void 0);
|
|
39
|
+
tslib_1.__decorate([
|
|
40
|
+
(0, class_validator_1.ValidateIf)((o) => o.mode === 'sentinel'),
|
|
41
|
+
(0, class_validator_1.IsNotEmpty)(),
|
|
42
|
+
(0, class_validator_1.IsString)(),
|
|
43
|
+
tslib_1.__metadata("design:type", String)
|
|
44
|
+
], RedisConfig.prototype, "sentinelMaster", void 0);
|
|
45
|
+
exports.redisConfig = (0, gg_config_1.registerConfig)(RedisConfig);
|
|
46
|
+
//# sourceMappingURL=redis.config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"redis.config.js","sourceRoot":"","sources":["../../../../../libs/gg-core/src/gg-redis/redis.config.ts"],"names":[],"mappings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0BAAQ,GAAE;;mDACwE;AAGxE,QAAA,WAAW,GAAG,IAAA,0BAAc,EAAC,WAAW,CAAC,CAAC"}
|
|
@@ -1,17 +1,45 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var RedlockModule_1;
|
|
2
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
4
|
exports.RedlockModule = void 0;
|
|
4
5
|
const tslib_1 = require("tslib");
|
|
5
6
|
const common_1 = require("@nestjs/common");
|
|
7
|
+
const gg_redis_1 = require("../gg-redis");
|
|
6
8
|
const redlock_options_1 = require("./redlock.options");
|
|
7
9
|
const redlock_service_1 = require("./redlock.service");
|
|
8
|
-
let RedlockModule = class RedlockModule
|
|
10
|
+
let RedlockModule = RedlockModule_1 = class RedlockModule {
|
|
11
|
+
static register() {
|
|
12
|
+
return {
|
|
13
|
+
module: RedlockModule_1,
|
|
14
|
+
providers: [
|
|
15
|
+
{
|
|
16
|
+
provide: redlock_options_1.REDIS_LOCK_CLIENT,
|
|
17
|
+
inject: [gg_redis_1.redisConfig.KEY],
|
|
18
|
+
useFactory: (conf) => {
|
|
19
|
+
const client = (0, gg_redis_1.createRedisClient)(conf, {
|
|
20
|
+
enableOfflineQueue: false,
|
|
21
|
+
enableReadyCheck: false,
|
|
22
|
+
enableAutoPipelining: false,
|
|
23
|
+
autoResendUnfulfilledCommands: true,
|
|
24
|
+
commandTimeout: 6000,
|
|
25
|
+
socketTimeout: 10000,
|
|
26
|
+
connectTimeout: 5000,
|
|
27
|
+
keepAlive: 1,
|
|
28
|
+
retryStrategy: (times) => Math.min(times * 50, 1000),
|
|
29
|
+
reconnectOnError: (err) => err.message.includes('READONLY') || err.message.includes('ECONNRESET'),
|
|
30
|
+
});
|
|
31
|
+
client.on('error', (err) => console.error('Redis lock client error', err));
|
|
32
|
+
return client;
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
redlock_service_1.RedlockService,
|
|
36
|
+
],
|
|
37
|
+
exports: [redlock_service_1.RedlockService],
|
|
38
|
+
};
|
|
39
|
+
}
|
|
9
40
|
};
|
|
10
41
|
exports.RedlockModule = RedlockModule;
|
|
11
|
-
exports.RedlockModule = RedlockModule = tslib_1.__decorate([
|
|
12
|
-
(0, common_1.Module)({
|
|
13
|
-
providers: [redlock_service_1.RedlockService],
|
|
14
|
-
exports: [redlock_service_1.RedlockService],
|
|
15
|
-
})
|
|
42
|
+
exports.RedlockModule = RedlockModule = RedlockModule_1 = tslib_1.__decorate([
|
|
43
|
+
(0, common_1.Module)({})
|
|
16
44
|
], RedlockModule);
|
|
17
45
|
//# sourceMappingURL=redlock.module.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"redlock.module.js","sourceRoot":"","sources":["../../../../../libs/gg-core/src/gg-redlock/redlock.module.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"redlock.module.js","sourceRoot":"","sources":["../../../../../libs/gg-core/src/gg-redlock/redlock.module.ts"],"names":[],"mappings":";;;;;AAAA,2CAAuD;AAEvD,0CAA6D;AAC7D,uDAAsD;AACtD,uDAAmD;AAG5C,IAAM,aAAa,qBAAnB,MAAM,aAAa;IACjB,MAAM,CAAC,QAAQ;QACpB,OAAO;YACL,MAAM,EAAE,eAAa;YACrB,SAAS,EAAE;gBACT;oBACE,OAAO,EAAE,mCAAiB;oBAC1B,MAAM,EAAE,CAAC,sBAAW,CAAC,GAAG,CAAC;oBACzB,UAAU,EAAE,CAAC,IAAoC,EAAE,EAAE;wBACnD,MAAM,MAAM,GAAG,IAAA,4BAAiB,EAAC,IAAI,EAAE;4BACrC,kBAAkB,EAAE,KAAK;4BACzB,gBAAgB,EAAE,KAAK;4BACvB,oBAAoB,EAAE,KAAK;4BAC3B,6BAA6B,EAAE,IAAI;4BACnC,cAAc,EAAE,IAAI;4BACpB,aAAa,EAAE,KAAK;4BACpB,cAAc,EAAE,IAAI;4BACpB,SAAS,EAAE,CAAC;4BACZ,aAAa,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,GAAG,EAAE,EAAE,IAAI,CAAC;4BACpD,gBAAgB,EAAE,CAAC,GAAG,EAAE,EAAE,CACxB,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAC,IAAI,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAC;yBACzE,CAAC,CAAC;wBACH,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,yBAAyB,EAAE,GAAG,CAAC,CAAC,CAAC;wBAC3E,OAAO,MAAM,CAAC;oBAChB,CAAC;iBACF;gBACD,gCAAc;aACf;YACD,OAAO,EAAE,CAAC,gCAAc,CAAC;SAC1B,CAAC;IACJ,CAAC;CACF,CAAA;AA/BY,sCAAa;wBAAb,aAAa;IADzB,IAAA,eAAM,EAAC,EAAE,CAAC;GACE,aAAa,CA+BzB"}
|
|
@@ -1,8 +1 @@
|
|
|
1
|
-
export
|
|
2
|
-
export declare const ConfigurableModuleClass: import("@nestjs/common").ConfigurableModuleCls<RedlockOptions, "register", "create", {}>, MODULE_OPTIONS_TOKEN: string | symbol, OPTIONS_TYPE: RedlockOptions & Partial<{}>, ASYNC_OPTIONS_TYPE: import("@nestjs/common").ConfigurableModuleAsyncOptions<RedlockOptions, "create"> & Partial<{}>;
|
|
3
|
-
export declare const RedlockOpts: {
|
|
4
|
-
MODULE_OPTIONS_TOKEN: string | symbol;
|
|
5
|
-
OPTIONS_TYPE: RedlockOptions & Partial<{}>;
|
|
6
|
-
ASYNC_OPTIONS_TYPE: import("@nestjs/common").ConfigurableModuleAsyncOptions<RedlockOptions, "create"> & Partial<{}>;
|
|
7
|
-
ConfigurableModuleClass: import("@nestjs/common").ConfigurableModuleCls<RedlockOptions, "register", "create", {}>;
|
|
8
|
-
};
|
|
1
|
+
export declare const REDIS_LOCK_CLIENT: unique symbol;
|
|
@@ -1,13 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var _a;
|
|
3
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.
|
|
5
|
-
|
|
6
|
-
_a = new common_1.ConfigurableModuleBuilder({ moduleName: 'RedlockModule' }).setClassMethodName('register').build(), exports.ConfigurableModuleClass = _a.ConfigurableModuleClass, exports.MODULE_OPTIONS_TOKEN = _a.MODULE_OPTIONS_TOKEN, exports.OPTIONS_TYPE = _a.OPTIONS_TYPE, exports.ASYNC_OPTIONS_TYPE = _a.ASYNC_OPTIONS_TYPE;
|
|
7
|
-
exports.RedlockOpts = {
|
|
8
|
-
MODULE_OPTIONS_TOKEN: exports.MODULE_OPTIONS_TOKEN,
|
|
9
|
-
OPTIONS_TYPE: exports.OPTIONS_TYPE,
|
|
10
|
-
ASYNC_OPTIONS_TYPE: exports.ASYNC_OPTIONS_TYPE,
|
|
11
|
-
ConfigurableModuleClass: exports.ConfigurableModuleClass,
|
|
12
|
-
};
|
|
3
|
+
exports.REDIS_LOCK_CLIENT = void 0;
|
|
4
|
+
exports.REDIS_LOCK_CLIENT = Symbol('REDIS_LOCK_CLIENT');
|
|
13
5
|
//# sourceMappingURL=redlock.options.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"redlock.options.js","sourceRoot":"","sources":["../../../../../libs/gg-core/src/gg-redlock/redlock.options.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"redlock.options.js","sourceRoot":"","sources":["../../../../../libs/gg-core/src/gg-redlock/redlock.options.ts"],"names":[],"mappings":";;;AAAa,QAAA,iBAAiB,GAAG,MAAM,CAAC,mBAAmB,CAAC,CAAC"}
|
|
@@ -1,20 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
export interface LockOptions {
|
|
4
|
-
ttl?: number;
|
|
5
|
-
retryInterval?: number;
|
|
6
|
-
maxAttempts?: number;
|
|
7
|
-
}
|
|
1
|
+
import { default as Redis } from 'ioredis';
|
|
2
|
+
import { Mutex } from 'redis-semaphore';
|
|
8
3
|
export declare class RedlockService {
|
|
9
|
-
private readonly
|
|
4
|
+
private readonly client;
|
|
10
5
|
private readonly logger;
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
protected
|
|
18
|
-
protected
|
|
19
|
-
protected releaseOne(mutex: RedlockMutex): Promise<void>;
|
|
6
|
+
constructor(client: Redis);
|
|
7
|
+
getLock(resource: string, identifier?: string): Mutex;
|
|
8
|
+
acquire(resources: Mutex[]): Promise<Mutex[]>;
|
|
9
|
+
tryAcquire(resources: Mutex[]): Promise<boolean[]>;
|
|
10
|
+
release(resources: Mutex[]): Promise<void[]>;
|
|
11
|
+
protected tryAcquireOne(mutex: Mutex): Promise<boolean>;
|
|
12
|
+
protected acquireOne(mutex: Mutex): Promise<Mutex>;
|
|
13
|
+
protected releaseOne(mutex: Mutex): Promise<void>;
|
|
20
14
|
}
|
|
@@ -6,38 +6,20 @@ const tslib_1 = require("tslib");
|
|
|
6
6
|
const common_1 = require("@nestjs/common");
|
|
7
7
|
const ioredis_1 = require("ioredis");
|
|
8
8
|
const lodash_1 = require("lodash");
|
|
9
|
-
const luxon_1 = require("luxon");
|
|
10
9
|
const redis_semaphore_1 = require("redis-semaphore");
|
|
11
10
|
const redlock_options_1 = require("./redlock.options");
|
|
12
11
|
let RedlockService = RedlockService_1 = class RedlockService {
|
|
13
|
-
constructor(
|
|
14
|
-
this.
|
|
12
|
+
constructor(client) {
|
|
13
|
+
this.client = client;
|
|
15
14
|
this.logger = new common_1.Logger(RedlockService_1.name);
|
|
16
|
-
this.clients = this.options.map((host) => new ioredis_1.default(`redis://${host}`, {
|
|
17
|
-
autoResubscribe: true,
|
|
18
|
-
// increase retry to 1 sec
|
|
19
|
-
retryStrategy: (times) => Math.min(times * 50, 1000),
|
|
20
|
-
// reconnect on temp troubles
|
|
21
|
-
reconnectOnError: (err) => err.message.includes('READONLY') || err.message.includes('ECONNRESET'),
|
|
22
|
-
commandTimeout: 6000,
|
|
23
|
-
socketTimeout: 10000,
|
|
24
|
-
connectTimeout: 5000,
|
|
25
|
-
keepAlive: 1,
|
|
26
|
-
autoResendUnfulfilledCommands: true,
|
|
27
|
-
enableOfflineQueue: false,
|
|
28
|
-
enableReadyCheck: false,
|
|
29
|
-
enableAutoPipelining: false,
|
|
30
|
-
}));
|
|
31
15
|
}
|
|
32
16
|
getLock(resource, identifier) {
|
|
33
|
-
return new redis_semaphore_1.
|
|
17
|
+
return new redis_semaphore_1.Mutex(this.client, resource, {
|
|
34
18
|
acquireAttemptsLimit: 2000,
|
|
35
|
-
retryInterval:
|
|
36
|
-
acquireTimeout:
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
...(identifier && { identifier }),
|
|
40
|
-
...(identifier && { acquiredExternally: true }),
|
|
19
|
+
retryInterval: 200,
|
|
20
|
+
acquireTimeout: 100_000,
|
|
21
|
+
lockTimeout: 101_000,
|
|
22
|
+
...(identifier && { identifier, acquiredExternally: true }),
|
|
41
23
|
refreshInterval: 0,
|
|
42
24
|
});
|
|
43
25
|
}
|
|
@@ -63,7 +45,7 @@ let RedlockService = RedlockService_1 = class RedlockService {
|
|
|
63
45
|
await mutex.acquire();
|
|
64
46
|
}
|
|
65
47
|
catch (e) {
|
|
66
|
-
if (!(e instanceof redis_semaphore_1.TimeoutError)
|
|
48
|
+
if (!(e instanceof redis_semaphore_1.TimeoutError) && !(e instanceof redis_semaphore_1.LostLockError))
|
|
67
49
|
throw e;
|
|
68
50
|
if (e instanceof redis_semaphore_1.TimeoutError) {
|
|
69
51
|
this.logger.warn({
|
|
@@ -74,13 +56,12 @@ let RedlockService = RedlockService_1 = class RedlockService {
|
|
|
74
56
|
throw new common_1.HttpException({ message: 'Resource locked' }, 423);
|
|
75
57
|
}
|
|
76
58
|
if (e instanceof redis_semaphore_1.LostLockError) {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
}
|
|
59
|
+
this.logger.error({
|
|
60
|
+
msg: `Lock lost`,
|
|
61
|
+
resource: (0, lodash_1.get)(mutex, '_key', mutex.identifier),
|
|
62
|
+
identifier: mutex.identifier,
|
|
63
|
+
});
|
|
64
|
+
throw new common_1.HttpException({ message: 'Resource lock lost' }, 423);
|
|
84
65
|
}
|
|
85
66
|
}
|
|
86
67
|
return mutex;
|
|
@@ -97,7 +78,7 @@ let RedlockService = RedlockService_1 = class RedlockService {
|
|
|
97
78
|
exports.RedlockService = RedlockService;
|
|
98
79
|
exports.RedlockService = RedlockService = RedlockService_1 = tslib_1.__decorate([
|
|
99
80
|
(0, common_1.Injectable)(),
|
|
100
|
-
tslib_1.__param(0, (0, common_1.Inject)(redlock_options_1.
|
|
101
|
-
tslib_1.__metadata("design:paramtypes", [
|
|
81
|
+
tslib_1.__param(0, (0, common_1.Inject)(redlock_options_1.REDIS_LOCK_CLIENT)),
|
|
82
|
+
tslib_1.__metadata("design:paramtypes", [ioredis_1.default])
|
|
102
83
|
], RedlockService);
|
|
103
84
|
//# sourceMappingURL=redlock.service.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"redlock.service.js","sourceRoot":"","sources":["../../../../../libs/gg-core/src/gg-redlock/redlock.service.ts"],"names":[],"mappings":";;;;;AAAA,2CAA2E;AAC3E,qCAA2C;AAC3C,mCAA6B;AAC7B,
|
|
1
|
+
{"version":3,"file":"redlock.service.js","sourceRoot":"","sources":["../../../../../libs/gg-core/src/gg-redlock/redlock.service.ts"],"names":[],"mappings":";;;;;AAAA,2CAA2E;AAC3E,qCAA2C;AAC3C,mCAA6B;AAC7B,qDAAqE;AACrE,uDAAsD;AAG/C,IAAM,cAAc,sBAApB,MAAM,cAAc;IAGzB,YAA8C,MAA8B;QAAb,WAAM,GAAN,MAAM,CAAO;QAF3D,WAAM,GAAG,IAAI,eAAM,CAAC,gBAAc,CAAC,IAAI,CA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AO,KAAK,CAAC,OAAO,EAAE,CAAC;IACzB,CAAC;CACF,CAAA;AA7EY,wCAAc;yBAAd,cAAc;IAD1B,IAAA,mBAAU,GAAE;IAIS,mBAAA,IAAA,eAAM,EAAC,mCAAiB,CAAC,CAAA;6CAA0B,iBAAK;GAHjE,cAAc,CA6E1B"}
|
package/src/index.d.ts
CHANGED
package/src/index.js
CHANGED
|
@@ -11,5 +11,6 @@ tslib_1.__exportStar(require("./gg-gcp"), exports);
|
|
|
11
11
|
tslib_1.__exportStar(require("./gg-kernel"), exports);
|
|
12
12
|
tslib_1.__exportStar(require("./gg-metrics"), exports);
|
|
13
13
|
tslib_1.__exportStar(require("./gg-micro"), exports);
|
|
14
|
+
tslib_1.__exportStar(require("./gg-redis"), exports);
|
|
14
15
|
tslib_1.__exportStar(require("./gg-redlock"), exports);
|
|
15
16
|
//# sourceMappingURL=index.js.map
|
package/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../libs/gg-core/src/index.ts"],"names":[],"mappings":";;;AAAA,oDAA0B;AAC1B,qDAA2B;AAC3B,sDAA4B;AAC5B,oDAA0B;AAC1B,wDAA8B;AAC9B,sDAA4B;AAC5B,mDAAyB;AACzB,sDAA4B;AAC5B,uDAA6B;AAC7B,qDAA2B;AAC3B,uDAA6B"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../libs/gg-core/src/index.ts"],"names":[],"mappings":";;;AAAA,oDAA0B;AAC1B,qDAA2B;AAC3B,sDAA4B;AAC5B,oDAA0B;AAC1B,wDAA8B;AAC9B,sDAA4B;AAC5B,mDAAyB;AACzB,sDAA4B;AAC5B,uDAA6B;AAC7B,qDAA2B;AAC3B,qDAA2B;AAC3B,uDAA6B"}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.redisConfig = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const class_validator_1 = require("class-validator");
|
|
6
|
-
const lodash_1 = require("lodash");
|
|
7
|
-
const gg_config_1 = require("../gg-config");
|
|
8
|
-
class RedisConfig {
|
|
9
|
-
constructor() {
|
|
10
|
-
this.host = (0, lodash_1.get)(process.env, 'REDIS_HOST');
|
|
11
|
-
this.port = (0, lodash_1.get)(process.env, 'REDIS_PORT', 6349);
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
tslib_1.__decorate([
|
|
15
|
-
(0, class_validator_1.IsNotEmpty)(),
|
|
16
|
-
tslib_1.__metadata("design:type", String)
|
|
17
|
-
], RedisConfig.prototype, "host", void 0);
|
|
18
|
-
tslib_1.__decorate([
|
|
19
|
-
(0, class_validator_1.IsNotEmpty)(),
|
|
20
|
-
tslib_1.__metadata("design:type", Object)
|
|
21
|
-
], RedisConfig.prototype, "port", void 0);
|
|
22
|
-
exports.redisConfig = (0, gg_config_1.registerConfig)(RedisConfig);
|
|
23
|
-
//# sourceMappingURL=redis.config.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"redis.config.js","sourceRoot":"","sources":["../../../../../libs/gg-core/src/gg-cache/redis.config.ts"],"names":[],"mappings":";;;;AAAA,qDAA6C;AAC7C,mCAA6B;AAC7B,4CAA8C;AAE9C,MAAM,WAAW;IAAjB;QAEkB,SAAI,GAAW,IAAA,YAAG,EAAC,OAAO,CAAC,GAAG,EAAE,YAAY,CAAC,CAAC;QAG9C,SAAI,GAAG,IAAA,YAAG,EAAC,OAAO,CAAC,GAAG,EAAE,YAAY,EAAE,IAAI,CAAW,CAAC;IACxE,CAAC;CAAA;AAJiB;IADf,IAAA,4BAAU,GAAE;;yCACiD;AAG9C;IADf,IAAA,4BAAU,GAAE;;yCACyD;AAG3D,QAAA,WAAW,GAAG,IAAA,0BAAc,EAAC,WAAW,CAAC,CAAC"}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.redlockConfig = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const class_validator_1 = require("class-validator");
|
|
6
|
-
const lodash_1 = require("lodash");
|
|
7
|
-
const process = require("node:process");
|
|
8
|
-
const gg_config_1 = require("../gg-config");
|
|
9
|
-
class RedlockConfig {
|
|
10
|
-
constructor() {
|
|
11
|
-
this.hosts = (0, lodash_1.get)(process.env, 'REDLOCK_HOSTS', '').split(';');
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
tslib_1.__decorate([
|
|
15
|
-
(0, class_validator_1.IsArray)(),
|
|
16
|
-
(0, class_validator_1.ArrayMinSize)(3),
|
|
17
|
-
(0, class_validator_1.IsString)({ each: true }),
|
|
18
|
-
(0, class_validator_1.IsOptional)(),
|
|
19
|
-
tslib_1.__metadata("design:type", Array)
|
|
20
|
-
], RedlockConfig.prototype, "hosts", void 0);
|
|
21
|
-
exports.redlockConfig = (0, gg_config_1.registerConfig)(RedlockConfig);
|
|
22
|
-
//# sourceMappingURL=redlock.config.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"redlock.config.js","sourceRoot":"","sources":["../../../../../libs/gg-core/src/gg-redlock/redlock.config.ts"],"names":[],"mappings":";;;;AAAA,qDAA8E;AAC9E,mCAA6B;AAC7B,wCAAwC;AACxC,4CAA8C;AAE9C,MAAM,aAAa;IAAnB;QAKkB,UAAK,GAAa,IAAA,YAAG,EAAC,OAAO,CAAC,GAAG,EAAE,eAAe,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACrF,CAAC;CAAA;AADiB;IAJf,IAAA,yBAAO,GAAE;IACT,IAAA,8BAAY,EAAC,CAAC,CAAC;IACf,IAAA,0BAAQ,EAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;IACxB,IAAA,4BAAU,GAAE;;4CACsE;AAGxE,QAAA,aAAa,GAAG,IAAA,0BAAc,EAAC,aAAa,CAAC,CAAC"}
|