@brown-ds/distribution 0.2.20 → 0.2.21

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 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.node.util.serialize = distributionLib.node.util.serialize;
49
+ distribution.node.util.deserialize = distributionLib.node.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.21",
4
4
  "description": "A library for building distributed systems.",
5
5
  "main": "distribution.js",
6
6
  "useLibrary": false,