redux-cluster 1.10.0 → 2.0.1

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.
Files changed (57) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +345 -471
  3. package/dist/cjs/core/backup.d.ts +10 -0
  4. package/dist/cjs/core/backup.d.ts.map +1 -0
  5. package/dist/cjs/core/backup.js +166 -0
  6. package/dist/cjs/core/redux-cluster.d.ts +47 -0
  7. package/dist/cjs/core/redux-cluster.d.ts.map +1 -0
  8. package/dist/cjs/core/redux-cluster.js +370 -0
  9. package/dist/cjs/index.d.ts +22 -0
  10. package/dist/cjs/index.d.ts.map +1 -0
  11. package/dist/cjs/index.js +43 -0
  12. package/dist/cjs/network/client.d.ts +23 -0
  13. package/dist/cjs/network/client.d.ts.map +1 -0
  14. package/dist/cjs/network/client.js +251 -0
  15. package/dist/cjs/network/server.d.ts +39 -0
  16. package/dist/cjs/network/server.d.ts.map +1 -0
  17. package/dist/cjs/network/server.js +440 -0
  18. package/dist/cjs/package.json +1 -0
  19. package/dist/cjs/types/index.d.ts +125 -0
  20. package/dist/cjs/types/index.d.ts.map +1 -0
  21. package/dist/cjs/types/index.js +20 -0
  22. package/dist/cjs/utils/crypto.d.ts +22 -0
  23. package/dist/cjs/utils/crypto.d.ts.map +1 -0
  24. package/dist/cjs/utils/crypto.js +404 -0
  25. package/dist/esm/core/backup.d.ts +10 -0
  26. package/dist/esm/core/backup.d.ts.map +1 -0
  27. package/dist/esm/core/backup.js +129 -0
  28. package/dist/esm/core/redux-cluster.d.ts +47 -0
  29. package/dist/esm/core/redux-cluster.d.ts.map +1 -0
  30. package/dist/esm/core/redux-cluster.js +363 -0
  31. package/dist/esm/index.d.ts +22 -0
  32. package/dist/esm/index.d.ts.map +1 -0
  33. package/dist/esm/index.js +25 -0
  34. package/dist/esm/network/client.d.ts +23 -0
  35. package/dist/esm/network/client.d.ts.map +1 -0
  36. package/dist/esm/network/client.js +214 -0
  37. package/dist/esm/network/server.d.ts +39 -0
  38. package/dist/esm/network/server.d.ts.map +1 -0
  39. package/dist/esm/network/server.js +403 -0
  40. package/dist/esm/package.json +1 -0
  41. package/dist/esm/types/index.d.ts +125 -0
  42. package/dist/esm/types/index.d.ts.map +1 -0
  43. package/dist/esm/types/index.js +17 -0
  44. package/dist/esm/utils/crypto.d.ts +22 -0
  45. package/dist/esm/utils/crypto.d.ts.map +1 -0
  46. package/dist/esm/utils/crypto.js +351 -0
  47. package/package.json +115 -34
  48. package/index.js +0 -678
  49. package/test.auto.js +0 -94
  50. package/test.auto.proc1.js +0 -97
  51. package/test.auto.proc2.js +0 -85
  52. package/test.visual.client.highload.js +0 -102
  53. package/test.visual.client.js +0 -103
  54. package/test.visual.error.js +0 -45
  55. package/test.visual.js +0 -97
  56. package/test.visual.server.highload.js +0 -102
  57. package/test.visual.server.js +0 -103
