@rayondigital/nest-dapr 0.9.15 → 0.9.16
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/nest-actor-manager.d.ts +0 -1
- package/dist/actors/nest-actor-manager.js +7 -31
- package/dist/actors/stateful.actor.d.ts +1 -1
- package/dist/actors/stateful.actor.js +10 -13
- package/dist/dapr-actor-state.decorator.d.ts +2 -2
- package/dist/dapr.loader.js +0 -1
- package/package.json +1 -1
|
@@ -4,7 +4,6 @@ import { DaprContextService } from '../dapr-context-service';
|
|
|
4
4
|
import { DaprModuleActorOptions } from '../dapr.module';
|
|
5
5
|
export declare class NestActorManager {
|
|
6
6
|
setup(moduleRef: ModuleRef, options: DaprModuleActorOptions, onActivateFn?: (actorId: ActorId, instance: AbstractActor) => Promise<void>): void;
|
|
7
|
-
setupRemindersAndTimers(): void;
|
|
8
7
|
setupReentrancy(): void;
|
|
9
8
|
setupCSLWrapper(contextService: DaprContextService, invokeWrapperFn?: (actorId: ActorId, methodName: string, data: any, method: (actorId: ActorId, methodName: string, data: any) => Promise<any>) => Promise<any>): void;
|
|
10
9
|
private resolveDependencies;
|
|
@@ -23,8 +23,6 @@ exports.NestActorManager = void 0;
|
|
|
23
23
|
const crypto_1 = require("crypto");
|
|
24
24
|
const ActorClientHTTP_1 = __importDefault(require("@dapr/dapr/actors/client/ActorClient/ActorClientHTTP"));
|
|
25
25
|
const ActorManager_1 = __importDefault(require("@dapr/dapr/actors/runtime/ActorManager"));
|
|
26
|
-
const ActorReminderData_1 = __importDefault(require("@dapr/dapr/actors/runtime/ActorReminderData"));
|
|
27
|
-
const ActorTimerData_1 = __importDefault(require("@dapr/dapr/actors/runtime/ActorTimerData"));
|
|
28
26
|
const common_1 = require("@nestjs/common");
|
|
29
27
|
const instance_wrapper_1 = require("@nestjs/core/injector/instance-wrapper");
|
|
30
28
|
const dapr_context_service_1 = require("../dapr-context-service");
|
|
@@ -51,40 +49,18 @@ let NestActorManager = NestActorManager_1 = class NestActorManager {
|
|
|
51
49
|
return instance;
|
|
52
50
|
});
|
|
53
51
|
};
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
const originalFireReminder = ActorManager_1.default.prototype.fireReminder;
|
|
57
|
-
const originalFireTimer = ActorManager_1.default.prototype.fireTimer;
|
|
58
|
-
ActorManager_1.default.prototype.fireReminder = function (actorId, reminderName, requestBody) {
|
|
59
|
-
var _a;
|
|
52
|
+
const originalDeactivateActor = ActorManager_1.default.prototype.deactivateActor;
|
|
53
|
+
ActorManager_1.default.prototype.deactivateActor = function (actorId) {
|
|
60
54
|
return __awaiter(this, void 0, void 0, function* () {
|
|
61
55
|
try {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
const reminderState = reminderData.state;
|
|
65
|
-
let methodName = 'receiveReminder';
|
|
66
|
-
if (reminderState !== undefined && typeof reminderState === 'object') {
|
|
67
|
-
methodName = (_a = reminderState === null || reminderState === void 0 ? void 0 : reminderState.callback) !== null && _a !== void 0 ? _a : reminderState.method;
|
|
56
|
+
if (!this.actors.has(actorId.getId())) {
|
|
57
|
+
return;
|
|
68
58
|
}
|
|
69
|
-
|
|
59
|
+
yield originalDeactivateActor.bind(this)(actorId);
|
|
70
60
|
}
|
|
71
61
|
catch (error) {
|
|
72
|
-
common_1.Logger.error(`Error
|
|
73
|
-
|
|
74
|
-
}
|
|
75
|
-
});
|
|
76
|
-
};
|
|
77
|
-
ActorManager_1.default.prototype.fireTimer = function (actorId, timerName, requestBody) {
|
|
78
|
-
var _a;
|
|
79
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
80
|
-
try {
|
|
81
|
-
const requestBodyDeserialized = this.serializer.deserialize(requestBody || Buffer.from(''));
|
|
82
|
-
const timerData = ActorTimerData_1.default.fromObject(timerName, requestBodyDeserialized);
|
|
83
|
-
return yield this.callActorMethod(actorId, (_a = timerData.callback) !== null && _a !== void 0 ? _a : 'handleTimer', [timerData.state, timerName]);
|
|
84
|
-
}
|
|
85
|
-
catch (error) {
|
|
86
|
-
common_1.Logger.error(`Error firing timer ${actorId}/${timerName}`);
|
|
87
|
-
throw error;
|
|
62
|
+
common_1.Logger.error(`Error deactivating actor ${actorId}`);
|
|
63
|
+
common_1.Logger.error(error);
|
|
88
64
|
}
|
|
89
65
|
});
|
|
90
66
|
};
|
|
@@ -13,5 +13,5 @@ export declare class StatefulActor extends AbstractActor {
|
|
|
13
13
|
getAllState(): Promise<void>;
|
|
14
14
|
setAllStateFromProperties(): Promise<void>;
|
|
15
15
|
getState<T>(stateName: string, defaultValue?: T): Promise<T | undefined>;
|
|
16
|
-
private
|
|
16
|
+
private createInstance;
|
|
17
17
|
}
|
|
@@ -59,12 +59,18 @@ class StatefulActor extends dapr_1.AbstractActor {
|
|
|
59
59
|
this[property.key] = property.defaultValue;
|
|
60
60
|
}
|
|
61
61
|
else {
|
|
62
|
-
this[property.key] = this.
|
|
62
|
+
this[property.key] = this.createInstance(property.type);
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
65
|
else {
|
|
66
66
|
if (property.serializable) {
|
|
67
|
-
|
|
67
|
+
let instance;
|
|
68
|
+
if (typeof property.defaultValue === 'function') {
|
|
69
|
+
instance = property.defaultValue();
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
instance = this.createInstance(property.type);
|
|
73
|
+
}
|
|
68
74
|
this[property.key] = (_a = instance.fromJSON(rawValue)) !== null && _a !== void 0 ? _a : instance;
|
|
69
75
|
}
|
|
70
76
|
else {
|
|
@@ -104,18 +110,9 @@ class StatefulActor extends dapr_1.AbstractActor {
|
|
|
104
110
|
}
|
|
105
111
|
});
|
|
106
112
|
}
|
|
107
|
-
|
|
113
|
+
createInstance(type) {
|
|
108
114
|
try {
|
|
109
|
-
|
|
110
|
-
if (property.defaultValue instanceof Function || typeof property.defaultValue === 'function') {
|
|
111
|
-
return property.defaultValue();
|
|
112
|
-
}
|
|
113
|
-
return property.defaultValue;
|
|
114
|
-
}
|
|
115
|
-
if (property.type || property.serializable) {
|
|
116
|
-
const type = property.type;
|
|
117
|
-
return new type();
|
|
118
|
-
}
|
|
115
|
+
return new type();
|
|
119
116
|
}
|
|
120
117
|
catch (e) {
|
|
121
118
|
return undefined;
|
|
@@ -3,10 +3,10 @@ export interface StateProperty {
|
|
|
3
3
|
key: string | symbol;
|
|
4
4
|
name: string;
|
|
5
5
|
type: Function | Type<any>;
|
|
6
|
-
defaultValue?:
|
|
6
|
+
defaultValue?: any;
|
|
7
7
|
serializable?: boolean;
|
|
8
8
|
}
|
|
9
9
|
export declare function State(options?: {
|
|
10
|
-
defaultValue?:
|
|
10
|
+
defaultValue?: any;
|
|
11
11
|
name?: string;
|
|
12
12
|
}): PropertyDecorator;
|
package/dist/dapr.loader.js
CHANGED
|
@@ -57,7 +57,6 @@ let DaprLoader = DaprLoader_1 = class DaprLoader {
|
|
|
57
57
|
return;
|
|
58
58
|
}
|
|
59
59
|
this.actorManager.setup(this.moduleRef, this.options.actorOptions);
|
|
60
|
-
this.actorManager.setupRemindersAndTimers();
|
|
61
60
|
if (this.options.contextProvider !== dapr_module_1.DaprContextProvider.None) {
|
|
62
61
|
this.actorManager.setupCSLWrapper(this.contextService);
|
|
63
62
|
}
|
package/package.json
CHANGED