@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,109 @@
|
|
|
1
|
+
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
const CancelObject = require('../../../stack/stacks/cancel-object');
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
const SharedDataMixin = {
|
|
8
|
+
*setSharedData(key, value) {
|
|
9
|
+
const sharedDataobject = this.tcData.sharedRuntimeData.set(key, value);
|
|
10
|
+
this._handlePendings(key, sharedDataobject);
|
|
11
|
+
const cancelObject = new CancelObject();
|
|
12
|
+
const pendingId = this.setPending(() => {
|
|
13
|
+
cancelObject.set();
|
|
14
|
+
});
|
|
15
|
+
process.nextTick((self, cancelObject, pendingId, value) => {
|
|
16
|
+
if(!cancelObject.cancel) {
|
|
17
|
+
self.handlePendingIdSuccess(pendingId, value);
|
|
18
|
+
}
|
|
19
|
+
}, this, cancelObject, pendingId, value);
|
|
20
|
+
return yield;
|
|
21
|
+
},
|
|
22
|
+
setSharedDataSync(key, value) {
|
|
23
|
+
const sharedDataobject = this.tcData.sharedRuntimeData.set(key, value);
|
|
24
|
+
this._handlePendings(key, sharedDataobject);
|
|
25
|
+
return value;
|
|
26
|
+
},
|
|
27
|
+
getSharedData(key, defaultValue) {
|
|
28
|
+
const sharedData = this.tcData.sharedRuntimeData.get(key);
|
|
29
|
+
if(undefined !== sharedData) {
|
|
30
|
+
return sharedData.value;
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
return defaultValue;
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
*waitForSharedData(key, expectedValue) {
|
|
37
|
+
const value = this.tcData.sharedRuntimeData.wait(key, this, expectedValue, () => {
|
|
38
|
+
const cancelObject = new CancelObject();
|
|
39
|
+
const pendingId = this.setPending(() => {
|
|
40
|
+
cancelObject.set();
|
|
41
|
+
});
|
|
42
|
+
return {
|
|
43
|
+
id: pendingId,
|
|
44
|
+
cancelObject: cancelObject
|
|
45
|
+
};
|
|
46
|
+
});
|
|
47
|
+
if(null !== value) {
|
|
48
|
+
return value;
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
return yield;
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
*setSharedDataActor(key, value, name, index) {
|
|
55
|
+
if(undefined === name) {
|
|
56
|
+
return yield* this.setSharedData(`${this.name}[${this.instanceIndex}].${key}`, value);
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
return yield* this.setSharedData(`${name}[${index}].${key}`, value);
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
setSharedDataActorSync(key, value, name, index) {
|
|
63
|
+
if(undefined === name) {
|
|
64
|
+
return this.setSharedDataSync(`${this.name}[${this.instanceIndex}].${key}`, value);
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
return this.setSharedDataSync(`${name}[${index}].${key}`, value);
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
getSharedDataActor(key, name, index) {
|
|
71
|
+
if(undefined === name) {
|
|
72
|
+
return this.getSharedData(`${this.name}[${this.instanceIndex}].${key}`);
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
return this.getSharedData(`${name}[${index}].${key}`);
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
*waitForSharedDataActor(key, expectedValue) {
|
|
79
|
+
if(undefined === name) {
|
|
80
|
+
yield* this.waitForSharedData(`${this.name}[${this.instanceIndex}].${key}`, expectedValue);
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
yield* this.waitForSharedData(`${name}[${index}].${key}`, expectedValue);
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
_handlePendings(key, sharedDataobject) {
|
|
87
|
+
let found = true;
|
|
88
|
+
while(found) {
|
|
89
|
+
const index = sharedDataobject.pendings.findIndex((pending) => {
|
|
90
|
+
return undefined === pending.expectedValue ? true : sharedDataobject.value === pending.expectedValue;
|
|
91
|
+
});
|
|
92
|
+
if(-1 !== index) {
|
|
93
|
+
const sharedPendingData = sharedDataobject.pendings[index];
|
|
94
|
+
sharedDataobject.pendings.splice(index, 1);
|
|
95
|
+
process.nextTick((sharedPendingData, sharedDataobject) => {
|
|
96
|
+
if(!sharedPendingData.cancelObject.cancel) {
|
|
97
|
+
sharedPendingData.actor.handlePendingIdSuccess(sharedPendingData.pendingId, sharedDataobject.value);
|
|
98
|
+
}
|
|
99
|
+
}, sharedPendingData, sharedDataobject);
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
module.exports = SharedDataMixin;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
const CancelObject = require('../../../stack/stacks/cancel-object');
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
const SharedExecutionDataMixin = {
|
|
8
|
+
*setSharedExecutionData(key, value) {
|
|
9
|
+
const sharedDataobject = this.executionContext.sharedRuntimeData.set(key, value);
|
|
10
|
+
this._handlePendings(key, sharedDataobject);
|
|
11
|
+
const cancelObject = new CancelObject();
|
|
12
|
+
const pendingId = this.setPending(() => {
|
|
13
|
+
cancelObject.set();
|
|
14
|
+
});
|
|
15
|
+
process.nextTick((self, cancelObject, pendingId, value) => {
|
|
16
|
+
if(!cancelObject.cancel) {
|
|
17
|
+
self.handlePendingIdSuccess(pendingId, value);
|
|
18
|
+
}
|
|
19
|
+
}, this, cancelObject, pendingId, value);
|
|
20
|
+
return yield;
|
|
21
|
+
},
|
|
22
|
+
setSharedExecutionDataSync(key, value) {
|
|
23
|
+
const sharedDataobject = this.executionContext.sharedRuntimeData.set(key, value);
|
|
24
|
+
this._handlePendings(key, sharedDataobject);
|
|
25
|
+
return value;
|
|
26
|
+
},
|
|
27
|
+
getSharedExecutionData(key, defaultValue) {
|
|
28
|
+
const sharedData = this.executionContext.sharedRuntimeData.get(key);
|
|
29
|
+
if(undefined !== sharedData) {
|
|
30
|
+
return sharedData.value;
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
return defaultValue;
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
*waitForSharedExecutionData(key, expectedValue) {
|
|
37
|
+
const value = this.executionContext.sharedRuntimeData.wait(key, this, expectedValue, () => {
|
|
38
|
+
const cancelObject = new CancelObject();
|
|
39
|
+
const pendingId = this.setPending(() => {
|
|
40
|
+
cancelObject.set();
|
|
41
|
+
});
|
|
42
|
+
return {
|
|
43
|
+
id: pendingId,
|
|
44
|
+
cancelObject: cancelObject
|
|
45
|
+
};
|
|
46
|
+
});
|
|
47
|
+
if(null !== value) {
|
|
48
|
+
return value;
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
return yield;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
module.exports = SharedExecutionDataMixin;
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
const Address = require('../../../address/address');
|
|
5
|
+
const MessageSelector = require('../../../stack/stacks/message-selector');
|
|
6
|
+
const NetworkType = require('../../../stack/network/network-type');
|
|
7
|
+
const ActorPhaseConst = require('z-abs-funclayer-engine-cs/clientServer/execution/actor-phase-const');
|
|
8
|
+
const ActorTypeConst = require('z-abs-funclayer-engine-cs/clientServer/execution/actor-type-const');
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
const StackMixinClient = {
|
|
12
|
+
createConnection(stackName, connectionInstanceData, options) {
|
|
13
|
+
const optionsConnection = {
|
|
14
|
+
connectionOptions: null,
|
|
15
|
+
transportLayer: {
|
|
16
|
+
transportType: null,
|
|
17
|
+
transportProperties: null
|
|
18
|
+
},
|
|
19
|
+
messageSelector: null,
|
|
20
|
+
connectionWorker: null,
|
|
21
|
+
stackContentCache: this.executionContext.stackContentCache
|
|
22
|
+
};
|
|
23
|
+
let dstIndex = 0;
|
|
24
|
+
let srcIndex = 0;
|
|
25
|
+
let reuse = false;
|
|
26
|
+
this.getTransportLayerData(optionsConnection, options);
|
|
27
|
+
if(undefined !== options) {
|
|
28
|
+
if(undefined != options.dstIndex) {
|
|
29
|
+
dstIndex = options.dstIndex;
|
|
30
|
+
}
|
|
31
|
+
if(undefined !== options.srcIndex) {
|
|
32
|
+
srcIndex = options.srcIndex;
|
|
33
|
+
}
|
|
34
|
+
if(undefined !== options.reuse) {
|
|
35
|
+
reuse = options.reuse;
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
reuse = this.getTestDataBoolean(`${stackName}-reuse`, reuse);
|
|
39
|
+
}
|
|
40
|
+
if(undefined !== options.messageSelector) {
|
|
41
|
+
if('function' === typeof options.messageSelector) {
|
|
42
|
+
optionsConnection.messageSelector = new MessageSelector();
|
|
43
|
+
optionsConnection.messageSelector.onSelect = options.messageSelector;
|
|
44
|
+
}
|
|
45
|
+
else if('object' === typeof options.messageSelector) {
|
|
46
|
+
optionsConnection.messageSelector = options.messageSelector;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
if(undefined !== options.connectionWorker) {
|
|
50
|
+
optionsConnection.connectionWorker = options.connectionWorker;
|
|
51
|
+
}
|
|
52
|
+
if(undefined !== options.connectionOptions) {
|
|
53
|
+
optionsConnection.connectionOptions = options.connectionOptions;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
reuse = this.getTestDataBoolean(`${stackName}-reuse`, reuse);
|
|
58
|
+
}
|
|
59
|
+
const srcAddress = this.getSrcAddress(srcIndex, optionsConnection);
|
|
60
|
+
const srcDstAddress = this.getSrcDstAddress(dstIndex, optionsConnection);
|
|
61
|
+
this.executionContext.clientManager.getConnection(stackName, connectionInstanceData, this, reuse, srcAddress, srcDstAddress, optionsConnection);
|
|
62
|
+
},
|
|
63
|
+
switchProtocol(stackName, currentConnection, upgradedConnection) {
|
|
64
|
+
return this.executionContext.clientManager.switchProtocol(stackName, currentConnection, upgradedConnection, this);
|
|
65
|
+
},
|
|
66
|
+
resolveSrcAddress(srcIndex) {
|
|
67
|
+
const addressData = this.src[srcIndex];
|
|
68
|
+
if(Address.IS_GENERATED === addressData.type) {
|
|
69
|
+
return this._getStackAddress((addressName) => {
|
|
70
|
+
const srcAddress = this.executionContext.addresses.getSrc(addressName);
|
|
71
|
+
if(srcAddress) {
|
|
72
|
+
return srcAddress;
|
|
73
|
+
}
|
|
74
|
+
else if('DEFAULT_SRC' === addressName) {
|
|
75
|
+
return new Address(addressName, null, null, null, 'client', 'default-page', null);
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
return null;
|
|
79
|
+
}
|
|
80
|
+
}, addressData.value);
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
return addressData.value;
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
setSrcAddress(srcIndex, address) {
|
|
87
|
+
this.srcResolved[srcIndex] = address;
|
|
88
|
+
},
|
|
89
|
+
setSrcAddressPost(srcIndex, address) {
|
|
90
|
+
this.srcResolvedPost[srcIndex] = address;
|
|
91
|
+
},
|
|
92
|
+
getSrcAddress(srcIndex=0, options=null) {
|
|
93
|
+
if(srcIndex < this.src.length) {
|
|
94
|
+
if(ActorTypeConst.COND === this.typeId && ActorPhaseConst.POST === this.currentPhaseId) {
|
|
95
|
+
return this.srcResolvedPost[srcIndex];
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
return this.srcResolved[srcIndex];
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
else if(srcIndex >= this.src.length) {
|
|
102
|
+
const transportType = options ? options.transportLayer.transportType : NetworkType.TCP;
|
|
103
|
+
const srcAddress = this.executionContext.addressManager.getDefaultSrc(this.uniqueTcId, transportType, this.executionContext.clientManager.actors.get(this));
|
|
104
|
+
this.logWarning(() => `There is no client src address name. Default client src address will be used. ${srcAddress.host}:${srcAddress.port} - name: ${srcAddress.addressName}`, 'core', '26e8e0eb-aee4-49ec-a099-cc80f02631de', 1);
|
|
105
|
+
return srcAddress;
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
resolveSrcDstAddress(dstIndex) {
|
|
109
|
+
const addressData = this.srcDst[dstIndex];
|
|
110
|
+
if(Address.IS_GENERATED === addressData.type) {
|
|
111
|
+
return this._getStackAddress((addressName) => {
|
|
112
|
+
if(!Array.isArray(addressName)) {
|
|
113
|
+
return this.executionContext.addresses.getDst(addressName);
|
|
114
|
+
}
|
|
115
|
+
else {
|
|
116
|
+
const addresses = [];
|
|
117
|
+
for(let i = 0; i < addressName.length; ++i) {
|
|
118
|
+
const address = this.executionContext.addresses.getDst(addressName[i]);
|
|
119
|
+
if(undefined === address) {
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
addresses.push(address);
|
|
123
|
+
}
|
|
124
|
+
return addresses;
|
|
125
|
+
}
|
|
126
|
+
}, addressData.value);
|
|
127
|
+
}
|
|
128
|
+
else {
|
|
129
|
+
return addressData.value;
|
|
130
|
+
}
|
|
131
|
+
},
|
|
132
|
+
setSrcDstAddress(dstIndex, address) {
|
|
133
|
+
this.srcDstResolved[dstIndex] = address;
|
|
134
|
+
},
|
|
135
|
+
setSrcDstAddressPost(dstIndex, address) {
|
|
136
|
+
this.srcDstResolvedPost[dstIndex] = address;
|
|
137
|
+
},
|
|
138
|
+
getSrcDstAddress(dstIndex=0, options=null) {
|
|
139
|
+
if(dstIndex < this.srcDst.length) {
|
|
140
|
+
if(ActorTypeConst.COND === this.typeId && ActorPhaseConst.POST === this.currentPhaseId) {
|
|
141
|
+
return this.srcDstResolvedPost[dstIndex];
|
|
142
|
+
}
|
|
143
|
+
else {
|
|
144
|
+
return this.srcDstResolved[dstIndex];
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
else if(dstIndex >= this.srcDst.length) {
|
|
148
|
+
const transportType = options ? options.transportLayer.transportType : NetworkType.TCP;
|
|
149
|
+
const dstAddress = this.executionContext.addressManager.getDefaultDst(this.uniqueTcId, transportType, this.executionContext.clientManager.actors.get(this));
|
|
150
|
+
this.logWarning(() => `There is no client dst address name. Default client dst address will be used. ${dstAddress.host}:${dstAddress.port} - name: ${dstAddress.addressName}`, 'core', 'e72cf3a4-465f-4acc-a845-09e8d2690451', 1);
|
|
151
|
+
return dstAddress;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
module.exports = StackMixinClient;
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
const Address = require('../../../address/address');
|
|
5
|
+
const MessageSelector = require('../../../stack/stacks/message-selector');
|
|
6
|
+
const NetworkType = require('../../../stack/network/network-type');
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
const StackMixinServer = {
|
|
10
|
+
createServer(stackName, connectionInstanceData, options) {
|
|
11
|
+
const optionsConnection = {
|
|
12
|
+
connectionOptions: null,
|
|
13
|
+
transportLayer: {
|
|
14
|
+
transportType: null,
|
|
15
|
+
transportProperties: null
|
|
16
|
+
},
|
|
17
|
+
messageSelector: null,
|
|
18
|
+
connectionWorker: null,
|
|
19
|
+
stackContentCache: this.executionContext.stackContentCache
|
|
20
|
+
};
|
|
21
|
+
let srvIndex = 0;
|
|
22
|
+
let dstIndex = 0;
|
|
23
|
+
let srvOptionsAddress = undefined;
|
|
24
|
+
let dstOptionsAddress = undefined;
|
|
25
|
+
this.getTransportLayerData(optionsConnection, options);
|
|
26
|
+
if(undefined !== options) {
|
|
27
|
+
if(undefined !== options.srvIndex) {
|
|
28
|
+
srvIndex = options.srvIndex;
|
|
29
|
+
}
|
|
30
|
+
if(undefined !== options.dstIndex) {
|
|
31
|
+
dstIndex = options.dstIndex;
|
|
32
|
+
}
|
|
33
|
+
if(undefined !== options.messageSelector) {
|
|
34
|
+
if('function' === typeof options.messageSelector) {
|
|
35
|
+
optionsConnection.messageSelector = new MessageSelector();
|
|
36
|
+
optionsConnection.messageSelector.onSelect = options.messageSelector;
|
|
37
|
+
}
|
|
38
|
+
else if('object' === typeof options.messageSelector) {
|
|
39
|
+
if(!options.messageSelector.interceptor || (options.messageSelector.interceptor && 'inter' === this.type)) {
|
|
40
|
+
optionsConnection.messageSelector = options.messageSelector;
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
throw new Error('MessageSelector with interceptor == true can only be used by ActorInterception.');
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
if(undefined !== options.connectionOptions) {
|
|
48
|
+
optionsConnection.connectionOptions = options.connectionOptions;
|
|
49
|
+
}
|
|
50
|
+
if(undefined !== options.port && undefined !== options.host && undefined !== options.family) {
|
|
51
|
+
srvOptionsAddress = new Address('anonymous-(options)', options.host, options.family, options.port, 'server');
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
const srvAddress = undefined === srvOptionsAddress ? this.getSrvAddress(srvIndex, optionsConnection) : srvOptionsAddress;
|
|
55
|
+
const srvDstAddress = this.getSrvDstAddress(dstIndex, optionsConnection);
|
|
56
|
+
this.executionContext.serverManager.getServer(stackName, connectionInstanceData, this, srvAddress, srvDstAddress, optionsConnection);
|
|
57
|
+
},
|
|
58
|
+
switchProtocol(stackName, currentConnection, upgradedConnection) {
|
|
59
|
+
return this.executionContext.serverManager.switchProtocol(stackName, currentConnection, upgradedConnection, this);
|
|
60
|
+
},
|
|
61
|
+
resolveSrvAddress(srvIndex) {
|
|
62
|
+
if(srvIndex < this.srv.length) {
|
|
63
|
+
const addressData = this.srv[srvIndex];
|
|
64
|
+
if(Address.IS_GENERATED === addressData.type) {
|
|
65
|
+
return this._getStackAddress((addressName) => {
|
|
66
|
+
return this.executionContext.addresses.getSrv(addressName);
|
|
67
|
+
}, addressData.value);
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
return addressData.value;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
setSrvAddress(srvIndex, address) {
|
|
75
|
+
this.srvResolved[srvIndex] = address;
|
|
76
|
+
},
|
|
77
|
+
getSrvAddress(srvIndex=0, options=null) {
|
|
78
|
+
if(srvIndex < this.srv.length) {
|
|
79
|
+
return this.srvResolved[srvIndex];
|
|
80
|
+
}
|
|
81
|
+
else if(srvIndex >= this.srv.length) {
|
|
82
|
+
const transportType = options ? options.transportLayer.transportType : NetworkType.TCP;
|
|
83
|
+
const srvAddress = this.executionContext.addressManager.getDefaultSrv(this.uniqueTcId, transportType, this.executionContext.serverManager.actors.get(this));
|
|
84
|
+
this.logWarning(() => `There is no server srv address name. Default server srv address will be used. ${srvAddress.host}:${srvAddress.port} - name: ${srvAddress.addressName}`, 'core', 'cfbf1f3e-9ae5-48a1-bbf3-203500e5fadd', 1);
|
|
85
|
+
return srvAddress;
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
resolveSrvDstAddress(dstIndex) {
|
|
89
|
+
if(dstIndex < this.srvDst.length) {
|
|
90
|
+
const addressData = this.srvDst[dstIndex];
|
|
91
|
+
if(Address.IS_GENERATED === addressData.type) {
|
|
92
|
+
return this._getStackAddress((addressName) => {
|
|
93
|
+
return this.executionContext.addresses.getDst(addressName);
|
|
94
|
+
}, addressData.value);
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
return addressData.value;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
setSrvDstAddress(dstIndex, address) {
|
|
102
|
+
this.srvDstResolved[dstIndex] = address;
|
|
103
|
+
},
|
|
104
|
+
getSrvDstAddress(dstIndex=0, options=null) {
|
|
105
|
+
if(dstIndex < this.srvDst.length) {
|
|
106
|
+
return this.srvDstResolved[dstIndex];
|
|
107
|
+
}
|
|
108
|
+
else if(dstIndex >= this.srvDst.length) {
|
|
109
|
+
const transportType = options ? options.transportLayer.transportType : NetworkType.MC;
|
|
110
|
+
if(NetworkType.MC === transportType) {
|
|
111
|
+
const dstAddress = this.executionContext.addressManager.getDefaultDst(this.uniqueTcId, NetworkType.MC, this.executionContext.serverManager.actors.get(this));
|
|
112
|
+
this.logWarning(() => `There is no server dst address name. Default server dst address will be used. ${dstAddress.host}:${dstAddress.port} - name: ${dstAddress.addressName}`, 'core', 'f607cdd9-4182-4d32-9347-e29222685b63', 1);
|
|
113
|
+
return dstAddress;
|
|
114
|
+
}
|
|
115
|
+
else {
|
|
116
|
+
return null;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
module.exports = StackMixinServer;
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
const ConnectionInstance = require('../../../stack/stacks/connection-instance');
|
|
5
|
+
const NetworkType = require('../../../stack/network/network-type');
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
const StackMixin = {
|
|
9
|
+
initStackMixin() {
|
|
10
|
+
this._connectedConnections = new Set();
|
|
11
|
+
this._closePendingConnections = new Set();
|
|
12
|
+
this._closePendingsCb = null;
|
|
13
|
+
this.addressLocks = new Set();
|
|
14
|
+
},
|
|
15
|
+
lockAddress(address, cb) {
|
|
16
|
+
//console.log('LOCK;', `${address.addressName} - ${address.host}:${address.port}`, this.logName);
|
|
17
|
+
this.executionContext.addressManager.lock(this.uniqueTcId, address, () => {
|
|
18
|
+
this.addressLocks.add(address);
|
|
19
|
+
cb();
|
|
20
|
+
});
|
|
21
|
+
},
|
|
22
|
+
unlockAddress(address) {
|
|
23
|
+
if(address) {
|
|
24
|
+
//console.log('UNLOCK;', `${address.addressName} - ${address.host}:${address.port}`, this.logName);
|
|
25
|
+
if(this.addressLocks.has(address)) {
|
|
26
|
+
this.addressLocks.delete(address);
|
|
27
|
+
this.executionContext.addressManager.unlock(this.uniqueTcId, address);
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
this.executionContext.addressManager.releaseDefaultAddressUnicast(this.uniqueTcId, address)
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
_unlockAddresses(showWarning) {
|
|
35
|
+
if(0 !== this.addressLocks.size) {
|
|
36
|
+
if(showWarning) {
|
|
37
|
+
this.logWarning(`Actor ${this.logName} has address locks.`, 'core', 'e13d2b3c-2340-4ffa-a4c7-268f2b7a79ac');
|
|
38
|
+
}
|
|
39
|
+
this.addressLocks.forEach((addressData, address) => {
|
|
40
|
+
//console.log('*** UNLOCK;', `${address.host}:${address.port}`, this.logName);
|
|
41
|
+
this.executionContext.addressManager.unlock(this.uniqueTcId, address);
|
|
42
|
+
});
|
|
43
|
+
this.addressLocks.clear();
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
addConnectedConnection(connection) {
|
|
47
|
+
this._connectedConnections.add(connection);
|
|
48
|
+
},
|
|
49
|
+
removeConnectedConnection(connection) {
|
|
50
|
+
this._connectedConnections.delete(connection);
|
|
51
|
+
},
|
|
52
|
+
hasConnectedConnection() {
|
|
53
|
+
return 0 !== this._connectedConnections.size;
|
|
54
|
+
},
|
|
55
|
+
addClosePendingConnection(connection) {
|
|
56
|
+
this._closePendingConnections.add(connection);
|
|
57
|
+
},
|
|
58
|
+
removeClosePendingConnection(connection) {
|
|
59
|
+
if(this._closePendingConnections.delete(connection)) {
|
|
60
|
+
if(this._closePendingsCb) {
|
|
61
|
+
if(0 === this._closePendingConnections.size) {
|
|
62
|
+
const cb = this._closePendingsCb;
|
|
63
|
+
this._closePendingsCb = null;
|
|
64
|
+
this.process.nextTick(cb);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
_awaitClosePendingConnections(cb) {
|
|
70
|
+
if(0 === this._closePendingConnections.size) {
|
|
71
|
+
this.process.nextTick(cb);
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
this._closePendingsCb = cb;
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
awakeYield() {
|
|
78
|
+
const pendingId = this.setPending(null);
|
|
79
|
+
this.pendingSuccess(pendingId, null);
|
|
80
|
+
},
|
|
81
|
+
create() {
|
|
82
|
+
return new ConnectionInstance(this.awakeYield.bind(this));
|
|
83
|
+
},
|
|
84
|
+
*closeConnection(connection) {
|
|
85
|
+
yield connection.close(false);
|
|
86
|
+
},
|
|
87
|
+
_getStackAddress(cbGetAddresses, addressName) {
|
|
88
|
+
const srvAddress = cbGetAddresses(addressName);
|
|
89
|
+
if(!srvAddress) {
|
|
90
|
+
if('' === addressName) {
|
|
91
|
+
throw new Error(`There are no default address name.`);
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
throw new Error(`There are no address with address name '${addressName}'. Have you forgot to stage or define the address?`);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
return srvAddress;
|
|
98
|
+
},
|
|
99
|
+
getTransportLayerData(optionsConnection, options) {
|
|
100
|
+
const transportLayer = optionsConnection.transportLayer;
|
|
101
|
+
if(options) {
|
|
102
|
+
if(options.networkType) {
|
|
103
|
+
transportLayer.transportType = options.networkType;
|
|
104
|
+
}
|
|
105
|
+
if(options.transportProperties) {
|
|
106
|
+
transportLayer.transportProperties = new Map(options.transportProperties);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
if(!transportLayer.transportType) {
|
|
110
|
+
transportLayer.transportType = this.getTestDataNumber('transport-type', 'default', {
|
|
111
|
+
default: NetworkType.DEFAULT,
|
|
112
|
+
tcp: NetworkType.TCP,
|
|
113
|
+
udp: NetworkType.UDP,
|
|
114
|
+
mc: NetworkType.MC,
|
|
115
|
+
tls: NetworkType.TLS
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
if(!transportLayer.transportProperties) {
|
|
119
|
+
const transportProperties = this.getTestDataArrayStrings('transport-properties', []);
|
|
120
|
+
if(0 < transportProperties.length) {
|
|
121
|
+
transportLayer.transportProperties = new Map(transportProperties);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
module.exports = StackMixin;
|