@aj-shadow/z-abs-funclayer-engine-server 0.0.0-aj-beta.221
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/.gitattributes +26 -0
- package/LICENSE.txt +96 -0
- package/README.md +5 -0
- package/npm-shrinkwrap.json +13 -0
- package/package.json +10 -0
- package/project/server/_build/Server-FuncLayer-Engine-server.bld +12 -0
- package/project/server/_build/z-abs-funclayer-engine-server.prj +12 -0
- package/project/server/address/address-calculator.js +377 -0
- package/project/server/address/address-data.js +364 -0
- package/project/server/address/address-manager.js +251 -0
- package/project/server/address/address.js +176 -0
- package/project/server/address/addresses.js +122 -0
- package/project/server/address/dns-url-cache.js +130 -0
- package/project/server/address/interfaces.js +100 -0
- package/project/server/address/local-dns.js +35 -0
- package/project/server/address/login-report.js +56 -0
- package/project/server/address/networks.js +598 -0
- package/project/server/address/real-networks.js +102 -0
- package/project/server/address/subnet.js +60 -0
- package/project/server/communication/messages/messages-s-to-c/message-execution-started.js +17 -0
- package/project/server/communication/messages/messages-s-to-c/message-execution-stopped.js +14 -0
- package/project/server/communication/messages/messages-s-to-c/message-test-case-debug-paused.js +18 -0
- package/project/server/communication/messages/messages-s-to-c/message-test-case-log.js +25 -0
- package/project/server/communication/messages/messages-s-to-c/message-test-case-started.js +21 -0
- package/project/server/communication/messages/messages-s-to-c/message-test-case-state.js +18 -0
- package/project/server/communication/messages/messages-s-to-c/message-test-case-stopped.js +22 -0
- package/project/server/communication/messages/messages-s-to-c/message-test-stage-started.js +19 -0
- package/project/server/communication/messages/messages-s-to-c/message-test-stage-stopped.js +19 -0
- package/project/server/communication/messages/messages-s-to-c/message-test-suite-started.js +16 -0
- package/project/server/communication/messages/messages-s-to-c/message-test-suite-stopped.js +19 -0
- package/project/server/communication/messages/messages-s-to-w/message-test-case-debug-actor-index-ok.js +15 -0
- package/project/server/communication/messages/messages-w-to-s/message-test-case-debug-actor-index.js +15 -0
- package/project/server/debug/debug-step-over.js +54 -0
- package/project/server/debug/debugger.js +102 -0
- package/project/server/debug-dashboard/debug-dashboard.js +14 -0
- package/project/server/debug-dashboard/gauge-manager.js +44 -0
- package/project/server/debug-dashboard/gauge.js +37 -0
- package/project/server/engine/actor/actor-condition.js +335 -0
- package/project/server/engine/actor/actor-intercepting.js +32 -0
- package/project/server/engine/actor/actor-local.js +24 -0
- package/project/server/engine/actor/actor-mixins/asynch-mixin.js +103 -0
- package/project/server/engine/actor/actor-mixins/content-mixin.js +22 -0
- package/project/server/engine/actor/actor-mixins/logger-mixin.js +603 -0
- package/project/server/engine/actor/actor-mixins/process-mixin.js +35 -0
- package/project/server/engine/actor/actor-mixins/shared-data-mixin.js +109 -0
- package/project/server/engine/actor/actor-mixins/shared-execution-data-mixin.js +57 -0
- package/project/server/engine/actor/actor-mixins/stack-mixin-client.js +157 -0
- package/project/server/engine/actor/actor-mixins/stack-mixin-server.js +123 -0
- package/project/server/engine/actor/actor-mixins/stack-mixin.js +128 -0
- package/project/server/engine/actor/actor-mixins/test-data-mixin.js +402 -0
- package/project/server/engine/actor/actor-mixins/timer-mixin.js +44 -0
- package/project/server/engine/actor/actor-mixins/verify-mixin-base.js +668 -0
- package/project/server/engine/actor/actor-mixins/verify-mixin-mandatory.js +46 -0
- package/project/server/engine/actor/actor-mixins/verify-mixin-optional.js +44 -0
- package/project/server/engine/actor/actor-mixins/verify-mixin-value.js +71 -0
- package/project/server/engine/actor/actor-originating.js +32 -0
- package/project/server/engine/actor/actor-part-mixins/part-asynch-mixin.js +24 -0
- package/project/server/engine/actor/actor-part-mixins/part-logger-mixin.js +39 -0
- package/project/server/engine/actor/actor-part-mixins/part-shared-runtime-data-mixin.js +33 -0
- package/project/server/engine/actor/actor-part-mixins/part-timer-mixin.js +12 -0
- package/project/server/engine/actor/actor-part-mixins/part-verify-mixin-mandatory.js +15 -0
- package/project/server/engine/actor/actor-part-mixins/part-verify-mixin-optional.js +15 -0
- package/project/server/engine/actor/actor-part-mixins/part-verify-mixin-value.js +15 -0
- package/project/server/engine/actor/actor-part-post.js +37 -0
- package/project/server/engine/actor/actor-part-pre.js +37 -0
- package/project/server/engine/actor/actor-pending.js +79 -0
- package/project/server/engine/actor/actor-proxy.js +38 -0
- package/project/server/engine/actor/actor-results.js +36 -0
- package/project/server/engine/actor/actor-state-timeout.js +35 -0
- package/project/server/engine/actor/actor-sut.js +38 -0
- package/project/server/engine/actor/actor-terminating.js +32 -0
- package/project/server/engine/actor/actor.js +553 -0
- package/project/server/engine/actor-phase.js +26 -0
- package/project/server/engine/actor-state-machine-base.js +298 -0
- package/project/server/engine/actor-state-machine-data.js +383 -0
- package/project/server/engine/actor-state-machine-exec.js +137 -0
- package/project/server/engine/actor-state-machine-post.js +177 -0
- package/project/server/engine/actor-state-machine-pre.js +142 -0
- package/project/server/engine/actor-state-machine-process.js +88 -0
- package/project/server/engine/actor-state-machine-state.js +52 -0
- package/project/server/engine/actor-state-machine.js +185 -0
- package/project/server/engine/actor-state.js +35 -0
- package/project/server/engine/actor-worker.js +68 -0
- package/project/server/engine/actors-phase.js +49 -0
- package/project/server/engine/actors.js +317 -0
- package/project/server/engine/data/content-audio.js +18 -0
- package/project/server/engine/data/content-base.js +91 -0
- package/project/server/engine/data/content-binary.js +15 -0
- package/project/server/engine/data/content-cache.js +67 -0
- package/project/server/engine/data/content-data.js +254 -0
- package/project/server/engine/data/content-documents.js +18 -0
- package/project/server/engine/data/content-image.js +20 -0
- package/project/server/engine/data/content-other.js +19 -0
- package/project/server/engine/data/content-text.js +19 -0
- package/project/server/engine/data/content-undefined.js +14 -0
- package/project/server/engine/data/content-video.js +20 -0
- package/project/server/engine/data/content.js +60 -0
- package/project/server/engine/data/runtime-data-shared.js +75 -0
- package/project/server/engine/data/test-data.js +239 -0
- package/project/server/engine/execution-context-test-case.js +48 -0
- package/project/server/engine/execution-context-test-suite.js +66 -0
- package/project/server/engine/execution-context.js +93 -0
- package/project/server/engine/stage-setter.js +132 -0
- package/project/server/engine/stage.js +83 -0
- package/project/server/engine/test-case-load.js +25 -0
- package/project/server/engine/test-case-loader.js +125 -0
- package/project/server/engine/test-case-not-found.js +29 -0
- package/project/server/engine/test-case-result-type.js +42 -0
- package/project/server/engine/test-case.js +417 -0
- package/project/server/engine/test-output.js +116 -0
- package/project/server/engine/test-statistics-test-case.js +59 -0
- package/project/server/engine/test-statistics-test-suite.js +63 -0
- package/project/server/engine/test-suite.js +276 -0
- package/project/server/stack/api/base-64.js +16 -0
- package/project/server/stack/api/const-commands-decoder.js +15 -0
- package/project/server/stack/api/const-commands-encoder.js +15 -0
- package/project/server/stack/api/hmacSha1.js +14 -0
- package/project/server/stack/api/json-web-token.js +38 -0
- package/project/server/stack/api/sdp/sdp-decoder.js +70 -0
- package/project/server/stack/api/sdp/sdp-encoder.js +40 -0
- package/project/server/stack/api/sdp/sdp-media-attribute.js +13 -0
- package/project/server/stack/api/sdp/sdp-media-session.js +16 -0
- package/project/server/stack/api/sdp/sdp-message.js +17 -0
- package/project/server/stack/api/sdp/sdp-origin.js +17 -0
- package/project/server/stack/api/sdp/sdp-session-attribute.js +13 -0
- package/project/server/stack/api/sdp/sdp-timing.js +15 -0
- package/project/server/stack/api/text-protocol-header.js +35 -0
- package/project/server/stack/factory/stack-components-helpers.js +22 -0
- package/project/server/stack/factory/stack-components-template-base-actors.js +124 -0
- package/project/server/stack/factory/stack-components-template-base-test-cases.js +22 -0
- package/project/server/stack/factory/stack-components-templates-actors.js +15 -0
- package/project/server/stack/factory/stack-components-templates-test-cases.js +20 -0
- package/project/server/stack/managers/client-manager/client-manager.js +193 -0
- package/project/server/stack/managers/connection-manager/connection-data.js +82 -0
- package/project/server/stack/managers/connection-manager/connection-manager.js +177 -0
- package/project/server/stack/managers/connection-manager/connection-object.js +148 -0
- package/project/server/stack/managers/connection-manager/shared-data.js +14 -0
- package/project/server/stack/managers/manager.js +95 -0
- package/project/server/stack/managers/server-manager/server-manager.js +76 -0
- package/project/server/stack/managers/server-manager/server.js +384 -0
- package/project/server/stack/managers/shared-manager.js +117 -0
- package/project/server/stack/network/buffer-manager.js +190 -0
- package/project/server/stack/network/mc/mc-connection-client-shared.js +51 -0
- package/project/server/stack/network/mc/mc-connection-client.js +117 -0
- package/project/server/stack/network/mc/mc-connection-server-shared.js +51 -0
- package/project/server/stack/network/mc/mc-connection-server.js +58 -0
- package/project/server/stack/network/mc/mc-connection-shared.js +26 -0
- package/project/server/stack/network/mc/mc-connection.js +33 -0
- package/project/server/stack/network/mc/mc-server.js +90 -0
- package/project/server/stack/network/network-connection-shared.js +177 -0
- package/project/server/stack/network/network-connection.js +134 -0
- package/project/server/stack/network/network-helper.js +12 -0
- package/project/server/stack/network/network-server.js +36 -0
- package/project/server/stack/network/network-type.js +46 -0
- package/project/server/stack/network/tcp/tcp-connection-client-shared.js +18 -0
- package/project/server/stack/network/tcp/tcp-connection-client.js +71 -0
- package/project/server/stack/network/tcp/tcp-connection-server-shared.js +14 -0
- package/project/server/stack/network/tcp/tcp-connection-server.js +16 -0
- package/project/server/stack/network/tcp/tcp-connection-shared.js +55 -0
- package/project/server/stack/network/tcp/tcp-connection.js +167 -0
- package/project/server/stack/network/tcp/tcp-server.js +35 -0
- package/project/server/stack/network/tls/tls-connection-client-shared.js +18 -0
- package/project/server/stack/network/tls/tls-connection-client.js +76 -0
- package/project/server/stack/network/tls/tls-connection-server-shared.js +14 -0
- package/project/server/stack/network/tls/tls-connection-server.js +16 -0
- package/project/server/stack/network/tls/tls-connection-shared.js +63 -0
- package/project/server/stack/network/tls/tls-connection.js +176 -0
- package/project/server/stack/network/tls/tls-server.js +45 -0
- package/project/server/stack/network/transport.js +19 -0
- package/project/server/stack/network/udp/udp-connection-client-shared.js +47 -0
- package/project/server/stack/network/udp/udp-connection-client.js +93 -0
- package/project/server/stack/network/udp/udp-connection-server-shared.js +51 -0
- package/project/server/stack/network/udp/udp-connection-server.js +58 -0
- package/project/server/stack/network/udp/udp-connection-shared.js +26 -0
- package/project/server/stack/network/udp/udp-connection.js +33 -0
- package/project/server/stack/network/udp/udp-server.js +74 -0
- package/project/server/stack/pending/pending-const.js +22 -0
- package/project/server/stack/pending/pending-context-receive.js +18 -0
- package/project/server/stack/pending/pending-context-send.js +18 -0
- package/project/server/stack/pending/pending-context.js +18 -0
- package/project/server/stack/pending/pending-inner.js +107 -0
- package/project/server/stack/pending/pending-switch.js +146 -0
- package/project/server/stack/stacks/ascii-dictionary.js +289 -0
- package/project/server/stack/stacks/binary-log.js +88 -0
- package/project/server/stack/stacks/bit-byte.js +51 -0
- package/project/server/stack/stacks/browser-data.js +25 -0
- package/project/server/stack/stacks/cancel-object.js +16 -0
- package/project/server/stack/stacks/connection-client.js +228 -0
- package/project/server/stack/stacks/connection-instance.js +69 -0
- package/project/server/stack/stacks/connection-ip.js +374 -0
- package/project/server/stack/stacks/connection-server.js +169 -0
- package/project/server/stack/stacks/connection-web.js +113 -0
- package/project/server/stack/stacks/connection-worker-client.js +29 -0
- package/project/server/stack/stacks/connection-worker-connection.js +41 -0
- package/project/server/stack/stacks/connection-worker-server.js +29 -0
- package/project/server/stack/stacks/connection-worker.js +99 -0
- package/project/server/stack/stacks/connection.js +132 -0
- package/project/server/stack/stacks/decoder.js +83 -0
- package/project/server/stack/stacks/encoder.js +82 -0
- package/project/server/stack/stacks/ip-log.js +24 -0
- package/project/server/stack/stacks/message-selector.js +22 -0
- package/project/server/stack/stacks/msg-ip.js +18 -0
- package/project/server/stack/stacks/stack-content-cache.js +27 -0
- package/project/z-abs-funclayer-engine-server.tree +230 -0
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
const ActorStateMachineData = require('./actor-state-machine-data');
|
|
5
|
+
const ActorStateMachineExec = require('./actor-state-machine-exec');
|
|
6
|
+
const ActorStateMachinePre = require('./actor-state-machine-pre');
|
|
7
|
+
const ActorStateMachinePost = require('./actor-state-machine-post');
|
|
8
|
+
const ActorResultConst = require('z-abs-funclayer-engine-cs/clientServer/execution/actor-result-const');
|
|
9
|
+
const ActorTypeConst = require('z-abs-funclayer-engine-cs/clientServer/execution/actor-type-const');
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class ActorStateMachine {
|
|
13
|
+
static RUN_NONE = 0;
|
|
14
|
+
static RUN_DATA_PRE = 1;
|
|
15
|
+
static RUN_DATA_EXEC = 2;
|
|
16
|
+
static RUN_DATA_PRE_EXEC = 3;
|
|
17
|
+
static RUN_DATA_POST = 4;
|
|
18
|
+
static RUN_DATA_PRE_POST = 5;
|
|
19
|
+
static RUN_DATA_EXEC_POST = 6;
|
|
20
|
+
static RUN_DATA_PRE_EXEC_POST = 7;
|
|
21
|
+
|
|
22
|
+
constructor() {
|
|
23
|
+
this.actorStateMachineData = null;
|
|
24
|
+
this.actorStateMachinePre = null;
|
|
25
|
+
this.actorStateMachineExec = null;
|
|
26
|
+
this.actorStateMachinePost = null;
|
|
27
|
+
this.kindOfRun = 0;
|
|
28
|
+
this.cbDone = null;
|
|
29
|
+
this.tcSettings = null;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
init(tc, uniqueTcId, executionContext, actors, debug, cbMessage) {
|
|
33
|
+
this.actorStateMachinePre = null;
|
|
34
|
+
this.actorStateMachineExec = null;
|
|
35
|
+
this.actorStateMachinePost = null;
|
|
36
|
+
this.kindOfRun = 0;
|
|
37
|
+
this.cbDone = null;
|
|
38
|
+
this.tcSettings = tc.tc.settings;
|
|
39
|
+
this.actorStateMachineData = new ActorStateMachineData(tc, uniqueTcId, executionContext, cbMessage, actors.preActors, actors.execActors, actors.postActors, debug);
|
|
40
|
+
if(0 !== actors.preActors.actors.length) {
|
|
41
|
+
this.actorStateMachinePre = new ActorStateMachinePre(tc, uniqueTcId, executionContext, cbMessage, actors.preActors, debug);
|
|
42
|
+
this.kindOfRun += 1;
|
|
43
|
+
}
|
|
44
|
+
if(0 !== actors.execActors.actors.length) {
|
|
45
|
+
this.actorStateMachineExec = new ActorStateMachineExec(tc, uniqueTcId, executionContext, cbMessage, actors.execActors, debug);
|
|
46
|
+
this.kindOfRun += 2;
|
|
47
|
+
}
|
|
48
|
+
if(0 !== actors.postActors.actors.length) {
|
|
49
|
+
this.actorStateMachinePost = new ActorStateMachinePost(tc, uniqueTcId, executionContext, cbMessage, actors.postActors, debug);
|
|
50
|
+
this.kindOfRun += 4;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
run(done, cbDone) {
|
|
55
|
+
this.cbDone = cbDone;
|
|
56
|
+
switch(this.kindOfRun) {
|
|
57
|
+
case ActorStateMachine.RUN_NONE:
|
|
58
|
+
this._calculateSumResult(done, ActorResultConst.NONE, ActorResultConst.NONE, ActorResultConst.NONE);
|
|
59
|
+
break;
|
|
60
|
+
case ActorStateMachine.RUN_DATA_PRE:
|
|
61
|
+
this.actorStateMachineData.data((dataResultId) => {
|
|
62
|
+
this.actorStateMachinePre.run(dataResultId, (resultIdPre) => {
|
|
63
|
+
this._calculateSumResult(done, resultIdPre, ActorResultConst.NONE, ActorResultConst.NONE);
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
break;
|
|
67
|
+
case ActorStateMachine.RUN_DATA_EXEC:
|
|
68
|
+
this.actorStateMachineData.data((dataResultId) => {
|
|
69
|
+
this.actorStateMachineExec.run(dataResultId, (resultIdExec) => {
|
|
70
|
+
this._calculateSumResult(done, ActorResultConst.NONE, resultIdExec, ActorResultConst.NONE);
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
break;
|
|
74
|
+
case ActorStateMachine.RUN_DATA_PRE_EXEC:
|
|
75
|
+
this.actorStateMachineData.data((dataResultId) => {
|
|
76
|
+
this.actorStateMachinePre.run(dataResultId, (resultIdPre) => {
|
|
77
|
+
this.actorStateMachineExec.run(Math.max(dataResultId, resultIdPre), (resultIdExec) => {
|
|
78
|
+
this._calculateSumResult(done, resultIdPre, resultIdExec, ActorResultConst.NONE);
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
break;
|
|
83
|
+
case ActorStateMachine.RUN_DATA_POST:
|
|
84
|
+
this.actorStateMachineData.data((dataResultId) => {
|
|
85
|
+
this.actorStateMachinePost.run(dataResultId, (resultIdPost) => {
|
|
86
|
+
this._calculateSumResult(done, ActorResultConst.NONE, ActorResultConst.NONE, resultIdPost);
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
break;
|
|
90
|
+
case ActorStateMachine.RUN_DATA_PRE_POST:
|
|
91
|
+
this.actorStateMachineData.data((dataResultId) => {
|
|
92
|
+
this.actorStateMachinePre.run(dataResultId, (resultIdPre) => {
|
|
93
|
+
this.actorStateMachinePost.run(Math.max(dataResultId, resultIdPre), (resultIdPost) => {
|
|
94
|
+
this._calculateSumResult(done, resultIdPre, ActorResultConst.NONE, resultIdPost);
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
});
|
|
98
|
+
break;
|
|
99
|
+
case ActorStateMachine.RUN_DATA_EXEC_POST:
|
|
100
|
+
this.actorStateMachineData.data((dataResultId) => {
|
|
101
|
+
this.actorStateMachineExec.run(dataResultId, (resultIdExec) => {
|
|
102
|
+
this.actorStateMachinePost.run(Math.max(dataResultId, resultIdExec), (resultIdPost) => {
|
|
103
|
+
this._calculateSumResult(done, ActorResultConst.NONE, resultIdExec, resultIdPost);
|
|
104
|
+
});
|
|
105
|
+
});
|
|
106
|
+
});
|
|
107
|
+
break;
|
|
108
|
+
case ActorStateMachine.RUN_DATA_PRE_EXEC_POST:
|
|
109
|
+
this.actorStateMachineData.data((dataResultId) => {
|
|
110
|
+
this.actorStateMachinePre.run(dataResultId, (resultIdPre) => {
|
|
111
|
+
this.actorStateMachineExec.run(Math.max(dataResultId, resultIdPre), (resultIdExec) => {
|
|
112
|
+
this.actorStateMachinePost.run(Math.max(dataResultId, resultIdPre, resultIdExec), (resultIdPost) => {
|
|
113
|
+
this._calculateSumResult(done, resultIdPre, resultIdExec, resultIdPost);
|
|
114
|
+
});
|
|
115
|
+
});
|
|
116
|
+
});
|
|
117
|
+
});
|
|
118
|
+
break;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
runCommentOut(done, cbDone) {
|
|
123
|
+
this.cbDone = cbDone;
|
|
124
|
+
this._calculateSumResult(done, ActorResultConst.NONE, ActorResultConst.NONE, ActorResultConst.NONE);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
stop(done) {
|
|
128
|
+
let pendings = 0;
|
|
129
|
+
if(null !== this.actorStateMachineData) {
|
|
130
|
+
++pendings;
|
|
131
|
+
this.actorStateMachineData.stop(() => {
|
|
132
|
+
if(0 === --pendings) {
|
|
133
|
+
done();
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
if(null !== this.actorStateMachinePre) {
|
|
138
|
+
++pendings;
|
|
139
|
+
this.actorStateMachinePre.stop(() => {
|
|
140
|
+
if(0 === --pendings) {
|
|
141
|
+
done();
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
if(null !== this.actorStateMachineExec) {
|
|
146
|
+
++pendings;
|
|
147
|
+
this.actorStateMachineExec.stop(() => {
|
|
148
|
+
if(0 === --pendings) {
|
|
149
|
+
done();
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
if(null !== this.actorStateMachinePost) {
|
|
154
|
+
++pendings;
|
|
155
|
+
this.actorStateMachinePost.stop(() => {
|
|
156
|
+
if(0 === --pendings) {
|
|
157
|
+
done();
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
if(0 === pendings) {
|
|
162
|
+
done();
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
_calculateSumResult(cbDone, resultIdPre, resultIdExec, resultIdPost, tcResultId = -1) {
|
|
167
|
+
this.cbDone((commentOut, last) => {
|
|
168
|
+
if(undefined !== this.tcSettings && 1 === this.tcSettings.length && !commentOut) {
|
|
169
|
+
if(ActorResultConst.getTableNameResultIds(this.tcSettings[0].preResult, true) === resultIdPre && ActorResultConst.getTableNameResultIds(this.tcSettings[0].execResult, true) === resultIdExec && ActorResultConst.getTableNameResultIds(this.tcSettings[0].postResult, true) === resultIdPost) {
|
|
170
|
+
return cbDone(ActorResultConst.SUCCESS, resultIdPre, resultIdExec, resultIdPost, last);
|
|
171
|
+
}
|
|
172
|
+
else {
|
|
173
|
+
return cbDone(ActorResultConst.FAILURE, resultIdPre, resultIdExec, resultIdPost, last);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
else {
|
|
177
|
+
const resultId = -1 === tcResultId ? Math.max(resultIdPre, resultIdExec, resultIdPost) : tcResultId;
|
|
178
|
+
return cbDone(resultId, resultIdPre, resultIdExec, resultIdPost, last);
|
|
179
|
+
}
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
module.exports = ActorStateMachine;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
const ActorStateConst = require('z-abs-funclayer-engine-cs/clientServer/execution/actor-state-const');
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class ActorState {
|
|
8
|
+
constructor(actor) {
|
|
9
|
+
this.actor = actor;
|
|
10
|
+
this.currentActorStateId = ActorStateConst.DATA;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
set(actorStateId) {
|
|
14
|
+
this.currentActorStateId = actorStateId;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
setNext() {
|
|
18
|
+
this.currentActorStateId += 1;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
getActorStateId() {
|
|
22
|
+
return this.currentActorStateId;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
getName() {
|
|
26
|
+
return ActorStateConst.actorStateNames[this.currentActorStateId];
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
getNameFromState(actorStateId) {
|
|
30
|
+
return ActorStateConst.actorStateNames[actorStateId];
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
module.exports = ActorState;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
|
|
2
|
+
const WebWorkerThreads = require('webworker-threads');
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class ActorWorker {
|
|
6
|
+
constructor() {
|
|
7
|
+
this.threadsIdle = [];
|
|
8
|
+
this.threadsWorking = new Map();
|
|
9
|
+
this._createThreadPool(15);
|
|
10
|
+
this.jobQueue = [];
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
load() {
|
|
14
|
+
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
doData(cmd) {
|
|
18
|
+
this._addJob(cmd);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
doInitServer(cmd) {
|
|
22
|
+
this._addJob(cmd);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
doInitClient(cmd) {
|
|
26
|
+
this._addJob(cmd);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
doRun(cmd) {
|
|
30
|
+
this._addJob(cmd);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
doExit(cmd) {
|
|
34
|
+
this._addJob(cmd);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
_createThreadPool(nbrOfThreads) {
|
|
38
|
+
for(let i = 0; i < nbrOfThreads; ++i) {
|
|
39
|
+
let thread = WebWorkerThreads.create();
|
|
40
|
+
this.threadsIdle.push(thread);
|
|
41
|
+
thread.load('C:\\Users\\A\\Documents\\ActorBase\\Actor\\dist\\serverWorkers\\serverWorkerActor\\server-worker-actor-bundle.js');
|
|
42
|
+
thread.on('response', (data) => {
|
|
43
|
+
let response = JSON.parse(data);
|
|
44
|
+
let thread = this.threadsWorking.get(response.threadId);
|
|
45
|
+
if(0 === this.jobQueue.length) {
|
|
46
|
+
this.threadsIdle.push(thread);
|
|
47
|
+
this.threadsWorking.delete(response.threadId);
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
thread.emit('message', this.jobQueue.pop());
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
_addJob(msg) {
|
|
57
|
+
if(0 !== this.threadsIdle.length) {
|
|
58
|
+
let thread = this.threadsIdle.pop();
|
|
59
|
+
this.threadsWorking.set(thread.id, thread);
|
|
60
|
+
thread.emit('message', msg);
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
this.jobQueue.push(msg);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
module.exports = new ActorWorker();
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
const ActorPhaseConst = require('z-abs-funclayer-engine-cs/clientServer/execution/actor-phase-const');
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class ActorsPhase {
|
|
8
|
+
constructor(phaseId) {
|
|
9
|
+
this.phaseId = phaseId;
|
|
10
|
+
this.phaseName = ActorPhaseConst.getName(phaseId);
|
|
11
|
+
this.actors = [];
|
|
12
|
+
this.notStartedActors = new Map();
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
add(actor) {
|
|
16
|
+
this.actors.push(actor);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
addFront(actor) {
|
|
20
|
+
this.actors.splice(0, 0, actor);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
setIndex() {
|
|
24
|
+
this.actors.forEach((actor) => {
|
|
25
|
+
this.notStartedActors.set(actor.getIndexFromPhase(this.phaseId), actor);
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
getNextActors(actorDoneIndices) {
|
|
30
|
+
const foundActors = [];
|
|
31
|
+
this.notStartedActors.forEach((actor) => {
|
|
32
|
+
const found = undefined !== actor.getDependencies(this.phaseId).find((dependentActorIndex) => {
|
|
33
|
+
return undefined !== actorDoneIndices.find((actorDoneIndex) => {
|
|
34
|
+
return actorDoneIndex === dependentActorIndex;
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
if(found) {
|
|
38
|
+
foundActors.push(actor);
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
foundActors.forEach((actor) => {
|
|
42
|
+
this.notStartedActors.delete(actor.getIndex());
|
|
43
|
+
});
|
|
44
|
+
return foundActors;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
module.exports = ActorsPhase;
|
|
@@ -0,0 +1,317 @@
|
|
|
1
|
+
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
const ActorsPhase = require('./actors-phase');
|
|
5
|
+
const ActorPhaseConst = require('z-abs-funclayer-engine-cs/clientServer/execution/actor-phase-const');
|
|
6
|
+
const ActorTypeConst = require('z-abs-funclayer-engine-cs/clientServer/execution/actor-type-const');
|
|
7
|
+
const Logger = require('z-abs-corelayer-server/server/log/logger');
|
|
8
|
+
const ActorPathDist = require('z-abs-corelayer-server/server/path/actor-path-dist');
|
|
9
|
+
const MemoryCacheArray = require('z-abs-corelayer-cs/clientServer/memory/memory-cache-array');
|
|
10
|
+
const MemoryCacheMap = require('z-abs-corelayer-cs/clientServer/memory/memory-cache-map');
|
|
11
|
+
const FactoryFunction = require('z-abs-corelayer-cs/clientServer/factory/factory-function');
|
|
12
|
+
const Module = require('module');
|
|
13
|
+
const Path = require('path');
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class Actors {
|
|
17
|
+
static REPLACE_CONDITION = "(VERIFY_MANDATORY|VERIFY_OPTIONAL|VERIFY_VALUE|VERIFY_CONTENT_VALUE|VERIFY_CONTENT_MANDATORY|VERIFY_CONTENT_OPTIONAL|this.delay|this.delay|this.async\\(|this.callback\\(|this.setSharedData\\(|this.setSharedDataActor\\(|this.waitForSharedData\\(|this.waitForSharedDataActor\\(|this.setSharedExecutionData\\(|this.waitForSharedExecutionData\\(|this.getContent|this.getContentByName|this.closeConnection|this.createConnection|this.createServer|this.([^ ]*)Connection.send\\(|this.([^ ]*)Connection.sendLine\\(|this.([^ ]*)Connection.sendObject\\(|this.([^ ]*)Connection.sendHeader\\(|this.([^ ]*)Connection.sendRequestLine\\(|this.([^ ]*)Connection.sendHeaders\\(|this.([^ ]*)Connection.sendBody\\(|this.([^ ]*)Connection.receive\\(|this.([^ ]*)Connection.receiveLine\\(|this.([^ ]*)Connection.receiveObject\\(|this.([^ ]*)Connection.receiveSize\\(|this.([^ ]*)Connection.receiveHeader\\(|this.([^ ]*)Connection.receiveBody\\(|this.([^ ]*)Connection.accept\\(|this.([^ ]*)Connection.close\\(|this.([^ ]*)Connection.sendText\\(|this.([^ ]*)Connection.receiveText\\()";
|
|
18
|
+
static REPLACE_HANDLE = "\r\n switch(parameters[0]) {\r\n case 'VERIFY_MANDATORY':\r\n case 'VERIFY_OPTIONAL':\r\n case 'VERIFY_VALUE':\r\n case 'VERIFY_CONTENT_VALUE':\r\n return `this.${match}`;\r\n case 'VERIFY_CONTENT_MANDATORY':\r\n case 'VERIFY_CONTENT_OPTIONAL':\r\n return `yield* this.${match}`;\r\n case 'this.delay': \r\n case 'this.async(': \r\n case 'this.callback(': \r\n case 'this.setSharedData(': \r\n case 'this.setSharedDataActor(': \r\n case 'this.waitForSharedData(': \r\n case 'this.waitForSharedDataActor(': \r\n case 'this.setSharedExecutionData(': \r\n case 'this.waitForSharedExecutionData(': \r\n case 'this.getContent': \r\n case 'this.getContentByName': \r\n case 'this.closeConnection': \r\n return `yield* ${match}`;\r\n case 'this.createConnection': \r\n case 'this.createServer': \r\n return `yield ${match}`;\r\n case `this.${parameters[1]}Connection.send(`:\r\n case `this.${parameters[2]}Connection.sendLine(`:\r\n case `this.${parameters[3]}Connection.sendObject(`:\r\n case `this.${parameters[4]}Connection.sendHeader(`:\r\n case `this.${parameters[5]}Connection.sendRequestLine(`:\r\n case `this.${parameters[6]}Connection.sendHeaders(`:\r\n case `this.${parameters[7]}Connection.sendBody(`:\r\n case `this.${parameters[8]}Connection.receive(`:\r\n case `this.${parameters[9]}Connection.receiveLine(`:\r\n case `this.${parameters[10]}Connection.receiveObject(`:\r\n case `this.${parameters[11]}Connection.receiveSize(`:\r\n case `this.${parameters[12]}Connection.receiveHeader(`:\r\n case `this.${parameters[13]}Connection.receiveBody(`:\r\n case `this.${parameters[14]}Connection.accept(`:\r\n case `this.${parameters[15]}Connection.close(`:\r\n case `this.${parameters[16]}Connection.sendText(`:\r\n case `this.${parameters[17]}Connection.receiveText(`:\r\n return `yield ${match}`;\r\n default:\r\n ddb.writeln('Error:', parameters[0]);\r\n return match;\r\n };\r\n";
|
|
19
|
+
static replaceCondition = new RegExp(Actors.REPLACE_CONDITION, 'g');
|
|
20
|
+
static replaceHandle = new Function('match', 'parameters', Actors.REPLACE_HANDLE);
|
|
21
|
+
|
|
22
|
+
constructor(uniqueTcId, tc, executionContext, tcData, debug, config, slowAwaitTime, cbMessage) {
|
|
23
|
+
this.uniqueTcId = uniqueTcId;
|
|
24
|
+
this.tc = tc;
|
|
25
|
+
this.executionContext = executionContext;
|
|
26
|
+
this.tcData = tcData;
|
|
27
|
+
this.debug = debug;
|
|
28
|
+
this.config = config;
|
|
29
|
+
this.slowAwaitTime = slowAwaitTime;
|
|
30
|
+
this.cbMessage = cbMessage;
|
|
31
|
+
this.preActors = new ActorsPhase(ActorPhaseConst.PRE);
|
|
32
|
+
this.execActors = new ActorsPhase(ActorPhaseConst.EXEC);
|
|
33
|
+
this.postActors = new ActorsPhase(ActorPhaseConst.POST);
|
|
34
|
+
this.actors = MemoryCacheArray.create(MemoryCacheArray.TYPE_OBJECT);
|
|
35
|
+
this.nodes = MemoryCacheArray.create(MemoryCacheArray.TYPE_OBJECT);
|
|
36
|
+
this.results = MemoryCacheArray.create(MemoryCacheArray.TYPE_BOOLEAN);
|
|
37
|
+
this.instanceIndices = MemoryCacheMap.create(MemoryCacheMap.TYPE_STRING_INT);
|
|
38
|
+
this.actorFactories = new Map();
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
destructor() {
|
|
42
|
+
MemoryCacheArray.destructor(MemoryCacheArray.TYPE_OBJECT, this.actors);
|
|
43
|
+
MemoryCacheArray.destructor(MemoryCacheArray.TYPE_OBJECT, this.nodes);
|
|
44
|
+
MemoryCacheArray.destructor(MemoryCacheArray.TYPE_BOOLEAN, this.results);
|
|
45
|
+
MemoryCacheMap.destructor(MemoryCacheMap.TYPE_STRING_INT, this.instanceIndices);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
loadActors(cb) {
|
|
49
|
+
const actors = this.tc.actors;
|
|
50
|
+
const size = actors.length;
|
|
51
|
+
if(0 === size) {
|
|
52
|
+
process.nextTick((self, cb) => {
|
|
53
|
+
this._calculateIndices();
|
|
54
|
+
cb(true);
|
|
55
|
+
}, this, cb);
|
|
56
|
+
}
|
|
57
|
+
for(let i = 0; i < size; ++i) {
|
|
58
|
+
process.nextTick((self, actors, FactoryFunction, instanceIndices, ActorTypeConst, results, cb) => {
|
|
59
|
+
const actorData = actors[i];
|
|
60
|
+
const actor = FactoryFunction.create((self, actorData) => {
|
|
61
|
+
return !actorData.inlineCode ? self._loadFromFile(actorData) : self._loadFromString(actorData);
|
|
62
|
+
}, self, actorData);
|
|
63
|
+
if(actor) {
|
|
64
|
+
let instanceIndex = 0;
|
|
65
|
+
const actorName = actorData.name.substr(actorData.name.lastIndexOf('.') + 1);
|
|
66
|
+
if(instanceIndices.has(actorName)) {
|
|
67
|
+
instanceIndex = instanceIndices.get(actorName) + 1;
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
instanceIndex = 1;
|
|
71
|
+
}
|
|
72
|
+
instanceIndices.set(actorName, instanceIndex);
|
|
73
|
+
if(actorData.type !== ActorTypeConst.getName(actor.inheritedType)) {
|
|
74
|
+
results.push(false);
|
|
75
|
+
if(size === results.length) {
|
|
76
|
+
self._actorsLoaded(results, cb);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
actor.init(self.uniqueTcId, actorData, instanceIndex, self.cbMessage, self.executionContext, self.tcData, self.config, self.slowAwaitTime, self.nodes, (result) => {
|
|
81
|
+
self._addActor(actor);
|
|
82
|
+
results.push(result);
|
|
83
|
+
if(size === results.length) {
|
|
84
|
+
self._actorsLoaded(results, cb);
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
90
|
+
results.push(false);
|
|
91
|
+
if(size === results.length) {
|
|
92
|
+
self._actorsLoaded(results, cb);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}, this, actors, FactoryFunction, this.instanceIndices, ActorTypeConst, this.results, cb);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
_actorsLoaded(results, cb) {
|
|
100
|
+
const result = results.every((result) => {
|
|
101
|
+
return result;
|
|
102
|
+
});
|
|
103
|
+
if(result) {
|
|
104
|
+
this._calculateIndices();
|
|
105
|
+
this._calculatDependencies(this.preActors.actors, ActorPhaseConst.PRE);
|
|
106
|
+
this._calculatDependencies(this.execActors.actors, ActorPhaseConst.EXEC);
|
|
107
|
+
this._calculatDependencies(this.postActors.actors, ActorPhaseConst.POST);
|
|
108
|
+
}
|
|
109
|
+
cb(result);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
_calculateIndices() {
|
|
113
|
+
this.preActors.actors.forEach((actor) => {
|
|
114
|
+
this.nodes.push({
|
|
115
|
+
actor: actor,
|
|
116
|
+
name: actor.logName,
|
|
117
|
+
phaseId: ActorPhaseConst.PRE,
|
|
118
|
+
typeId: actor.typeId,
|
|
119
|
+
index: -1,
|
|
120
|
+
columnIndex: -1
|
|
121
|
+
});
|
|
122
|
+
});
|
|
123
|
+
this.execActors.actors.forEach((actor) => {
|
|
124
|
+
this.nodes.push({
|
|
125
|
+
actor: actor,
|
|
126
|
+
name: actor.logName,
|
|
127
|
+
phaseId: ActorPhaseConst.EXEC,
|
|
128
|
+
typeId: actor.typeId,
|
|
129
|
+
index: -1,
|
|
130
|
+
columnIndex: -1
|
|
131
|
+
});
|
|
132
|
+
});
|
|
133
|
+
if(0 !== this.executionContext.stageData.stagedSutNodes.length) {
|
|
134
|
+
this.executionContext.stageData.stagedSutNodes.forEach((stagedSutNode) => {
|
|
135
|
+
this.nodes.push({
|
|
136
|
+
name: stagedSutNode.name,
|
|
137
|
+
phaseId: ActorPhaseConst.EXEC,
|
|
138
|
+
typeId: ActorTypeConst.REAL_SUT,
|
|
139
|
+
index: -1,
|
|
140
|
+
columnIndex: -1,
|
|
141
|
+
criteriaType: stagedSutNode.criteriaType,
|
|
142
|
+
criteria: stagedSutNode.criteria
|
|
143
|
+
});
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
else {
|
|
147
|
+
this.nodes.push({
|
|
148
|
+
name: this.executionContext.stageData.stagedSut,
|
|
149
|
+
phaseId: ActorPhaseConst.EXEC,
|
|
150
|
+
typeId: ActorTypeConst.REAL_SUT,
|
|
151
|
+
index: -1,
|
|
152
|
+
columnIndex: -1
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
this.postActors.actors.forEach((actor) => {
|
|
156
|
+
this.nodes.push({
|
|
157
|
+
actor: actor,
|
|
158
|
+
name: actor.logName,
|
|
159
|
+
phaseId: ActorPhaseConst.POST,
|
|
160
|
+
typeId: actor.typeId,
|
|
161
|
+
index: -1,
|
|
162
|
+
columnIndex: -1
|
|
163
|
+
});
|
|
164
|
+
});
|
|
165
|
+
this._sortActors(this.nodes);
|
|
166
|
+
let orderIndex = 0;
|
|
167
|
+
let columnIndex = 0;
|
|
168
|
+
this.nodes.forEach((node, index) => {
|
|
169
|
+
if(ActorTypeConst.REAL_SUT !== node.typeId) {
|
|
170
|
+
node.actor.setIndex(index);
|
|
171
|
+
node.actor.setOrderIndex(orderIndex++);
|
|
172
|
+
this.actors.push(node.actor);
|
|
173
|
+
}
|
|
174
|
+
node.index = index;
|
|
175
|
+
});
|
|
176
|
+
this.nodes = this.nodes.filter((node) => {
|
|
177
|
+
return !(ActorTypeConst.COND === node.typeId && ActorPhaseConst.POST === node.phaseId);
|
|
178
|
+
});
|
|
179
|
+
this.nodes.forEach((node, index) => {
|
|
180
|
+
node.columnIndex = index;
|
|
181
|
+
if(ActorTypeConst.REAL_SUT !== node.typeId) {
|
|
182
|
+
node.actor.setColumnIndex(index);
|
|
183
|
+
}
|
|
184
|
+
});
|
|
185
|
+
this.preActors.setIndex();
|
|
186
|
+
this.execActors.setIndex();
|
|
187
|
+
this.postActors.setIndex();
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
_calculatDependencies(actors, phaseId) {
|
|
191
|
+
let previusActors = [];
|
|
192
|
+
actors.forEach((actor) => {
|
|
193
|
+
if(0 === previusActors.length) {
|
|
194
|
+
actor.setDependency(-1, phaseId);
|
|
195
|
+
}
|
|
196
|
+
else {
|
|
197
|
+
if('serial' === actor.getSequence()) {
|
|
198
|
+
this._dependOnPrevious(previusActors, actor, phaseId);
|
|
199
|
+
}
|
|
200
|
+
else if('parallel' === actor.getSequence()) {
|
|
201
|
+
this._dependOnPreviousDependencies(previusActors, actor, phaseId);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
previusActors.push(actor);
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
_dependOnPrevious(previusActors, actor, phaseId) {
|
|
209
|
+
let index = -1;
|
|
210
|
+
for(let i = previusActors.length - 1; i >= 0; --i) {
|
|
211
|
+
index = previusActors[i].getIndexFromPhase(phaseId);
|
|
212
|
+
break;
|
|
213
|
+
}
|
|
214
|
+
actor.setDependency(index, phaseId);
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
_dependOnPreviousDependencies(previusActors, actor, phaseId) {
|
|
218
|
+
let indices = [-1];
|
|
219
|
+
for(let i = previusActors.length - 1; i >= 0; --i) {
|
|
220
|
+
indices = previusActors[i].getDependenciesFromPhase(phaseId);
|
|
221
|
+
break;
|
|
222
|
+
}
|
|
223
|
+
indices.forEach((index) => {
|
|
224
|
+
actor.setDependency(index, phaseId);
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
_addActor(actor) {
|
|
229
|
+
if(ActorTypeConst.COND === actor.typeId) {
|
|
230
|
+
this.preActors.add(actor);
|
|
231
|
+
this.postActors.addFront(actor);
|
|
232
|
+
}
|
|
233
|
+
else {
|
|
234
|
+
switch(actor.phaseId) {
|
|
235
|
+
case ActorPhaseConst.PRE:
|
|
236
|
+
this.preActors.add(actor);
|
|
237
|
+
break;
|
|
238
|
+
case ActorPhaseConst.EXEC:
|
|
239
|
+
this.execActors.add(actor);
|
|
240
|
+
break;
|
|
241
|
+
case ActorPhaseConst.POST:
|
|
242
|
+
this.postActors.add(actor);
|
|
243
|
+
break;
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
_compareActors(a, b) {
|
|
249
|
+
if(a < b) {
|
|
250
|
+
return -1;
|
|
251
|
+
}
|
|
252
|
+
else if(b < a) {
|
|
253
|
+
return 1;
|
|
254
|
+
}
|
|
255
|
+
else {
|
|
256
|
+
return 0;
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
_sortActors(actors) {
|
|
261
|
+
actors.sort((a, b) => {
|
|
262
|
+
const phase = this._compareActors(a.phaseId, b.phaseId);
|
|
263
|
+
if(0 !== phase) {
|
|
264
|
+
return phase;
|
|
265
|
+
}
|
|
266
|
+
else if(ActorPhaseConst.EXEC === a.phaseId) {
|
|
267
|
+
const result = this._compareActors(a.typeId, b.typeId);
|
|
268
|
+
return result;
|
|
269
|
+
}
|
|
270
|
+
else {
|
|
271
|
+
return 0;
|
|
272
|
+
}
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
_loadFromFile(actorData) {
|
|
277
|
+
let actorFactory = this.actorFactories.get(actorData.name);
|
|
278
|
+
if(!actorFactory) {
|
|
279
|
+
const path = actorData.name.split('.');
|
|
280
|
+
const file = `${ActorPathDist.getActorFile(path.join(Path.sep))}.js`;
|
|
281
|
+
actorFactory = require(file);
|
|
282
|
+
this.actorFactories.set(actorData.name, actorFactory);
|
|
283
|
+
}
|
|
284
|
+
try {
|
|
285
|
+
return new actorFactory();
|
|
286
|
+
}
|
|
287
|
+
catch(err) {
|
|
288
|
+
LOG_ERROR(Logger.ERROR.CATCH, `Could not create the Actor: '${actorData.name}'. File: '${file}'`, err, err.stack);
|
|
289
|
+
}
|
|
290
|
+
return null;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
_loadFromString(actorData) {
|
|
294
|
+
let actorFactory = this.actorFactories.get(actorData.name);
|
|
295
|
+
if(!actorFactory) {
|
|
296
|
+
const path = actorData.name.split('.');
|
|
297
|
+
const fileName = `${ActorPathDist.getActorFile(path.join(Path.sep))}.js`;
|
|
298
|
+
const paths = Module._nodeModulePaths(Path.dirname(''));
|
|
299
|
+
const parent = module.parent;
|
|
300
|
+
const m = new Module('', parent);
|
|
301
|
+
m.filename = fileName;
|
|
302
|
+
m.paths = [].concat([]).concat(paths).concat([]);
|
|
303
|
+
const code = actorData.inlineCode.replace(Actors.replaceCondition, (...parameters) => {
|
|
304
|
+
const match = parameters.shift();
|
|
305
|
+
return Actors.replaceHandle(match, parameters);
|
|
306
|
+
});
|
|
307
|
+
m._compile(code, m.filename);
|
|
308
|
+
const actorFactory = m.exports;
|
|
309
|
+
this.actorFactories.set(actorData.name, actorFactory);
|
|
310
|
+
parent && parent.children && parent.children.splice(parent.children.indexOf(m), 1);
|
|
311
|
+
}
|
|
312
|
+
return new actorFactory();
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
|
|
317
|
+
module.exports = Actors;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
const ContentBase = require('./content-base');
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class ContentAudio extends ContentBase {
|
|
8
|
+
constructor(contentData, buffers, readData) {
|
|
9
|
+
super(buffers, readData);
|
|
10
|
+
this.name = contentData.name;
|
|
11
|
+
this.path = contentData.path;
|
|
12
|
+
this.mime = contentData.mime;
|
|
13
|
+
this.size = contentData.size;
|
|
14
|
+
this.description = contentData.description;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
module.exports = ContentAudio;
|