@brown-ds/distribution 0.2.28 → 0.2.29

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/README.md CHANGED
@@ -99,15 +99,25 @@ If you wanted to run this same sequence of commands in a script, you could do so
99
99
  ```js
100
100
  let distribution = require("@brown-ds/distribution")();
101
101
  // Now we're only doing a few of the things we did above
102
+ const out = (cb) => {
103
+ distribution.local.status.stop(cb); // Shut down the local node
104
+ };
102
105
  distribution.node.start(() => {
103
106
  // This will run only after the node has started
104
- node = { ip: '127.0.0.1', port: 8080 };
105
- distribution.local.status.spawn(node, () => {
107
+ const node = {ip: '127.0.0.1', port: 8765};
108
+ distribution.local.status.spawn(node, (e, v) => {
109
+ if (e) {
110
+ return out(console.log);
111
+ }
106
112
  // This will run only after the new node has been spawned
107
113
  distribution.all.status.get('sid', (e, v) => {
108
- // This will run only after we communicated with all nodes and got their sids
109
- console.log(v); // { '8cf1b': '8cf1b', '8cf1c': '8cf1c' }
110
- distribution.local.status.stop(console.log);
114
+ // This will run only after we communicated with all nodes and got their sids
115
+ console.log(v); // { '8cf1b': '8cf1b', '8cf1c': '8cf1c' }
116
+ // Shut down the remote node
117
+ distribution.local.comm.send([], {service: 'status', method: 'stop', node: node}, () => {
118
+ // Finally, stop the local node
119
+ out(console.log); // null, {ip: '127.0.0.1', port: 1380}
120
+ });
111
121
  });
112
122
  });
113
123
  });
@@ -6,5 +6,5 @@ Do NOT edit this file directly. Use it as a black box.
6
6
 
7
7
  If you notice any issues with using this file, please contact the TAs.
8
8
  */
9
- function comm(_0x2019ba){const _0x285313={};_0x285313['gid']=_0x2019ba['gid']||'all';function _0x577a6a(_0x2056fd,_0x124d3c,_0x1f2069){globalThis['distributi'+'on']['local']['groups']['get'](_0x285313['gid'],(_0x2d1099,_0x592d32)=>{if(!_0x592d32){_0x1f2069(_0x2d1099);return;}const _0x208bd1=Object['keys'](_0x592d32)['length'];if(_0x208bd1===0x1f82+-0x5d*0x6+-0x1d54){_0x1f2069(new Error('No\x20nodes\x20i'+'n\x20group\x20'+_0x285313['gid']+'\x20found!'));return;}let _0x502634=0x1*-0x210e+0xaf2+-0x587*-0x4;const _0x34ae1c={},_0x4e14df={};for(const _0x5d24fd of Object['keys'](_0x592d32)){const _0x3ca66f=_0x592d32[_0x5d24fd],_0x21dcd4={'node':{'ip':_0x3ca66f['ip'],'port':_0x3ca66f['port']},'service':_0x124d3c['service'],'method':_0x124d3c['method'],'gid':_0x124d3c['gid']||'local'};globalThis['distributi'+'on']['local']['comm']['send'](_0x2056fd,_0x21dcd4,(_0x504bd9,_0x213b4a)=>{_0x504bd9?_0x4e14df[_0x5d24fd]=_0x504bd9:_0x34ae1c[_0x5d24fd]=_0x213b4a;_0x502634+=-0xb*0x2+0x31c+-0x305;if(_0x502634===_0x208bd1)return _0x1f2069(_0x4e14df,_0x34ae1c);});}});}return{'send':_0x577a6a};}module['exports']=comm;
9
+ function comm(_0x17e568){const _0x543f7b={};_0x543f7b['gid']=_0x17e568['gid']||'all';function _0x4738df(_0x114e26,_0x27d271,_0x43252b){globalThis['distributi'+'on']['local']['groups']['get'](_0x543f7b['gid'],(_0x5d70cd,_0x40759f)=>{if(!_0x40759f){_0x43252b(_0x5d70cd);return;}const _0x369edf=Object['keys'](_0x40759f)['length'];if(_0x369edf===-0x2*0x3f5+-0x2*0x9f1+0x1bcc){_0x43252b(new Error('No\x20nodes\x20i'+'n\x20group\x20'+_0x543f7b['gid']+'\x20found!'));return;}let _0x1b730e=0x1072+0xfdd+-0x204f;const _0x5ae99f={},_0x2af7b0={};for(const _0x33c7ce of Object['keys'](_0x40759f)){const _0x959419=_0x40759f[_0x33c7ce],_0x574b2d={'node':{'ip':_0x959419['ip'],'port':_0x959419['port']},'service':_0x27d271['service'],'method':_0x27d271['method'],'gid':_0x27d271['gid']||'local'};globalThis['distributi'+'on']['local']['comm']['send'](_0x114e26,_0x574b2d,(_0x4aadb3,_0x3ecdc4)=>{_0x4aadb3?_0x2af7b0[_0x33c7ce]=_0x4aadb3:_0x5ae99f[_0x33c7ce]=_0x3ecdc4;_0x1b730e+=0x6da+0x1*0x17ee+-0x1ec7;if(_0x1b730e===_0x369edf)return _0x43252b(_0x2af7b0,_0x5ae99f);});}});return;_0x43252b(new Error('comm.send\x20'+'not\x20implem'+'ented'));}return{'send':_0x4738df};}module['exports']=comm;
10
10
  /* eslint-enable */
@@ -6,5 +6,5 @@ Do NOT edit this file directly. Use it as a black box.
6
6
 
7
7
  If you notice any issues with using this file, please contact the TAs.
8
8
  */
9
- function status(_0xe569d2){const _0x2b7dcc={};_0x2b7dcc['gid']=_0xe569d2['gid']||'all';function _0x502cb(_0x1e3422,_0x5d23ae){const _0x5c5355=[_0x1e3422],_0x2b2161={'service':'status','method':'get'};globalThis['distributi'+'on'][_0x2b7dcc['gid']]['comm']['send'](_0x5c5355,_0x2b2161,(_0x466833,_0xe860e9)=>{switch(_0x1e3422){case'heapTotal':const _0x2b6d9a=Object['values'](_0xe860e9)['reduce']((_0x22e7fd,_0x129ddc)=>{return _0x22e7fd+_0x129ddc;},-0x122d+-0x1*0x235d+0x358a);return _0x5d23ae(_0x466833,_0x2b6d9a);break;case'nid':const _0x3bc516=Object['values'](_0xe860e9)['reduce']((_0x41c188,_0x302416)=>{return _0x41c188['concat'](_0x302416);},[]);return _0x5d23ae(_0x466833,_0x3bc516);break;default:return _0x5d23ae(_0x466833,_0xe860e9);break;}});}function _0x5076fe(_0x6ee9a0,_0xc6f21d){globalThis['distributi'+'on']['local']['status']['spawn'](_0x6ee9a0,(_0x2fadf6,_0x459797)=>{globalThis['distributi'+'on'][_0x2b7dcc['gid']]['comm']['send']([_0x2b7dcc['gid'],_0x6ee9a0],{'service':'groups','method':'add'},()=>{});if(_0x2fadf6)return _0xc6f21d(_0x2fadf6);globalThis['distributi'+'on']['local']['groups']['add'](_0x2b7dcc['gid'],_0x6ee9a0,()=>{return _0xc6f21d(null,_0x459797);});});return;_0xc6f21d(new Error('status.spa'+'wn\x20not\x20imp'+'lemented'));}function _0x5cfcfa(_0x5397c5){globalThis['distributi'+'on'][_0x2b7dcc['gid']]['comm']['send']([],{'service':'status','method':'stop'},()=>{globalThis['distributi'+'on']['local']['status']['stop'](_0x5397c5);});return;_0x5397c5(new Error('status.sto'+'p\x20not\x20impl'+'emented'));}return{'get':_0x502cb,'stop':_0x5cfcfa,'spawn':_0x5076fe};}module['exports']=status;
9
+ function status(_0x423aac){const _0x41f0a4={};_0x41f0a4['gid']=_0x423aac['gid']||'all';function _0x28bb8a(_0x5996f0,_0x40a397){const _0x45ffcc=[_0x5996f0],_0x321e52={'service':'status','method':'get'};globalThis['distributi'+'on'][_0x41f0a4['gid']]['comm']['send'](_0x45ffcc,_0x321e52,(_0x3ac603,_0x3c8658)=>{switch(_0x5996f0){case'heapTotal':const _0x16d43a=Object['values'](_0x3c8658)['reduce']((_0x36a757,_0x4c9396)=>{return _0x36a757+_0x4c9396;},-0x7f*0x4a+0x19*0x1d+-0x15*-0x19d);return _0x40a397(_0x3ac603,_0x16d43a);break;case'nid':const _0x34ffda=Object['values'](_0x3c8658)['reduce']((_0x27a954,_0x186898)=>{return _0x27a954['concat'](_0x186898);},[]);return _0x40a397(_0x3ac603,_0x34ffda);break;default:return _0x40a397(_0x3ac603,_0x3c8658);break;}});return;_0x40a397(new Error('status.get'+'\x20not\x20imple'+'mented'));}function _0x38df6f(_0x1b0684,_0x2f73ba){globalThis['distributi'+'on']['local']['status']['spawn'](_0x1b0684,(_0x484b26,_0x1ab6fd)=>{globalThis['distributi'+'on'][_0x41f0a4['gid']]['comm']['send']([_0x41f0a4['gid'],_0x1b0684],{'service':'groups','method':'add'},()=>{});if(_0x484b26)return _0x2f73ba(_0x484b26);globalThis['distributi'+'on']['local']['groups']['add'](_0x41f0a4['gid'],_0x1b0684,()=>{return _0x2f73ba(null,_0x1ab6fd);});});return;_0x2f73ba(new Error('status.spa'+'wn\x20not\x20imp'+'lemented'));}function _0x547b3a(_0x4b6742){globalThis['distributi'+'on'][_0x41f0a4['gid']]['comm']['send']([],{'service':'status','method':'stop'},()=>{globalThis['distributi'+'on']['local']['status']['stop'](_0x4b6742);});return;_0x4b6742(new Error('status.sto'+'p\x20not\x20impl'+'emented'));}return{'get':_0x28bb8a,'stop':_0x547b3a,'spawn':_0x38df6f};}module['exports']=status;
10
10
  /* eslint-enable */
package/distribution.js CHANGED
@@ -21,17 +21,17 @@ function bootstrap(config) {
21
21
  }
22
22
  // __end_solution__
23
23
  const distribution = {};
24
+
24
25
  // @ts-ignore This is the first time globalThis.distribution is being initialized, so the object does not have all the necessary properties.
25
26
  globalThis.distribution = distribution;
26
27
  distribution.util = require('./distribution/util/util.js');
27
28
 
28
29
  // @ts-ignore node.server is lazily initialized.
29
30
  distribution.node = require('./distribution/local/node.js');
30
- distribution.local = require('./distribution/local/local.js');
31
-
32
31
  if (config) {
33
32
  distribution.node.config = config;
34
33
  }
34
+ distribution.local = require('./distribution/local/local.js');
35
35
 
36
36
  const {setup} = require('./distribution/all/all.js');
37
37
  distribution.all = setup({gid: 'all'});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brown-ds/distribution",
3
- "version": "0.2.28",
3
+ "version": "0.2.29",
4
4
  "description": "A library for building distributed systems.",
5
5
  "main": "distribution.js",
6
6
  "useLibrary": false,