package/test.auto.js DELETED
@@ -1,94 +0,0 @@
1
- /**
2
- * Redux-Cluster Test
3
- * (c) 2018 by Siarhei Dudko.
4
- *
5
- * standart test (cluster IPC channel)
6
- * LICENSE MIT
7
- */
8
-
9
- "use strict"
10
-
11
- var ReduxCluster = require('./index.js'),
12
- Cluster = require('cluster'),
13
- Lodash = require('lodash'),
14
- Colors = require('colors');
15
-
16
- function editProcessStorage(state = {versions:[]}, action){
17
- try {
18
- switch (action.type){
19
- case 'TASK':
20
- var state_new = Lodash.clone(state);
21
- if(state_new.versions.length > 500){
22
- state_new.versions.splice(0,100);
23
- }
24
- state_new.versions.push(action.payload.version);
25
- return state_new;
26
- break;
27
- default:
28
- break;
29
- }
30
- } catch(e){
31
- }
32
- var state_new = Lodash.clone(state);
33
- return state_new;
34
- }
35
-
36
- function editProcessStorage2(state = {versions:[]}, action){
37
- try {
38
- switch (action.type){
39
- case 'UPDATE':
40
- var state_new = Lodash.clone(state);
41
- state_new.versions = action.payload.versions;
42
- return state_new;
43
- break;
44
- default:
45
- break;
46
- }
47
- } catch(e){
48
- }
49
- var state_new = Lodash.clone(state);
50
- return state_new;
51
- }
52
-
53
-
54
- var Test = ReduxCluster.createStore(editProcessStorage);
55
- Test.mode = "action";
56
- var Test2 = ReduxCluster.createStore(editProcessStorage2);
57
-
58
- if(Cluster.isMaster){
59
- setTimeout(function(){Cluster.fork();}, i*20000)
60
-
61
- Test.dispatch({type:'TASK', payload: {version:'MasterTest0'}});
62
- var i = 0;
63
- setInterval(function(){
64
- Test.dispatch({type:'TASK', payload: {version:'MasterTest'+i}});
65
- i++;
66
- }, 55);
67
-
68
- } else {
69
-
70
- Test.dispatch({type:'TASK', payload: {version:'WorkerTest0'}});
71
- var i = 0;
72
- setInterval(function(){
73
- Test.dispatch({type:'TASK', payload: {version:'WorkerTest'+i}});
74
- i++;
75
- }, 99, i);
76
-
77
- Test.subscribe(function(){
78
- Test2.dispatch({type:'UPDATE', payload: {versions:Test.getState().versions}});
79
- });
80
- }
81
-
82
- if(Cluster.isMaster){
83
- var ok = 0;
84
- var bad = 0;
85
- setInterval(function(){
86
- if(Lodash.isEqual(Test.getState().versions, Test2.getState().versions)){
87
- ok++;
88
- console.log(Colors.green("ok-"+ok+'|'+parseInt((ok*100/(ok+bad)), 10)+'%'));
89
- }else {
90
- bad++;
91
- console.log(Colors.red("bad-"+bad+'|'+parseInt((bad*100/(ok+bad)), 10)+'%'));
92
- }
93
- }, 1000);
94
- }
@@ -1,97 +0,0 @@
1
- /**
2
- * Redux-Cluster Test
3
- * (c) 2018 by Siarhei Dudko.
4
- *
5
- * standart test (cluster IPC channel)
6
- * LICENSE MIT
7
- */
8
-
9
- "use strict"
10
-
11
- var ReduxCluster = require('./index.js'),
12
- Cluster = require('cluster'),
13
- Lodash = require('lodash'),
14
- Colors = require('colors');
15
-
16
- function editProcessStorage(state = {versions:[]}, action){
17
- try {
18
- switch (action.type){
19
- case 'TASK':
20
- var state_new = Lodash.clone(state);
21
- if(state_new.versions.length > 500){
22
- state_new.versions.splice(0,100);
23
- }
24
- state_new.versions.push(action.payload.version);
25
- return state_new;
26
- break;
27
- default:
28
- break;
29
- }
30
- } catch(e){
31
- }
32
- var state_new = Lodash.clone(state);
33
- return state_new;
34
- }
35
-
36
- function editProcessStorage2(state = {versions:[]}, action){
37
- try {
38
- switch (action.type){
39
- case 'UPDATE':
40
- var state_new = Lodash.clone(state);
41
- state_new.versions = action.payload.versions;
42
- return state_new;
43
- break;
44
- default:
45
- break;
46
- }
47
- } catch(e){
48
- }
49
- var state_new = Lodash.clone(state);
50
- return state_new;
51
- }
52
-
53
-
54
- var Test = ReduxCluster.createStore(editProcessStorage);
55
- Test.mode = "action";
56
- var Test2 = ReduxCluster.createStore(editProcessStorage2);
57
- Test2.mode = "snapshot";
58
-
59
- if(Cluster.isMaster){
60
- Test.backup({count:1, path:"./test1.backup", key:"test"}).finally(function(){
61
- Test.createServer({host: "0.0.0.0", port: 8888, logins:{test:'123456'}});
62
- Test2.createClient({host: "localhost", port: 8889, login:"test2", password:'123456'});
63
-
64
- setTimeout(function(){Cluster.fork();}, i*20000);
65
-
66
- Test.dispatch({type:'TASK', payload: {version:'MasterTest0'}});
67
- var i = 0;
68
- setInterval(function(){
69
- Test.dispatch({type:'TASK', payload: {version:'MasterTest'+i}});
70
- i++;
71
- }, 500);
72
- });
73
- } else {
74
-
75
- Test.dispatch({type:'TASK', payload: {version:'WorkerTest0'}});
76
- var i = 0;
77
- setInterval(function(){
78
- Test.dispatch({type:'TASK', payload: {version:'WorkerTest'+i}});
79
- i++;
80
- }, 505, i);
81
- }
82
-
83
- if(!Cluster.isMaster){
84
- var ok = 0;
85
- var bad = 0;
86
- setInterval(function(){
87
- if(Lodash.isEqual(Test.getState().versions, Test2.getState().versions)){
88
- ok++;
89
- console.log(Colors.green("ok-"+ok+'|'+parseInt((ok*100/(ok+bad)), 10)+'%'));
90
- }else {
91
- bad++;
92
- console.log(Colors.red("bad-"+bad+'|'+parseInt((bad*100/(ok+bad)), 10)+'%'));
93
- console.log(Test.getState().versions.length+' | '+Test2.getState().versions.length)
94
- console.log(Test.getState().versions[Test.getState().versions.length-1]+' | '+ Test2.getState().versions[Test2.getState().versions.length-1] );
95
- }
96
- }, 500);
97
- }
@@ -1,85 +0,0 @@
1
- /**
2
- * Redux-Cluster Test
3
- * (c) 2018 by Siarhei Dudko.
4
- *
5
- * standart test (cluster IPC channel)
6
- * LICENSE MIT
7
- */
8
-
9
- "use strict"
10
-
11
- var ReduxCluster = require('./index.js'),
12
- Cluster = require('cluster'),
13
- Lodash = require('lodash'),
14
- Colors = require('colors');
15
-
16
- function editProcessStorage(state = {versions:[]}, action){
17
- try {
18
- switch (action.type){
19
- case 'TASK':
20
- var state_new = Lodash.clone(state);
21
- if(state_new.versions.length > 500){
22
- state_new.versions.splice(0,100);
23
- }
24
- state_new.versions.push(action.payload.version);
25
- return state_new;
26
- break;
27
- default:
28
- break;
29
- }
30
- } catch(e){
31
- }
32
- var state_new = Lodash.clone(state);
33
- return state_new;
34
- }
35
-
36
- function editProcessStorage2(state = {versions:[]}, action){
37
- try {
38
- switch (action.type){
39
- case 'UPDATE':
40
- var state_new = Lodash.clone(state);
41
- state_new.versions = action.payload.versions;
42
- return state_new;
43
- break;
44
- default:
45
- break;
46
- }
47
- } catch(e){
48
- }
49
- var state_new = Lodash.clone(state);
50
- return state_new;
51
- }
52
-
53
-
54
- var Test = ReduxCluster.createStore(editProcessStorage);
55
- var Test2 = ReduxCluster.createStore(editProcessStorage2);
56
-
57
- if(Cluster.isMaster){
58
-
59
- Test.createClient({host: "localhost", port: 8888, login:"test", password:'123456'});
60
-
61
- setTimeout(function(){Cluster.fork();}, i*20000);
62
-
63
- Test.dispatch({type:'TASK', payload: {version:'MasterRemote0'}});
64
- var i = 0;
65
- setInterval(function(){
66
- Test.dispatch({type:'TASK', payload: {version:'MasterRemote'+i}});
67
- i++;
68
- }, 550);
69
-
70
- } else {
71
- Test2.backup({count:1, path:"./test2.backup", key:"test"}).finally(function(){
72
- Test2.createServer({host: "0.0.0.0", port: 8889, logins:{test2:'123456'}});
73
-
74
- Test.dispatch({type:'TASK', payload: {version:'WorkerRemote0'}});
75
- var i = 0;
76
- setInterval(function(){
77
- Test.dispatch({type:'TASK', payload: {version:'WorkerRemote'+i}});
78
- i++;
79
- }, 560, i);
80
-
81
- Test.subscribe(function(){
82
- Test2.dispatch({type:'UPDATE', payload: {versions:Test.getState().versions}});
83
- });
84
- });
85
- }
@@ -1,102 +0,0 @@
1
- /**
2
- * Redux-Cluster Test
3
- * (c) 2018 by Siarhei Dudko.
4
- *
5
- * standart test, include test Socket IPC and TCP (remote) client
6
- * LICENSE MIT
7
- */
8
-
9
- "use strict"
10
-
11
- var ReduxCluster = require('./index.js'),
12
- Cluster = require('cluster'),
13
- Lodash = require('lodash');
14
-
15
-
16
- var Test = ReduxCluster.createStore(editProcessStorage);
17
- var Test2 = ReduxCluster.createStore(editProcessStorage2);
18
-
19
- var testTwo = true;
20
-
21
- if(Cluster.isMaster){
22
- Test.createClient({path: "./mysock.sock", login:"test1", password:'12345'});
23
- if(testTwo)
24
- Test2.createClient({host: "127.0.0.1", port: 8888, login:"test2", password:'123456'});
25
- }
26
-
27
- function editProcessStorage(state = {version:''}, action){
28
- try {
29
- switch (action.type){
30
- case 'TASK':
31
- var state_new = Lodash.clone(state);
32
- state_new.version = action.payload.version;
33
- return state_new;
34
- break;
35
- default:
36
- break;
37
- }
38
- } catch(e){
39
- }
40
- var state_new = Lodash.clone(state);
41
- return state_new;
42
- }
43
- function editProcessStorage2(state = {version:''}, action){
44
- try {
45
- switch (action.type){
46
- case 'TASK':
47
- var state_new = Lodash.clone(state);
48
- state_new.version = action.payload.version;
49
- return state_new;
50
- break;
51
- default:
52
- break;
53
- }
54
- } catch(e){
55
- }
56
- var state_new = Lodash.clone(state);
57
- return state_new;
58
- }
59
-
60
- Test.subscribe(function(){
61
- if(Cluster.isMaster){
62
- var name = 'm';
63
- } else {
64
- var name = Cluster.worker.id;
65
- }
66
- console.log(' S1 | ' + name + ' | ' + JSON.stringify(Test.getState()));
67
- });
68
-
69
- if(testTwo)
70
- Test2.subscribe(function(){
71
- if(Cluster.isMaster){
72
- var name = 'm';
73
- } else {
74
- var name = Cluster.worker.id;
75
- }
76
- console.log(' S2 | ' + name + ' | ' + JSON.stringify(Test2.getState()));
77
- });
78
-
79
- if(Cluster.isMaster){
80
- for(var i=0; i < 5; i++){
81
- Cluster.fork();
82
- }
83
- Test.dispatch({type:'TASK', payload: {version:'OneRemoteMasterTest0'}});
84
- if(testTwo){
85
- Test2.dispatch({type:'TASK', payload: {version:'TwoRemoteMasterTest0'}});
86
- }
87
- var i = 0;
88
- setInterval(function(){
89
- Test.dispatch({type:'TASK', payload: {version:'OneRemoteMasterTest'+i}});
90
- if(testTwo)
91
- Test2.dispatch({type:'TASK', payload: {version:'TwoRemoteMasterTest'+i}});
92
- i++;
93
- }, 700);
94
- } else {
95
- var i = 0;
96
- setInterval(function(){
97
- Test.dispatch({type:'TASK', payload: {version:'OneRemoteWorkerTest'+i}});
98
- if(testTwo)
99
- Test2.dispatch({type:'TASK', payload: {version:'TwoRemoteWorkerTest'+i}});
100
- i++;
101
- }, (Cluster.worker.id*500), i);
102
- }
@@ -1,103 +0,0 @@
1
- /**
2
- * Redux-Cluster Test
3
- * (c) 2018 by Siarhei Dudko.
4
- *
5
- * standart test, include test Socket IPC and TCP (remote) client
6
- * LICENSE MIT
7
- */
8
-
9
- "use strict"
10
-
11
- var ReduxCluster = require('./index.js'),
12
- Cluster = require('cluster'),
13
- Lodash = require('lodash');
14
-
15
-
16
- var Test = ReduxCluster.createStore(editProcessStorage);
17
- var Test2 = ReduxCluster.createStore(editProcessStorage2);
18
-
19
- var testTwo = true;
20
-
21
- if(Cluster.isMaster){
22
- Test.createClient({host: "localhost", port: 8888, login:"test2", password:'123456'});
23
- } else {
24
- if(testTwo)
25
- Test2.createClient({path: "./mysock.sock", login:"test1", password:'12345'});
26
- }
27
-
28
- function editProcessStorage(state = {version:''}, action){
29
- try {
30
- switch (action.type){
31
- case 'TASK':
32
- var state_new = Lodash.clone(state);
33
- state_new.version = action.payload.version;
34
- return state_new;
35
- break;
36
- default:
37
- break;
38
- }
39
- } catch(e){
40
- }
41
- var state_new = Lodash.clone(state);
42
- return state_new;
43
- }
44
- function editProcessStorage2(state = {version:''}, action){
45
- try {
46
- switch (action.type){
47
- case 'TASK':
48
- var state_new = Lodash.clone(state);
49
- state_new.version = action.payload.version;
50
- return state_new;
51
- break;
52
- default:
53
- break;
54
- }
55
- } catch(e){
56
- }
57
- var state_new = Lodash.clone(state);
58
- return state_new;
59
- }
60
-
61
- Test.subscribe(function(){
62
- if(Cluster.isMaster){
63
- var name = 'm';
64
- } else {
65
- var name = Cluster.worker.id;
66
- }
67
- console.log(' S1 | ' + name + ' | ' + JSON.stringify(Test.getState()));
68
- });
69
-
70
- if(testTwo)
71
- Test2.subscribe(function(){
72
- if(Cluster.isMaster){
73
- var name = 'm';
74
- } else {
75
- var name = Cluster.worker.id;
76
- }
77
- console.log(' S2 | ' + name + ' | ' + JSON.stringify(Test2.getState()));
78
- });
79
-
80
- if(Cluster.isMaster){
81
- for(var i=0; i < 2; i++){
82
- setTimeout(function(){Cluster.fork();}, i*10000);
83
- }
84
- Test.dispatch({type:'TASK', payload: {version:'OneRemoteMasterTest0'}});
85
- if(testTwo){
86
- Test2.dispatch({type:'TASK', payload: {version:'TwoRemoteMasterTest0'}});
87
- }
88
- var i = 0;
89
- setInterval(function(){
90
- Test.dispatch({type:'TASK', payload: {version:'OneRemoteMasterTest'+i}});
91
- if(testTwo)
92
- Test2.dispatch({type:'TASK', payload: {version:'TwoRemoteMasterTest'+i}});
93
- i++;
94
- }, 11000);
95
- } else {
96
- var i = 0;
97
- setInterval(function(){
98
- Test.dispatch({type:'TASK', payload: {version:'OneRemoteWorkerTest'+i}});
99
- if(testTwo)
100
- Test2.dispatch({type:'TASK', payload: {version:'TwoRemoteWorkerTest'+i}});
101
- i++;
102
- }, 22000+(Cluster.worker.id*1500), i);
103
- }
@@ -1,45 +0,0 @@
1
- /**
2
- * Redux-Cluster Test
3
- * (c) 2018 by Siarhei Dudko.
4
- *
5
- * test error
6
- * LICENSE MIT
7
- */
8
-
9
- "use strict"
10
-
11
- var ReduxCluster = require('./index.js'),
12
- Cluster = require('cluster'),
13
- Lodash = require('lodash');
14
-
15
-
16
- var Test = ReduxCluster.createStore(editProcessStorage);
17
-
18
- try{
19
- if(Cluster.isMaster)
20
- var Test2 = ReduxCluster.createStore(editProcessStorage);
21
- } catch(err){
22
- console.error(err.message);
23
- }
24
-
25
- function editProcessStorage(state = {version:''}, action){
26
- try {
27
- switch (action.type){
28
- case 'TASK':
29
- var state_new = Lodash.clone(state);
30
- state_new.version = action.payload.version;
31
- return state_new;
32
- break;
33
- default:
34
- break;
35
- }
36
- } catch(e){
37
- }
38
- var state_new = Lodash.clone(state);
39
- return state_new;
40
- }
41
-
42
- Test.dispatch({type:"REDUX_CLUSTER_SYNC", payload:{test:1}});
43
-
44
- if(Cluster.isMaster)
45
- Cluster.fork();
package/test.visual.js DELETED
@@ -1,97 +0,0 @@
1
- /**
2
- * Redux-Cluster Test
3
- * (c) 2018 by Siarhei Dudko.
4
- *
5
- * standart test (cluster IPC channel)
6
- * LICENSE MIT
7
- */
8
-
9
- "use strict"
10
-
11
- var ReduxCluster = require('./index.js'),
12
- Cluster = require('cluster'),
13
- Lodash = require('lodash'),
14
- Colors = require('colors');
15
-
16
-
17
- var Test = ReduxCluster.createStore(editProcessStorage);
18
- var Test2 = ReduxCluster.createStore(editProcessStorage2);
19
-
20
- var testTwo = true;
21
-
22
- function editProcessStorage(state = {version:''}, action){
23
- try {
24
- switch (action.type){
25
- case 'TASK':
26
- var state_new = Lodash.clone(state);
27
- state_new.version = action.payload.version;
28
- return state_new;
29
- break;
30
- default:
31
- break;
32
- }
33
- } catch(e){
34
- }
35
- var state_new = Lodash.clone(state);
36
- return state_new;
37
- }
38
- function editProcessStorage2(state = {version:''}, action){
39
- try {
40
- switch (action.type){
41
- case 'TASK':
42
- var state_new = Lodash.clone(state);
43
- state_new.version = action.payload.version;
44
- return state_new;
45
- break;
46
- default:
47
- break;
48
- }
49
- } catch(e){
50
- }
51
- var state_new = Lodash.clone(state);
52
- return state_new;
53
- }
54
-
55
- Test.subscribe(function(){
56
- if(Cluster.isMaster){
57
- var name = 'm';
58
- } else {
59
- var name = Cluster.worker.id;
60
- }
61
- console.log(Colors.gray(name + ' | ' + JSON.stringify(Test.getState())));
62
- });
63
-
64
- if(testTwo)
65
- Test2.subscribe(function(){
66
- if(Cluster.isMaster){
67
- var name = 'm';
68
- } else {
69
- var name = Cluster.worker.id;
70
- }
71
- console.log(Colors.yellow(name + ' | ' + JSON.stringify(Test2.getState())));
72
- });
73
-
74
- if(Cluster.isMaster){
75
- for(var i=0; i < 3; i++){
76
- setTimeout(function(){Cluster.fork();}, i*20000)
77
- }
78
- Test.dispatch({type:'TASK', payload: {version:'OneMasterTest0'}});
79
- if(testTwo){
80
- Test2.dispatch({type:'TASK', payload: {version:'TwoMasterTest0'}});
81
- }
82
- var i = 0;
83
- setInterval(function(){
84
- Test.dispatch({type:'TASK', payload: {version:'OneMasterTest'+i}});
85
- if(testTwo)
86
- Test2.dispatch({type:'TASK', payload: {version:'TwoMasterTest'+i}});
87
- i++;
88
- }, 5000);
89
- } else {
90
- var i = 0;
91
- setInterval(function(){
92
- Test.dispatch({type:'TASK', payload: {version:'OneWorkerTest'+i}});
93
- if(testTwo)
94
- Test2.dispatch({type:'TASK', payload: {version:'TwoWorkerTest'+i}});
95
- i++;
96
- }, 5000, i);
97
- }