@samet-it/be-redis-common 1.1.1 → 1.1.2
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.types.d.ts +5 -1
- package/dist/channel/redis-direct.channel.d.ts +5 -1
- package/dist/channel/redis-direct.channel.js +4 -0
- package/dist/channel/redis.channel.d.ts +18 -2
- package/dist/channel/redis.channel.js +20 -2
- package/dist/connection/index.types.d.ts +5 -1
- package/dist/connection/redis-direct.connection.d.ts +1 -1
- package/package.json +2 -2
|
@@ -5,8 +5,12 @@ import type { RedisClientType } from "redis";
|
|
|
5
5
|
import type { KeyValue } from "@leyyo/common";
|
|
6
6
|
/**
|
|
7
7
|
* Redis channel interface
|
|
8
|
+
*
|
|
9
|
+
* Generics:
|
|
10
|
+
* - 0-`ENT`: entity {@link Entity}
|
|
11
|
+
* - 1-`ID`: id type {@link KeyValue}
|
|
8
12
|
* */
|
|
9
|
-
export interface RedisChannelLike<
|
|
13
|
+
export interface RedisChannelLike<ENT extends Entity<ID>, ID extends KeyValue> extends CacheChannelLike<RedisConnectionLike, ENT, ID> {
|
|
10
14
|
/** @inheritDoc */
|
|
11
15
|
get props(): Readonly<RedisChannelProps>;
|
|
12
16
|
}
|
|
@@ -5,8 +5,12 @@ import type { RedisDirectChannelOpt } from "./index.types";
|
|
|
5
5
|
import type { KeyValue } from "@leyyo/common";
|
|
6
6
|
/**
|
|
7
7
|
* Redis direct channel class
|
|
8
|
+
*
|
|
9
|
+
* Generics:
|
|
10
|
+
* - 0-`ENT`: entity {@link Entity}
|
|
11
|
+
* - 1-`ID`: id type {@link KeyValue}
|
|
8
12
|
* */
|
|
9
|
-
export declare class RedisDirectChannel<
|
|
13
|
+
export declare class RedisDirectChannel<ENT extends Entity<ID>, ID extends KeyValue> extends RedisChannel<ENT, ID> {
|
|
10
14
|
/**
|
|
11
15
|
* Constructor
|
|
12
16
|
*
|
|
@@ -5,6 +5,10 @@ const redis_channel_1 = require("./redis.channel");
|
|
|
5
5
|
const be_base_common_1 = require("@samet-it/be-base-common");
|
|
6
6
|
/**
|
|
7
7
|
* Redis direct channel class
|
|
8
|
+
*
|
|
9
|
+
* Generics:
|
|
10
|
+
* - 0-`ENT`: entity {@link Entity}
|
|
11
|
+
* - 1-`ID`: id type {@link KeyValue}
|
|
8
12
|
* */
|
|
9
13
|
class RedisDirectChannel extends redis_channel_1.RedisChannel {
|
|
10
14
|
/**
|
|
@@ -5,12 +5,28 @@ import { CacheChannel } from "@samet-it/be-cache-common";
|
|
|
5
5
|
import type { KeyValue, Opt } from "@leyyo/common";
|
|
6
6
|
/**
|
|
7
7
|
* Redis abstract channel class
|
|
8
|
+
*
|
|
9
|
+
* Generics:
|
|
10
|
+
* - 0-`ENT`: entity {@link Entity}
|
|
11
|
+
* - 1-`ID`: id type {@link KeyValue}
|
|
8
12
|
* */
|
|
9
|
-
export declare abstract class RedisChannel<
|
|
13
|
+
export declare abstract class RedisChannel<ENT extends Entity<ID>, ID extends KeyValue> extends CacheChannel<RedisConnectionLike, ENT, ID> implements RedisChannelLike<ENT, ID> {
|
|
10
14
|
/** @inheritDoc */
|
|
11
15
|
protected _props: RedisChannelProps;
|
|
16
|
+
/**
|
|
17
|
+
* Constructor
|
|
18
|
+
*
|
|
19
|
+
* @param {RedisConnectionLike} conn - redis connection
|
|
20
|
+
* @param {RedisChannelOpt} opt - options
|
|
21
|
+
* */
|
|
12
22
|
protected constructor(conn: RedisConnectionLike, opt?: RedisChannelOpt);
|
|
13
|
-
|
|
23
|
+
/**
|
|
24
|
+
* @Check error
|
|
25
|
+
*
|
|
26
|
+
* @param {Error} e - error instance
|
|
27
|
+
* @param {Opt} params - parameters
|
|
28
|
+
* */
|
|
29
|
+
protected _checkError(e: Error, params?: Opt): void;
|
|
14
30
|
/** @inheritDoc */
|
|
15
31
|
get props(): Readonly<RedisChannelProps>;
|
|
16
32
|
/** @inheritDoc */
|
|
@@ -15,9 +15,19 @@ const be_cache_common_1 = require("@samet-it/be-cache-common");
|
|
|
15
15
|
// noinspection JSUnusedGlobalSymbols
|
|
16
16
|
/**
|
|
17
17
|
* Redis abstract channel class
|
|
18
|
+
*
|
|
19
|
+
* Generics:
|
|
20
|
+
* - 0-`ENT`: entity {@link Entity}
|
|
21
|
+
* - 1-`ID`: id type {@link KeyValue}
|
|
18
22
|
* */
|
|
19
23
|
class RedisChannel extends be_cache_common_1.CacheChannel {
|
|
20
24
|
// endregion protected-property
|
|
25
|
+
/**
|
|
26
|
+
* Constructor
|
|
27
|
+
*
|
|
28
|
+
* @param {RedisConnectionLike} conn - redis connection
|
|
29
|
+
* @param {RedisChannelOpt} opt - options
|
|
30
|
+
* */
|
|
21
31
|
constructor(conn, opt) {
|
|
22
32
|
super(conn, opt);
|
|
23
33
|
conn.onFirstConnected(() => __awaiter(this, void 0, void 0, function* () {
|
|
@@ -33,16 +43,24 @@ class RedisChannel extends be_cache_common_1.CacheChannel {
|
|
|
33
43
|
this._props.isConnected = false;
|
|
34
44
|
}));
|
|
35
45
|
}
|
|
36
|
-
|
|
46
|
+
// region protected-methods
|
|
47
|
+
/**
|
|
48
|
+
* @Check error
|
|
49
|
+
*
|
|
50
|
+
* @param {Error} e - error instance
|
|
51
|
+
* @param {Opt} params - parameters
|
|
52
|
+
* */
|
|
53
|
+
_checkError(e, params) {
|
|
37
54
|
be_base_common_1.errorHandler.addStat(e);
|
|
38
55
|
if (e instanceof be_cache_common_1.CacheError) {
|
|
39
56
|
// todo append params
|
|
40
57
|
throw e;
|
|
41
58
|
}
|
|
42
59
|
else {
|
|
43
|
-
throw be_base_common_1.errorHandler.common.castForClass(be_cache_common_1.CacheError, e,
|
|
60
|
+
throw be_base_common_1.errorHandler.common.castForClass(be_cache_common_1.CacheError, e, params);
|
|
44
61
|
}
|
|
45
62
|
}
|
|
63
|
+
// endregion protected-methods
|
|
46
64
|
// region getter
|
|
47
65
|
/** @inheritDoc */
|
|
48
66
|
get props() {
|
|
@@ -18,10 +18,14 @@ export interface RedisDirectConnectionLike extends RedisConnectionLike {
|
|
|
18
18
|
/**
|
|
19
19
|
* Create new channel
|
|
20
20
|
*
|
|
21
|
+
* Generics:
|
|
22
|
+
* - 0-`ENT`: entity {@link Entity}
|
|
23
|
+
* - 1-`ID`: id type {@link KeyValue}
|
|
24
|
+
*
|
|
21
25
|
* @param {RedisDirectChannelOpt?} opt - direct channel options
|
|
22
26
|
* @return {RedisChannelLike<Entity>} - new channel
|
|
23
27
|
* */
|
|
24
|
-
newChannel<
|
|
28
|
+
newChannel<ENT extends Entity<ID>, ID extends KeyValue>(opt?: RedisDirectChannelOpt): RedisChannelLike<ENT, ID>;
|
|
25
29
|
}
|
|
26
30
|
/**
|
|
27
31
|
* Redis connection option
|
|
@@ -14,5 +14,5 @@ export declare class RedisDirectConnection extends RedisConnection implements Re
|
|
|
14
14
|
* */
|
|
15
15
|
constructor(opt?: RedisConnDirectOpt);
|
|
16
16
|
/** @inheritDoc */
|
|
17
|
-
newChannel<
|
|
17
|
+
newChannel<ENT extends Entity<ID>, ID extends KeyValue>(opt?: RedisDirectChannelOpt): RedisChannelLike<ENT, ID>;
|
|
18
18
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@samet-it/be-redis-common",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.2",
|
|
4
4
|
"description": "Redis common component",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"redis",
|
|
@@ -70,7 +70,7 @@
|
|
|
70
70
|
"@leyyo/common": "^1.2.1",
|
|
71
71
|
"@leyyo/env": "^1.2.1",
|
|
72
72
|
"@samet-it/be-base-common": "^1.1.1",
|
|
73
|
-
"@samet-it/be-cache-common": "^1.1.
|
|
73
|
+
"@samet-it/be-cache-common": "^1.1.2",
|
|
74
74
|
"redis": "^5.10.0"
|
|
75
75
|
}
|
|
76
76
|
}
|