@rsdk/nats.common 5.6.0-next.4 → 5.6.0-next.6

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,3 +1,7 @@
1
- import type { Constructor } from '@rsdk/common';
1
+ import { type Constructor } from '@rsdk/common';
2
2
  import type { HealthIndicator } from '@rsdk/core';
3
- export declare const createNatsClientIndicatorProvider: (connectionName?: string) => Constructor<HealthIndicator>;
3
+ /**
4
+ * @param connectionName Connection name
5
+ * @param isOptional Flag indicating whether the readiness probe is optional. If set to `true`, an error in the probe will not affect the global system status.
6
+ */
7
+ export declare const createNatsClientIndicatorProvider: (connectionName?: string, isOptional?: boolean) => Constructor<HealthIndicator>;
@@ -1,16 +1,21 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createNatsClientIndicatorProvider = void 0;
4
+ const common_1 = require("@rsdk/common");
4
5
  const core_1 = require("@rsdk/core");
5
6
  const get_connection_indicator_key_fn_1 = require("../utils/get-connection-indicator-key.fn");
6
7
  const client_indicator_1 = require("./client.indicator");
7
- const createNatsClientIndicatorProvider = (connectionName) => {
8
+ /**
9
+ * @param connectionName Connection name
10
+ * @param isOptional Flag indicating whether the readiness probe is optional. If set to `true`, an error in the probe will not affect the global system status.
11
+ */
12
+ const createNatsClientIndicatorProvider = (connectionName, isOptional) => {
8
13
  const DynamicNatsClientIndicator = class extends client_indicator_1.NatsClientIndicator {
9
14
  constructor(connection) {
10
15
  super(connection);
11
16
  }
12
17
  };
13
- (0, core_1.Indicator)((0, get_connection_indicator_key_fn_1.getConnectionIndicatorKey)(connectionName))(DynamicNatsClientIndicator);
18
+ (0, core_1.Indicator)((0, get_connection_indicator_key_fn_1.getConnectionIndicatorKey)(connectionName), (0, common_1.omitUndefined)({ isOptional }))(DynamicNatsClientIndicator);
14
19
  return DynamicNatsClientIndicator;
15
20
  };
16
21
  exports.createNatsClientIndicatorProvider = createNatsClientIndicatorProvider;
@@ -1 +1 @@
1
- {"version":3,"file":"client.indicator.provider.js","sourceRoot":"","sources":["../../src/client/client.indicator.provider.ts"],"names":[],"mappings":";;;AAEA,qCAAuC;AAGvC,8FAAqF;AAErF,yDAAyD;AAElD,MAAM,iCAAiC,GAAG,CAC/C,cAAuB,EACO,EAAE;IAChC,MAAM,0BAA0B,GAAG,KAAM,SAAQ,sCAAmB;QAClE,YAAY,UAA0B;YACpC,KAAK,CAAC,UAAU,CAAC,CAAC;QACpB,CAAC;KACF,CAAC;IAEF,IAAA,gBAAS,EAAC,IAAA,2DAAyB,EAAC,cAAc,CAAC,CAAC,CAClD,0BAA0B,CAC3B,CAAC;IAEF,OAAO,0BAA0B,CAAC;AACpC,CAAC,CAAC;AAdW,QAAA,iCAAiC,qCAc5C"}
1
+ {"version":3,"file":"client.indicator.provider.js","sourceRoot":"","sources":["../../src/client/client.indicator.provider.ts"],"names":[],"mappings":";;;AAAA,yCAA+D;AAE/D,qCAAuC;AAGvC,8FAAqF;AAErF,yDAAyD;AAEzD;;;GAGG;AACI,MAAM,iCAAiC,GAAG,CAC/C,cAAuB,EACvB,UAAoB,EACU,EAAE;IAChC,MAAM,0BAA0B,GAAG,KAAM,SAAQ,sCAAmB;QAClE,YAAY,UAA0B;YACpC,KAAK,CAAC,UAAU,CAAC,CAAC;QACpB,CAAC;KACF,CAAC;IAEF,IAAA,gBAAS,EACP,IAAA,2DAAyB,EAAC,cAAc,CAAC,EACzC,IAAA,sBAAa,EAAC,EAAE,UAAU,EAAE,CAAC,CAC9B,CAAC,0BAA0B,CAAC,CAAC;IAE9B,OAAO,0BAA0B,CAAC;AACpC,CAAC,CAAC;AAhBW,QAAA,iCAAiC,qCAgB5C"}
@@ -1,5 +1,5 @@
1
1
  import type { DynamicModule } from '@nestjs/common';
2
2
  import type { ModuleOptions } from './module-options.interface';
3
3
  export declare class NatsClientModule {
4
- static forRoot({ connectionName, configConstructor, jetstreamOptions, }: ModuleOptions): DynamicModule;
4
+ static forRoot({ connectionName, configConstructor, jetstreamOptions, isOptionalIndicator, }: ModuleOptions): DynamicModule;
5
5
  }
@@ -16,7 +16,7 @@ const client_provider_1 = require("./client.provider");
16
16
  const jetstream_client_provider_1 = require("./jetstream-client.provider");
17
17
  const topics_service_1 = require("./topics.service");
18
18
  let NatsClientModule = NatsClientModule_1 = class NatsClientModule {
19
- static forRoot({ connectionName, configConstructor, jetstreamOptions, }) {
19
+ static forRoot({ connectionName, configConstructor, jetstreamOptions, isOptionalIndicator, }) {
20
20
  configConstructor = configConstructor ?? client_config_1.DefaultNatsConfig;
21
21
  let natsConfigToken = client_constants_1.NATS_CONFIG_INJECTION_TOKEN;
22
22
  let natsClientToken = client_constants_1.NATS_CLIENT_INJECTION_TOKEN;
@@ -43,7 +43,7 @@ let NatsClientModule = NatsClientModule_1 = class NatsClientModule {
43
43
  provide: client_constants_1.NATS_CLIENT_INJECTION_TOKEN_FOR_PACKAGE,
44
44
  useExisting: natsClientToken,
45
45
  },
46
- (0, client_indicator_provider_1.createNatsClientIndicatorProvider)(connectionName),
46
+ (0, client_indicator_provider_1.createNatsClientIndicatorProvider)(connectionName, isOptionalIndicator),
47
47
  ...exportProviders,
48
48
  ],
49
49
  exports: exportProviders,
@@ -1 +1 @@
1
- {"version":3,"file":"client.module.js","sourceRoot":"","sources":["../../src/client/client.module.ts"],"names":[],"mappings":";;;;;;;;;;AACA,2CAAgD;AAEhD,mDAAoD;AACpD,yDAQ4B;AAC5B,2EAAgF;AAChF,uDAAuD;AACvD,2EAA0E;AAE1E,qDAAiD;AAO1C,IAAM,gBAAgB,wBAAtB,MAAM,gBAAgB;IAC3B,MAAM,CAAC,OAAO,CAAC,EACb,cAAc,EACd,iBAAiB,EACjB,gBAAgB,GACF;QACd,iBAAiB,GAAG,iBAAiB,IAAI,iCAAiB,CAAC;QAE3D,IAAI,eAAe,GAAoB,8CAA2B,CAAC;QACnE,IAAI,eAAe,GAAoB,8CAA2B,CAAC;QACnE,IAAI,kBAAkB,GACpB,wDAAqC,CAAC;QAExC,IAAI,cAAc,EAAE,CAAC;YACnB,eAAe,GAAG,IAAA,wCAAqB,EAAC,cAAc,CAAC,CAAC;YACxD,eAAe,GAAG,IAAA,wCAAqB,EAAC,cAAc,CAAC,CAAC;YACxD,kBAAkB,GAAG,IAAA,2CAAwB,EAAC,cAAc,CAAC,CAAC;QAChE,CAAC;QAED,MAAM,eAAe,GAAe;YAClC,IAAA,oCAAkB,EAAC,iBAAiB,EAAE,eAAe,CAAC;YACtD,IAAA,uDAA2B,EACzB,eAAe,EACf,kBAAkB,EAClB,gBAAgB,CACjB;YACD;gBACE,OAAO,EAAE,eAAe;gBACxB,MAAM,EAAE,CAAC,iBAAiB,CAAC;gBAC3B,UAAU,EAAE,CAAC,MAAyB,EAAE,EAAE,CAAC,MAAM;aAClD;SACF,CAAC;QAEF,OAAO;YACL,MAAM,EAAE,kBAAgB;YACxB,MAAM,EAAE,IAAI;YACZ,SAAS,EAAE;gBACT;oBACE,OAAO,EAAE,0DAAuC;oBAChD,WAAW,EAAE,eAAe;iBAC7B;gBACD,IAAA,6DAAiC,EAAC,cAAc,CAAC;gBACjD,GAAG,eAAe;aACnB;YACD,OAAO,EAAE,eAAe;SACzB,CAAC;IACJ,CAAC;CACF,CAAA;AA/CY,4CAAgB;2BAAhB,gBAAgB;IAL5B,IAAA,eAAM,GAAE;IACR,IAAA,eAAM,EAAC;QACN,SAAS,EAAE,CAAC,8BAAa,CAAC;QAC1B,OAAO,EAAE,CAAC,8BAAa,CAAC;KACzB,CAAC;GACW,gBAAgB,CA+C5B"}
1
+ {"version":3,"file":"client.module.js","sourceRoot":"","sources":["../../src/client/client.module.ts"],"names":[],"mappings":";;;;;;;;;;AACA,2CAAgD;AAEhD,mDAAoD;AACpD,yDAQ4B;AAC5B,2EAAgF;AAChF,uDAAuD;AACvD,2EAA0E;AAE1E,qDAAiD;AAO1C,IAAM,gBAAgB,wBAAtB,MAAM,gBAAgB;IAC3B,MAAM,CAAC,OAAO,CAAC,EACb,cAAc,EACd,iBAAiB,EACjB,gBAAgB,EAChB,mBAAmB,GACL;QACd,iBAAiB,GAAG,iBAAiB,IAAI,iCAAiB,CAAC;QAE3D,IAAI,eAAe,GAAoB,8CAA2B,CAAC;QACnE,IAAI,eAAe,GAAoB,8CAA2B,CAAC;QACnE,IAAI,kBAAkB,GACpB,wDAAqC,CAAC;QAExC,IAAI,cAAc,EAAE,CAAC;YACnB,eAAe,GAAG,IAAA,wCAAqB,EAAC,cAAc,CAAC,CAAC;YACxD,eAAe,GAAG,IAAA,wCAAqB,EAAC,cAAc,CAAC,CAAC;YACxD,kBAAkB,GAAG,IAAA,2CAAwB,EAAC,cAAc,CAAC,CAAC;QAChE,CAAC;QAED,MAAM,eAAe,GAAe;YAClC,IAAA,oCAAkB,EAAC,iBAAiB,EAAE,eAAe,CAAC;YACtD,IAAA,uDAA2B,EACzB,eAAe,EACf,kBAAkB,EAClB,gBAAgB,CACjB;YACD;gBACE,OAAO,EAAE,eAAe;gBACxB,MAAM,EAAE,CAAC,iBAAiB,CAAC;gBAC3B,UAAU,EAAE,CAAC,MAAyB,EAAE,EAAE,CAAC,MAAM;aAClD;SACF,CAAC;QAEF,OAAO;YACL,MAAM,EAAE,kBAAgB;YACxB,MAAM,EAAE,IAAI;YACZ,SAAS,EAAE;gBACT;oBACE,OAAO,EAAE,0DAAuC;oBAChD,WAAW,EAAE,eAAe;iBAC7B;gBACD,IAAA,6DAAiC,EAAC,cAAc,EAAE,mBAAmB,CAAC;gBACtE,GAAG,eAAe;aACnB;YACD,OAAO,EAAE,eAAe;SACzB,CAAC;IACJ,CAAC;CACF,CAAA;AAhDY,4CAAgB;2BAAhB,gBAAgB;IAL5B,IAAA,eAAM,GAAE;IACR,IAAA,eAAM,EAAC;QACN,SAAS,EAAE,CAAC,8BAAa,CAAC;QAC1B,OAAO,EAAE,CAAC,8BAAa,CAAC;KACzB,CAAC;GACW,gBAAgB,CAgD5B"}
@@ -5,4 +5,9 @@ export interface ModuleOptions {
5
5
  connectionName?: string;
6
6
  configConstructor?: Constructor<DefaultNatsConfig>;
7
7
  jetstreamOptions?: JetStreamOptions;
8
+ /**
9
+ * Flag indicating whether the readiness probe for connection is optional.
10
+ * If set to `true`, an error in the probe will not affect the global system status.
11
+ */
12
+ isOptionalIndicator?: boolean;
8
13
  }
@@ -4,5 +4,6 @@ export declare class NatsStreamIndicatorModuleGenerator {
4
4
  streamName: string;
5
5
  connectionName?: string | undefined;
6
6
  domain?: string | undefined;
7
+ isOptional?: boolean;
7
8
  }): DynamicModule;
8
9
  }
@@ -7,7 +7,7 @@ const constants_1 = require("./constants");
7
7
  const stream_indicator_provider_1 = require("./stream.indicator.provider");
8
8
  class NatsStreamIndicatorModuleGenerator {
9
9
  static createClientModuleDefinition(target, opts) {
10
- const { streamName, connectionName, domain } = opts;
10
+ const { streamName, connectionName, domain, isOptional } = opts;
11
11
  const moduleDefinition = {
12
12
  global: true,
13
13
  module: NatsStreamIndicatorModuleGenerator,
@@ -26,7 +26,7 @@ class NatsStreamIndicatorModuleGenerator {
26
26
  provide: constants_1.NATS_STREAM_INDICATOR_DOMAIN,
27
27
  useValue: domain,
28
28
  },
29
- (0, stream_indicator_provider_1.createNatsStreamIndicatorProvider)(streamName, connectionName, domain),
29
+ (0, stream_indicator_provider_1.createNatsStreamIndicatorProvider)(streamName, connectionName, domain, isOptional),
30
30
  ],
31
31
  };
32
32
  metadata_1.RsdkMetadata.add(target, opts, constants_1.NATS_STREAM_INDICATORS_SCOPE);
@@ -1 +1 @@
1
- {"version":3,"file":"stream.indicator.generator.js","sourceRoot":"","sources":["../../src/stream-indicator/stream.indicator.generator.ts"],"names":[],"mappings":";;;AACA,6CAA8C;AAE9C,iEAGoC;AAEpC,2CAKqB;AACrB,2EAAgF;AAEhF,MAAa,kCAAkC;IAC7C,MAAM,CAAC,4BAA4B,CACjC,MAAc,EACd,IAIC;QAED,MAAM,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;QAEpD,MAAM,gBAAgB,GAAkB;YACtC,MAAM,EAAE,IAAI;YACZ,MAAM,EAAE,kCAAkC;YAC1C,SAAS,EAAE;gBACT;oBACE,OAAO,EAAE,4CAAgC;oBACzC,WAAW,EAAE,cAAc;wBACzB,CAAC,CAAC,IAAA,wCAAqB,EAAC,cAAc,CAAC;wBACvC,CAAC,CAAC,8CAA2B;iBAChC;gBACD;oBACE,OAAO,EAAE,6CAAiC;oBAC1C,QAAQ,EAAE,UAAU;iBACrB;gBACD;oBACE,OAAO,EAAE,wCAA4B;oBACrC,QAAQ,EAAE,MAAM;iBACjB;gBACD,IAAA,6DAAiC,EAAC,UAAU,EAAE,cAAc,EAAE,MAAM,CAAC;aACtE;SACF,CAAC;QAEF,uBAAY,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,EAAE,wCAA4B,CAAC,CAAC;QAE7D,OAAO,gBAAgB,CAAC;IAC1B,CAAC;CACF;AArCD,gFAqCC"}
1
+ {"version":3,"file":"stream.indicator.generator.js","sourceRoot":"","sources":["../../src/stream-indicator/stream.indicator.generator.ts"],"names":[],"mappings":";;;AACA,6CAA8C;AAE9C,iEAGoC;AAEpC,2CAKqB;AACrB,2EAAgF;AAEhF,MAAa,kCAAkC;IAC7C,MAAM,CAAC,4BAA4B,CACjC,MAAc,EACd,IAKC;QAED,MAAM,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,EAAE,UAAU,EAAE,GAAG,IAAI,CAAC;QAEhE,MAAM,gBAAgB,GAAkB;YACtC,MAAM,EAAE,IAAI;YACZ,MAAM,EAAE,kCAAkC;YAC1C,SAAS,EAAE;gBACT;oBACE,OAAO,EAAE,4CAAgC;oBACzC,WAAW,EAAE,cAAc;wBACzB,CAAC,CAAC,IAAA,wCAAqB,EAAC,cAAc,CAAC;wBACvC,CAAC,CAAC,8CAA2B;iBAChC;gBACD;oBACE,OAAO,EAAE,6CAAiC;oBAC1C,QAAQ,EAAE,UAAU;iBACrB;gBACD;oBACE,OAAO,EAAE,wCAA4B;oBACrC,QAAQ,EAAE,MAAM;iBACjB;gBACD,IAAA,6DAAiC,EAC/B,UAAU,EACV,cAAc,EACd,MAAM,EACN,UAAU,CACX;aACF;SACF,CAAC;QAEF,uBAAY,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,EAAE,wCAA4B,CAAC,CAAC;QAE7D,OAAO,gBAAgB,CAAC;IAC1B,CAAC;CACF;AA3CD,gFA2CC"}
@@ -1,3 +1,9 @@
1
- import type { Constructor } from '@rsdk/common';
1
+ import { type Constructor } from '@rsdk/common';
2
2
  import type { HealthIndicator } from '@rsdk/core';
3
- export declare const createNatsStreamIndicatorProvider: (streamName: string, connectionName?: string, domain?: string) => Constructor<HealthIndicator>;
3
+ /**
4
+ * @param streamName Stream name
5
+ * @param connectionName Connection name
6
+ * @param domain JetStream domain
7
+ * @param isOptional Flag indicating whether the readiness probe is optional. If set to `true`, an error in the probe will not affect the global system status.
8
+ */
9
+ export declare const createNatsStreamIndicatorProvider: (streamName: string, connectionName?: string, domain?: string, isOptional?: boolean) => Constructor<HealthIndicator>;
@@ -1,16 +1,23 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createNatsStreamIndicatorProvider = void 0;
4
+ const common_1 = require("@rsdk/common");
4
5
  const core_1 = require("@rsdk/core");
5
6
  const stream_indicator_1 = require("../stream-indicator/stream.indicator");
6
7
  const get_stream_indicator_key_fn_1 = require("../utils/get-stream-indicator-key.fn");
7
- const createNatsStreamIndicatorProvider = (streamName, connectionName, domain) => {
8
+ /**
9
+ * @param streamName Stream name
10
+ * @param connectionName Connection name
11
+ * @param domain JetStream domain
12
+ * @param isOptional Flag indicating whether the readiness probe is optional. If set to `true`, an error in the probe will not affect the global system status.
13
+ */
14
+ const createNatsStreamIndicatorProvider = (streamName, connectionName, domain, isOptional) => {
8
15
  const DynamicNatsStreamIndicator = class extends stream_indicator_1.NatsStreamIndicator {
9
16
  constructor(connection, streamName, domain) {
10
17
  super(connection, streamName, domain);
11
18
  }
12
19
  };
13
- (0, core_1.Indicator)((0, get_stream_indicator_key_fn_1.getStreamIndicatorKey)(streamName, connectionName, domain))(DynamicNatsStreamIndicator);
20
+ (0, core_1.Indicator)((0, get_stream_indicator_key_fn_1.getStreamIndicatorKey)(streamName, connectionName, domain), (0, common_1.omitUndefined)({ isOptional }))(DynamicNatsStreamIndicator);
14
21
  return DynamicNatsStreamIndicator;
15
22
  };
16
23
  exports.createNatsStreamIndicatorProvider = createNatsStreamIndicatorProvider;
@@ -1 +1 @@
1
- {"version":3,"file":"stream.indicator.provider.js","sourceRoot":"","sources":["../../src/stream-indicator/stream.indicator.provider.ts"],"names":[],"mappings":";;;AAEA,qCAAuC;AAGvC,2EAA2E;AAC3E,sFAA6E;AAEtE,MAAM,iCAAiC,GAAG,CAC/C,UAAkB,EAClB,cAAuB,EACvB,MAAe,EACe,EAAE;IAChC,MAAM,0BAA0B,GAAG,KAAM,SAAQ,sCAAmB;QAClE,YACE,UAA0B,EAC1B,UAAkB,EAClB,MAAe;YAEf,KAAK,CAAC,UAAU,EAAE,UAAU,EAAE,MAAM,CAAC,CAAC;QACxC,CAAC;KACF,CAAC;IAEF,IAAA,gBAAS,EAAC,IAAA,mDAAqB,EAAC,UAAU,EAAE,cAAc,EAAE,MAAM,CAAC,CAAC,CAClE,0BAA0B,CAC3B,CAAC;IAEF,OAAO,0BAA0B,CAAC;AACpC,CAAC,CAAC;AApBW,QAAA,iCAAiC,qCAoB5C"}
1
+ {"version":3,"file":"stream.indicator.provider.js","sourceRoot":"","sources":["../../src/stream-indicator/stream.indicator.provider.ts"],"names":[],"mappings":";;;AAAA,yCAA+D;AAE/D,qCAAuC;AAGvC,2EAA2E;AAC3E,sFAA6E;AAE7E;;;;;GAKG;AACI,MAAM,iCAAiC,GAAG,CAC/C,UAAkB,EAClB,cAAuB,EACvB,MAAe,EACf,UAAoB,EACU,EAAE;IAChC,MAAM,0BAA0B,GAAG,KAAM,SAAQ,sCAAmB;QAClE,YACE,UAA0B,EAC1B,UAAkB,EAClB,MAAe;YAEf,KAAK,CAAC,UAAU,EAAE,UAAU,EAAE,MAAM,CAAC,CAAC;QACxC,CAAC;KACF,CAAC;IAEF,IAAA,gBAAS,EACP,IAAA,mDAAqB,EAAC,UAAU,EAAE,cAAc,EAAE,MAAM,CAAC,EACzD,IAAA,sBAAa,EAAC,EAAE,UAAU,EAAE,CAAC,CAC9B,CAAC,0BAA0B,CAAC,CAAC;IAE9B,OAAO,0BAA0B,CAAC;AACpC,CAAC,CAAC;AAtBW,QAAA,iCAAiC,qCAsB5C"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rsdk/nats.common",
3
- "version": "5.6.0-next.4",
3
+ "version": "5.6.0-next.6",
4
4
  "description": "Common functionality for nats consumers and producers",
5
5
  "license": "Apache License 2.0",
6
6
  "publishConfig": {
@@ -27,5 +27,5 @@
27
27
  "lodash": "^4.17.21",
28
28
  "protobufjs": "^7.2.3"
29
29
  },
30
- "gitHead": "1ebbec65200193150eb64ff321831c41983c5556"
30
+ "gitHead": "692b9bc92787c05026df3d3ca6fcd7b9bdea0f97"
31
31
  }
@@ -1,4 +1,4 @@
1
- import type { Constructor } from '@rsdk/common';
1
+ import { type Constructor, omitUndefined } from '@rsdk/common';
2
2
  import type { HealthIndicator } from '@rsdk/core';
3
3
  import { Indicator } from '@rsdk/core';
4
4
  import type { NatsConnection } from 'nats';
@@ -7,8 +7,13 @@ import { getConnectionIndicatorKey } from '../utils/get-connection-indicator-key
7
7
 
8
8
  import { NatsClientIndicator } from './client.indicator';
9
9
 
10
+ /**
11
+ * @param connectionName Connection name
12
+ * @param isOptional Flag indicating whether the readiness probe is optional. If set to `true`, an error in the probe will not affect the global system status.
13
+ */
10
14
  export const createNatsClientIndicatorProvider = (
11
15
  connectionName?: string,
16
+ isOptional?: boolean,
12
17
  ): Constructor<HealthIndicator> => {
13
18
  const DynamicNatsClientIndicator = class extends NatsClientIndicator {
14
19
  constructor(connection: NatsConnection) {
@@ -16,9 +21,10 @@ export const createNatsClientIndicatorProvider = (
16
21
  }
17
22
  };
18
23
 
19
- Indicator(getConnectionIndicatorKey(connectionName))(
20
- DynamicNatsClientIndicator,
21
- );
24
+ Indicator(
25
+ getConnectionIndicatorKey(connectionName),
26
+ omitUndefined({ isOptional }),
27
+ )(DynamicNatsClientIndicator);
22
28
 
23
29
  return DynamicNatsClientIndicator;
24
30
  };
@@ -27,6 +27,7 @@ export class NatsClientModule {
27
27
  connectionName,
28
28
  configConstructor,
29
29
  jetstreamOptions,
30
+ isOptionalIndicator,
30
31
  }: ModuleOptions): DynamicModule {
31
32
  configConstructor = configConstructor ?? DefaultNatsConfig;
32
33
 
@@ -63,7 +64,7 @@ export class NatsClientModule {
63
64
  provide: NATS_CLIENT_INJECTION_TOKEN_FOR_PACKAGE,
64
65
  useExisting: natsClientToken,
65
66
  },
66
- createNatsClientIndicatorProvider(connectionName),
67
+ createNatsClientIndicatorProvider(connectionName, isOptionalIndicator),
67
68
  ...exportProviders,
68
69
  ],
69
70
  exports: exportProviders,
@@ -7,4 +7,10 @@ export interface ModuleOptions {
7
7
  connectionName?: string;
8
8
  configConstructor?: Constructor<DefaultNatsConfig>;
9
9
  jetstreamOptions?: JetStreamOptions;
10
+
11
+ /**
12
+ * Flag indicating whether the readiness probe for connection is optional.
13
+ * If set to `true`, an error in the probe will not affect the global system status.
14
+ */
15
+ isOptionalIndicator?: boolean;
10
16
  }
@@ -21,9 +21,10 @@ export class NatsStreamIndicatorModuleGenerator {
21
21
  streamName: string;
22
22
  connectionName?: string | undefined;
23
23
  domain?: string | undefined;
24
+ isOptional?: boolean;
24
25
  },
25
26
  ): DynamicModule {
26
- const { streamName, connectionName, domain } = opts;
27
+ const { streamName, connectionName, domain, isOptional } = opts;
27
28
 
28
29
  const moduleDefinition: DynamicModule = {
29
30
  global: true,
@@ -43,7 +44,12 @@ export class NatsStreamIndicatorModuleGenerator {
43
44
  provide: NATS_STREAM_INDICATOR_DOMAIN,
44
45
  useValue: domain,
45
46
  },
46
- createNatsStreamIndicatorProvider(streamName, connectionName, domain),
47
+ createNatsStreamIndicatorProvider(
48
+ streamName,
49
+ connectionName,
50
+ domain,
51
+ isOptional,
52
+ ),
47
53
  ],
48
54
  };
49
55
 
@@ -1,4 +1,4 @@
1
- import type { Constructor } from '@rsdk/common';
1
+ import { type Constructor, omitUndefined } from '@rsdk/common';
2
2
  import type { HealthIndicator } from '@rsdk/core';
3
3
  import { Indicator } from '@rsdk/core';
4
4
  import type { NatsConnection } from 'nats';
@@ -6,10 +6,17 @@ import type { NatsConnection } from 'nats';
6
6
  import { NatsStreamIndicator } from '../stream-indicator/stream.indicator';
7
7
  import { getStreamIndicatorKey } from '../utils/get-stream-indicator-key.fn';
8
8
 
9
+ /**
10
+ * @param streamName Stream name
11
+ * @param connectionName Connection name
12
+ * @param domain JetStream domain
13
+ * @param isOptional Flag indicating whether the readiness probe is optional. If set to `true`, an error in the probe will not affect the global system status.
14
+ */
9
15
  export const createNatsStreamIndicatorProvider = (
10
16
  streamName: string,
11
17
  connectionName?: string,
12
18
  domain?: string,
19
+ isOptional?: boolean,
13
20
  ): Constructor<HealthIndicator> => {
14
21
  const DynamicNatsStreamIndicator = class extends NatsStreamIndicator {
15
22
  constructor(
@@ -21,9 +28,10 @@ export const createNatsStreamIndicatorProvider = (
21
28
  }
22
29
  };
23
30
 
24
- Indicator(getStreamIndicatorKey(streamName, connectionName, domain))(
25
- DynamicNatsStreamIndicator,
26
- );
31
+ Indicator(
32
+ getStreamIndicatorKey(streamName, connectionName, domain),
33
+ omitUndefined({ isOptional }),
34
+ )(DynamicNatsStreamIndicator);
27
35
 
28
36
  return DynamicNatsStreamIndicator;
29
37
  };