UNPKG

@hotmeshio/hotmesh

Version:

Serverless Workflow

1 lines 5.76 kB
'use strict';function a(){const F=['store','isArray','rollCallInterval','defineProperty','initRouter','doRollCall','SubServiceFactory','guid','1089756ohnvKa','reclaimCount','../sub/factory','logger','subscriptionHandler','initSubChannel','router','appId','setThrottle','94764nuydeM','consumeMessages','max','ceil','HMSH_QUORUM_ROLLCALL_CYCLES','subscribe','originator','stop','WORKER','722010judZMi','identifyProvider','sayPong','initStreamChannel','interval','getThrottleRate','93270LSqRkH','279630CoFiWa','inited','stream','toString','ConnectorService','reclaimDelay','../../modules/utils','mintKey','STREAMS','topic','verifyWorkerFields','throttle','ping','cancelRollCall','StreamServiceFactory','../../modules/enums','pub','counts','96525LdHsts','signature','pong','__esModule','../stream/factory','config','type','callback','details','initClients','worker\x20must\x20include\x20`store`,\x20`stream`,\x20and\x20`sub`\x20fields\x20along\x20with\x20a\x20callback\x20function\x20and\x20topic.','namespace','init','306936XSbZdV','KeyType','QUORUM','WorkerService','initStoreChannel','worker-event-received','../connector/factory','reporting','formatISODate','StreamRole','random','StoreServiceFactory','../store/factory'];a=function(){return F;};return a();}const r=b;(function(c,d){const q=b,e=c();while(!![]){try{const f=-parseInt(q(0x1d9))/0x1+-parseInt(q(0x214))/0x2+-parseInt(q(0x213))/0x3+parseInt(q(0x1fb))/0x4+parseInt(q(0x20d))/0x5+-parseInt(q(0x204))/0x6+parseInt(q(0x1e6))/0x7;if(f===d)break;else e['push'](e['shift']());}catch(g){e['push'](e['shift']());}}}(a,0x2b539));function b(c,d){const e=a();return b=function(f,g){f=f-0x1cb;let h=e[f];return h;},b(c,d);}Object[r(0x1f6)](exports,r(0x1dc),{'value':!0x0}),exports[r(0x1e9)]=void 0x0;const key_1=require('../../modules/key'),utils_1=require(r(0x1cd)),factory_1=require(r(0x1ec)),router_1=require('../router'),stream_1=require('../../types/stream'),enums_1=require(r(0x1d6)),factory_2=require(r(0x1dd)),factory_3=require(r(0x1fd)),factory_4=require(r(0x1f2));class WorkerService{constructor(){const s=r;this[s(0x1ed)]=!0x1;}static async['init'](c,d,f,g,h){const t=r,j=[];if(Array[t(0x1f4)](g['workers']))for(const k of g['workers']){await factory_1[t(0x1cb)][t(0x1e2)](k);const m=new WorkerService();m[t(0x1d1)](k),m[t(0x1e4)]=c,m[t(0x202)]=d,m[t(0x1fa)]=f,m[t(0x1e0)]=k['callback'],m['topic']=k['topic'],m[t(0x1de)]=g,m[t(0x1fe)]=h,await m['initStoreChannel'](m,k[t(0x1f3)]),await m[t(0x200)](m,k['sub'],k[t(0x1d7)]??k[t(0x1f3)]),await m[t(0x209)][t(0x209)](key_1[t(0x1e7)]['QUORUM'],m[t(0x1ff)](),d),await m[t(0x209)]['subscribe'](key_1[t(0x1e7)]['QUORUM'],m[t(0x1ff)](),d,m[t(0x1d0)]),await m[t(0x209)][t(0x209)](key_1[t(0x1e7)][t(0x1e8)],m[t(0x1ff)](),d,m[t(0x1fa)]),await m[t(0x210)](m,k[t(0x216)],k['store']),m[t(0x201)]=await m[t(0x1f7)](k,h);const p=m[t(0x1f3)][t(0x1ce)](key_1[t(0x1e7)][t(0x1cf)],{'appId':m[t(0x202)],'topic':k['topic']});await m[t(0x201)][t(0x205)](p,t(0x20c),m[t(0x1fa)],k[t(0x1e0)]),m[t(0x215)]=(0x0,utils_1[t(0x1ee)])(new Date()),j['push'](m);}return j;}[r(0x1d1)](c){const u=r;if(!((0x0,utils_1[u(0x20e)])(c[u(0x1f3)])&&(0x0,utils_1[u(0x20e)])(c[u(0x216)])&&(0x0,utils_1[u(0x20e)])(c['sub'])&&c['topic']&&c['callback']))throw new Error(u(0x1e3));}async[r(0x1ea)](c,d){const v=r;c[v(0x1f3)]=await factory_4[v(0x1f1)][v(0x1e5)](d,c[v(0x1e4)],c['appId'],c[v(0x1fe)]);}async[r(0x200)](c,d,f){const w=r;c[w(0x209)]=await factory_3[w(0x1f9)][w(0x1e5)](d,f,c[w(0x1e4)],c[w(0x202)],c[w(0x1fa)],c[w(0x1fe)]);}async[r(0x210)](c,d,f){const x=r;c[x(0x216)]=await factory_2[x(0x1d5)][x(0x1e5)](d,f,c[x(0x1e4)],c[x(0x202)],c[x(0x1fe)]);}async[r(0x1f7)](c,d){const y=r,f=await this['store'][y(0x212)](c[y(0x1d0)]);return new router_1['Router']({'namespace':this[y(0x1e4)],'appId':this[y(0x202)],'guid':this[y(0x1fa)],'role':stream_1[y(0x1ef)]['WORKER'],'topic':c[y(0x1d0)],'reclaimDelay':c[y(0x1cc)],'reclaimCount':c['reclaimCount'],'throttle':f},this['stream'],d);}[r(0x1ff)](){const c=this;return async(d,f)=>{const z=b;c['logger']['debug'](z(0x1eb),{'topic':d,'type':f['type']}),'throttle'===f[z(0x1df)]?null!==f[z(0x1d0)]&&c[z(0x1d2)](f[z(0x1d2)]):z(0x1d3)===f['type']?c[z(0x20f)](c[z(0x202)],c['guid'],f[z(0x20a)],f[z(0x1e1)]):'rollcall'===f[z(0x1df)]&&null!==f[z(0x1d0)]&&c[z(0x1f8)](f);};}async[r(0x1f8)](c){const A=r;let d=0x0;const f=isNaN(c[A(0x206)])?enums_1[A(0x208)]:c[A(0x206)];this[A(0x1f5)]&&clearTimeout(this[A(0x1f5)]);const g=c['interval']/0x2,h=g+Math[A(0x207)](Math[A(0x1f0)]()*g);do{if(await(0x0,utils_1['sleepFor'])(Math['ceil'](0x3e8*Math[A(0x1f0)]())),await this[A(0x20f)](this[A(0x202)],this['guid'],null,!0x0,c[A(0x1da)]),!c[A(0x211)])return;const {promise:j,timerId:k}=(0x0,utils_1['XSleepFor'])(0x3e8*h);this[A(0x1f5)]=k,await j;}while(this['rollCallInterval']&&d++<f-0x1);}[r(0x1d4)](){const B=r;this[B(0x1f5)]&&(clearTimeout(this[B(0x1f5)]),delete this['rollCallInterval']);}[r(0x20b)](){const C=r;this[C(0x1d4)]();}async[r(0x20f)](c,d,f,g=!0x1,h=!0x1){const D=r;let j;if(g){const k={'appId':this[D(0x202)],'topic':this[D(0x1d0)]};j={'engine_id':this[D(0x1fa)],'namespace':this[D(0x1e4)],'app_id':this[D(0x202)],'worker_topic':this['topic'],'stream':this[D(0x1f3)][D(0x1ce)](key_1[D(0x1e7)][D(0x1cf)],k),'counts':this[D(0x201)]?.[D(0x1d8)],'timestamp':(0x0,utils_1[D(0x1ee)])(new Date()),'inited':this[D(0x215)],'throttle':this[D(0x201)]?.['throttle'],'reclaimDelay':this[D(0x201)]?.['reclaimDelay'],'reclaimCount':this['router']?.[D(0x1fc)],'system':await(0x0,utils_1['getSystemHealth'])(),'signature':h?this['callback'][D(0x217)]():void 0x0};}this[D(0x209)]['publish'](key_1[D(0x1e7)]['QUORUM'],{'type':D(0x1db),'guid':d,'originator':f,'profile':j},c);}async[r(0x1d2)](c){const E=r;this[E(0x201)]?.[E(0x203)](c);}}exports[r(0x1e9)]=WorkerService;