@brown-ds/distribution 0.2.20 → 0.2.22

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.
@@ -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
- const http=require('node:http'),log=require('../util/lo'+'g.js');function send(_0xecb36b,_0x45a5c1,_0x39d3f0){_0xecb36b=_0xecb36b||[];if(!_0x45a5c1){_0x39d3f0(new Error('Remote\x20is\x20'+'required'));return;}const _0x4b898=_0x45a5c1['node'],_0x3718ee=_0x45a5c1['service'],_0x525a3f=_0x45a5c1['method'],_0x3c927=_0x45a5c1['gid']||'local';if(!(_0xecb36b instanceof Array)){_0x39d3f0(new Error('Message\x20mu'+'st\x20be\x20an\x20a'+'rray'));return;}if(!_0x4b898){_0x39d3f0(new Error('Node\x20is\x20re'+'quired'));return;}if(!_0x3718ee){_0x39d3f0(new Error('Service\x20is'+'\x20required'));return;}if(!_0x525a3f){_0x39d3f0(new Error('Method\x20is\x20'+'required'));return;}log('[comm.send'+']:\x20Sending'+'\x20'+JSON['stringify'](_0xecb36b)+'\x20to\x20'+_0x45a5c1['service']+':'+_0x45a5c1['method']+'\x20on\x20'+_0x45a5c1['node']['ip']+':'+_0x45a5c1['node']['port']);const _0x16f8f1=globalThis['distributi'+'on']['util']['serialize'](_0xecb36b),_0x11e4d3={'hostname':_0x4b898['ip'],'port':_0x4b898['port'],'path':'/'+_0x3c927+'/'+_0x3718ee+'/'+_0x525a3f,'method':'PUT','headers':{'Content-Type':'applicatio'+'n/json','Content-Length':Buffer['byteLength'](_0x16f8f1)}},_0x52f1e4=http['request'](_0x11e4d3,_0x4187a8=>{let _0x1d065f='';_0x4187a8['on']('data',function(_0x1384d5){_0x1d065f+=_0x1384d5;}),_0x4187a8['on']('end',function(){const [_0x926e74,_0x25bba6]=globalThis['distributi'+'on']['util']['deserializ'+'e'](_0x1d065f);if(_0x39d3f0)return _0x39d3f0(_0x926e74,_0x25bba6);}),_0x4187a8['on']('error',_0x2ddc79=>{if(_0x39d3f0)return _0x39d3f0(new Error('Error\x20on\x20r'+'esponse'));});});_0x52f1e4['on']('error',_0x423c60=>{if(_0x39d3f0)return _0x39d3f0(new Error(_0x423c60));}),_0x52f1e4['write'](_0x16f8f1),_0x52f1e4['end']();}module['exports']={'send':send};
9
+ const http=require('node:http'),log=require('../util/lo'+'g.js');function createGuardedCallback(_0x28a30d){let _0x6436f4=0x692+-0x210c+0x1a7a;function _0x5b1792(_0x27b8d8,_0x4b8275){_0x6436f4+=-0x223*0xd+0x1d74+-0x1ac;if(_0x6436f4>0x16d2+-0x165c+-0x75){log('Warning:\x20C'+'allback\x20fu'+'nction\x20cal'+'led\x20'+_0x6436f4+'\x20times');return;}if(_0x28a30d!==undefined){_0x28a30d(_0x27b8d8,_0x4b8275);return;}}return _0x5b1792;}function send(_0x408349,_0x1edc84,_0x543a04){_0x543a04=createGuardedCallback(_0x543a04);if(_0x1edc84===undefined){_0x543a04(new Error('Remote\x20is\x20'+'required'));return;}if(_0x1edc84?.['node']?.['ip']===undefined||_0x1edc84?.['node']?.['port']===undefined){_0x543a04(new Error('Remote\x20nod'+'e\x20IP\x20and\x20p'+'ort\x20requir'+'ed'));return;}if(_0x1edc84?.['service']===undefined){_0x543a04(new Error('Remote\x20ser'+'vice\x20is\x20re'+'quired'));return;}if(_0x1edc84?.['method']===undefined){_0x543a04(new Error('Remote\x20met'+'hod\x20is\x20req'+'uired'));return;}if(!(_0x408349 instanceof Array)){_0x543a04(new Error('Message\x20mu'+'st\x20be\x20an\x20a'+'rray\x20of\x20ar'+'guments'));return;}const _0x26dd72=_0x1edc84['node'],_0x23eff8=_0x1edc84['service'],_0x5d4911=_0x1edc84['method'],_0x433a42=_0x1edc84['gid']||'local';log('[comm.send'+']:\x20Sending'+'\x20'+JSON['stringify'](_0x408349)+'\x20to\x20'+_0x1edc84['service']+':'+_0x1edc84['method']+'\x20on\x20'+_0x1edc84['node']['ip']+':'+_0x1edc84['node']['port']);const _0x28523a=globalThis['distributi'+'on']['util']['serialize'](_0x408349),_0x34c38d={'hostname':_0x26dd72['ip'],'port':_0x26dd72['port'],'path':'/'+_0x433a42+'/'+_0x23eff8+'/'+_0x5d4911,'method':'PUT','headers':{'Content-Type':'applicatio'+'n/json','Content-Length':Buffer['byteLength'](_0x28523a)}},_0x273854=http['request'](_0x34c38d,_0x1c1358=>{let _0x20394f='';_0x1c1358['on']('data',function(_0x1b730d){_0x20394f+=_0x1b730d;}),_0x1c1358['on']('end',function(){let _0x2c38c5=undefined,_0x1a3a93=undefined;try{const _0x5b7551=globalThis['distributi'+'on']['util']['deserializ'+'e'](_0x20394f);_0x2c38c5=_0x5b7551[-0x2c1+-0x2496+0x2757],_0x1a3a93=_0x5b7551[-0x1*-0x2465+0x4f0*-0x4+0x10a4*-0x1];}catch(_0x1fed1c){let _0xa55726=_0x20394f['slice'](-0x1bb*-0x16+0x1010+-0x3622,0x1a*0x35+-0x1e9d+-0x1d23*-0x1);_0x20394f['length']>-0x1975+-0xabe+-0x281b*-0x1&&(_0xa55726+='...');_0x543a04(new Error('Failed\x20to\x20'+'deserializ'+'e\x20HTTP\x20res'+'ponse:\x20'+_0xa55726));return;}_0x543a04(_0x2c38c5,_0x1a3a93);return;}),_0x1c1358['on']('error',_0x31ad54=>{_0x543a04(new Error('HTTP\x20respo'+'nse\x20error:'+'\x20'+_0x31ad54?.['message']));return;});});_0x273854['on']('error',_0x183288=>{_0x543a04(new Error('HTTP\x20reque'+'st\x20error:\x20'+_0x183288?.['message']));return;}),_0x273854['write'](_0x28523a),_0x273854['end']();}module['exports']={'send':send};
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
- const http=require('node:http'),url=require('node:url'),log=require('../util/lo'+'g.js'),yargs=require('yargs/yarg'+'s');function setNodeConfig(){const _0x45db11=yargs(process['argv'])['help'](![])['version'](![])['parse']();let _0x35a63f,_0x2463db,_0xc6645f;typeof _0x45db11['ip']==='string'&&(_0x35a63f=_0x45db11['ip']);(typeof _0x45db11['port']==='string'||typeof _0x45db11['port']==='number')&&(_0x2463db=parseInt(String(_0x45db11['port']),0x98*-0x27+-0xde7*-0x2+-0x49c));(_0x45db11['help']===!![]||_0x45db11['h']===!![])&&(console['log']('Node\x20usage'+':'),console['log']('\x20\x20--ip\x20<ip'+'\x20address>\x20'+'\x20\x20\x20\x20\x20The\x20i'+'p\x20address\x20'+'to\x20bind\x20th'+'e\x20node\x20to'),console['log']('\x20\x20--port\x20<'+'port>\x20\x20\x20\x20\x20'+'\x20\x20\x20\x20\x20The\x20p'+'ort\x20to\x20bin'+'d\x20the\x20node'+'\x20to'),console['log']('\x20\x20--config'+'\x20<config>\x20'+'\x20\x20\x20\x20\x20The\x20s'+'erialized\x20'+'config\x20str'+'ing'),process['exit'](-0x22dc+-0xaf6+-0x1e*-0x187));if(typeof _0x45db11['config']==='string'){const {ip:_0x205e75,port:_0x3a2308,onStart:_0x350664}=globalThis['distributi'+'on']['util']['deserializ'+'e'](_0x45db11['config']);typeof _0x205e75==='string'&&(_0x35a63f=_0x205e75),typeof _0x3a2308==='number'&&(_0x2463db=_0x3a2308),typeof _0x350664==='function'&&(_0xc6645f=_0x350664);}return _0x35a63f=_0x35a63f||'127.0.0.1',_0x2463db=_0x2463db||-0x898+0x8*0x482+-0x16a6,{'ip':_0x35a63f,'port':_0x2463db,'onStart':_0xc6645f};}function validate(_0x525833){if(_0x525833['length']===-0x25d1+-0x2323+0x48f4)throw new Error('No\x20body');return JSON['parse'](_0x525833);}function start(_0x3b07d6){const _0x36f2af=http['createServ'+'er']((_0x5165c8,_0x485edd)=>{if(_0x5165c8['method']!=='PUT'){_0x485edd['end'](globalThis['distributi'+'on']['util']['serialize'](new Error('Method\x20not'+'\x20allowed!')));return;}const [,_0x475dfb,_0x2b4373,_0x114424]=url['parse'](_0x5165c8['url'])['pathname']['split']('/');log('[server]\x20g'+'ot\x20request'+'\x20'+_0x475dfb+'\x20'+_0x2b4373+':'+_0x114424+'\x20from\x20'+_0x5165c8['socket']['remoteAddr'+'ess']);const _0x3279e1=[];_0x5165c8['on']('data',_0x3f3d97=>{_0x3279e1['push'](_0x3f3d97);}),_0x5165c8['on']('end',()=>{let _0x285e6f;try{_0x285e6f=validate(Buffer['concat'](_0x3279e1)['toString']());}catch(_0x31c4c5){_0x485edd['end'](globalThis['distributi'+'on']['util']['serialize']([_0x31c4c5]));return;}const _0x34cc1a=globalThis['distributi'+'on']['util']['deserializ'+'e'](_0x285e6f);!Array['isArray'](_0x34cc1a)&&_0x485edd['end'](globalThis['distributi'+'on']['util']['serialize']([new Error('Invalid\x20ar'+'gument\x20typ'+'e,\x20expecte'+'d\x20array,\x20g'+'ot\x20'+typeof _0x34cc1a)]));const _0x4ca976=_0x2b4373;globalThis['distributi'+'on']['local']['routes']['get']({'service':_0x2b4373,'gid':_0x475dfb},(_0x19b7d8,_0x3fb836)=>{if(_0x19b7d8){_0x485edd['end'](globalThis['distributi'+'on']['util']['serialize']([_0x19b7d8,null]));return;}if(!_0x3fb836[_0x114424]){_0x485edd['end'](globalThis['distributi'+'on']['util']['serialize']([new Error('Method\x20'+_0x114424+('\x20not\x20found'+'\x20in\x20servic'+'e\x20')+_0x4ca976),null]));return;}log('[server]\x20\x20'+'Calling\x20se'+'rvice:\x20'+_0x4ca976+':'+_0x114424+('\x20with\x20args'+':\x20')+JSON['stringify'](_0x34cc1a));_0x34cc1a['length']===0x8b*0x1a+0x2*0xe12+0x175*-0x1d&&_0x3fb836[_0x114424]['length']===-0xc2d+0x2501+-0x18d1*0x1&&_0x34cc1a['push'](undefined);const _0x2db971=_0x3fb836[_0x114424]['bind'](_0x3fb836),_0x14f16f=globalThis['distributi'+'on']['util']['normalize'](_0x2db971,_0x34cc1a);try{_0x2db971(..._0x14f16f,(_0x15bb7e,_0x5c30ff)=>_0x485edd['end'](globalThis['distributi'+'on']['util']['serialize']([_0x15bb7e,_0x5c30ff])));}catch(_0x48acc8){_0x485edd['end'](globalThis['distributi'+'on']['util']['serialize']([_0x48acc8,null]));}});});}),_0x108909=globalThis['distributi'+'on']['node']['config'];_0x36f2af['once']('listening',()=>{log('Server\x20run'+'ning\x20at\x20ht'+'tp://'+_0x108909['ip']+':'+_0x108909['port']+'/'),globalThis['distributi'+'on']['node']['server']=_0x36f2af,_0x3b07d6(null);}),_0x36f2af['once']('error',_0x4b712b=>{log('Server\x20err'+'or:\x20'+_0x4b712b),_0x3b07d6(_0x4b712b);}),_0x36f2af['listen'](_0x108909['port'],_0x108909['ip']);}module['exports']={'start':start,'config':setNodeConfig()};
9
+ const http=require('node:http'),url=require('node:url'),log=require('../util/lo'+'g.js'),yargs=require('yargs/yarg'+'s');function setNodeConfig(){const _0x5ac1e9=yargs(process['argv'])['help'](![])['version'](![])['parse']();let _0x58b69f,_0x318377,_0x5ac937;typeof _0x5ac1e9['ip']==='string'&&(_0x58b69f=_0x5ac1e9['ip']);(typeof _0x5ac1e9['port']==='string'||typeof _0x5ac1e9['port']==='number')&&(_0x318377=parseInt(String(_0x5ac1e9['port']),-0x409*-0x1+0x22cd+-0x26cc));(_0x5ac1e9['help']===!![]||_0x5ac1e9['h']===!![])&&(console['log']('Node\x20usage'+':'),console['log']('\x20\x20--ip\x20<ip'+'\x20address>\x20'+'\x20\x20\x20\x20\x20The\x20i'+'p\x20address\x20'+'to\x20bind\x20th'+'e\x20node\x20to'),console['log']('\x20\x20--port\x20<'+'port>\x20\x20\x20\x20\x20'+'\x20\x20\x20\x20\x20The\x20p'+'ort\x20to\x20bin'+'d\x20the\x20node'+'\x20to'),console['log']('\x20\x20--config'+'\x20<config>\x20'+'\x20\x20\x20\x20\x20The\x20s'+'erialized\x20'+'config\x20str'+'ing'),process['exit'](-0xc23+0x9bf*0x1+-0x99*-0x4));if(typeof _0x5ac1e9['config']==='string'){let _0x4fe36b=undefined;try{_0x4fe36b=globalThis['distributi'+'on']['util']['deserializ'+'e'](_0x5ac1e9['config']);}catch(_0x9d2859){try{_0x4fe36b=JSON['parse'](_0x5ac1e9['config']);}catch{console['error']('Cannot\x20des'+'erialize\x20c'+'onfig\x20stri'+'ng:\x20'+_0x5ac1e9['config']),process['exit'](0x2534*-0x1+-0xb*0x2+0x254b);}}typeof _0x4fe36b?.['ip']==='string'&&(_0x58b69f=_0x4fe36b?.['ip']),typeof _0x4fe36b?.['port']==='number'&&(_0x318377=_0x4fe36b?.['port']),typeof _0x4fe36b?.['onStart']==='function'&&(_0x5ac937=_0x4fe36b?.['onStart']);}return _0x58b69f=_0x58b69f??'127.0.0.1',_0x318377=_0x318377??-0xe73+0x7ce+-0x24b*-0x5,{'ip':_0x58b69f,'port':_0x318377,'onStart':_0x5ac937};}function validate(_0x23c72e){if(_0x23c72e['length']===0x5b5+0x1590+-0x1b45)throw new Error('No\x20body');return JSON['parse'](_0x23c72e);}function start(_0x4ea169){const _0x5df02a=http['createServ'+'er']((_0x5f8ee6,_0x189323)=>{if(_0x5f8ee6['method']!=='PUT'){_0x189323['end'](globalThis['distributi'+'on']['util']['serialize'](new Error('Method\x20not'+'\x20allowed!')));return;}const [,_0x44d9a4,_0x211999,_0x4207f6]=url['parse'](_0x5f8ee6['url'])['pathname']['split']('/');log('[server]\x20g'+'ot\x20request'+'\x20'+_0x44d9a4+'\x20'+_0x211999+':'+_0x4207f6+'\x20from\x20'+_0x5f8ee6['socket']['remoteAddr'+'ess']);const _0x24d1c6=[];_0x5f8ee6['on']('data',_0x3900dc=>{_0x24d1c6['push'](_0x3900dc);}),_0x5f8ee6['on']('end',()=>{let _0x1453e1;try{_0x1453e1=validate(Buffer['concat'](_0x24d1c6)['toString']());}catch(_0x176127){_0x189323['end'](globalThis['distributi'+'on']['util']['serialize']([_0x176127]));return;}const _0x544639=globalThis['distributi'+'on']['util']['deserializ'+'e'](_0x1453e1);!Array['isArray'](_0x544639)&&_0x189323['end'](globalThis['distributi'+'on']['util']['serialize']([new Error('Invalid\x20ar'+'gument\x20typ'+'e,\x20expecte'+'d\x20array,\x20g'+'ot\x20'+typeof _0x544639)]));const _0x39b28a=_0x211999;globalThis['distributi'+'on']['local']['routes']['get']({'service':_0x211999,'gid':_0x44d9a4},(_0x39ce9f,_0x4f9c34)=>{if(_0x39ce9f){_0x189323['end'](globalThis['distributi'+'on']['util']['serialize']([_0x39ce9f,null]));return;}if(!_0x4f9c34[_0x4207f6]){_0x189323['end'](globalThis['distributi'+'on']['util']['serialize']([new Error('Method\x20'+_0x4207f6+('\x20not\x20found'+'\x20in\x20servic'+'e\x20')+_0x39b28a),null]));return;}log('[server]\x20\x20'+'Calling\x20se'+'rvice:\x20'+_0x39b28a+':'+_0x4207f6+('\x20with\x20args'+':\x20')+JSON['stringify'](_0x544639));_0x544639['length']===0x12d2+0x2f*-0x61+-0x102&&_0x4f9c34[_0x4207f6]['length']===-0x1c17+0x3b2+0x1868&&_0x544639['push'](undefined);const _0x40a06c=_0x4f9c34[_0x4207f6]['bind'](_0x4f9c34),_0x156f79=globalThis['distributi'+'on']['util']['normalize'](_0x40a06c,_0x544639);try{_0x40a06c(..._0x156f79,(_0x538e4a,_0x35be1c)=>_0x189323['end'](globalThis['distributi'+'on']['util']['serialize']([_0x538e4a,_0x35be1c])));}catch(_0x51a50e){_0x189323['end'](globalThis['distributi'+'on']['util']['serialize']([_0x51a50e,null]));}});});});globalThis['distributi'+'on']['node']['server']=_0x5df02a;const _0x18c49f=globalThis['distributi'+'on']['node']['config'];_0x5df02a['once']('listening',()=>{log('Server\x20run'+'ning\x20at\x20ht'+'tp://'+_0x18c49f['ip']+':'+_0x18c49f['port']+'/'),_0x4ea169(null);}),_0x5df02a['once']('error',_0x339745=>{log('Server\x20err'+'or:\x20'+_0x339745),_0x4ea169(_0x339745);}),_0x5df02a['listen'](_0x18c49f['port'],_0x18c49f['ip']);}module['exports']={'start':start,'config':setNodeConfig()};
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
- const log=require('../util/lo'+'g'),routesStore=new Map();function get(_0x46a330,_0x5ca7b0){log('[routes.ge'+'t]\x20Getting'+'\x20service:\x20'+JSON['stringify'](_0x46a330));if(!_0x46a330)return _0x5ca7b0(new Error('No\x20configu'+'ration\x20pro'+'vided!'));typeof _0x46a330==='string'&&(_0x46a330={'service':_0x46a330});const _0x1cfbc6=_0x46a330['service'],_0x13571f=_0x46a330['gid'];if(_0x13571f&&_0x13571f!=='local')return log('[routes.ge'+'t]\x20Found\x20d'+'istributed'+'\x20service:\x20'+_0x1cfbc6),_0x5ca7b0(null,globalThis['distributi'+'on'][_0x13571f][_0x1cfbc6]);else{const _0x1a374f=routesStore['get'](_0x1cfbc6);if(_0x1a374f)return log('[routes.ge'+'t]\x20Found\x20l'+'ocal\x20servi'+'ce:\x20'+_0x1cfbc6),_0x5ca7b0(null,_0x1a374f);else{const _0x182935=globalThis['toLocal']['get'](_0x1cfbc6);return _0x182935?(log('[routes.ge'+'t]\x20Found\x20R'+'PC:\x20'+_0x1cfbc6),_0x5ca7b0(null,{'call':_0x182935})):_0x5ca7b0(new Error('Service\x20'+_0x1cfbc6+('\x20not\x20found'+'\x20in\x20routes')));}}}function put(_0x160b72,_0x182dbd,_0x58aa05){log('[routes.pu'+'t]\x20Putting'+'\x20service:\x20'+_0x182dbd),routesStore['set'](_0x182dbd,_0x160b72);if(_0x58aa05)return _0x58aa05(null,_0x182dbd);}function rem(_0x588da7,_0x1661e9){const _0x5d0f91=routesStore['get'](_0x588da7);return routesStore['delete'](_0x588da7),_0x1661e9(null,_0x5d0f91);}module['exports']={'get':get,'put':put,'rem':rem};
9
+ const log=require('../util/lo'+'g'),routesStore=new Map();function get(_0x3b8f9b,_0xd999cf){log('[routes.ge'+'t]\x20Getting'+'\x20service:\x20'+JSON['stringify'](_0x3b8f9b));if(!_0x3b8f9b)return _0xd999cf(new Error('No\x20configu'+'ration\x20pro'+'vided!'));typeof _0x3b8f9b==='string'&&(_0x3b8f9b={'service':_0x3b8f9b});const _0x261a09=_0x3b8f9b['service'],_0x5a7a79=_0x3b8f9b['gid'];if(_0x5a7a79&&_0x5a7a79!=='local')return log('[routes.ge'+'t]\x20Found\x20d'+'istributed'+'\x20service:\x20'+_0x261a09),_0xd999cf(null,globalThis['distributi'+'on'][_0x5a7a79][_0x261a09]);else{const _0x2a941b=routesStore['get'](_0x261a09);if(_0x2a941b)return log('[routes.ge'+'t]\x20Found\x20l'+'ocal\x20servi'+'ce:\x20'+_0x261a09),_0xd999cf(null,_0x2a941b);else{const _0x7718e2=globalThis['toLocal']['get'](_0x261a09);return _0x7718e2?(log('[routes.ge'+'t]\x20Found\x20R'+'PC:\x20'+_0x261a09),_0xd999cf(null,{'call':_0x7718e2})):_0xd999cf(new Error('Service\x20'+_0x261a09+('\x20not\x20found'+'\x20in\x20routes')));}}}function put(_0x2a5b78,_0x187cc1,_0x49386c){log('[routes.pu'+'t]\x20Putting'+'\x20service:\x20'+_0x187cc1),routesStore['set'](_0x187cc1,_0x2a5b78);if(_0x49386c)return _0x49386c(null,_0x187cc1);}function rem(_0x3c28d1,_0x2f32b8){const _0x4533ce=routesStore['get'](_0x3c28d1);return routesStore['delete'](_0x3c28d1),_0x2f32b8(null,_0x4533ce);}module['exports']={'get':get,'put':put,'rem':rem};
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
- const log=require('../util/lo'+'g'),counts=-0x250f*0x1+0x24a2+-0x6d*-0x1;function get(_0x3e276e,_0x5d4aef){if(_0x3e276e in globalThis['distributi'+'on']['node']['config']){_0x5d4aef(null,globalThis['distributi'+'on']['node']['config'][_0x3e276e]);return;}if(_0x3e276e==='sid'){_0x5d4aef(null,globalThis['distributi'+'on']['util']['id']['getSID'](globalThis['distributi'+'on']['node']['config']));return;}if(_0x3e276e==='nid'){_0x5d4aef(null,globalThis['distributi'+'on']['util']['id']['getNID'](globalThis['distributi'+'on']['node']['config']));return;}if(_0x3e276e==='counts'){_0x5d4aef(null,counts);return;}if(_0x3e276e==='heapTotal'){_0x5d4aef(null,process['memoryUsag'+'e']()['heapTotal']);return;}if(_0x3e276e==='heapUsed'){_0x5d4aef(null,process['memoryUsag'+'e']()['heapUsed']);return;}_0x5d4aef(new Error('Status\x20key'+'\x20not\x20found'));};const fs=require('fs'),path=require('path'),proc=require('node:child'+'_process');function getDistribution(){let _0x2b3e6f=path['join'](process['cwd'](),'config.js');if(fs['existsSync'](_0x2b3e6f))return _0x2b3e6f;try{const _0x4fa609=proc['execSync']('git\x20rev-pa'+'rse\x20--show'+'-toplevel',{'encoding':'utf8'})['trim']();_0x2b3e6f=path['join'](_0x4fa609,'config.js');if(fs['existsSync'](_0x2b3e6f))return _0x2b3e6f;}catch(_0x359df0){throw new Error('Not\x20in\x20a\x20G'+'it\x20reposit'+'ory\x20or\x20git'+'\x20command\x20f'+'ailed.');}_0x2b3e6f=path['join'](__dirname,'../../','config.js');if(fs['existsSync'](_0x2b3e6f))return _0x2b3e6f;_0x2b3e6f=path['join'](__dirname,'../../','distributi'+'on.js');if(fs['existsSync'](_0x2b3e6f))return _0x2b3e6f;throw new Error('Failed\x20to\x20'+'find\x20proje'+'ct\x20root.');}function createOnStart(_0x525698,_0x3a8393){const _0x315b8e='\x0a\x20\x20\x20\x20retur'+'n\x20function'+'(e)\x20{\x0a\x20\x20\x20\x20'+'\x20\x20let\x20onSt'+'art\x20=\x20'+_0x525698['toString']()+(';\x0a\x20\x20\x20\x20\x20\x20le'+'t\x20callback'+'RPC\x20=\x20')+globalThis['distributi'+'on']['util']['wire']['createRPC'](globalThis['distributi'+'on']['util']['wire']['toAsync'](_0x3a8393))['toString']()+(';\x0a\x20\x20\x20\x20\x20\x20if'+'\x20(e)\x20{\x0a\x20\x20\x20'+'\x20\x20\x20\x20\x20callb'+'ackRPC(e,\x20'+'null,\x20()\x20='+'>\x20{});\x0a\x20\x20\x20'+'\x20\x20\x20\x20\x20retur'+'n;\x0a\x20\x20\x20\x20\x20\x20}'+'\x0a\x20\x20\x20\x20\x20\x20try'+'\x20{\x0a\x20\x20\x20\x20\x20\x20\x20'+'\x20onStart()'+';\x0a\x20\x20\x20\x20\x20\x20\x20\x20'+'callbackRP'+'C(null,\x20gl'+'obal.distr'+'ibution.no'+'de.config,'+'\x20()\x20=>\x20{})'+';\x0a\x20\x20\x20\x20\x20\x20}\x20'+'catch(e)\x20{'+'\x0a\x20\x20\x20\x20\x20\x20\x20\x20c'+'allbackRPC'+'(e,\x20null,\x20'+'()\x20=>\x20{});'+'\x0a\x20\x20\x20\x20\x20\x20}\x0a\x20'+'\x20\x20\x20};\x0a\x20\x20');return new Function(_0x315b8e)();}function spawn(_0x3598eb,_0x29bb2e){const _0x22e1dc=_0x3598eb;_0x22e1dc['onStart']=_0x22e1dc['onStart']||function(){};if(!_0x22e1dc['port']||!_0x22e1dc['ip']){_0x29bb2e(new Error('Port\x20and\x20I'+'P\x20are\x20requ'+'ired\x20in\x20th'+'e\x20configur'+'ation'));return;}log('[status.sp'+'awn]\x20Spawn'+'ing\x20node\x20w'+'ith\x20config'+'uration:\x20'+JSON['stringify'](_0x22e1dc));const _0x5b6444=(_0x4c27ed,_0x1d8e9d)=>{if(_0x4c27ed){_0x29bb2e(_0x4c27ed);return;}globalThis['distributi'+'on']['local']['groups']['add']('all',_0x1d8e9d,()=>{_0x29bb2e(_0x4c27ed,_0x1d8e9d);});};_0x22e1dc['onStart']=createOnStart(_0x22e1dc['onStart'],_0x5b6444);const _0x39f737=getDistribution(),_0x4908c2=proc['spawn']('node',[_0x39f737,'--config',globalThis['distributi'+'on']['util']['serialize'](_0x22e1dc)],{'detached':!![],'stdio':'inherit'});_0x4908c2;return;_0x29bb2e(new Error('status.spa'+'wn\x20not\x20imp'+'lemented'));}function stop(_0x3e8f2d){log('[status.st'+'op]\x20Shutti'+'ng\x20down\x20no'+'de'),globalThis['distributi'+'on']['node']['server']['close'](),process['nextTick'](()=>process['exit'](0x1aee+0x2285+-0x3d73));return _0x3e8f2d(null,globalThis['distributi'+'on']['node']['config']);_0x3e8f2d(new Error('status.sto'+'p\x20not\x20impl'+'emented'));}module['exports']={'get':get,'spawn':spawn,'stop':stop};
9
+ const log=require('../util/lo'+'g'),counts=-0x26b*0xd+0xf*0x192+-0x1*-0x7e1;function get(_0x545045,_0xc9c56a){if(_0x545045 in globalThis['distributi'+'on']['node']['config']){_0xc9c56a(null,globalThis['distributi'+'on']['node']['config'][_0x545045]);return;}if(_0x545045==='sid'){_0xc9c56a(null,globalThis['distributi'+'on']['util']['id']['getSID'](globalThis['distributi'+'on']['node']['config']));return;}if(_0x545045==='nid'){_0xc9c56a(null,globalThis['distributi'+'on']['util']['id']['getNID'](globalThis['distributi'+'on']['node']['config']));return;}if(_0x545045==='counts'){_0xc9c56a(null,counts);return;}if(_0x545045==='heapTotal'){_0xc9c56a(null,process['memoryUsag'+'e']()['heapTotal']);return;}if(_0x545045==='heapUsed'){_0xc9c56a(null,process['memoryUsag'+'e']()['heapUsed']);return;}_0xc9c56a(new Error('Status\x20key'+'\x20not\x20found'));};const fs=require('fs'),path=require('path'),proc=require('node:child'+'_process');function getDistribution(){let _0x210eaa=path['join'](__dirname,'../../','distributi'+'on.js');if(fs['existsSync'](_0x210eaa))return _0x210eaa;try{const _0x3e529b=proc['execSync']('git\x20rev-pa'+'rse\x20--show'+'-toplevel',{'encoding':'utf8'})['trim']();_0x210eaa=path['join'](_0x3e529b,'distributi'+'on.js');if(fs['existsSync'](_0x210eaa))return _0x210eaa;}catch(_0x224009){throw new Error('Not\x20in\x20a\x20G'+'it\x20reposit'+'ory\x20or\x20git'+'\x20command\x20f'+'ailed.');}_0x210eaa=path['join'](process['cwd'](),'distributi'+'on.js');if(fs['existsSync'](_0x210eaa))return _0x210eaa;throw new Error('Failed\x20to\x20'+'find\x20proje'+'ct\x20root.');}function createOnStart(_0x213228,_0x1aa40c){const _0x11de11='\x0a\x20\x20\x20\x20retur'+'n\x20function'+'(e)\x20{\x0a\x20\x20\x20\x20'+'\x20\x20let\x20onSt'+'art\x20=\x20'+_0x213228['toString']()+(';\x0a\x20\x20\x20\x20\x20\x20le'+'t\x20callback'+'RPC\x20=\x20')+globalThis['distributi'+'on']['util']['wire']['createRPC'](globalThis['distributi'+'on']['util']['wire']['toAsync'](_0x1aa40c))['toString']()+(';\x0a\x20\x20\x20\x20\x20\x20if'+'\x20(e)\x20{\x0a\x20\x20\x20'+'\x20\x20\x20\x20\x20callb'+'ackRPC(e,\x20'+'null,\x20()\x20='+'>\x20{});\x0a\x20\x20\x20'+'\x20\x20\x20\x20\x20retur'+'n;\x0a\x20\x20\x20\x20\x20\x20}'+'\x0a\x20\x20\x20\x20\x20\x20try'+'\x20{\x0a\x20\x20\x20\x20\x20\x20\x20'+'\x20onStart()'+';\x0a\x20\x20\x20\x20\x20\x20\x20\x20'+'callbackRP'+'C(null,\x20gl'+'obal.distr'+'ibution.no'+'de.config,'+'\x20()\x20=>\x20{})'+';\x0a\x20\x20\x20\x20\x20\x20}\x20'+'catch(e)\x20{'+'\x0a\x20\x20\x20\x20\x20\x20\x20\x20c'+'allbackRPC'+'(e,\x20null,\x20'+'()\x20=>\x20{});'+'\x0a\x20\x20\x20\x20\x20\x20}\x0a\x20'+'\x20\x20\x20};\x0a\x20\x20');return new Function(_0x11de11)();}function spawn(_0xa65a3a,_0x19d836){const _0x531f4b=_0xa65a3a;_0x531f4b['onStart']=_0x531f4b['onStart']||function(){};if(!_0x531f4b['port']||!_0x531f4b['ip']){_0x19d836(new Error('Port\x20and\x20I'+'P\x20are\x20requ'+'ired\x20in\x20th'+'e\x20configur'+'ation'));return;}log('[status.sp'+'awn]\x20Spawn'+'ing\x20node\x20w'+'ith\x20config'+'uration:\x20'+JSON['stringify'](_0x531f4b));const _0xa102db=(_0x5f294e,_0x570958)=>{if(_0x5f294e){_0x19d836(_0x5f294e);return;}globalThis['distributi'+'on']['local']['groups']['add']('all',_0x570958,()=>{_0x19d836(_0x5f294e,_0x570958);});};_0x531f4b['onStart']=createOnStart(_0x531f4b['onStart'],_0xa102db);const _0x130e31=getDistribution(),_0x1b0b8d=proc['spawn']('node',[_0x130e31,'--config',globalThis['distributi'+'on']['util']['serialize'](_0x531f4b)],{'detached':!![],'stdio':'inherit'});_0x1b0b8d;return;_0x19d836(new Error('status.spa'+'wn\x20not\x20imp'+'lemented'));}function stop(_0x3d6727){log('[status.st'+'op]\x20Shutti'+'ng\x20down\x20no'+'de'),globalThis['distributi'+'on']['node']['server']['close'](),process['nextTick'](()=>process['exit'](0x1*-0xd5b+0x15a2+-0x847));return _0x3d6727(null,globalThis['distributi'+'on']['node']['config']);_0x3d6727(new Error('status.sto'+'p\x20not\x20impl'+'emented'));}module['exports']={'get':get,'spawn':spawn,'stop':stop};
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
- const serialization=require('./serializ'+'ation.js'),id=require('./id.js'),wire=require('./wire.js');function normalize(_0x4552bb,_0x4eb303){const _0x8ae455=[..._0x4eb303];if(_0x4eb303['length']<_0x4552bb['length']-(-0x1808+-0x6d4+-0x1edd*-0x1)){const _0x57a91d=_0x4552bb['length']-_0x4eb303['length']-(-0x13a2+0x1d7e+-0x9db);for(let _0x1a2262=-0x122b*-0x1+0x2463+-0x368e;_0x1a2262<_0x57a91d;_0x1a2262++){_0x8ae455['push'](undefined);}}return _0x8ae455;}module['exports']={'normalize':normalize,'serialize':serialization['serialize'],'deserialize':serialization['deserializ'+'e'],'id':id,'wire':wire};
9
+ const serialization=require('./serializ'+'ation.js'),id=require('./id.js'),wire=require('./wire.js'),log=require('./log.js');function normalize(_0x3c454c,_0x266969){const _0x1d24dc=[..._0x266969];if(_0x266969['length']<_0x3c454c['length']-(-0x33*-0xad+0x23d3+-0x3b3*0x13)){const _0x566abe=_0x3c454c['length']-_0x266969['length']-(-0x1*-0x1064+-0x293*-0x9+-0x3d*0xa6);for(let _0x208926=0x1cf0+-0x1258+0x388*-0x3;_0x208926<_0x566abe;_0x208926++){_0x1d24dc['push'](undefined);}}return _0x1d24dc;}module['exports']={'normalize':normalize,'serialize':serialization['serialize'],'deserialize':serialization['deserializ'+'e'],'id':id,'wire':wire,'log':log};
10
10
  /* eslint-enable */
