@rayondigital/nest-dapr 0.9.34 → 0.9.35

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.
@@ -6,6 +6,7 @@ import { NestActorManager } from './actors/nest-actor-manager';
6
6
  import { DaprContextService } from './dapr-context-service';
7
7
  import { DaprMetadataAccessor } from './dapr-metadata.accessor';
8
8
  import { DaprModuleOptions } from './dapr.module';
9
+ import { DaprPubSubClient } from './pubsub/dapr-pubsub-client.service';
9
10
  export declare class DaprLoader implements OnApplicationBootstrap, OnApplicationShutdown {
10
11
  private readonly discoveryService;
11
12
  private readonly metadataScanner;
@@ -15,9 +16,10 @@ export declare class DaprLoader implements OnApplicationBootstrap, OnApplication
15
16
  private readonly daprActorClient;
16
17
  private readonly moduleRef;
17
18
  private readonly contextService;
19
+ private readonly pubSubClient;
18
20
  private readonly actorManager;
19
21
  private readonly logger;
20
- constructor(discoveryService: DiscoveryService, metadataScanner: MetadataScanner, daprServer: DaprServer, daprMetadataAccessor: DaprMetadataAccessor, options: DaprModuleOptions, daprActorClient: DaprActorClient, moduleRef: ModuleRef, contextService: DaprContextService, actorManager: NestActorManager);
22
+ constructor(discoveryService: DiscoveryService, metadataScanner: MetadataScanner, daprServer: DaprServer, daprMetadataAccessor: DaprMetadataAccessor, options: DaprModuleOptions, daprActorClient: DaprActorClient, moduleRef: ModuleRef, contextService: DaprContextService, pubSubClient: DaprPubSubClient, actorManager: NestActorManager);
21
23
  onApplicationBootstrap(): Promise<void>;
22
24
  onApplicationShutdown(): Promise<void>;
23
25
  loadDaprHandlers(): void;
@@ -36,8 +36,9 @@ const nest_actor_manager_1 = require("./actors/nest-actor-manager");
36
36
  const dapr_context_service_1 = require("./dapr-context-service");
37
37
  const dapr_metadata_accessor_1 = require("./dapr-metadata.accessor");
38
38
  const dapr_module_1 = require("./dapr.module");
39
+ const dapr_pubsub_client_service_1 = require("./pubsub/dapr-pubsub-client.service");
39
40
  let DaprLoader = DaprLoader_1 = class DaprLoader {
40
- constructor(discoveryService, metadataScanner, daprServer, daprMetadataAccessor, options, daprActorClient, moduleRef, contextService, actorManager) {
41
+ constructor(discoveryService, metadataScanner, daprServer, daprMetadataAccessor, options, daprActorClient, moduleRef, contextService, pubSubClient, actorManager) {
41
42
  this.discoveryService = discoveryService;
42
43
  this.metadataScanner = metadataScanner;
43
44
  this.daprServer = daprServer;
@@ -46,11 +47,12 @@ let DaprLoader = DaprLoader_1 = class DaprLoader {
46
47
  this.daprActorClient = daprActorClient;
47
48
  this.moduleRef = moduleRef;
48
49
  this.contextService = contextService;
50
+ this.pubSubClient = pubSubClient;
49
51
  this.actorManager = actorManager;
50
52
  this.logger = new common_1.Logger(DaprLoader_1.name);
51
53
  }
52
54
  onApplicationBootstrap() {
53
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
55
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
54
56
  return __awaiter(this, void 0, void 0, function* () {
55
57
  if (this.options.disabled) {
56
58
  this.logger.log('Dapr server is disabled');
@@ -63,12 +65,15 @@ let DaprLoader = DaprLoader_1 = class DaprLoader {
63
65
  if ((_c = (_b = (_a = this.options.clientOptions) === null || _a === void 0 ? void 0 : _a.actor) === null || _b === void 0 ? void 0 : _b.reentrancy) === null || _c === void 0 ? void 0 : _c.enabled) {
64
66
  this.actorManager.setupReentrancy();
65
67
  }
68
+ if ((_d = this.options.pubsubOptions) === null || _d === void 0 ? void 0 : _d.defaultName) {
69
+ this.pubSubClient.setDefaultName(this.options.pubsubOptions.defaultName);
70
+ }
66
71
  if (this.options.actorOptions) {
67
- this.daprActorClient.setAllowInternalCalls((_e = (_d = this.options.actorOptions) === null || _d === void 0 ? void 0 : _d.allowInternalCalls) !== null && _e !== void 0 ? _e : false);
68
- this.daprActorClient.setPrefix((_g = (_f = this.options.actorOptions) === null || _f === void 0 ? void 0 : _f.prefix) !== null && _g !== void 0 ? _g : '', (_j = (_h = this.options.actorOptions) === null || _h === void 0 ? void 0 : _h.delimiter) !== null && _j !== void 0 ? _j : '-');
69
- this.daprActorClient.setTypeNamePrefix((_l = (_k = this.options.actorOptions) === null || _k === void 0 ? void 0 : _k.typeNamePrefix) !== null && _l !== void 0 ? _l : '');
70
- if ((_m = this.options.actorOptions) === null || _m === void 0 ? void 0 : _m.prefix) {
71
- this.logger.log(`Actors will be prefixed with ${(_p = (_o = this.options.actorOptions) === null || _o === void 0 ? void 0 : _o.prefix) !== null && _p !== void 0 ? _p : ''} and delimited with ${(_r = (_q = this.options.actorOptions) === null || _q === void 0 ? void 0 : _q.delimiter) !== null && _r !== void 0 ? _r : '-'}`);
72
+ this.daprActorClient.setAllowInternalCalls((_f = (_e = this.options.actorOptions) === null || _e === void 0 ? void 0 : _e.allowInternalCalls) !== null && _f !== void 0 ? _f : false);
73
+ this.daprActorClient.setPrefix((_h = (_g = this.options.actorOptions) === null || _g === void 0 ? void 0 : _g.prefix) !== null && _h !== void 0 ? _h : '', (_k = (_j = this.options.actorOptions) === null || _j === void 0 ? void 0 : _j.delimiter) !== null && _k !== void 0 ? _k : '-');
74
+ this.daprActorClient.setTypeNamePrefix((_m = (_l = this.options.actorOptions) === null || _l === void 0 ? void 0 : _l.typeNamePrefix) !== null && _m !== void 0 ? _m : '');
75
+ if ((_o = this.options.actorOptions) === null || _o === void 0 ? void 0 : _o.prefix) {
76
+ this.logger.log(`Actors will be prefixed with ${(_q = (_p = this.options.actorOptions) === null || _p === void 0 ? void 0 : _p.prefix) !== null && _q !== void 0 ? _q : ''} and delimited with ${(_s = (_r = this.options.actorOptions) === null || _r === void 0 ? void 0 : _r.delimiter) !== null && _s !== void 0 ? _s : '-'}`);
72
77
  }
73
78
  }
74
79
  yield this.daprServer.actor.init();
@@ -218,6 +223,7 @@ DaprLoader = DaprLoader_1 = __decorate([
218
223
  dapr_metadata_accessor_1.DaprMetadataAccessor, Object, dapr_actor_client_service_1.DaprActorClient,
219
224
  core_1.ModuleRef,
220
225
  dapr_context_service_1.DaprContextService,
226
+ dapr_pubsub_client_service_1.DaprPubSubClient,
221
227
  nest_actor_manager_1.NestActorManager])
222
228
  ], DaprLoader);
223
229
  exports.DaprLoader = DaprLoader;
@@ -77,17 +77,10 @@ let DaprModule = DaprModule_1 = class DaprModule {
77
77
  dapr_metadata_accessor_1.DaprMetadataAccessor,
78
78
  dapr_context_service_1.DaprContextService,
79
79
  dapr_actor_client_service_1.DaprActorClient,
80
- {
81
- provide: dapr_pubsub_client_service_1.DaprPubSubClient,
82
- scope: common_1.Scope.DEFAULT,
83
- inject: [exports.DAPR_MODULE_OPTIONS_TOKEN, dapr_1.DaprClient],
84
- useFactory: (options, daprClient) => {
85
- return new dapr_pubsub_client_service_1.DaprPubSubClient(options, daprClient);
86
- },
87
- },
80
+ dapr_pubsub_client_service_1.DaprPubSubClient,
88
81
  core_1.Reflector,
89
82
  ],
90
- exports: [dapr_1.DaprClient, dapr_pubsub_client_service_1.DaprPubSubClient, exports.DAPR_MODULE_OPTIONS_TOKEN],
83
+ exports: [dapr_1.DaprClient, dapr_pubsub_client_service_1.DaprPubSubClient, dapr_context_service_1.DaprContextService, actor_runtime_service_1.ActorRuntimeService, dapr_actor_client_service_1.DaprActorClient],
91
84
  };
92
85
  }
93
86
  static registerAsync(options) {
@@ -118,18 +111,11 @@ let DaprModule = DaprModule_1 = class DaprModule {
118
111
  dapr_metadata_accessor_1.DaprMetadataAccessor,
119
112
  dapr_context_service_1.DaprContextService,
120
113
  dapr_actor_client_service_1.DaprActorClient,
121
- {
122
- provide: dapr_pubsub_client_service_1.DaprPubSubClient,
123
- scope: common_1.Scope.DEFAULT,
124
- inject: [exports.DAPR_MODULE_OPTIONS_TOKEN, dapr_1.DaprClient],
125
- useFactory: (options, daprClient) => {
126
- return new dapr_pubsub_client_service_1.DaprPubSubClient(options, daprClient);
127
- },
128
- },
114
+ dapr_pubsub_client_service_1.DaprPubSubClient,
129
115
  core_1.Reflector,
130
116
  ...(options.extraProviders || []),
131
117
  ],
132
- exports: [dapr_1.DaprClient, dapr_pubsub_client_service_1.DaprPubSubClient, exports.DAPR_MODULE_OPTIONS_TOKEN],
118
+ exports: [dapr_1.DaprClient, dapr_pubsub_client_service_1.DaprPubSubClient, dapr_context_service_1.DaprContextService, actor_runtime_service_1.ActorRuntimeService, dapr_actor_client_service_1.DaprActorClient],
133
119
  };
134
120
  }
135
121
  static createAsyncProviders(options) {
@@ -1,18 +1,17 @@
1
1
  import { DaprClient } from '@dapr/dapr';
2
2
  import { OnApplicationShutdown } from '@nestjs/common';
3
- import { DaprModuleOptions } from '../dapr.module';
4
3
  import { PublishMessage } from './publish.message';
5
4
  export declare class DaprPubSubClient implements OnApplicationShutdown {
6
- private readonly options;
7
5
  private readonly daprClient;
8
6
  private readonly logger;
9
- private readonly defaultName;
10
- private readonly buffer;
7
+ private defaultName;
11
8
  private subscription;
9
+ private readonly buffer;
12
10
  private readonly bufferSize;
13
11
  private readonly bufferTimeSpan;
14
12
  private onError;
15
- constructor(options: DaprModuleOptions, daprClient: DaprClient);
13
+ constructor(daprClient: DaprClient);
14
+ setDefaultName(name: string): void;
16
15
  registerErrorHandler(handler: (messages: PublishMessage[], error: Error) => void): void;
17
16
  protected handleError(messages: PublishMessage[], error: Error): Promise<void>;
18
17
  onApplicationShutdown(signal?: string): Promise<void>;
@@ -8,9 +8,6 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
8
8
  var __metadata = (this && this.__metadata) || function (k, v) {
9
9
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
10
  };
11
- var __param = (this && this.__param) || function (paramIndex, decorator) {
12
- return function (target, key) { decorator(target, key, paramIndex); }
13
- };
14
11
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
15
12
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
16
13
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -27,19 +24,19 @@ const dapr_1 = require("@dapr/dapr");
27
24
  const common_1 = require("@nestjs/common");
28
25
  const rxjs_1 = require("rxjs");
29
26
  const operators_1 = require("rxjs/operators");
30
- const dapr_module_1 = require("../dapr.module");
31
27
  let DaprPubSubClient = DaprPubSubClient_1 = class DaprPubSubClient {
32
- constructor(options, daprClient) {
33
- var _a, _b;
34
- this.options = options;
28
+ constructor(daprClient) {
35
29
  this.daprClient = daprClient;
36
30
  this.logger = new common_1.Logger(DaprPubSubClient_1.name);
31
+ this.defaultName = 'pubsub';
37
32
  this.buffer = new rxjs_1.Subject();
38
33
  this.bufferSize = 10;
39
34
  this.bufferTimeSpan = 1000;
40
- this.defaultName = (_b = (_a = this.options.pubsubOptions) === null || _a === void 0 ? void 0 : _a.defaultName) !== null && _b !== void 0 ? _b : 'pubsub';
41
35
  this.setupBufferSubscription();
42
36
  }
37
+ setDefaultName(name) {
38
+ this.defaultName = name;
39
+ }
43
40
  registerErrorHandler(handler) {
44
41
  this.onError = handler;
45
42
  }
@@ -198,7 +195,6 @@ let DaprPubSubClient = DaprPubSubClient_1 = class DaprPubSubClient {
198
195
  };
199
196
  DaprPubSubClient = DaprPubSubClient_1 = __decorate([
200
197
  (0, common_1.Injectable)(),
201
- __param(0, (0, common_1.Inject)(dapr_module_1.DAPR_MODULE_OPTIONS_TOKEN)),
202
- __metadata("design:paramtypes", [Object, dapr_1.DaprClient])
198
+ __metadata("design:paramtypes", [dapr_1.DaprClient])
203
199
  ], DaprPubSubClient);
204
200
  exports.DaprPubSubClient = DaprPubSubClient;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rayondigital/nest-dapr",
3
- "version": "0.9.34",
3
+ "version": "0.9.35",
4
4
  "description": "Develop NestJs microservices using Dapr pubsub, actors and other bindings",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",