@samet-it/be-redis-common 1.3.1 → 1.3.3
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/channel/index.d.ts +3 -3
- package/dist/channel/index.js +3 -19
- package/dist/channel/index.types.d.ts +2 -3
- package/dist/channel/index.types.js +1 -2
- package/dist/channel/redis-direct.channel.d.ts +4 -5
- package/dist/channel/redis-direct.channel.js +6 -8
- package/dist/channel/redis.channel.d.ts +3 -4
- package/dist/channel/redis.channel.js +141 -170
- package/dist/config/index.d.ts +2 -2
- package/dist/config/index.js +2 -18
- package/dist/config/index.types.d.ts +1 -1
- package/dist/config/index.types.js +1 -2
- package/dist/config/redis-common.config.d.ts +2 -2
- package/dist/config/redis-common.config.js +2 -5
- package/dist/connection/index.d.ts +4 -4
- package/dist/connection/index.js +4 -20
- package/dist/connection/index.types.d.ts +2 -3
- package/dist/connection/index.types.js +1 -2
- package/dist/connection/redis-connection.fn.d.ts +1 -1
- package/dist/connection/redis-connection.fn.js +3 -6
- package/dist/connection/redis-direct.connection.d.ts +4 -5
- package/dist/connection/redis-direct.connection.js +8 -10
- package/dist/connection/redis.connection.d.ts +1 -1
- package/dist/connection/redis.connection.js +131 -181
- package/dist/index.d.ts +5 -3
- package/dist/index.foretell.d.ts +1 -0
- package/dist/index.foretell.js +8 -0
- package/dist/index.js +5 -19
- package/dist/index.loader.d.ts +1 -0
- package/dist/index.loader.js +10 -0
- package/dist/internal.d.ts +1 -0
- package/dist/internal.js +2 -0
- package/package.json +5 -7
- package/dist/assets/.gitkeep +0 -0
package/dist/channel/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from './index.types';
|
|
2
|
-
export * from './redis.channel';
|
|
3
|
-
export * from './redis-direct.channel';
|
|
1
|
+
export * from './index.types.js';
|
|
2
|
+
export * from './redis.channel.js';
|
|
3
|
+
export * from './redis-direct.channel.js';
|
package/dist/channel/index.js
CHANGED
|
@@ -1,19 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./index.types"), exports);
|
|
18
|
-
__exportStar(require("./redis.channel"), exports);
|
|
19
|
-
__exportStar(require("./redis-direct.channel"), exports);
|
|
1
|
+
export * from './index.types.js';
|
|
2
|
+
export * from './redis.channel.js';
|
|
3
|
+
export * from './redis-direct.channel.js';
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { RedisConnectionLike } from "../connection";
|
|
1
|
+
import { RedisConnectionLike } from "../connection/index.js";
|
|
2
2
|
import { CacheChannelLike, CacheChannelOpt, CacheChannelProps, CacheExecOpt } from "@samet-it/be-cache-common";
|
|
3
|
-
import { Entity } from "@samet-it/be-base-common";
|
|
3
|
+
import { Entity, KeyValue } from "@samet-it/be-base-common";
|
|
4
4
|
import { RedisClientType } from "redis";
|
|
5
|
-
import { KeyValue } from "@leyyo/common";
|
|
6
5
|
/**
|
|
7
6
|
* Redis channel interface
|
|
8
7
|
*
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { RedisChannel } from "./redis.channel";
|
|
2
|
-
import { type Entity } from "@samet-it/be-base-common";
|
|
3
|
-
import { RedisConnectionLike } from "../connection";
|
|
4
|
-
import { RedisDirectChannelOpt } from "./index.types";
|
|
5
|
-
import { KeyValue } from "@leyyo/common";
|
|
1
|
+
import { RedisChannel } from "./redis.channel.js";
|
|
2
|
+
import { type Entity, KeyValue } from "@samet-it/be-base-common";
|
|
3
|
+
import { RedisConnectionLike } from "../connection/index.js";
|
|
4
|
+
import { RedisDirectChannelOpt } from "./index.types.js";
|
|
6
5
|
/**
|
|
7
6
|
* Redis direct channel class
|
|
8
7
|
*
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const redis_channel_1 = require("./redis.channel");
|
|
5
|
-
const be_base_common_1 = require("@samet-it/be-base-common");
|
|
1
|
+
import { RedisChannel } from "./redis.channel.js";
|
|
2
|
+
import { logCommon, setFqn } from "@samet-it/be-base-common";
|
|
3
|
+
import { FQN } from "../internal.js";
|
|
6
4
|
/**
|
|
7
5
|
* Redis direct channel class
|
|
8
6
|
*
|
|
@@ -10,7 +8,7 @@ const be_base_common_1 = require("@samet-it/be-base-common");
|
|
|
10
8
|
* - 0-`ENT`: entity {@link Entity}
|
|
11
9
|
* - 1-`ID`: id type {@link KeyValue}
|
|
12
10
|
* */
|
|
13
|
-
class RedisDirectChannel extends
|
|
11
|
+
export class RedisDirectChannel extends RedisChannel {
|
|
14
12
|
/**
|
|
15
13
|
* Constructor
|
|
16
14
|
*
|
|
@@ -19,7 +17,7 @@ class RedisDirectChannel extends redis_channel_1.RedisChannel {
|
|
|
19
17
|
* */
|
|
20
18
|
constructor(conn, opt) {
|
|
21
19
|
super(conn, opt);
|
|
22
|
-
this.logger =
|
|
20
|
+
this.logger = logCommon.of(`RedisDirect${opt.name ? '#' + opt.name : ''}`);
|
|
23
21
|
}
|
|
24
22
|
}
|
|
25
|
-
|
|
23
|
+
setFqn(RedisDirectChannel, FQN);
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { RedisConnectionLike } from "../connection";
|
|
2
|
-
import { RedisChannelLike, RedisChannelOpt, RedisChannelProps, RedisExecOpt } from "./index.types";
|
|
3
|
-
import { Entity } from "@samet-it/be-base-common";
|
|
1
|
+
import { RedisConnectionLike } from "../connection/index.js";
|
|
2
|
+
import { RedisChannelLike, RedisChannelOpt, RedisChannelProps, RedisExecOpt } from "./index.types.js";
|
|
3
|
+
import { Entity, KeyValue } from "@samet-it/be-base-common";
|
|
4
4
|
import { CacheChannel } from "@samet-it/be-cache-common";
|
|
5
|
-
import { KeyValue } from "@leyyo/common";
|
|
6
5
|
import { RedisClientType } from "redis";
|
|
7
6
|
/**
|
|
8
7
|
* Redis abstract channel class
|
|
@@ -1,16 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.RedisChannel = void 0;
|
|
13
|
-
const be_cache_common_1 = require("@samet-it/be-cache-common");
|
|
1
|
+
import { setFqn } from "@samet-it/be-base-common";
|
|
2
|
+
import { CacheChannel } from "@samet-it/be-cache-common";
|
|
3
|
+
import { FQN } from "../internal.js";
|
|
14
4
|
// noinspection JSUnusedGlobalSymbols
|
|
15
5
|
/**
|
|
16
6
|
* Redis abstract channel class
|
|
@@ -19,7 +9,7 @@ const be_cache_common_1 = require("@samet-it/be-cache-common");
|
|
|
19
9
|
* - 0-`ENT`: entity {@link Entity}
|
|
20
10
|
* - 1-`ID`: id type {@link KeyValue}
|
|
21
11
|
* */
|
|
22
|
-
class RedisChannel extends
|
|
12
|
+
export class RedisChannel extends CacheChannel {
|
|
23
13
|
// endregion protected-property
|
|
24
14
|
/**
|
|
25
15
|
* Constructor
|
|
@@ -42,186 +32,167 @@ class RedisChannel extends be_cache_common_1.CacheChannel {
|
|
|
42
32
|
// endregion getter
|
|
43
33
|
// region native-calls
|
|
44
34
|
/** @inheritDoc */
|
|
45
|
-
$get(path, opt) {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
if (typeof path !== 'string') {
|
|
51
|
-
return undefined;
|
|
52
|
-
}
|
|
53
|
-
try {
|
|
54
|
-
return yield this.client.get(path);
|
|
55
|
-
}
|
|
56
|
-
catch (e) {
|
|
57
|
-
this.checkError(e, { name: 'GET', method: '$get' });
|
|
58
|
-
}
|
|
35
|
+
async $get(path, opt) {
|
|
36
|
+
if (!this.isConnected) {
|
|
37
|
+
return undefined;
|
|
38
|
+
}
|
|
39
|
+
if (typeof path !== 'string') {
|
|
59
40
|
return undefined;
|
|
60
|
-
}
|
|
41
|
+
}
|
|
42
|
+
try {
|
|
43
|
+
return await this.client.get(path);
|
|
44
|
+
}
|
|
45
|
+
catch (e) {
|
|
46
|
+
this.checkError(e, { name: 'GET', method: '$get' });
|
|
47
|
+
}
|
|
48
|
+
return undefined;
|
|
61
49
|
}
|
|
62
50
|
/** @inheritDoc */
|
|
63
|
-
$getMore(paths, _opt) {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
if (paths.length == 1) {
|
|
72
|
-
try {
|
|
73
|
-
const rec = (yield this.client.get(paths[0]));
|
|
74
|
-
return rec ? [rec] : [];
|
|
75
|
-
}
|
|
76
|
-
catch (e) {
|
|
77
|
-
this.checkError(e, { name: 'GET', method: '$getMore' });
|
|
78
|
-
return [];
|
|
79
|
-
}
|
|
80
|
-
}
|
|
51
|
+
async $getMore(paths, _opt) {
|
|
52
|
+
if (!this.isConnected) {
|
|
53
|
+
return [];
|
|
54
|
+
}
|
|
55
|
+
if (paths.length < 1) {
|
|
56
|
+
return [];
|
|
57
|
+
}
|
|
58
|
+
if (paths.length == 1) {
|
|
81
59
|
try {
|
|
82
|
-
|
|
60
|
+
const rec = (await this.client.get(paths[0]));
|
|
61
|
+
return rec ? [rec] : [];
|
|
83
62
|
}
|
|
84
63
|
catch (e) {
|
|
85
|
-
this.checkError(e, { name: '
|
|
64
|
+
this.checkError(e, { name: 'GET', method: '$getMore' });
|
|
86
65
|
return [];
|
|
87
66
|
}
|
|
88
|
-
}
|
|
67
|
+
}
|
|
68
|
+
try {
|
|
69
|
+
return (await this.client.mGet(paths));
|
|
70
|
+
}
|
|
71
|
+
catch (e) {
|
|
72
|
+
this.checkError(e, { name: 'MGET', method: '$getMore' });
|
|
73
|
+
return [];
|
|
74
|
+
}
|
|
89
75
|
}
|
|
90
76
|
/** @inheritDoc */
|
|
91
|
-
$set(path, value, _opt) {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
if (typeof path !== 'string' || typeof value !== 'string') {
|
|
97
|
-
return false;
|
|
98
|
-
}
|
|
99
|
-
try {
|
|
100
|
-
yield this.client.set(path, value);
|
|
101
|
-
return true;
|
|
102
|
-
}
|
|
103
|
-
catch (e) {
|
|
104
|
-
this.checkError(e, { name: 'SET', method: '$set' });
|
|
105
|
-
}
|
|
77
|
+
async $set(path, value, _opt) {
|
|
78
|
+
if (!this.isConnected) {
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
if (typeof path !== 'string' || typeof value !== 'string') {
|
|
106
82
|
return false;
|
|
107
|
-
}
|
|
83
|
+
}
|
|
84
|
+
try {
|
|
85
|
+
await this.client.set(path, value);
|
|
86
|
+
return true;
|
|
87
|
+
}
|
|
88
|
+
catch (e) {
|
|
89
|
+
this.checkError(e, { name: 'SET', method: '$set' });
|
|
90
|
+
}
|
|
91
|
+
return false;
|
|
108
92
|
}
|
|
109
93
|
/** @inheritDoc */
|
|
110
|
-
$setMore(map, _opt) {
|
|
111
|
-
|
|
112
|
-
|
|
94
|
+
async $setMore(map, _opt) {
|
|
95
|
+
if (!this.isConnected) {
|
|
96
|
+
return 0;
|
|
97
|
+
}
|
|
98
|
+
if (!map || typeof map !== 'object' || Array.isArray(map)) {
|
|
99
|
+
return 0;
|
|
100
|
+
}
|
|
101
|
+
const keys = Object.keys(map);
|
|
102
|
+
switch (keys.length) {
|
|
103
|
+
case 0:
|
|
113
104
|
return 0;
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
try {
|
|
133
|
-
yield this.client.mSet(map);
|
|
134
|
-
}
|
|
135
|
-
catch (e) {
|
|
136
|
-
this.checkError(e, { name: 'MSET', method: '$setMore' });
|
|
137
|
-
}
|
|
138
|
-
return keys.length;
|
|
139
|
-
}
|
|
140
|
-
});
|
|
105
|
+
case 1:
|
|
106
|
+
const key = keys[0];
|
|
107
|
+
try {
|
|
108
|
+
await this.client.set(key, map[key]);
|
|
109
|
+
}
|
|
110
|
+
catch (e) {
|
|
111
|
+
this.checkError(e, { name: 'SET', method: '$setMore' });
|
|
112
|
+
}
|
|
113
|
+
return 1;
|
|
114
|
+
default:
|
|
115
|
+
try {
|
|
116
|
+
await this.client.mSet(map);
|
|
117
|
+
}
|
|
118
|
+
catch (e) {
|
|
119
|
+
this.checkError(e, { name: 'MSET', method: '$setMore' });
|
|
120
|
+
}
|
|
121
|
+
return keys.length;
|
|
122
|
+
}
|
|
141
123
|
}
|
|
142
124
|
/** @inheritDoc */
|
|
143
|
-
$delete(path, _opt) {
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
if (typeof path !== 'string') {
|
|
149
|
-
return false;
|
|
150
|
-
}
|
|
151
|
-
try {
|
|
152
|
-
const result = yield this.client.del(path);
|
|
153
|
-
return result > 0;
|
|
154
|
-
}
|
|
155
|
-
catch (e) {
|
|
156
|
-
this.checkError(e, { name: 'DEL', method: '$delete' });
|
|
157
|
-
}
|
|
125
|
+
async $delete(path, _opt) {
|
|
126
|
+
if (!this.isConnected) {
|
|
127
|
+
return false;
|
|
128
|
+
}
|
|
129
|
+
if (typeof path !== 'string') {
|
|
158
130
|
return false;
|
|
159
|
-
}
|
|
131
|
+
}
|
|
132
|
+
try {
|
|
133
|
+
const result = await this.client.del(path);
|
|
134
|
+
return result > 0;
|
|
135
|
+
}
|
|
136
|
+
catch (e) {
|
|
137
|
+
this.checkError(e, { name: 'DEL', method: '$delete' });
|
|
138
|
+
}
|
|
139
|
+
return false;
|
|
160
140
|
}
|
|
161
141
|
/** @inheritDoc */
|
|
162
|
-
$deleteMore(paths, _opt) {
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
return paths.length;
|
|
177
|
-
});
|
|
142
|
+
async $deleteMore(paths, _opt) {
|
|
143
|
+
if (!this.isConnected) {
|
|
144
|
+
return 0;
|
|
145
|
+
}
|
|
146
|
+
if (paths.length < 1) {
|
|
147
|
+
return 0;
|
|
148
|
+
}
|
|
149
|
+
try {
|
|
150
|
+
await this.client.del(paths);
|
|
151
|
+
}
|
|
152
|
+
catch (e) {
|
|
153
|
+
this.checkError(e, { name: 'DEL', method: '$deleteMore' });
|
|
154
|
+
}
|
|
155
|
+
return paths.length;
|
|
178
156
|
}
|
|
179
157
|
/** @inheritDoc */
|
|
180
|
-
$addLinks(idPath, paths, _opt) {
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
return paths.length;
|
|
195
|
-
});
|
|
158
|
+
async $addLinks(idPath, paths, _opt) {
|
|
159
|
+
if (!this.isConnected) {
|
|
160
|
+
return 0;
|
|
161
|
+
}
|
|
162
|
+
if (paths.length < 1) {
|
|
163
|
+
return 0;
|
|
164
|
+
}
|
|
165
|
+
try {
|
|
166
|
+
await this.client.sAdd(idPath, paths);
|
|
167
|
+
}
|
|
168
|
+
catch (e) {
|
|
169
|
+
this.checkError(e, { name: 'SADD', method: '$addLinks' });
|
|
170
|
+
}
|
|
171
|
+
return paths.length;
|
|
196
172
|
}
|
|
197
173
|
/** @inheritDoc */
|
|
198
|
-
$expire(path, seconds, _opt) {
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
}
|
|
209
|
-
});
|
|
174
|
+
async $expire(path, seconds, _opt) {
|
|
175
|
+
if (!this.isConnected) {
|
|
176
|
+
return false;
|
|
177
|
+
}
|
|
178
|
+
try {
|
|
179
|
+
return (await this.client.expire(path, seconds)) > 0;
|
|
180
|
+
}
|
|
181
|
+
catch (e) {
|
|
182
|
+
this.checkError(e, { name: 'EXPIRE', method: '$expire' });
|
|
183
|
+
}
|
|
210
184
|
}
|
|
211
185
|
/** @inheritDoc */
|
|
212
|
-
$getLinks(idPath, _opt) {
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
this.checkError(e, { name: 'SMEMBERS', method: '$getLinks' });
|
|
223
|
-
}
|
|
224
|
-
});
|
|
186
|
+
async $getLinks(idPath, _opt) {
|
|
187
|
+
if (!this.isConnected) {
|
|
188
|
+
return [];
|
|
189
|
+
}
|
|
190
|
+
try {
|
|
191
|
+
return (await this.client.sMembers(idPath)) ?? [];
|
|
192
|
+
}
|
|
193
|
+
catch (e) {
|
|
194
|
+
this.checkError(e, { name: 'SMEMBERS', method: '$getLinks' });
|
|
195
|
+
}
|
|
225
196
|
}
|
|
226
197
|
}
|
|
227
|
-
|
|
198
|
+
setFqn(RedisChannel, FQN);
|
package/dist/config/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './redis-common.config';
|
|
2
|
-
export * from './index.types';
|
|
1
|
+
export * from './redis-common.config.js';
|
|
2
|
+
export * from './index.types.js';
|
package/dist/config/index.js
CHANGED
|
@@ -1,18 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./redis-common.config"), exports);
|
|
18
|
-
__exportStar(require("./index.types"), exports);
|
|
1
|
+
export * from './redis-common.config.js';
|
|
2
|
+
export * from './index.types.js';
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { RedisCommonConf } from "./index.types";
|
|
1
|
+
import { RedisCommonConf } from "./index.types.js";
|
|
2
2
|
/**
|
|
3
3
|
* Redis common config
|
|
4
4
|
* */
|
|
5
|
-
export declare const redisCommonConfig: import("@
|
|
5
|
+
export declare const redisCommonConfig: import("@samet-it/be-base-common").EnvScopeRuntime<RedisCommonConf, "REDIS", undefined>;
|
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.redisCommonConfig = void 0;
|
|
4
|
-
const env_1 = require("@leyyo/env");
|
|
1
|
+
import { envCore } from "@samet-it/be-base-common";
|
|
5
2
|
/**
|
|
6
3
|
* Redis common config
|
|
7
4
|
* */
|
|
8
|
-
|
|
5
|
+
export const redisCommonConfig = envCore.configure
|
|
9
6
|
.scope('RedisCommon', 'REDIS')
|
|
10
7
|
.start()
|
|
11
8
|
// @formatter:off
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export * from './index.types';
|
|
2
|
-
export * from './redis.connection';
|
|
3
|
-
export * from './redis-direct.connection';
|
|
4
|
-
export * from './redis-connection.fn';
|
|
1
|
+
export * from './index.types.js';
|
|
2
|
+
export * from './redis.connection.js';
|
|
3
|
+
export * from './redis-direct.connection.js';
|
|
4
|
+
export * from './redis-connection.fn.js';
|
package/dist/connection/index.js
CHANGED
|
@@ -1,20 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./index.types"), exports);
|
|
18
|
-
__exportStar(require("./redis.connection"), exports);
|
|
19
|
-
__exportStar(require("./redis-direct.connection"), exports);
|
|
20
|
-
__exportStar(require("./redis-connection.fn"), exports);
|
|
1
|
+
export * from './index.types.js';
|
|
2
|
+
export * from './redis.connection.js';
|
|
3
|
+
export * from './redis-direct.connection.js';
|
|
4
|
+
export * from './redis-connection.fn.js';
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { CacheConnectionLike, CacheConnOpt, CacheConnProps } from "@samet-it/be-cache-common";
|
|
2
2
|
import { RedisClientType } from "redis";
|
|
3
|
-
import { Entity } from "@samet-it/be-base-common";
|
|
4
|
-
import { RedisChannelLike, RedisDirectChannelOpt } from "../channel";
|
|
5
|
-
import { KeyValue } from "@leyyo/common";
|
|
3
|
+
import { Entity, KeyValue } from "@samet-it/be-base-common";
|
|
4
|
+
import { RedisChannelLike, RedisDirectChannelOpt } from "../channel/index.js";
|
|
6
5
|
/**
|
|
7
6
|
* Redis connection interface
|
|
8
7
|
* */
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.redisConnection = redisConnection;
|
|
4
|
-
const redis_direct_connection_1 = require("./redis-direct.connection");
|
|
1
|
+
import { RedisDirectConnection } from "./redis-direct.connection.js";
|
|
5
2
|
// noinspection JSUnusedGlobalSymbols
|
|
6
3
|
/**
|
|
7
4
|
* Crete new redis connection
|
|
@@ -9,6 +6,6 @@ const redis_direct_connection_1 = require("./redis-direct.connection");
|
|
|
9
6
|
* @param {RedisConnDirectOpt} opt - option
|
|
10
7
|
* @return {RedisDirectConnectionLike} - new redis connection
|
|
11
8
|
* */
|
|
12
|
-
function redisConnection(opt) {
|
|
13
|
-
return new
|
|
9
|
+
export function redisConnection(opt) {
|
|
10
|
+
return new RedisDirectConnection(opt);
|
|
14
11
|
}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { RedisConnection } from "./redis.connection";
|
|
2
|
-
import { Entity } from "@samet-it/be-base-common";
|
|
3
|
-
import { RedisChannelLike, RedisDirectChannelOpt } from "../channel";
|
|
4
|
-
import { RedisConnDirectOpt, RedisDirectConnectionLike } from "./index.types";
|
|
5
|
-
import { KeyValue } from "@leyyo/common";
|
|
1
|
+
import { RedisConnection } from "./redis.connection.js";
|
|
2
|
+
import { Entity, KeyValue } from "@samet-it/be-base-common";
|
|
3
|
+
import { RedisChannelLike, RedisDirectChannelOpt } from "../channel/index.js";
|
|
4
|
+
import { RedisConnDirectOpt, RedisDirectConnectionLike } from "./index.types.js";
|
|
6
5
|
/**
|
|
7
6
|
* Redis connection direct class
|
|
8
7
|
* */
|
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const be_base_common_1 = require("@samet-it/be-base-common");
|
|
6
|
-
const channel_1 = require("../channel");
|
|
1
|
+
import { RedisConnection } from "./redis.connection.js";
|
|
2
|
+
import { logCommon, setFqn } from "@samet-it/be-base-common";
|
|
3
|
+
import { RedisDirectChannel } from "../channel/index.js";
|
|
4
|
+
import { FQN } from "../internal.js";
|
|
7
5
|
/**
|
|
8
6
|
* Redis connection direct class
|
|
9
7
|
* */
|
|
10
|
-
class RedisDirectConnection extends
|
|
8
|
+
export class RedisDirectConnection extends RedisConnection {
|
|
11
9
|
/**
|
|
12
10
|
* Constructor
|
|
13
11
|
*
|
|
@@ -15,11 +13,11 @@ class RedisDirectConnection extends redis_connection_1.RedisConnection {
|
|
|
15
13
|
* */
|
|
16
14
|
constructor(opt) {
|
|
17
15
|
super(opt);
|
|
18
|
-
this.logger =
|
|
16
|
+
this.logger = logCommon.of(`RedisConnection${opt?.name ? '#' + opt?.name : ''}`);
|
|
19
17
|
}
|
|
20
18
|
/** @inheritDoc */
|
|
21
19
|
newChannel(opt) {
|
|
22
|
-
return new
|
|
20
|
+
return new RedisDirectChannel(this, opt);
|
|
23
21
|
}
|
|
24
22
|
}
|
|
25
|
-
|
|
23
|
+
setFqn(RedisDirectConnection, FQN);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { RedisClientType } from 'redis';
|
|
2
|
-
import { RedisConnectionLike, RedisConnOpt, RedisConnProps } from "./index.types";
|
|
2
|
+
import { RedisConnectionLike, RedisConnOpt, RedisConnProps } from "./index.types.js";
|
|
3
3
|
import { CacheConnection } from "@samet-it/be-cache-common";
|
|
4
4
|
/**
|
|
5
5
|
* Redis connection abstract class
|
|
@@ -1,57 +1,49 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
36
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
37
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
38
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
39
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
40
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
41
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
42
|
-
});
|
|
43
|
-
};
|
|
44
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
45
|
-
exports.RedisConnection = void 0;
|
|
46
|
-
const redis = __importStar(require("redis"));
|
|
47
|
-
const config_1 = require("../config");
|
|
48
|
-
const be_cache_common_1 = require("@samet-it/be-cache-common");
|
|
49
|
-
const be_base_common_1 = require("@samet-it/be-base-common");
|
|
50
|
-
const common_1 = require("@leyyo/common");
|
|
1
|
+
import * as redis from 'redis';
|
|
2
|
+
import { redisCommonConfig } from "../config/index.js";
|
|
3
|
+
import { CacheConnection, CacheError } from "@samet-it/be-cache-common";
|
|
4
|
+
import { errorCommon, logCommon, setFqn } from "@samet-it/be-base-common";
|
|
5
|
+
import { FQN } from "../internal.js";
|
|
51
6
|
/**
|
|
52
7
|
* Redis connection abstract class
|
|
53
8
|
* */
|
|
54
|
-
class RedisConnection extends
|
|
9
|
+
export class RedisConnection extends CacheConnection {
|
|
10
|
+
// region private-property
|
|
11
|
+
/**
|
|
12
|
+
* Base/starting/min delay for connection
|
|
13
|
+
*
|
|
14
|
+
* @type {number} - as seconds
|
|
15
|
+
* */
|
|
16
|
+
static CONN_BASE_DELAY = 500; // 0.5 sec
|
|
17
|
+
/**
|
|
18
|
+
* Last/max delay for connection
|
|
19
|
+
*
|
|
20
|
+
* @type {number} - as seconds
|
|
21
|
+
* */
|
|
22
|
+
static CONN_MAX_DELAY = 1_000 * 60 * 60; // 60 minutes
|
|
23
|
+
/**
|
|
24
|
+
* Try count
|
|
25
|
+
*
|
|
26
|
+
* @type {number} - times
|
|
27
|
+
* */
|
|
28
|
+
static CONN_TRY_COUNT = 100; // 100 times
|
|
29
|
+
/**
|
|
30
|
+
* Base/starting/min delay for ping
|
|
31
|
+
*
|
|
32
|
+
* @type {number} - as seconds
|
|
33
|
+
* */
|
|
34
|
+
static PING_BASE_DELAY = 200; // 0.2 sec
|
|
35
|
+
/**
|
|
36
|
+
* Last/max delay ping
|
|
37
|
+
*
|
|
38
|
+
* @type {number} - as seconds
|
|
39
|
+
* */
|
|
40
|
+
static PING_MAX_DELAY = 1_000 * 60 * 10; // 10 minutes
|
|
41
|
+
/**
|
|
42
|
+
* Try count
|
|
43
|
+
*
|
|
44
|
+
* @type {number} - times
|
|
45
|
+
* */
|
|
46
|
+
static PING_TRY_COUNT = 100; // 100 times
|
|
55
47
|
// endregion protected-property
|
|
56
48
|
/**
|
|
57
49
|
* Constructor
|
|
@@ -61,7 +53,7 @@ class RedisConnection extends be_cache_common_1.CacheConnection {
|
|
|
61
53
|
constructor(opt) {
|
|
62
54
|
super(opt);
|
|
63
55
|
if (!this.logger) {
|
|
64
|
-
this.logger =
|
|
56
|
+
this.logger = logCommon.of(this);
|
|
65
57
|
}
|
|
66
58
|
this._readFromEnv();
|
|
67
59
|
this._buildUrl();
|
|
@@ -81,19 +73,18 @@ class RedisConnection extends be_cache_common_1.CacheConnection {
|
|
|
81
73
|
* Read credentials from environment
|
|
82
74
|
* */
|
|
83
75
|
_readFromEnv() {
|
|
84
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
85
76
|
const { _props: props } = this;
|
|
86
|
-
let env =
|
|
77
|
+
let env = redisCommonConfig.valueShort;
|
|
87
78
|
if (props.envVariant) {
|
|
88
|
-
env =
|
|
79
|
+
env = redisCommonConfig.configure.getVariation(props.envVariant).valueShort;
|
|
89
80
|
}
|
|
90
|
-
props.isEnabled =
|
|
91
|
-
props.protocol =
|
|
92
|
-
props.host =
|
|
93
|
-
props.port =
|
|
94
|
-
props.username =
|
|
95
|
-
props.password =
|
|
96
|
-
props.dbNumber =
|
|
81
|
+
props.isEnabled = props.isEnabled ?? env.ENABLED;
|
|
82
|
+
props.protocol = props.protocol ?? env.PROTOCOL;
|
|
83
|
+
props.host = props.host ?? env.HOST;
|
|
84
|
+
props.port = props.port ?? env.PORT;
|
|
85
|
+
props.username = props.username ?? env.USER;
|
|
86
|
+
props.password = props.password ?? env.PASS;
|
|
87
|
+
props.dbNumber = props.dbNumber ?? env.DB_NUMBER;
|
|
97
88
|
}
|
|
98
89
|
/**
|
|
99
90
|
* Build url from credentials
|
|
@@ -127,129 +118,88 @@ class RedisConnection extends be_cache_common_1.CacheConnection {
|
|
|
127
118
|
// endregion protected-method
|
|
128
119
|
// region connect
|
|
129
120
|
/** {@inheritDoc} */
|
|
130
|
-
connect() {
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
if (this.isConnected) {
|
|
137
|
-
return true;
|
|
138
|
-
}
|
|
139
|
-
if (this._props.connectTryCount > RedisConnection.CONN_TRY_COUNT) {
|
|
140
|
-
const err = new be_cache_common_1.CacheError('Maximum try county', { tryCount: this._props.connectTryCount });
|
|
141
|
-
this.logger.error(common_1.errorCommon.text(err, 'connect'));
|
|
142
|
-
return false;
|
|
143
|
-
}
|
|
144
|
-
try {
|
|
145
|
-
props.client = redis.createClient({ url: this._props.producedUrl });
|
|
146
|
-
props.client
|
|
147
|
-
.on("error", err => {
|
|
148
|
-
this.logger.warn(common_1.errorCommon.text(err, 'connection', this._props.connectTryCount));
|
|
149
|
-
props.connectTryCount++;
|
|
150
|
-
const old = this.isConnected;
|
|
151
|
-
props.isConnected = false;
|
|
152
|
-
if (old) {
|
|
153
|
-
this._triggerOnCase('disconnected', this._onDisconnected, false);
|
|
154
|
-
}
|
|
155
|
-
setTimeout(() => this.connect().then(), this._connectionDelay);
|
|
156
|
-
})
|
|
157
|
-
.on('connect', () => {
|
|
158
|
-
this.logger.info(`on[connect]`);
|
|
159
|
-
props.isConnected = true;
|
|
160
|
-
props.connectTryCount = 0;
|
|
161
|
-
this._triggerOnCase('connected', this._onConnected, false);
|
|
162
|
-
if (props.isFirst === undefined) {
|
|
163
|
-
this._triggerOnCase('first-connected', this._onFirstConnected, true);
|
|
164
|
-
props.isFirst = false;
|
|
165
|
-
}
|
|
166
|
-
// clear stopped ping
|
|
167
|
-
if (this._props.pingTryCount > RedisConnection.PING_TRY_COUNT) {
|
|
168
|
-
this._props.pingTryCount = 0;
|
|
169
|
-
setTimeout(() => this.ping(true).then(), 30000);
|
|
170
|
-
}
|
|
171
|
-
})
|
|
172
|
-
.on('ready', () => this.logger.info('on[ready]'))
|
|
173
|
-
.on('close', () => this.logger.info('on[close]'))
|
|
174
|
-
.on('reconnecting', () => this.logger.info('on[reconnecting]'))
|
|
175
|
-
.on('end', () => this.logger.info('on[end]'));
|
|
176
|
-
yield props.client.connect();
|
|
177
|
-
this.logger.info('Connected');
|
|
178
|
-
setTimeout(() => this.ping(true).then(), 30000);
|
|
179
|
-
}
|
|
180
|
-
catch (e) {
|
|
181
|
-
this.logger.warn(common_1.errorCommon.text(e, 'connection', this._props.connectTryCount));
|
|
182
|
-
}
|
|
121
|
+
async connect() {
|
|
122
|
+
const { _props: props } = this;
|
|
123
|
+
if (!this.isEnabled) {
|
|
124
|
+
return false;
|
|
125
|
+
}
|
|
126
|
+
if (this.isConnected) {
|
|
183
127
|
return true;
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
this.logger.
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
128
|
+
}
|
|
129
|
+
if (this._props.connectTryCount > RedisConnection.CONN_TRY_COUNT) {
|
|
130
|
+
const err = new CacheError('Maximum try county', { tryCount: this._props.connectTryCount });
|
|
131
|
+
this.logger.error(errorCommon.text(err, 'connect'));
|
|
132
|
+
return false;
|
|
133
|
+
}
|
|
134
|
+
try {
|
|
135
|
+
props.client = redis.createClient({ url: this._props.producedUrl });
|
|
136
|
+
props.client
|
|
137
|
+
.on("error", err => {
|
|
138
|
+
this.logger.warn(errorCommon.text(err, 'connection', this._props.connectTryCount));
|
|
139
|
+
props.connectTryCount++;
|
|
140
|
+
const old = this.isConnected;
|
|
141
|
+
props.isConnected = false;
|
|
142
|
+
if (old) {
|
|
143
|
+
this._triggerOnCase('disconnected', this._onDisconnected, false);
|
|
144
|
+
}
|
|
145
|
+
setTimeout(() => this.connect().then(), this._connectionDelay);
|
|
146
|
+
})
|
|
147
|
+
.on('connect', () => {
|
|
148
|
+
this.logger.info(`on[connect]`);
|
|
149
|
+
props.isConnected = true;
|
|
150
|
+
props.connectTryCount = 0;
|
|
151
|
+
this._triggerOnCase('connected', this._onConnected, false);
|
|
152
|
+
if (props.isFirst === undefined) {
|
|
153
|
+
this._triggerOnCase('first-connected', this._onFirstConnected, true);
|
|
154
|
+
props.isFirst = false;
|
|
203
155
|
}
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
this.
|
|
207
|
-
setTimeout(() => this.ping(true).then(),
|
|
208
|
-
next = false;
|
|
156
|
+
// clear stopped ping
|
|
157
|
+
if (this._props.pingTryCount > RedisConnection.PING_TRY_COUNT) {
|
|
158
|
+
this._props.pingTryCount = 0;
|
|
159
|
+
setTimeout(() => this.ping(true).then(), 30_000);
|
|
209
160
|
}
|
|
161
|
+
})
|
|
162
|
+
.on('ready', () => this.logger.info('on[ready]'))
|
|
163
|
+
.on('close', () => this.logger.info('on[close]'))
|
|
164
|
+
.on('reconnecting', () => this.logger.info('on[reconnecting]'))
|
|
165
|
+
.on('end', () => this.logger.info('on[end]'));
|
|
166
|
+
await props.client.connect();
|
|
167
|
+
this.logger.info('Connected');
|
|
168
|
+
setTimeout(() => this.ping(true).then(), 30_000);
|
|
169
|
+
}
|
|
170
|
+
catch (e) {
|
|
171
|
+
this.logger.warn(errorCommon.text(e, 'connection', this._props.connectTryCount));
|
|
172
|
+
}
|
|
173
|
+
return true;
|
|
174
|
+
}
|
|
175
|
+
/** {@inheritDoc} */
|
|
176
|
+
async ping(next) {
|
|
177
|
+
if (!this.isEnabled) {
|
|
178
|
+
return false;
|
|
179
|
+
}
|
|
180
|
+
if (this._props.pingTryCount > RedisConnection.PING_TRY_COUNT) {
|
|
181
|
+
const err = new CacheError('Maximum try county', { tryCount: this._props.pingTryCount });
|
|
182
|
+
this.logger.error(errorCommon.text(err, 'connect'));
|
|
183
|
+
return false;
|
|
184
|
+
}
|
|
185
|
+
let result = false;
|
|
186
|
+
if (this.isConnected) {
|
|
187
|
+
try {
|
|
188
|
+
await this.client.ping();
|
|
189
|
+
this._props.pingTryCount = 0;
|
|
190
|
+
result = true;
|
|
210
191
|
}
|
|
211
|
-
|
|
212
|
-
|
|
192
|
+
catch (err) {
|
|
193
|
+
this._props.pingTryCount++;
|
|
194
|
+
this.logger.warn(errorCommon.text(err, 'ping', this._props.pingTryCount));
|
|
195
|
+
setTimeout(() => this.ping(true).then(), this._pingDelay);
|
|
196
|
+
next = false;
|
|
213
197
|
}
|
|
214
|
-
|
|
215
|
-
|
|
198
|
+
}
|
|
199
|
+
if (next) {
|
|
200
|
+
setTimeout(() => this.ping(true).then(), 30_000);
|
|
201
|
+
}
|
|
202
|
+
return result;
|
|
216
203
|
}
|
|
217
204
|
}
|
|
218
|
-
|
|
219
|
-
// region private-property
|
|
220
|
-
/**
|
|
221
|
-
* Base/starting/min delay for connection
|
|
222
|
-
*
|
|
223
|
-
* @type {number} - as seconds
|
|
224
|
-
* */
|
|
225
|
-
RedisConnection.CONN_BASE_DELAY = 500; // 0.5 sec
|
|
226
|
-
/**
|
|
227
|
-
* Last/max delay for connection
|
|
228
|
-
*
|
|
229
|
-
* @type {number} - as seconds
|
|
230
|
-
* */
|
|
231
|
-
RedisConnection.CONN_MAX_DELAY = 1000 * 60 * 60; // 60 minutes
|
|
232
|
-
/**
|
|
233
|
-
* Try count
|
|
234
|
-
*
|
|
235
|
-
* @type {number} - times
|
|
236
|
-
* */
|
|
237
|
-
RedisConnection.CONN_TRY_COUNT = 100; // 100 times
|
|
238
|
-
/**
|
|
239
|
-
* Base/starting/min delay for ping
|
|
240
|
-
*
|
|
241
|
-
* @type {number} - as seconds
|
|
242
|
-
* */
|
|
243
|
-
RedisConnection.PING_BASE_DELAY = 200; // 0.2 sec
|
|
244
|
-
/**
|
|
245
|
-
* Last/max delay ping
|
|
246
|
-
*
|
|
247
|
-
* @type {number} - as seconds
|
|
248
|
-
* */
|
|
249
|
-
RedisConnection.PING_MAX_DELAY = 1000 * 60 * 10; // 10 minutes
|
|
250
|
-
/**
|
|
251
|
-
* Try count
|
|
252
|
-
*
|
|
253
|
-
* @type {number} - times
|
|
254
|
-
* */
|
|
255
|
-
RedisConnection.PING_TRY_COUNT = 100; // 100 times
|
|
205
|
+
setFqn(RedisConnection, FQN);
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
-
export * from './connection';
|
|
2
|
-
export * from './config';
|
|
3
|
-
export * from './channel';
|
|
1
|
+
export * from './connection/index.js';
|
|
2
|
+
export * from './config/index.js';
|
|
3
|
+
export * from './channel/index.js';
|
|
4
|
+
export * from './index.foretell.js';
|
|
5
|
+
export * from './index.loader.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const foretell_sametRedisCommon: any[];
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { foretell_sametBaseCommon } from "@samet-it/be-base-common";
|
|
2
|
+
import { foretell_sametCacheCommon } from "@samet-it/be-cache-common/dist/index.foretell.js";
|
|
3
|
+
// noinspection JSUnusedGlobalSymbols
|
|
4
|
+
export const foretell_sametRedisCommon = [
|
|
5
|
+
// dependencies
|
|
6
|
+
...foretell_sametBaseCommon,
|
|
7
|
+
...foretell_sametCacheCommon,
|
|
8
|
+
];
|
package/dist/index.js
CHANGED
|
@@ -1,19 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./connection"), exports);
|
|
18
|
-
__exportStar(require("./config"), exports);
|
|
19
|
-
__exportStar(require("./channel"), exports);
|
|
1
|
+
export * from './connection/index.js';
|
|
2
|
+
export * from './config/index.js';
|
|
3
|
+
export * from './channel/index.js';
|
|
4
|
+
export * from './index.foretell.js';
|
|
5
|
+
export * from './index.loader.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const loader_sametRedisCommon: import("@samet-it/be-base-common").LoaderLike;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { defineLoader } from "@samet-it/be-base-common";
|
|
2
|
+
import { FQN } from "./internal.js";
|
|
3
|
+
import { loader_sametBaseCommon } from "@samet-it/be-base-common";
|
|
4
|
+
import { loader_sametCacheCommon } from "@samet-it/be-cache-common/dist/index.loader.js";
|
|
5
|
+
// noinspection JSUnusedGlobalSymbols
|
|
6
|
+
export const loader_sametRedisCommon = defineLoader(FQN,
|
|
7
|
+
// dependencies
|
|
8
|
+
...loader_sametBaseCommon, ...loader_sametCacheCommon,
|
|
9
|
+
// classes
|
|
10
|
+
() => import('./channel/redis.channel.js').then(m => m.RedisChannel), () => import('./channel/redis-direct.channel.js').then(m => m.RedisDirectChannel), () => import('./connection/redis.connection.js').then(m => m.RedisConnection), () => import('./connection/redis-direct.connection.js').then(m => m.RedisDirectConnection), () => import('./config/redis-common.config.js').then(m => m.redisCommonConfig));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const NME: string, FQN: string, VER: string, CNF: import("@samet-it/be-base-common").LeyyoConfig;
|
package/dist/internal.js
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@samet-it/be-redis-common",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.3",
|
|
4
4
|
"description": "Redis common component",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"redis",
|
|
@@ -20,13 +20,13 @@
|
|
|
20
20
|
"email": "mustafay@samet.com.tr"
|
|
21
21
|
},
|
|
22
22
|
"main": "dist/index.js",
|
|
23
|
-
"type": "
|
|
23
|
+
"type": "module",
|
|
24
24
|
"scripts": {
|
|
25
25
|
"clear": "rimraf dist && rimraf coverage",
|
|
26
26
|
"clear:nm": "rimraf node_modules && npm run clear",
|
|
27
27
|
"lint": "eslint src/**/*.ts --quiet",
|
|
28
28
|
"lint:verbose": "eslint src/**/*.ts",
|
|
29
|
-
"asset": "node -r ts-node/register commands/assets.
|
|
29
|
+
"asset": "node -r ts-node/register commands/assets.js",
|
|
30
30
|
"build": "npm run clear && tsc && npm run asset",
|
|
31
31
|
"test": "jest --config=jest.json --detectOpenHandles",
|
|
32
32
|
"coverage": "rimraf coverage && jest --config=jest.json --coverage --coverageDirectory=coverage",
|
|
@@ -68,10 +68,8 @@
|
|
|
68
68
|
}
|
|
69
69
|
},
|
|
70
70
|
"dependencies": {
|
|
71
|
-
"@
|
|
72
|
-
"@
|
|
73
|
-
"@samet-it/be-base-common": "^1.3.1",
|
|
74
|
-
"@samet-it/be-cache-common": "^1.3.1",
|
|
71
|
+
"@samet-it/be-base-common": "^1.3.6",
|
|
72
|
+
"@samet-it/be-cache-common": "^1.3.7",
|
|
75
73
|
"redis": "^5.10.0"
|
|
76
74
|
}
|
|
77
75
|
}
|
package/dist/assets/.gitkeep
DELETED
|
File without changes
|