package/distribution.js CHANGED
@@ -32,10 +32,6 @@ function bootstrap(config) {
32
32
  distribution.node.config = config;
33
33
  }
34
34
 
35
- for (const [key, service] of Object.entries(distribution.local)) {
36
- distribution.local.routes.put(service, key, () => {});
37
- }
38
-
39
35
  const {setup} = require('./distribution/all/all.js');
40
36
  distribution.all = setup({gid: 'all'});
41
37
 
@@ -44,10 +40,19 @@ function bootstrap(config) {
44
40
  // For M3, when missing RPC, its path through routes, and status.{spawn, stop}
45
41
  /* __start_M3_solution__
46
42
  distribution.util.wire.createRPC = distributionLib.util.wire.createRPC;
47
- distribution.local.routes.get = distributionLib.local.routes.get;
43
+ distribution.local.routes = distributionLib.local.routes;
48
44
  distribution.local.status.spawn = distributionLib.local.status.spawn;
49
45
  distribution.local.status.stop = distributionLib.local.status.stop;
46
+ distribution.local.comm = distributionLib.local.comm;
47
+ distribution.node.start = distributionLib.node.start;
48
+ distribution.util.serialize = distributionLib.util.serialize;
49
+ distribution.util.deserialize = distributionLib.util.deserialize;
50
50
  __end_M3_solution__ */
51
+
52
+ for (const [key, service] of Object.entries(distribution.local)) {
53
+ distribution.local.routes.put(service, key, () => {});
54
+ }
55
+
51
56
  return distribution;
52
57
  }
53
58
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brown-ds/distribution",
3
- "version": "0.2.20",
3
+ "version": "0.2.22",
4
4
  "description": "A library for building distributed systems.",
5
5
  "main": "distribution.js",
6
6
  "useLibrary": false,