@brown-ds/distribution 0.1.7 → 0.1.8

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('http'),url=require('url'),log=require('../util/lo'+'g'),serialization=require('../util/se'+'rializatio'+'n');function isValidBody(_0x377981){if(_0x377981['length']===-0x1814+-0x1cf9*0x1+0x350d)return new Error('No\x20body');try{_0x377981=JSON['parse'](_0x377981);}catch(_0x185f27){return _0x185f27;}return undefined;}function endRequest(_0x540e16,_0x3d1ccb){_0x540e16['end'](serialization['serialize']([_0x3d1ccb]));}const start=function(_0x966886){const _0x3a6518=http['createServ'+'er']((_0x81d7f9,_0x24b09d)=>{if(_0x81d7f9['method']!=='PUT'){_0x24b09d['end'](serialization['serialize'](new Error('Method\x20not'+'\x20allowed!')));return;}const _0x25b575=url['parse'](_0x81d7f9['url'])['pathname'],[,_0x10d46f,_0x549703,_0x7b93c4]=_0x25b575['split']('/');log('[server]\x20g'+'ot\x20request'+'\x20'+_0x10d46f+'\x20'+_0x549703+':'+_0x7b93c4+'\x20from\x20'+_0x81d7f9['connection']['remoteAddr'+'ess']);let _0x5b05d9=[];_0x81d7f9['on']('data',_0x259bfc=>{_0x5b05d9['push'](_0x259bfc);}),_0x81d7f9['on']('end',()=>{_0x5b05d9=Buffer['concat'](_0x5b05d9)['toString']();let _0x3c4071;if(_0x3c4071=isValidBody(_0x5b05d9)){endRequest(_0x24b09d,_0x3c4071);return;}_0x5b05d9=JSON['parse'](_0x5b05d9),_0x5b05d9=serialization['deserializ'+'e'](_0x5b05d9);const _0xeab15c=_0x5b05d9;!Array['isArray'](_0xeab15c)&&endRequest(_0x24b09d,new Error('Invalid\x20ar'+'gument\x20typ'+'e,\x20expecte'+'d\x20array,\x20g'+'ot\x20'+typeof _0xeab15c));const _0x336473=_0x549703;global['distributi'+'on']['local']['routes']['get']({'service':_0x549703,'gid':_0x10d46f},(_0x53dc03,_0x1c3871)=>{const _0x9e7383=(_0x365a8e,_0x1d3e09)=>{_0x24b09d['end'](serialization['serialize']([_0x365a8e,_0x1d3e09]));};if(_0x53dc03){_0x9e7383(_0x53dc03);return;}if(!_0x1c3871[_0x7b93c4]){_0x9e7383(new Error('Method\x20'+_0x7b93c4+('\x20not\x20found'+'\x20in\x20servic'+'e\x20')+_0x336473));return;}log('[server]\x20\x20'+'Calling\x20se'+'rvice:\x20'+_0x336473+':'+_0x7b93c4+('\x20with\x20args'+':\x20')+JSON['stringify'](_0xeab15c));_0xeab15c['length']===-0x1ecd+-0x33*0x95+0x3c7d&&_0x1c3871[_0x7b93c4]['length']===0x43f*0x1+-0x9*0x24+-0x28*0x13&&_0xeab15c['push'](undefined);try{_0x1c3871[_0x7b93c4](..._0xeab15c,_0x9e7383);}catch(_0xebf001){_0x9e7383(_0xebf001);}});});});_0x3a6518['listen'](global['nodeConfig']['port'],global['nodeConfig']['ip'],()=>{log('Server\x20run'+'ning\x20at\x20ht'+'tp://'+global['nodeConfig']['ip']+':'+global['nodeConfig']['port']+'/'),global['distributi'+'on']['node']['server']=_0x3a6518,_0x966886(_0x3a6518);}),_0x3a6518['on']('error',_0x51f1ef=>{log('Server\x20err'+'or:\x20'+_0x51f1ef);throw _0x51f1ef;});};module['exports']={'start':start};
9
+ const http=require('http'),url=require('url'),log=require('../util/lo'+'g'),serialization=require('../util/se'+'rializatio'+'n');function isValidBody(_0x4c3a39){if(_0x4c3a39['length']===-0x2493+0x1399*0x1+0x10fa)return new Error('No\x20body');try{_0x4c3a39=JSON['parse'](_0x4c3a39);}catch(_0x59b2c1){return _0x59b2c1;}return undefined;}function endRequest(_0x57bcac,_0xf40322){_0x57bcac['end'](serialization['serialize']([_0xf40322]));}const start=function(_0xad6612){const _0x346156=http['createServ'+'er']((_0x2c7bc6,_0x764d1d)=>{if(_0x2c7bc6['method']!=='PUT'){_0x764d1d['end'](serialization['serialize'](new Error('Method\x20not'+'\x20allowed!')));return;}const _0x2cf799=url['parse'](_0x2c7bc6['url'])['pathname'],[,_0x2e70ee,_0x3c26fb,_0x29f792]=_0x2cf799['split']('/');log('[server]\x20g'+'ot\x20request'+'\x20'+_0x2e70ee+'\x20'+_0x3c26fb+':'+_0x29f792+'\x20from\x20'+_0x2c7bc6['connection']['remoteAddr'+'ess']);let _0x6e3a2b=[];_0x2c7bc6['on']('data',_0x5b5087=>{_0x6e3a2b['push'](_0x5b5087);}),_0x2c7bc6['on']('end',()=>{_0x6e3a2b=Buffer['concat'](_0x6e3a2b)['toString']();let _0x3c28d0;if(_0x3c28d0=isValidBody(_0x6e3a2b)){endRequest(_0x764d1d,_0x3c28d0);return;}_0x6e3a2b=JSON['parse'](_0x6e3a2b),_0x6e3a2b=serialization['deserializ'+'e'](_0x6e3a2b);const _0x58fb43=_0x6e3a2b;!Array['isArray'](_0x58fb43)&&endRequest(_0x764d1d,new Error('Invalid\x20ar'+'gument\x20typ'+'e,\x20expecte'+'d\x20array,\x20g'+'ot\x20'+typeof _0x58fb43));const _0x288319=_0x3c26fb;global['distributi'+'on']['local']['routes']['get']({'service':_0x3c26fb,'gid':_0x2e70ee},(_0x54c3b6,_0x250f7c)=>{const _0x3abf4b=(_0x77c04,_0x2cf3f4)=>{_0x764d1d['end'](serialization['serialize']([_0x77c04,_0x2cf3f4]));};if(_0x54c3b6){_0x3abf4b(_0x54c3b6);return;}if(!_0x250f7c[_0x29f792]){_0x3abf4b(new Error('Method\x20'+_0x29f792+('\x20not\x20found'+'\x20in\x20servic'+'e\x20')+_0x288319));return;}log('[server]\x20\x20'+'Calling\x20se'+'rvice:\x20'+_0x288319+':'+_0x29f792+('\x20with\x20args'+':\x20')+JSON['stringify'](_0x58fb43));_0x58fb43['length']===-0x12a9+-0x1*-0x960+0x1*0x94a&&_0x250f7c[_0x29f792]['length']===0x98a*-0x2+-0x27*-0x89+-0x1c8&&_0x58fb43['push'](undefined);try{_0x250f7c[_0x29f792](..._0x58fb43,_0x3abf4b);}catch(_0x5e53a3){_0x3abf4b(_0x5e53a3);}});});});_0x346156['listen'](global['nodeConfig']['port'],global['nodeConfig']['ip'],()=>{log('Server\x20run'+'ning\x20at\x20ht'+'tp://'+global['nodeConfig']['ip']+':'+global['nodeConfig']['port']+'/'),global['distributi'+'on']['node']['server']=_0x346156,_0xad6612(_0x346156);}),_0x346156['on']('error',_0x3b7e44=>{log('Server\x20err'+'or:\x20'+_0x3b7e44);throw _0x3b7e44;});};module['exports']={'start':start};
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 id=require('../util/id'),log=require('../util/lo'+'g'),status={};global['moreStatus']={'sid':id['getSID'](global['nodeConfig']),'nid':id['getNID'](global['nodeConfig']),'counts':0x0},status['get']=function(_0x1be8dc,_0x4c0a93){_0x4c0a93=_0x4c0a93||function(){};if(_0x1be8dc in global['nodeConfig']){_0x4c0a93(null,global['nodeConfig'][_0x1be8dc]);return;}if(_0x1be8dc in global['moreStatus']){_0x4c0a93(null,global['moreStatus'][_0x1be8dc]);return;}if(_0x1be8dc==='heapTotal'){_0x4c0a93(null,process['memoryUsag'+'e']()['heapTotal']);return;}if(_0x1be8dc==='heapUsed'){_0x4c0a93(null,process['memoryUsag'+'e']()['heapUsed']);return;}_0x4c0a93(new Error('Status\x20key'+'\x20not\x20found'));};const path=require('path'),{spawn}=require('child_proc'+'ess'),wire=require('../util/wi'+'re'),createSpawnedCb=function(_0x2879fd,_0x27dd3e){const _0x14c6a3='\x0a\x20\x20\x20\x20let\x20o'+'nStart\x20=\x20'+_0x2879fd['toString']()+(';\x0a\x0a\x20\x20\x20\x20let'+'\x20callbackR'+'PC\x20=\x20')+wire['createRPC'](wire['toAsync'](_0x27dd3e))['toString']()+(';\x0a\x0a\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.nodeC'+'onfig,\x20()\x20'+'=>\x20{});\x0a\x20\x20'+'\x20\x20}\x0a\x20\x20\x20\x20ca'+'tch\x20(e)\x20{\x0a'+'\x20\x20\x20\x20\x20\x20\x20\x20ca'+'llbackRPC('+'e,\x20null,\x20('+')\x20=>\x20{});\x0a'+'\x20\x20\x20\x20}\x0a\x20\x20\x20\x20');return new Function(_0x14c6a3);};status['spawn']=function(_0x20a828,_0x1e970c){const _0x428b72=_0x20a828;_0x428b72['onStart']=_0x428b72['onStart']||function(){};if(!_0x428b72['port']||!_0x428b72['ip']){_0x1e970c(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'](_0x428b72)),_0x428b72['onStart']=createSpawnedCb(_0x428b72['onStart'],_0x1e970c);const _0x50ef78=path['join'](__dirname,'../../dist'+'ribution.j'+'s'),_0x4b345b=spawn('node',[_0x50ef78,'--config',global['distributi'+'on']['util']['serialize'](_0x428b72)],{'detached':!![],'stdio':'inherit'});_0x4b345b;},status['stop']=function(_0x1c7ed2){_0x1c7ed2=_0x1c7ed2||function(){},_0x1c7ed2(null,global['nodeConfig']),log('[status.st'+'op]\x20Shutti'+'ng\x20down\x20no'+'de'),global['distributi'+'on']['node']['server']['close'](),process['exit'](0x11*0x10b+-0x1*-0x2335+-0x34f0);},module['exports']=status;
9
+ const id=require('../util/id'),log=require('../util/lo'+'g'),status={};global['moreStatus']={'sid':id['getSID'](global['nodeConfig']),'nid':id['getNID'](global['nodeConfig']),'counts':0x0},status['get']=function(_0x2b5ce7,_0x5ee026){_0x5ee026=_0x5ee026||function(){};if(_0x2b5ce7 in global['nodeConfig']){_0x5ee026(null,global['nodeConfig'][_0x2b5ce7]);return;}if(_0x2b5ce7 in global['moreStatus']){_0x5ee026(null,global['moreStatus'][_0x2b5ce7]);return;}if(_0x2b5ce7==='heapTotal'){_0x5ee026(null,process['memoryUsag'+'e']()['heapTotal']);return;}if(_0x2b5ce7==='heapUsed'){_0x5ee026(null,process['memoryUsag'+'e']()['heapUsed']);return;}_0x5ee026(new Error('Status\x20key'+'\x20not\x20found'));};const path=require('path'),{spawn}=require('child_proc'+'ess'),wire=require('../util/wi'+'re'),createSpawnedCb=function(_0x5d134e,_0x4dae95){const _0x1a5ad8='\x0a\x20\x20\x20\x20let\x20o'+'nStart\x20=\x20'+_0x5d134e['toString']()+(';\x0a\x0a\x20\x20\x20\x20let'+'\x20callbackR'+'PC\x20=\x20')+wire['createRPC'](wire['toAsync'](_0x4dae95))['toString']()+(';\x0a\x0a\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.nodeC'+'onfig,\x20()\x20'+'=>\x20{});\x0a\x20\x20'+'\x20\x20}\x0a\x20\x20\x20\x20ca'+'tch\x20(e)\x20{\x0a'+'\x20\x20\x20\x20\x20\x20\x20\x20ca'+'llbackRPC('+'e,\x20null,\x20('+')\x20=>\x20{});\x0a'+'\x20\x20\x20\x20}\x0a\x20\x20\x20\x20');return new Function(_0x1a5ad8);};status['spawn']=function(_0x3f1a05,_0x6d6fee){const _0x383824=_0x3f1a05;_0x383824['onStart']=_0x383824['onStart']||function(){};if(!_0x383824['port']||!_0x383824['ip']){_0x6d6fee(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'](_0x383824)),_0x383824['onStart']=createSpawnedCb(_0x383824['onStart'],_0x6d6fee);const _0x57dd81=path['join'](__dirname,'../../dist'+'ribution.j'+'s'),_0x51bab0=spawn('node',[_0x57dd81,'--config',global['distributi'+'on']['util']['serialize'](_0x383824)],{'detached':!![],'stdio':'inherit'});_0x51bab0;},status['stop']=function(_0x9812ba){_0x9812ba=_0x9812ba||function(){},_0x9812ba(null,global['nodeConfig']),log('[status.st'+'op]\x20Shutti'+'ng\x20down\x20no'+'de'),global['distributi'+'on']['node']['server']['close'](),process['exit'](0x1599+-0x2510+-0x6b*-0x25);},module['exports']=status;
10
10
  /* eslint-enable */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brown-ds/distribution",
3
- "version": "0.1.7",
3
+ "version": "0.1.8",
4
4
  "description": "A library for building distributed systems.",
5
5
  "main": "distribution.js",
6
6
  "useLibrary": false,