@zeltjs/redis 0.11.0 → 0.12.0-canary.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/index.cjs CHANGED
@@ -39,12 +39,22 @@ var RedisService = class {
39
39
  get client() {
40
40
  return this._client;
41
41
  }
42
- async startup() {}
42
+ async startup() {
43
+ try {
44
+ await this._client.connect();
45
+ } catch (error) {
46
+ this._client.disconnect();
47
+ throw error;
48
+ }
49
+ }
43
50
  async shutdown() {
44
51
  this._client.disconnect();
45
52
  }
46
53
  constructor(config = (0, _zeltjs_core.inject)(require_redis_config.RedisConfig), lifecycle = (0, _zeltjs_core.inject)(_zeltjs_core.LifecycleManager)) {
47
- this._client = new ioredis.default(config.url, config.options);
54
+ this._client = new ioredis.default(config.url, {
55
+ ...config.options,
56
+ lazyConnect: true
57
+ });
48
58
  lifecycle.register(this);
49
59
  }
50
60
  };
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.cts","names":[],"sources":["../src/redis.service.ts"],"mappings":";;;;;cAOa,YAAA,YAAwB,SAAA;EAAA,iBAClB,OAAA;cAEL,MAAA,GAAM,WAAA,EAAwB,SAAA,GAAS,gBAAA;EAAA,IAK/C,MAAA,CAAA,GAAU,KAAA;EAIR,OAAA,CAAA,GAAW,OAAA;EAEX,QAAA,CAAA,GAAY,OAAA;AAAA"}
1
+ {"version":3,"file":"index.d.cts","names":[],"sources":["../src/redis.service.ts"],"mappings":";;;;;cAOa,YAAA,YAAwB,SAAA;EAAA,iBAClB,OAAA;cAEL,MAAA,GAAM,WAAA,EAAwB,SAAA,GAAS,gBAAA;EAAA,IAQ/C,MAAA,CAAA,GAAU,KAAA;EAIR,OAAA,CAAA,GAAW,OAAA;EAaX,QAAA,CAAA,GAAY,OAAA;AAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../src/redis.service.ts"],"mappings":";;;;;cAOa,YAAA,YAAwB,SAAA;EAAA,iBAClB,OAAA;cAEL,MAAA,GAAM,WAAA,EAAwB,SAAA,GAAS,gBAAA;EAAA,IAK/C,MAAA,CAAA,GAAU,KAAA;EAIR,OAAA,CAAA,GAAW,OAAA;EAEX,QAAA,CAAA,GAAY,OAAA;AAAA"}
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../src/redis.service.ts"],"mappings":";;;;;cAOa,YAAA,YAAwB,SAAA;EAAA,iBAClB,OAAA;cAEL,MAAA,GAAM,WAAA,EAAwB,SAAA,GAAS,gBAAA;EAAA,IAQ/C,MAAA,CAAA,GAAU,KAAA;EAIR,OAAA,CAAA,GAAW,OAAA;EAaX,QAAA,CAAA,GAAY,OAAA;AAAA"}
package/dist/index.js CHANGED
@@ -15,12 +15,22 @@ var RedisService = class {
15
15
  get client() {
16
16
  return this._client;
17
17
  }
18
- async startup() {}
18
+ async startup() {
19
+ try {
20
+ await this._client.connect();
21
+ } catch (error) {
22
+ this._client.disconnect();
23
+ throw error;
24
+ }
25
+ }
19
26
  async shutdown() {
20
27
  this._client.disconnect();
21
28
  }
22
29
  constructor(config = inject(RedisConfig), lifecycle = inject(LifecycleManager)) {
23
- this._client = new Redis(config.url, config.options);
30
+ this._client = new Redis(config.url, {
31
+ ...config.options,
32
+ lazyConnect: true
33
+ });
24
34
  lifecycle.register(this);
25
35
  }
26
36
  };
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["Injectable","inject","LifecycleManager","Redis","RedisConfig","RedisService","client","_client","startup","shutdown","disconnect","config","lifecycle","url","options","register"],"sources":["../src/redis.service.ts"],"sourcesContent":["import type { Lifecycle } from '@zeltjs/core';\nimport { Injectable, inject, LifecycleManager } from '@zeltjs/core';\nimport Redis from 'ioredis';\n\nimport { RedisConfig } from './redis.config';\n\n@Injectable()\nexport class RedisService implements Lifecycle {\n private readonly _client: Redis;\n\n constructor(config = inject(RedisConfig), lifecycle = inject(LifecycleManager)) {\n this._client = new Redis(config.url, config.options);\n lifecycle.register(this);\n }\n\n get client(): Redis {\n return this._client;\n }\n\n async startup(): Promise<void> {}\n\n async shutdown(): Promise<void> {\n this._client.disconnect();\n }\n}\n"],"mappings":";;;;;;;;;;;;;AAOA,IAAaK,eAAb,MAAaA;CAQX,IAAIC,SAAgB;AAClB,SAAO,KAAKC;;CAGd,MAAMC,UAAyB;CAE/B,MAAMC,WAA0B;AAC9B,OAAKF,QAAQG,YAAU;;CAZzB,YAAYC,SAASV,OAAOG,YAAY,EAAEQ,YAAYX,OAAOC,iBAAiB,EAAE;AAC9E,OAAKK,UAAU,IAAIJ,MAAMQ,OAAOE,KAAKF,OAAOG,QAAO;AACnDF,YAAUG,SAAS,KAAI"}
1
+ {"version":3,"file":"index.js","names":["Injectable","inject","LifecycleManager","Redis","RedisConfig","RedisService","client","_client","startup","connect","error","disconnect","shutdown","config","lifecycle","url","options","lazyConnect","register"],"sources":["../src/redis.service.ts"],"sourcesContent":["import type { Lifecycle } from '@zeltjs/core';\nimport { Injectable, inject, LifecycleManager } from '@zeltjs/core';\nimport Redis from 'ioredis';\n\nimport { RedisConfig } from './redis.config';\n\n@Injectable()\nexport class RedisService implements Lifecycle {\n private readonly _client: Redis;\n\n constructor(config = inject(RedisConfig), lifecycle = inject(LifecycleManager)) {\n // lazyConnect defers the network handshake to startup(); ioredis skips it\n // entirely at construction time, so `client` is safe to read from other\n // constructors (e.g. namespace() call sites) before the app has started.\n this._client = new Redis(config.url, { ...config.options, lazyConnect: true });\n lifecycle.register(this);\n }\n\n get client(): Redis {\n return this._client;\n }\n\n async startup(): Promise<void> {\n try {\n await this._client.connect();\n } catch (error) {\n // ioredis keeps rescheduling reconnects via retryStrategy after a\n // rejected connect(), and LifecycleManager never calls shutdown() for\n // a lifecycle whose own startup() threw, so this is the only place\n // left to stop the socket/reconnect timer before rethrowing.\n this._client.disconnect();\n throw error;\n }\n }\n\n async shutdown(): Promise<void> {\n this._client.disconnect();\n }\n}\n"],"mappings":";;;;;;;;;;;;;AAOA,IAAaK,eAAb,MAAaA;CAWX,IAAIC,SAAgB;AAClB,SAAO,KAAKC;;CAGd,MAAMC,UAAyB;AAC7B,MAAI;AACF,SAAM,KAAKD,QAAQE,SAAO;WACnBC,OAAO;AAKd,QAAKH,QAAQI,YAAU;AACvB,SAAMD;;;CAIV,MAAME,WAA0B;AAC9B,OAAKL,QAAQI,YAAU;;CA1BzB,YAAYE,SAASZ,OAAOG,YAAY,EAAEU,YAAYb,OAAOC,iBAAiB,EAAE;AAI9E,OAAKK,UAAU,IAAIJ,MAAMU,OAAOE,KAAK;GAAE,GAAGF,OAAOG;GAASC,aAAa;GAAK,CAAA;AAC5EH,YAAUI,SAAS,KAAI"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeltjs/redis",
3
- "version": "0.11.0",
3
+ "version": "0.12.0-canary.1",
4
4
  "description": "Redis integration for Zelt applications",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -39,8 +39,8 @@
39
39
  ],
40
40
  "peerDependencies": {
41
41
  "testcontainers": ">=10 <12",
42
- "@zeltjs/core": "0.11.0",
43
- "@zeltjs/testing": "0.11.0"
42
+ "@zeltjs/core": "0.12.0-canary.1",
43
+ "@zeltjs/testing": "0.12.0-canary.1"
44
44
  },
45
45
  "peerDependenciesMeta": {
46
46
  "@zeltjs/testing": {
@@ -56,8 +56,8 @@
56
56
  "devDependencies": {
57
57
  "@types/node": "22.19.17",
58
58
  "testcontainers": "10.25.0",
59
- "@zeltjs/core": "0.11.0",
60
- "@zeltjs/testing": "0.11.0"
59
+ "@zeltjs/core": "0.12.0-canary.1",
60
+ "@zeltjs/testing": "0.12.0-canary.1"
61
61
  },
62
62
  "volta": {
63
63
  "extends": "../../package.json"