ee-core 2.9.2 → 2.10.0
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/LICENSE +21 -21
- package/README.md +65 -65
- package/addon/index.js +34 -34
- package/addon/window/index.js +98 -98
- package/bin/tools.js +8 -8
- package/config/cache.js +41 -38
- package/config/config.default.js +331 -330
- package/config/index.js +75 -73
- package/const/channel.js +17 -17
- package/const/index.js +8 -8
- package/controller/baseContextClass.js +34 -34
- package/controller/index.js +34 -34
- package/core/index.js +10 -10
- package/core/lib/ee.js +216 -216
- package/core/lib/loader/context_loader.js +106 -106
- package/core/lib/loader/ee_loader.js +435 -435
- package/core/lib/loader/file_loader.js +326 -326
- package/core/lib/loader/mixin/addon.js +32 -32
- package/core/lib/loader/mixin/config.js +130 -130
- package/core/lib/loader/mixin/controller.js +125 -125
- package/core/lib/loader/mixin/service.js +28 -28
- package/core/lib/utils/base_context_class.js +34 -34
- package/core/lib/utils/function.js +30 -30
- package/core/lib/utils/index.js +133 -133
- package/core/lib/utils/sequencify.js +59 -59
- package/core/lib/utils/timing.js +77 -77
- package/cross/index.js +183 -183
- package/cross/spawnProcess.js +183 -183
- package/ee/appLoader.js +48 -48
- package/ee/application.js +99 -99
- package/ee/baseApp.js +103 -102
- package/ee/eeApp.js +408 -408
- package/ee/index.js +57 -57
- package/electron/app/index.js +64 -58
- package/electron/index.js +19 -19
- package/electron/window/index.js +73 -73
- package/electron/window/winState.js +186 -186
- package/exception/index.js +112 -112
- package/html/boot.html +98 -98
- package/html/cross-failure.html +28 -28
- package/html/failure.html +28 -28
- package/html/index.js +13 -13
- package/httpclient/index.js +161 -161
- package/index.js +54 -54
- package/jobs/baseJobClass.js +16 -16
- package/jobs/child/app.js +65 -65
- package/jobs/child/forkProcess.js +145 -145
- package/jobs/child/index.js +82 -82
- package/jobs/child-pool/index.js +213 -213
- package/jobs/index.js +8 -8
- package/jobs/load-balancer/algorithm/index.js +11 -11
- package/jobs/load-balancer/algorithm/minimumConnection.js +18 -18
- package/jobs/load-balancer/algorithm/polling.js +11 -11
- package/jobs/load-balancer/algorithm/random.js +9 -9
- package/jobs/load-balancer/algorithm/specify.js +14 -14
- package/jobs/load-balancer/algorithm/weights.js +21 -21
- package/jobs/load-balancer/algorithm/weightsMinimumConnection.js +29 -29
- package/jobs/load-balancer/algorithm/weightsPolling.js +22 -22
- package/jobs/load-balancer/algorithm/weightsRandom.js +16 -16
- package/jobs/load-balancer/consts.js +9 -9
- package/jobs/load-balancer/index.js +201 -201
- package/jobs/load-balancer/scheduler.js +31 -31
- package/jobs/renderer/index.js +141 -141
- package/jobs/renderer/loadView.js +40 -40
- package/jobs/unification.js +63 -63
- package/loader/index.js +172 -172
- package/log/index.js +68 -68
- package/log/logger.js +86 -80
- package/main/index.js +56 -56
- package/message/childMessage.js +54 -54
- package/message/index.js +18 -18
- package/old-utils/index.js +91 -91
- package/package.json +38 -38
- package/ps/index.js +371 -371
- package/services/baseContextClass.js +34 -34
- package/services/index.js +40 -40
- package/socket/httpServer.js +147 -147
- package/socket/index.js +81 -81
- package/socket/io.js +27 -27
- package/socket/ipcServer.js +112 -112
- package/socket/socketServer.js +69 -67
- package/storage/index.js +38 -38
- package/storage/jsondb/adapters/Base.js +23 -23
- package/storage/jsondb/adapters/FileSync.js +64 -52
- package/storage/jsondb/main.js +55 -42
- package/storage/jsondbStorage.js +195 -195
- package/storage/sqliteStorage.js +123 -123
- package/utils/co.js +237 -237
- package/utils/copyto.js +160 -160
- package/utils/depd/index.js +538 -538
- package/utils/depd/lib/browser/index.js +77 -77
- package/utils/extend.js +73 -73
- package/utils/get-port/index.d.ts +64 -64
- package/utils/get-port/index.js +148 -148
- package/utils/helper.js +220 -220
- package/utils/index.js +160 -160
- package/utils/ip.js +261 -261
- package/utils/is.js +145 -145
- package/utils/json.js +72 -72
- package/utils/pargv.js +263 -263
- package/utils/time/index.js +19 -19
- package/utils/time/ms.js +162 -162
- package/utils/wrap.js +35 -35
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 轮询
|
|
3
|
-
*/
|
|
4
|
-
module.exports = function (tasks, currentIndex, context) {
|
|
5
|
-
if (!tasks.length) return null;
|
|
6
|
-
|
|
7
|
-
const task = tasks[currentIndex];
|
|
8
|
-
context.currentIndex ++;
|
|
9
|
-
context.currentIndex %= tasks.length;
|
|
10
|
-
|
|
11
|
-
return task || null;
|
|
1
|
+
/**
|
|
2
|
+
* 轮询
|
|
3
|
+
*/
|
|
4
|
+
module.exports = function (tasks, currentIndex, context) {
|
|
5
|
+
if (!tasks.length) return null;
|
|
6
|
+
|
|
7
|
+
const task = tasks[currentIndex];
|
|
8
|
+
context.currentIndex ++;
|
|
9
|
+
context.currentIndex %= tasks.length;
|
|
10
|
+
|
|
11
|
+
return task || null;
|
|
12
12
|
};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 随机
|
|
3
|
-
*/
|
|
4
|
-
module.exports = function (tasks) {
|
|
5
|
-
|
|
6
|
-
const length = tasks.length;
|
|
7
|
-
const target = tasks[Math.floor(Math.random() * length)];
|
|
8
|
-
|
|
9
|
-
return target || null;
|
|
1
|
+
/**
|
|
2
|
+
* 随机
|
|
3
|
+
*/
|
|
4
|
+
module.exports = function (tasks) {
|
|
5
|
+
|
|
6
|
+
const length = tasks.length;
|
|
7
|
+
const target = tasks[Math.floor(Math.random() * length)];
|
|
8
|
+
|
|
9
|
+
return target || null;
|
|
10
10
|
};
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 声明绑定
|
|
3
|
-
*/
|
|
4
|
-
module.exports = function (tasks, id) {
|
|
5
|
-
let task;
|
|
6
|
-
|
|
7
|
-
for (let i = 0; i < tasks.length; i++) {
|
|
8
|
-
if (tasks[i].id === id) {
|
|
9
|
-
task = tasks[i];
|
|
10
|
-
break;
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
return task || null;
|
|
1
|
+
/**
|
|
2
|
+
* 声明绑定
|
|
3
|
+
*/
|
|
4
|
+
module.exports = function (tasks, id) {
|
|
5
|
+
let task;
|
|
6
|
+
|
|
7
|
+
for (let i = 0; i < tasks.length; i++) {
|
|
8
|
+
if (tasks[i].id === id) {
|
|
9
|
+
task = tasks[i];
|
|
10
|
+
break;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
return task || null;
|
|
15
15
|
};
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 权重
|
|
3
|
-
*/
|
|
4
|
-
module.exports = function (tasks, weightTotal, context) {
|
|
5
|
-
|
|
6
|
-
if (!tasks.length) return null;
|
|
7
|
-
|
|
8
|
-
let max = tasks[0].weight, maxIndex = 0, sum;
|
|
9
|
-
|
|
10
|
-
for (let i = 0; i < tasks.length; i++) {
|
|
11
|
-
sum = (tasks[i].weight || 0) + Math.random() * weightTotal;
|
|
12
|
-
if (sum >= max) {
|
|
13
|
-
max = sum;
|
|
14
|
-
maxIndex = i;
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
context.weightIndex += 1;
|
|
19
|
-
context.weightIndex %= (weightTotal + 1);
|
|
20
|
-
|
|
21
|
-
return tasks[maxIndex];
|
|
1
|
+
/**
|
|
2
|
+
* 权重
|
|
3
|
+
*/
|
|
4
|
+
module.exports = function (tasks, weightTotal, context) {
|
|
5
|
+
|
|
6
|
+
if (!tasks.length) return null;
|
|
7
|
+
|
|
8
|
+
let max = tasks[0].weight, maxIndex = 0, sum;
|
|
9
|
+
|
|
10
|
+
for (let i = 0; i < tasks.length; i++) {
|
|
11
|
+
sum = (tasks[i].weight || 0) + Math.random() * weightTotal;
|
|
12
|
+
if (sum >= max) {
|
|
13
|
+
max = sum;
|
|
14
|
+
maxIndex = i;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
context.weightIndex += 1;
|
|
19
|
+
context.weightIndex %= (weightTotal + 1);
|
|
20
|
+
|
|
21
|
+
return tasks[maxIndex];
|
|
22
22
|
};
|
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 权重最小连接数
|
|
3
|
-
*/
|
|
4
|
-
module.exports = function (tasks, weightTotal, connectionsMap, context) {
|
|
5
|
-
|
|
6
|
-
if (!tasks.length) return null;
|
|
7
|
-
|
|
8
|
-
let min = tasks[0].weight, minIndex = 0, sum;
|
|
9
|
-
|
|
10
|
-
const connectionsTotal = tasks.reduce((total, cur) => {
|
|
11
|
-
total += (connectionsMap[cur.id] || 0);
|
|
12
|
-
return total;
|
|
13
|
-
}, 0);
|
|
14
|
-
|
|
15
|
-
// algorithm: (weight + connections'weight) + random factor
|
|
16
|
-
for (let i = 0; i < tasks.length; i++) {
|
|
17
|
-
sum =
|
|
18
|
-
(tasks[i].weight || 0) + (Math.random() * weightTotal) +
|
|
19
|
-
(( (connectionsMap[tasks[i].id] || 0) * weightTotal ) / connectionsTotal);
|
|
20
|
-
if (sum <= min) {
|
|
21
|
-
min = sum;
|
|
22
|
-
minIndex = i;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
context.weightIndex += 1;
|
|
27
|
-
context.weightIndex %= (weightTotal + 1);
|
|
28
|
-
|
|
29
|
-
return tasks[minIndex];
|
|
1
|
+
/**
|
|
2
|
+
* 权重最小连接数
|
|
3
|
+
*/
|
|
4
|
+
module.exports = function (tasks, weightTotal, connectionsMap, context) {
|
|
5
|
+
|
|
6
|
+
if (!tasks.length) return null;
|
|
7
|
+
|
|
8
|
+
let min = tasks[0].weight, minIndex = 0, sum;
|
|
9
|
+
|
|
10
|
+
const connectionsTotal = tasks.reduce((total, cur) => {
|
|
11
|
+
total += (connectionsMap[cur.id] || 0);
|
|
12
|
+
return total;
|
|
13
|
+
}, 0);
|
|
14
|
+
|
|
15
|
+
// algorithm: (weight + connections'weight) + random factor
|
|
16
|
+
for (let i = 0; i < tasks.length; i++) {
|
|
17
|
+
sum =
|
|
18
|
+
(tasks[i].weight || 0) + (Math.random() * weightTotal) +
|
|
19
|
+
(( (connectionsMap[tasks[i].id] || 0) * weightTotal ) / connectionsTotal);
|
|
20
|
+
if (sum <= min) {
|
|
21
|
+
min = sum;
|
|
22
|
+
minIndex = i;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
context.weightIndex += 1;
|
|
27
|
+
context.weightIndex %= (weightTotal + 1);
|
|
28
|
+
|
|
29
|
+
return tasks[minIndex];
|
|
30
30
|
};
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 权重轮询
|
|
3
|
-
*/
|
|
4
|
-
module.exports = function (tasks, weightIndex, weightTotal, context) {
|
|
5
|
-
|
|
6
|
-
if (!tasks.length) return null;
|
|
7
|
-
|
|
8
|
-
let weight = 0;
|
|
9
|
-
let task;
|
|
10
|
-
|
|
11
|
-
for (let i = 0; i < tasks.length; i++) {
|
|
12
|
-
weight += tasks[i].weight || 0;
|
|
13
|
-
if (weight > weightIndex) {
|
|
14
|
-
task = tasks[i];
|
|
15
|
-
break;
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
context.weightIndex += 1;
|
|
20
|
-
context.weightIndex %= (weightTotal + 1);
|
|
21
|
-
|
|
22
|
-
return task;
|
|
1
|
+
/**
|
|
2
|
+
* 权重轮询
|
|
3
|
+
*/
|
|
4
|
+
module.exports = function (tasks, weightIndex, weightTotal, context) {
|
|
5
|
+
|
|
6
|
+
if (!tasks.length) return null;
|
|
7
|
+
|
|
8
|
+
let weight = 0;
|
|
9
|
+
let task;
|
|
10
|
+
|
|
11
|
+
for (let i = 0; i < tasks.length; i++) {
|
|
12
|
+
weight += tasks[i].weight || 0;
|
|
13
|
+
if (weight > weightIndex) {
|
|
14
|
+
task = tasks[i];
|
|
15
|
+
break;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
context.weightIndex += 1;
|
|
20
|
+
context.weightIndex %= (weightTotal + 1);
|
|
21
|
+
|
|
22
|
+
return task;
|
|
23
23
|
};
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 权重随机
|
|
3
|
-
*/
|
|
4
|
-
module.exports = function (tasks, weightTotal) {
|
|
5
|
-
let task;
|
|
6
|
-
let weight = Math.ceil(Math.random() * weightTotal);
|
|
7
|
-
|
|
8
|
-
for (let i = 0; i < tasks.length; i++) {
|
|
9
|
-
weight -= tasks[i].weight || 0;
|
|
10
|
-
if (weight <= 0) {
|
|
11
|
-
task = tasks[i];
|
|
12
|
-
break;
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
return task || null;
|
|
1
|
+
/**
|
|
2
|
+
* 权重随机
|
|
3
|
+
*/
|
|
4
|
+
module.exports = function (tasks, weightTotal) {
|
|
5
|
+
let task;
|
|
6
|
+
let weight = Math.ceil(Math.random() * weightTotal);
|
|
7
|
+
|
|
8
|
+
for (let i = 0; i < tasks.length; i++) {
|
|
9
|
+
weight -= tasks[i].weight || 0;
|
|
10
|
+
if (weight <= 0) {
|
|
11
|
+
task = tasks[i];
|
|
12
|
+
break;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
return task || null;
|
|
17
17
|
};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
polling: 'polling', // 轮询
|
|
3
|
-
weights: 'weights', // 权重
|
|
4
|
-
random: 'random', // 随机
|
|
5
|
-
specify: 'specify', // 声明绑定
|
|
6
|
-
weightsPolling: 'weightsPolling', // 权重轮询
|
|
7
|
-
weightsRandom: 'weightsRandom', // 权重随机
|
|
8
|
-
minimumConnection: 'minimumConnection', // 最小连接数
|
|
9
|
-
weightsMinimumConnection: 'weightsMinimumConnection', // 权重最小连接数
|
|
1
|
+
module.exports = {
|
|
2
|
+
polling: 'polling', // 轮询
|
|
3
|
+
weights: 'weights', // 权重
|
|
4
|
+
random: 'random', // 随机
|
|
5
|
+
specify: 'specify', // 声明绑定
|
|
6
|
+
weightsPolling: 'weightsPolling', // 权重轮询
|
|
7
|
+
weightsRandom: 'weightsRandom', // 权重随机
|
|
8
|
+
minimumConnection: 'minimumConnection', // 最小连接数
|
|
9
|
+
weightsMinimumConnection: 'weightsMinimumConnection', // 权重最小连接数
|
|
10
10
|
};
|