@samet-it/be-redis-common 1.1.10 → 1.3.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.
@@ -1,8 +1,8 @@
1
- import type { RedisConnectionLike } from "../connection";
2
- import type { CacheChannelProps, CacheChannelLike, CacheChannelOpt, CacheExecOpt } from "@samet-it/be-cache-common";
3
- import type { Entity } from "@samet-it/be-base-common";
4
- import type { RedisClientType } from "redis";
5
- import type { KeyValue } from "@leyyo/common";
1
+ import { RedisConnectionLike } from "../connection";
2
+ import { CacheChannelLike, CacheChannelOpt, CacheChannelProps, CacheExecOpt } from "@samet-it/be-cache-common";
3
+ import { Entity } from "@samet-it/be-base-common";
4
+ import { RedisClientType } from "redis";
5
+ import { KeyValue } from "@leyyo/common";
6
6
  /**
7
7
  * Redis channel interface
8
8
  *
@@ -1,8 +1,8 @@
1
1
  import { RedisChannel } from "./redis.channel";
2
2
  import { type Entity } from "@samet-it/be-base-common";
3
- import type { RedisConnectionLike } from "../connection";
4
- import type { RedisDirectChannelOpt } from "./index.types";
5
- import type { KeyValue } from "@leyyo/common";
3
+ import { RedisConnectionLike } from "../connection";
4
+ import { RedisDirectChannelOpt } from "./index.types";
5
+ import { KeyValue } from "@leyyo/common";
6
6
  /**
7
7
  * Redis direct channel class
8
8
  *
@@ -19,7 +19,7 @@ class RedisDirectChannel extends redis_channel_1.RedisChannel {
19
19
  * */
20
20
  constructor(conn, opt) {
21
21
  super(conn, opt);
22
- this.logger = be_base_common_1.logger.create(`RedisDirect${opt.name ? '#' + opt.name : ''}`);
22
+ this.logger = be_base_common_1.logger.of(`RedisDirect${opt.name ? '#' + opt.name : ''}`);
23
23
  }
24
24
  }
25
25
  exports.RedisDirectChannel = RedisDirectChannel;
@@ -1,9 +1,9 @@
1
- import type { RedisConnectionLike } from "../connection";
2
- import type { RedisChannelProps, RedisChannelLike, RedisChannelOpt, RedisExecOpt } from "./index.types";
3
- import { type Entity } from "@samet-it/be-base-common";
1
+ import { RedisConnectionLike } from "../connection";
2
+ import { RedisChannelLike, RedisChannelOpt, RedisChannelProps, RedisExecOpt } from "./index.types";
3
+ import { Entity } from "@samet-it/be-base-common";
4
4
  import { CacheChannel } from "@samet-it/be-cache-common";
5
- import type { KeyValue } from "@leyyo/common";
6
- import type { RedisClientType } from "redis";
5
+ import { KeyValue } from "@leyyo/common";
6
+ import { RedisClientType } from "redis";
7
7
  /**
8
8
  * Redis abstract channel class
9
9
  *
@@ -1,4 +1,4 @@
1
- import type { EnvBase } from "@leyyo/env";
1
+ import { EnvBase } from "@leyyo/env";
2
2
  export interface RedisCommonConf extends EnvBase {
3
3
  /**
4
4
  * Redis Enabled
@@ -1,4 +1,4 @@
1
- import type { RedisCommonConf } from "./index.types";
1
+ import { RedisCommonConf } from "./index.types";
2
2
  /**
3
3
  * Redis common config
4
4
  * */
@@ -1,9 +1,8 @@
1
- import type { CacheConnectionLike, CacheConnOpt } from "@samet-it/be-cache-common";
2
- import type { RedisClientType } from "redis";
3
- import type { Entity } from "@samet-it/be-base-common";
4
- import type { RedisDirectChannelOpt, RedisChannelLike } from "../channel";
5
- import type { CacheConnProps } from "@samet-it/be-cache-common";
6
- import type { KeyValue } from "@leyyo/common";
1
+ import { CacheConnectionLike, CacheConnOpt, CacheConnProps } from "@samet-it/be-cache-common";
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";
7
6
  /**
8
7
  * Redis connection interface
9
8
  * */
@@ -1,4 +1,4 @@
1
- import type { RedisConnDirectOpt, RedisDirectConnectionLike } from "./index.types";
1
+ import { RedisConnDirectOpt, RedisDirectConnectionLike } from "./index.types";
2
2
  /**
3
3
  * Crete new redis connection
4
4
  *
@@ -1,8 +1,8 @@
1
1
  import { RedisConnection } from "./redis.connection";
2
- import { type Entity } from "@samet-it/be-base-common";
3
- import { type RedisDirectChannelOpt, type RedisChannelLike } from "../channel";
4
- import type { RedisConnDirectOpt, RedisDirectConnectionLike } from "./index.types";
5
- import type { KeyValue } from "@leyyo/common";
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";
6
6
  /**
7
7
  * Redis connection direct class
8
8
  * */
