@rayondigital/nest-dapr 0.9.16 → 0.9.18
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/actors/abstract-actor.d.ts +36 -0
- package/dist/actors/abstract-actor.js +143 -0
- package/dist/actors/actor-proxy-builder.js +5 -7
- package/dist/actors/client-cache.d.ts +19 -0
- package/dist/actors/client-cache.js +82 -0
- package/dist/actors/dapr-actor-client.service.d.ts +2 -2
- package/dist/actors/dapr-actor-client.service.js +10 -11
- package/dist/actors/stateful.actor.d.ts +1 -1
- package/dist/actors/stateful.actor.js +2 -2
- package/dist/index.d.ts +2 -1
- package/dist/index.js +3 -1
- package/package.json +1 -1
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import ActorId from '@dapr/dapr/actors/ActorId';
|
|
2
|
+
import ActorStateManager from '@dapr/dapr/actors/runtime/ActorStateManager';
|
|
3
|
+
import StateProvider from '@dapr/dapr/actors/runtime/StateProvider';
|
|
4
|
+
import DaprClient from '@dapr/dapr/implementation/Client/DaprClient';
|
|
5
|
+
import { Temporal } from '@js-temporal/polyfill';
|
|
6
|
+
export declare abstract class AbstractActor {
|
|
7
|
+
private readonly stateManager;
|
|
8
|
+
private readonly id;
|
|
9
|
+
private readonly daprClient;
|
|
10
|
+
private readonly actorClient;
|
|
11
|
+
private readonly daprStateProvider;
|
|
12
|
+
private readonly actorType;
|
|
13
|
+
private readonly daprLogger;
|
|
14
|
+
constructor(daprClient: DaprClient, id: ActorId);
|
|
15
|
+
registerActorReminder<_Type>(reminderName: string, dueTime: Temporal.Duration, period?: Temporal.Duration, ttl?: Temporal.Duration, state?: any): Promise<void>;
|
|
16
|
+
unregisterActorReminder(reminderName: string): Promise<void>;
|
|
17
|
+
registerActorTimer(timerName: string, callback: string, dueTime: Temporal.Duration, period?: Temporal.Duration, ttl?: Temporal.Duration, state?: any): Promise<void>;
|
|
18
|
+
unregisterActorTimer(timerName: string): Promise<void>;
|
|
19
|
+
onActivateInternal(): Promise<void>;
|
|
20
|
+
onDeactivateInternal(): Promise<void>;
|
|
21
|
+
onActorMethodPreInternal(): Promise<void>;
|
|
22
|
+
onActorMethodPostInternal(): Promise<void>;
|
|
23
|
+
resetStateInternal(): Promise<void>;
|
|
24
|
+
saveStateInternal(): Promise<void>;
|
|
25
|
+
onActivate(): Promise<void>;
|
|
26
|
+
onDeactivate(): Promise<void>;
|
|
27
|
+
onActorMethodPre(): Promise<void>;
|
|
28
|
+
onActorMethodPost(): Promise<void>;
|
|
29
|
+
receiveReminder(_data: string): Promise<void>;
|
|
30
|
+
getDaprClient(): DaprClient;
|
|
31
|
+
getStateProvider(): StateProvider;
|
|
32
|
+
getStateManager<T>(): ActorStateManager<T>;
|
|
33
|
+
getActorId(): ActorId;
|
|
34
|
+
getActorType(): any;
|
|
35
|
+
getId(): string;
|
|
36
|
+
}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.AbstractActor = void 0;
|
|
16
|
+
const ActorStateManager_1 = __importDefault(require("@dapr/dapr/actors/runtime/ActorStateManager"));
|
|
17
|
+
const Logger_1 = require("@dapr/dapr/logger/Logger");
|
|
18
|
+
const polyfill_1 = require("@js-temporal/polyfill");
|
|
19
|
+
const client_cache_1 = require("./client-cache");
|
|
20
|
+
class AbstractActor {
|
|
21
|
+
constructor(daprClient, id) {
|
|
22
|
+
this.daprClient = daprClient;
|
|
23
|
+
this.actorClient = client_cache_1.DaprClientCache.getOrCreateActorClientFromOptions(daprClient.options);
|
|
24
|
+
this.daprLogger = new Logger_1.Logger('Actors', 'AbstractActor', daprClient.options.logger);
|
|
25
|
+
this.id = id;
|
|
26
|
+
this.stateManager = new ActorStateManager_1.default(this);
|
|
27
|
+
this.daprStateProvider = client_cache_1.DaprClientCache.getOrCreateStateProviderFromOptions(daprClient.options);
|
|
28
|
+
this.actorType = this.constructor.name;
|
|
29
|
+
}
|
|
30
|
+
registerActorReminder(reminderName, dueTime, period, ttl, state) {
|
|
31
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
32
|
+
yield this.actorClient.actor.registerActorReminder(this.actorType, this.id, reminderName, {
|
|
33
|
+
period: period !== null && period !== void 0 ? period : polyfill_1.Temporal.Duration.from({ hours: 1 }),
|
|
34
|
+
dueTime,
|
|
35
|
+
ttl,
|
|
36
|
+
data: state,
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
unregisterActorReminder(reminderName) {
|
|
41
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
42
|
+
yield this.actorClient.actor.unregisterActorReminder(this.actorType, this.id, reminderName);
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
registerActorTimer(timerName, callback, dueTime, period, ttl, state) {
|
|
46
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
47
|
+
return yield this.actorClient.actor.registerActorTimer(this.actorType, this.id, timerName, {
|
|
48
|
+
period: period !== null && period !== void 0 ? period : polyfill_1.Temporal.Duration.from({ hours: 12 }),
|
|
49
|
+
dueTime,
|
|
50
|
+
ttl,
|
|
51
|
+
data: state,
|
|
52
|
+
callback,
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
unregisterActorTimer(timerName) {
|
|
57
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
58
|
+
yield this.actorClient.actor.unregisterActorTimer(this.actorType, this.id, timerName);
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
onActivateInternal() {
|
|
62
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
63
|
+
yield this.resetStateInternal();
|
|
64
|
+
yield this.onActivate();
|
|
65
|
+
yield this.saveStateInternal();
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
onDeactivateInternal() {
|
|
69
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
70
|
+
yield this.resetStateInternal();
|
|
71
|
+
yield this.onDeactivate();
|
|
72
|
+
yield this.saveStateInternal();
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
onActorMethodPreInternal() {
|
|
76
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
77
|
+
yield this.onActorMethodPre();
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
onActorMethodPostInternal() {
|
|
81
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
82
|
+
yield this.onActorMethodPost();
|
|
83
|
+
yield this.saveStateInternal();
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
resetStateInternal() {
|
|
87
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
88
|
+
yield this.stateManager.clearCache();
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
saveStateInternal() {
|
|
92
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
93
|
+
yield this.stateManager.saveState();
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
onActivate() {
|
|
97
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
98
|
+
return;
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
onDeactivate() {
|
|
102
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
103
|
+
return;
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
onActorMethodPre() {
|
|
107
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
108
|
+
return;
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
onActorMethodPost() {
|
|
112
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
113
|
+
return;
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
receiveReminder(_data) {
|
|
117
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
118
|
+
this.daprLogger.warn(JSON.stringify({
|
|
119
|
+
error: 'ACTOR_METHOD_NOT_IMPLEMENTED',
|
|
120
|
+
errorMsg: `A reminder was created for the actor with id: ${this.id} but the method 'receiveReminder' was not implemented`,
|
|
121
|
+
}));
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
getDaprClient() {
|
|
125
|
+
return this.daprClient;
|
|
126
|
+
}
|
|
127
|
+
getStateProvider() {
|
|
128
|
+
return this.daprStateProvider;
|
|
129
|
+
}
|
|
130
|
+
getStateManager() {
|
|
131
|
+
return this.stateManager;
|
|
132
|
+
}
|
|
133
|
+
getActorId() {
|
|
134
|
+
return this.id;
|
|
135
|
+
}
|
|
136
|
+
getActorType() {
|
|
137
|
+
return this.actorType;
|
|
138
|
+
}
|
|
139
|
+
getId() {
|
|
140
|
+
return this.getActorId().getId();
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
exports.AbstractActor = AbstractActor;
|
|
@@ -8,14 +8,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
12
|
exports.ActorProxyBuilder = void 0;
|
|
16
|
-
const ActorClient_1 = __importDefault(require("@dapr/dapr/actors/client/ActorClient/ActorClient"));
|
|
17
|
-
const dapr_context_service_1 = require("../dapr-context-service");
|
|
18
13
|
const common_1 = require("@nestjs/common");
|
|
14
|
+
const dapr_context_service_1 = require("../dapr-context-service");
|
|
15
|
+
const client_cache_1 = require("./client-cache");
|
|
19
16
|
class ActorProxyBuilder {
|
|
20
17
|
constructor(moduleRef, actorTypeClass, ...args) {
|
|
21
18
|
this.moduleRef = moduleRef;
|
|
@@ -25,11 +22,12 @@ class ActorProxyBuilder {
|
|
|
25
22
|
this.actorTypeClass = actorTypeClass;
|
|
26
23
|
if (args.length == 1) {
|
|
27
24
|
const [daprClient] = args;
|
|
28
|
-
this.actorClient =
|
|
25
|
+
this.actorClient = client_cache_1.DaprClientCache.getOrCreateActorClientFromClient(daprClient);
|
|
29
26
|
}
|
|
30
27
|
else {
|
|
31
28
|
const [host, port, communicationProtocol, clientOptions] = args;
|
|
32
|
-
|
|
29
|
+
const options = Object.assign({ daprHost: host, daprPort: port, communicationProtocol: communicationProtocol }, clientOptions);
|
|
30
|
+
this.actorClient = client_cache_1.DaprClientCache.getOrCreateActorClientFromOptions(options);
|
|
33
31
|
}
|
|
34
32
|
}
|
|
35
33
|
build(actorId, actorTypeName) {
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { DaprClient, DaprClientOptions } from '@dapr/dapr';
|
|
2
|
+
import ActorClient from '@dapr/dapr/actors/client/ActorClient/ActorClient';
|
|
3
|
+
import StateProvider from '@dapr/dapr/actors/runtime/StateProvider';
|
|
4
|
+
export declare class DaprClientCache {
|
|
5
|
+
private static clients;
|
|
6
|
+
private static actorClients;
|
|
7
|
+
private static stateProviders;
|
|
8
|
+
static getDaprClient(): DaprClient | undefined;
|
|
9
|
+
static getAllClients(): DaprClient[];
|
|
10
|
+
static getAllActorClients(): ActorClient[];
|
|
11
|
+
static getAllStateProviders(): StateProvider[];
|
|
12
|
+
static getClientByHost(host: string): DaprClient | undefined;
|
|
13
|
+
static getActorClientByHost(host: string): ActorClient | undefined;
|
|
14
|
+
static getStateProviderByHost(host: string): StateProvider | undefined;
|
|
15
|
+
static getOrCreateActorClientFromClient(daprClient: DaprClient): ActorClient;
|
|
16
|
+
static getOrCreateStateProviderFromOptions(options: DaprClientOptions): StateProvider;
|
|
17
|
+
static getOrCreateActorClientFromOptions(options: DaprClientOptions): ActorClient;
|
|
18
|
+
static getOrCreateClientFromOptions(options: DaprClientOptions): DaprClient;
|
|
19
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
9
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.DaprClientCache = void 0;
|
|
13
|
+
const dapr_1 = require("@dapr/dapr");
|
|
14
|
+
const ActorClient_1 = __importDefault(require("@dapr/dapr/actors/client/ActorClient/ActorClient"));
|
|
15
|
+
const StateProvider_1 = __importDefault(require("@dapr/dapr/actors/runtime/StateProvider"));
|
|
16
|
+
const common_1 = require("@nestjs/common");
|
|
17
|
+
let DaprClientCache = class DaprClientCache {
|
|
18
|
+
static getDaprClient() {
|
|
19
|
+
if (this.clients.size === 0)
|
|
20
|
+
return undefined;
|
|
21
|
+
return this.clients.entries().next().value[1];
|
|
22
|
+
}
|
|
23
|
+
static getAllClients() {
|
|
24
|
+
return Array.from(this.clients.values());
|
|
25
|
+
}
|
|
26
|
+
static getAllActorClients() {
|
|
27
|
+
return Array.from(this.actorClients.values());
|
|
28
|
+
}
|
|
29
|
+
static getAllStateProviders() {
|
|
30
|
+
return Array.from(this.stateProviders.values());
|
|
31
|
+
}
|
|
32
|
+
static getClientByHost(host) {
|
|
33
|
+
return this.clients.get(host);
|
|
34
|
+
}
|
|
35
|
+
static getActorClientByHost(host) {
|
|
36
|
+
return this.actorClients.get(host);
|
|
37
|
+
}
|
|
38
|
+
static getStateProviderByHost(host) {
|
|
39
|
+
return this.stateProviders.get(host);
|
|
40
|
+
}
|
|
41
|
+
static getOrCreateActorClientFromClient(daprClient) {
|
|
42
|
+
if (this.actorClients.has(daprClient.options.daprHost)) {
|
|
43
|
+
return this.actorClients.get(daprClient.options.daprHost);
|
|
44
|
+
}
|
|
45
|
+
if (!this.clients.has(daprClient.options.daprHost)) {
|
|
46
|
+
this.clients.set(daprClient.options.daprHost, daprClient);
|
|
47
|
+
}
|
|
48
|
+
return this.getOrCreateActorClientFromOptions(daprClient.options);
|
|
49
|
+
}
|
|
50
|
+
static getOrCreateStateProviderFromOptions(options) {
|
|
51
|
+
if (this.stateProviders.has(options.daprHost)) {
|
|
52
|
+
return this.stateProviders.get(options.daprHost);
|
|
53
|
+
}
|
|
54
|
+
const actorClient = this.getOrCreateActorClientFromOptions(options);
|
|
55
|
+
const stateProvider = new StateProvider_1.default(actorClient);
|
|
56
|
+
this.stateProviders.set(options.daprHost, stateProvider);
|
|
57
|
+
return stateProvider;
|
|
58
|
+
}
|
|
59
|
+
static getOrCreateActorClientFromOptions(options) {
|
|
60
|
+
if (this.actorClients.has(options.daprHost)) {
|
|
61
|
+
return this.actorClients.get(options.daprHost);
|
|
62
|
+
}
|
|
63
|
+
const client = new ActorClient_1.default(options.daprHost, options.daprPort, options.communicationProtocol, options);
|
|
64
|
+
this.actorClients.set(options.daprHost, client);
|
|
65
|
+
return client;
|
|
66
|
+
}
|
|
67
|
+
static getOrCreateClientFromOptions(options) {
|
|
68
|
+
if (this.clients.has(options.daprHost)) {
|
|
69
|
+
return this.clients.get(options.daprHost);
|
|
70
|
+
}
|
|
71
|
+
const client = new dapr_1.DaprClient(options);
|
|
72
|
+
this.clients.set(options.daprHost, client);
|
|
73
|
+
return client;
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
DaprClientCache.clients = new Map();
|
|
77
|
+
DaprClientCache.actorClients = new Map();
|
|
78
|
+
DaprClientCache.stateProviders = new Map();
|
|
79
|
+
DaprClientCache = __decorate([
|
|
80
|
+
(0, common_1.Injectable)()
|
|
81
|
+
], DaprClientCache);
|
|
82
|
+
exports.DaprClientCache = DaprClientCache;
|
|
@@ -4,7 +4,7 @@ import { ModuleRef } from '@nestjs/core';
|
|
|
4
4
|
export declare class DaprActorClient {
|
|
5
5
|
private readonly moduleRef;
|
|
6
6
|
private readonly daprClient;
|
|
7
|
-
private
|
|
7
|
+
private actorProxyBuilders;
|
|
8
8
|
private interfaces;
|
|
9
9
|
private interfaceToActorTypeNames;
|
|
10
10
|
private prefix;
|
|
@@ -21,5 +21,5 @@ export declare class DaprActorClient {
|
|
|
21
21
|
getActorTypeName(typeName: string): string;
|
|
22
22
|
contains(actorTypeName: string): boolean;
|
|
23
23
|
private formatActorTypeName;
|
|
24
|
-
private
|
|
24
|
+
private getActorClientProxyBuilder;
|
|
25
25
|
}
|
|
@@ -18,7 +18,7 @@ let DaprActorClient = class DaprActorClient {
|
|
|
18
18
|
constructor(moduleRef, daprClient) {
|
|
19
19
|
this.moduleRef = moduleRef;
|
|
20
20
|
this.daprClient = daprClient;
|
|
21
|
-
this.
|
|
21
|
+
this.actorProxyBuilders = new Map();
|
|
22
22
|
this.interfaces = new Map();
|
|
23
23
|
this.interfaceToActorTypeNames = new Map();
|
|
24
24
|
this.prefix = '';
|
|
@@ -34,7 +34,7 @@ let DaprActorClient = class DaprActorClient {
|
|
|
34
34
|
}
|
|
35
35
|
register(actorTypeName, actorType, daprClient) {
|
|
36
36
|
this.interfaces.set(this.formatActorTypeName(actorTypeName), actorType);
|
|
37
|
-
this.
|
|
37
|
+
this.actorProxyBuilders.set(this.formatActorTypeName(actorTypeName), new actor_proxy_builder_1.ActorProxyBuilder(this.moduleRef, actorType, daprClient !== null && daprClient !== void 0 ? daprClient : this.daprClient));
|
|
38
38
|
}
|
|
39
39
|
registerInterface(actorType, interfaceType, daprClient) {
|
|
40
40
|
var _a, _b;
|
|
@@ -42,7 +42,7 @@ let DaprActorClient = class DaprActorClient {
|
|
|
42
42
|
const actorTypeName = (_b = actorType.name) !== null && _b !== void 0 ? _b : actorType.constructor.name;
|
|
43
43
|
this.interfaceToActorTypeNames.set(interfaceTypeName, actorTypeName);
|
|
44
44
|
this.interfaces.set(this.formatActorTypeName(interfaceTypeName), actorType);
|
|
45
|
-
this.
|
|
45
|
+
this.actorProxyBuilders.set(this.formatActorTypeName(interfaceTypeName), new actor_proxy_builder_1.ActorProxyBuilder(this.moduleRef, actorType, daprClient !== null && daprClient !== void 0 ? daprClient : this.daprClient));
|
|
46
46
|
}
|
|
47
47
|
getActorId(actorId) {
|
|
48
48
|
var _a;
|
|
@@ -62,7 +62,7 @@ let DaprActorClient = class DaprActorClient {
|
|
|
62
62
|
throw new Error(`Actor ${actorTypeName} not found`);
|
|
63
63
|
}
|
|
64
64
|
const fullActorId = this.getActorId(actorId);
|
|
65
|
-
const actorClient = this.
|
|
65
|
+
const actorClient = this.getActorClientProxyBuilder(actorTypeName);
|
|
66
66
|
return actorClient.build(fullActorId, actorTypeName);
|
|
67
67
|
}
|
|
68
68
|
getActorByTypeName(actorTypeName, actorId) {
|
|
@@ -76,13 +76,13 @@ let DaprActorClient = class DaprActorClient {
|
|
|
76
76
|
throw new Error(`Actor ${actorTypeName} not found`);
|
|
77
77
|
}
|
|
78
78
|
const fullActorId = this.getActorId(actorId);
|
|
79
|
-
const actorClient = this.
|
|
79
|
+
const actorClient = this.getActorClientProxyBuilder(actorTypeName);
|
|
80
80
|
return actorClient.build(fullActorId, actorTypeName);
|
|
81
81
|
}
|
|
82
82
|
getActorTypeName(typeName) {
|
|
83
83
|
if (this.interfaceToActorTypeNames.has(typeName)) {
|
|
84
84
|
const actorTypeName = this.interfaceToActorTypeNames.get(typeName);
|
|
85
|
-
if (this.
|
|
85
|
+
if (this.actorProxyBuilders.has(actorTypeName)) {
|
|
86
86
|
return actorTypeName;
|
|
87
87
|
}
|
|
88
88
|
else {
|
|
@@ -95,18 +95,17 @@ let DaprActorClient = class DaprActorClient {
|
|
|
95
95
|
return typeName;
|
|
96
96
|
}
|
|
97
97
|
contains(actorTypeName) {
|
|
98
|
-
return this.
|
|
98
|
+
return this.actorProxyBuilders.has(this.formatActorTypeName(actorTypeName));
|
|
99
99
|
}
|
|
100
100
|
formatActorTypeName(actorTypeName) {
|
|
101
101
|
return actorTypeName.toLowerCase();
|
|
102
102
|
}
|
|
103
|
-
|
|
104
|
-
return this.
|
|
103
|
+
getActorClientProxyBuilder(actorTypeName) {
|
|
104
|
+
return this.actorProxyBuilders.get(this.formatActorTypeName(actorTypeName));
|
|
105
105
|
}
|
|
106
106
|
};
|
|
107
107
|
DaprActorClient = __decorate([
|
|
108
108
|
(0, common_1.Injectable)(),
|
|
109
|
-
__metadata("design:paramtypes", [core_1.ModuleRef,
|
|
110
|
-
dapr_1.DaprClient])
|
|
109
|
+
__metadata("design:paramtypes", [core_1.ModuleRef, dapr_1.DaprClient])
|
|
111
110
|
], DaprActorClient);
|
|
112
111
|
exports.DaprActorClient = DaprActorClient;
|
|
@@ -10,9 +10,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.StatefulActor = void 0;
|
|
13
|
-
const dapr_1 = require("@dapr/dapr");
|
|
14
13
|
const constants_1 = require("../constants");
|
|
15
|
-
|
|
14
|
+
const abstract_actor_1 = require("./abstract-actor");
|
|
15
|
+
class StatefulActor extends abstract_actor_1.AbstractActor {
|
|
16
16
|
setState(stateName, value) {
|
|
17
17
|
return __awaiter(this, void 0, void 0, function* () {
|
|
18
18
|
yield this.getStateManager().setState(stateName, value);
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { DaprClientCache } from './actors/client-cache';
|
|
1
2
|
import { DaprActorClient } from './actors/dapr-actor-client.service';
|
|
2
3
|
import { StatefulActorOf } from './actors/stateful-actor-of';
|
|
3
4
|
import { IState, StatefulActor } from './actors/stateful.actor';
|
|
@@ -10,4 +11,4 @@ import { DaprMetadataAccessor } from './dapr-metadata.accessor';
|
|
|
10
11
|
import { DaprPubSub, DaprPubSubMetadata } from './dapr-pubsub.decorator';
|
|
11
12
|
import { DaprLoader } from './dapr.loader';
|
|
12
13
|
import { DaprModule } from './dapr.module';
|
|
13
|
-
export { DAPR_BINDING_METADATA, DAPR_PUBSUB_METADATA, DAPR_ACTOR_METADATA, DAPR_ACTOR_STATE_METADATA, DaprMetadataAccessor, DaprBindingMetadata, DaprBinding, DaprPubSubMetadata, DaprPubSub, DaprActorMetadata, State, DaprActor, DaprLoader, DaprModule, DaprActorClient, DaprContextService, StatefulActor, StatefulActorOf, IState, };
|
|
14
|
+
export { DAPR_BINDING_METADATA, DAPR_PUBSUB_METADATA, DAPR_ACTOR_METADATA, DAPR_ACTOR_STATE_METADATA, DaprMetadataAccessor, DaprBindingMetadata, DaprBinding, DaprPubSubMetadata, DaprPubSub, DaprActorMetadata, State, DaprActor, DaprLoader, DaprModule, DaprActorClient, DaprContextService, DaprClientCache, StatefulActor, StatefulActorOf, IState, };
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.StatefulActorOf = exports.StatefulActor = exports.DaprContextService = exports.DaprActorClient = exports.DaprModule = exports.DaprLoader = exports.DaprActor = exports.State = exports.DaprPubSub = exports.DaprBinding = exports.DaprMetadataAccessor = exports.DAPR_ACTOR_STATE_METADATA = exports.DAPR_ACTOR_METADATA = exports.DAPR_PUBSUB_METADATA = exports.DAPR_BINDING_METADATA = void 0;
|
|
3
|
+
exports.StatefulActorOf = exports.StatefulActor = exports.DaprClientCache = exports.DaprContextService = exports.DaprActorClient = exports.DaprModule = exports.DaprLoader = exports.DaprActor = exports.State = exports.DaprPubSub = exports.DaprBinding = exports.DaprMetadataAccessor = exports.DAPR_ACTOR_STATE_METADATA = exports.DAPR_ACTOR_METADATA = exports.DAPR_PUBSUB_METADATA = exports.DAPR_BINDING_METADATA = void 0;
|
|
4
|
+
const client_cache_1 = require("./actors/client-cache");
|
|
5
|
+
Object.defineProperty(exports, "DaprClientCache", { enumerable: true, get: function () { return client_cache_1.DaprClientCache; } });
|
|
4
6
|
const dapr_actor_client_service_1 = require("./actors/dapr-actor-client.service");
|
|
5
7
|
Object.defineProperty(exports, "DaprActorClient", { enumerable: true, get: function () { return dapr_actor_client_service_1.DaprActorClient; } });
|
|
6
8
|
const stateful_actor_of_1 = require("./actors/stateful-actor-of");
|
package/package.json
CHANGED