@@ -15,7 +15,7 @@ class RedisDirectConnection extends redis_connection_1.RedisConnection {
15
15
  * */
16
16
  constructor(opt) {
17
17
  super(opt);
18
- this.logger = be_base_common_1.logger.create(`RedisConnection${(opt === null || opt === void 0 ? void 0 : opt.name) ? '#' + (opt === null || opt === void 0 ? void 0 : opt.name) : ''}`);
18
+ this.logger = be_base_common_1.logger.of(`RedisConnection${(opt === null || opt === void 0 ? void 0 : opt.name) ? '#' + (opt === null || opt === void 0 ? void 0 : opt.name) : ''}`);
19
19
  }
20
20
  /** @inheritDoc */
21
21
  newChannel(opt) {
@@ -1,6 +1,6 @@
1
- import type { RedisConnectionLike, RedisConnProps, RedisConnOpt } from "./index.types";
1
+ import { RedisClientType } from 'redis';
2
+ import { RedisConnectionLike, RedisConnOpt, RedisConnProps } from "./index.types";
2
3
  import { CacheConnection } from "@samet-it/be-cache-common";
3
- import type { RedisClientType } from "redis";
4
4
  /**
5
5
  * Redis connection abstract class
6
6
  * */
@@ -47,6 +47,7 @@ const redis = __importStar(require("redis"));
47
47
  const config_1 = require("../config");
48
48
  const be_cache_common_1 = require("@samet-it/be-cache-common");
49
49
  const be_base_common_1 = require("@samet-it/be-base-common");
50
+ const common_1 = require("@leyyo/common");
50
51
  /**
51
52
  * Redis connection abstract class
52
53
  * */
@@ -60,7 +61,7 @@ class RedisConnection extends be_cache_common_1.CacheConnection {
60
61
  constructor(opt) {
61
62
  super(opt);
62
63
  if (!this.logger) {
63
- this.logger = be_base_common_1.logger.create(this);
64
+ this.logger = be_base_common_1.logger.of(this);
64
65
  }
65
66
  this._readFromEnv();
66
67
  this._buildUrl();
@@ -137,14 +138,14 @@ class RedisConnection extends be_cache_common_1.CacheConnection {
137
138
  }
138
139
  if (this._props.connectTryCount > RedisConnection.CONN_TRY_COUNT) {
139
140
  const err = new be_cache_common_1.CacheError('Maximum try county', { tryCount: this._props.connectTryCount });
140
- this.logger.error(be_base_common_1.errorHandler.common.logText(err, 'connect'));
141
+ this.logger.error(common_1.errorCommon.text(err, 'connect'));
141
142
  return false;
142
143
  }
143
144
  try {
144
145
  props.client = redis.createClient({ url: this._props.producedUrl });
145
146
  props.client
146
147
  .on("error", err => {
147
- this.logger.warn(be_base_common_1.errorHandler.common.logText(err, 'connection', this._props.connectTryCount));
148
+ this.logger.warn(common_1.errorCommon.text(err, 'connection', this._props.connectTryCount));
148
149
  props.connectTryCount++;
149
150
  const old = this.isConnected;
150
151
  props.isConnected = false;
@@ -177,7 +178,7 @@ class RedisConnection extends be_cache_common_1.CacheConnection {
177
178
  setTimeout(() => this.ping(true).then(), 30000);
178
179
  }
179
180
  catch (e) {
180
- this.logger.warn(be_base_common_1.errorHandler.common.logText(e, 'connection', this._props.connectTryCount));
181
+ this.logger.warn(common_1.errorCommon.text(e, 'connection', this._props.connectTryCount));
181
182
  }
182
183
  return true;
183
184
  });
@@ -190,7 +191,7 @@ class RedisConnection extends be_cache_common_1.CacheConnection {
190
191
  }
191
192
  if (this._props.pingTryCount > RedisConnection.PING_TRY_COUNT) {
192
193
  const err = new be_cache_common_1.CacheError('Maximum try county', { tryCount: this._props.pingTryCount });
193
- this.logger.error(be_base_common_1.errorHandler.common.logText(err, 'connect'));
194
+ this.logger.error(common_1.errorCommon.text(err, 'connect'));
194
195
  return false;
195
196
  }
196
197
  let result = false;
@@ -202,7 +203,7 @@ class RedisConnection extends be_cache_common_1.CacheConnection {
202
203
  }
203
204
  catch (err) {
204
205
  this._props.pingTryCount++;
205
- this.logger.warn(be_base_common_1.errorHandler.common.logText(err, 'ping', this._props.pingTryCount));
206
+ this.logger.warn(common_1.errorCommon.text(err, 'ping', this._props.pingTryCount));
206
207
  setTimeout(() => this.ping(true).then(), this._pingDelay);
207
208
  next = false;
208
209
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@samet-it/be-redis-common",
3
- "version": "1.1.10",
3
+ "version": "1.3.1",
4
4
  "description": "Redis common component",
5
5
  "keywords": [
6
6
  "redis",
@@ -68,10 +68,10 @@
68
68
  }
69
69
  },
70
70
  "dependencies": {
71
- "@leyyo/common": "^1.2.4",
72
- "@leyyo/env": "^1.2.5",
73
- "@samet-it/be-base-common": "^1.1.5",
74
- "@samet-it/be-cache-common": "^1.1.10",
71
+ "@leyyo/common": "^1.3.7",
72
+ "@leyyo/env": "^1.3.4",
73
+ "@samet-it/be-base-common": "^1.3.1",
74
+ "@samet-it/be-cache-common": "^1.3.1",
75
75
  "redis": "^5.10.0"
76
76
  }
77
77
  }