UNPKG

@hotmeshio/hotmesh

Version:

Serverless Workflow

1 lines 7.91 kB
'use strict';const p=b;(function(c,d){const o=b,e=c();while(!![]){try{const f=parseInt(o(0x137))/0x1*(-parseInt(o(0x145))/0x2)+parseInt(o(0x13c))/0x3*(-parseInt(o(0x136))/0x4)+parseInt(o(0x130))/0x5*(-parseInt(o(0xeb))/0x6)+parseInt(o(0xff))/0x7*(-parseInt(o(0xe6))/0x8)+-parseInt(o(0x128))/0x9*(-parseInt(o(0x11c))/0xa)+-parseInt(o(0x13f))/0xb*(parseInt(o(0x147))/0xc)+parseInt(o(0x146))/0xd*(parseInt(o(0x14b))/0xe);if(f===d)break;else e['push'](e['shift']());}catch(g){e['push'](e['shift']());}}}(a,0xdd897));function a(){const G=['XSleepFor','depth','4RMsomM','241nNGLId','../../types/hotmesh','reclaimDelay','HMSH_QUORUM_DELAY_MS','active','2818371sFsztv','initSubChannel','defineProperty','247731QoONZU','verifyQuorumFields','rollCall','quorum\x20config\x20must\x20include\x20`store`\x20and\x20`sub`\x20fields.','store','max','5638gBmhOx','13bAgcbN','588IREVFF','getVID','HMSH_QUORUM_ROLLCALL_CYCLES','engine','60383834isrelD','type','until_version','job','push','HMSH_ACTIVATION_MAX_RETRY','info','sayPong','identifyProvider','filter','rollCallInterval','../store/factory','mintKey','random','7657016AkIamL','requestQuorum','setCacheMode','version','STREAMS','7614mGyhSg','length','quorum-activation-succeeded','../../modules/enums','quorum-rollcall-succeeded','throttle','forEach','callbacks','__esModule','stream','details','unsub','router','quorum-activation-awaiting','namespace','counts','warn','activate','quorum-activation-error','untilVersion','7mHyPTD','originator','inited','reserveScoutRole','releaseScoutRole','QuorumService','initStoreChannel','nocache','pub','QUORUM','../sub/factory','routeToSubscribers','getStreamDepths','processWebHooks','rollcall','cache_mode','logger','stream_depth','guid','formatISODate','profiles','\x20not\x20activated.','publish','pong','quorum','debug','processTimeHooks','reclaimCount','StoreServiceFactory','10Iaanil','subscribe','subscriptionHandler','sleepFor','ping','doRollCall','../../modules/utils','cancelRollCall','quorum-event-received','sub','appId','toString','11714994vcBZDG','CompilerService','SubServiceFactory','KeyType','work','interval','cache','profile','4050huTbIP','init','cacheMode','getApp'];a=function(){return G;};return a();}Object[p(0x13e)](exports,p(0xf3),{'value':!0x0}),exports['QuorumService']=void 0x0;const enums_1=require(p(0xee)),utils_1=require(p(0x122)),compiler_1=require('../compiler'),hotmesh_1=require(p(0x138)),factory_1=require(p(0x109)),factory_2=require(p(0xe3));class QuorumService{constructor(){const q=p;this['profiles']=[],this[q(0x132)]=q(0x12e),this['untilVersion']=null,this[q(0x117)]=null,this['callbacks']=[];}static async[p(0x131)](c,d,f,g,h,j){const r=p;if(g['engine']){const k=new QuorumService();return k[r(0x140)](g),k[r(0xf9)]=c,k[r(0x126)]=d,k[r(0x111)]=f,k[r(0x10f)]=j,k['engine']=h,await k[r(0x105)](g[r(0x14a)][r(0x143)]),await k[r(0x13d)](g[r(0x14a)][r(0x125)],g['engine'][r(0x107)]??g[r(0x14a)][r(0x143)]),await k['subscribe']['subscribe'](hotmesh_1[r(0x12b)][r(0x108)],k[r(0x11e)](),d),await k[r(0x11d)][r(0x11d)](hotmesh_1['KeyType'][r(0x108)],k[r(0x11e)](),d,k[r(0x111)]),k['engine'][r(0x10c)](),k['engine'][r(0x119)](),k;}}[p(0x140)](c){const s=p;if(!(0x0,utils_1[s(0xe0)])(c['engine']['store'])||!(0x0,utils_1[s(0xe0)])(c[s(0x14a)][s(0x125)]))throw new Error(s(0x142));}async['initStoreChannel'](c){const t=p;this[t(0x143)]=await factory_2[t(0x11b)][t(0x131)](c,this[t(0xf9)],this[t(0x126)],this[t(0x10f)]);}async[p(0x13d)](c,d){const u=p;this['subscribe']=await factory_1[u(0x12a)][u(0x131)](c,d,this[u(0xf9)],this['appId'],this[u(0x111)],this[u(0x10f)]);}[p(0x11e)](){const c=this;return async(d,f)=>{const v=b;c[v(0x10f)]['debug'](v(0x124),{'topic':d,'type':f['type']}),v(0xfc)===f['type']?c['engine'][v(0xe8)](f[v(0x10e)],f[v(0xda)]):v(0x120)===f['type']?c[v(0xdf)](c[v(0x126)],c['guid'],f[v(0x100)],f[v(0xf5)]):v(0x116)===f['type']&&c[v(0x111)]===f[v(0x100)]?(c[v(0x117)]=c[v(0x117)]+0x1,f[v(0x12f)]&&c['profiles'][v(0xdc)](f[v(0x12f)])):v(0xf0)===f['type']?c[v(0x14a)][v(0xf0)](f[v(0xf0)]):v(0x12c)===f[v(0xd9)]?c[v(0x14a)][v(0x10c)]():'job'===f['type']?c[v(0x14a)][v(0x10a)](f['topic'],f[v(0xdb)]):'cron'===f['type']?c[v(0x14a)][v(0x119)]():v(0x10d)===f['type']&&c[v(0x121)](f),c[v(0xf2)][v(0xec)]>0x0&&c[v(0xf2)][v(0xf1)](g=>g(d,f));};}async[p(0xdf)](c,d,f,g=!0x1){const w=p;let h;if(g){const j=this[w(0x14a)][w(0x143)][w(0xe4)](hotmesh_1[w(0x12b)][w(0xea)],{'appId':this[w(0x126)]});h={'engine_id':this[w(0x111)],'namespace':this[w(0xf9)],'app_id':this[w(0x126)],'stream':j,'counts':this[w(0x14a)][w(0xf7)][w(0xfa)],'timestamp':(0x0,utils_1[w(0x112)])(new Date()),'inited':this['engine'][w(0x101)],'throttle':this[w(0x14a)][w(0xf7)][w(0xf0)],'reclaimDelay':this[w(0x14a)][w(0xf7)][w(0x139)],'reclaimCount':this['engine'][w(0xf7)][w(0x11a)],'system':await(0x0,utils_1['getSystemHealth'])()};}this[w(0x11d)]['publish'](hotmesh_1[w(0x12b)][w(0x108)],{'type':w(0x116),'guid':d,'originator':f,'profile':h},c);}async[p(0xe7)](c=enums_1[p(0x13a)],d=!0x1){const x=p,f=this[x(0x117)];return this[x(0x117)]=0x0,this[x(0x113)][x(0xec)]=0x0,await this[x(0x11d)][x(0x115)](hotmesh_1['KeyType'][x(0x108)],{'type':x(0x120),'originator':this[x(0x111)],'details':d},this[x(0x126)]),await(0x0,utils_1[x(0x11f)])(c),f;}async[p(0x121)](c){const y=p;let d=0x0;const f=isNaN(c['max'])?enums_1[y(0x149)]:c[y(0x144)];this['rollCallInterval']&&clearTimeout(this['rollCallInterval']);const g=c[y(0x12d)]/0x2,h=g+Math['ceil'](Math[y(0xe5)]()*g);do{if(await(0x0,utils_1[y(0x11f)])(Math['ceil'](0x3e8*Math[y(0xe5)]())),await this[y(0xdf)](this[y(0x126)],this[y(0x111)],null,!0x0),!c['interval'])return;const {promise:j,timerId:k}=(0x0,utils_1[y(0x134)])(0x3e8*h);this[y(0xe2)]=k,await j;}while(this['rollCallInterval']&&d++<f-0x1);}[p(0x123)](){const z=p;this['rollCallInterval']&&(clearTimeout(this[z(0xe2)]),delete this['rollCallInterval']);}['stop'](){this['cancelRollCall']();}async['pub'](c){const A=p;return await this[A(0x11d)][A(0x115)](hotmesh_1['KeyType'][A(0x108)],c,this[A(0x126)],c['topic']||c[A(0x111)]);}async[p(0x125)](c){const B=p;this[B(0xf2)][B(0xdc)](c);}async[p(0xf6)](c){const C=p;this['callbacks']=this[C(0xf2)][C(0xe1)](d=>d!==c);}async[p(0x141)](c=enums_1[p(0x13a)]){const D=p;await this[D(0xe7)](c,!0x0);const d=await this[D(0x14a)][D(0xf4)][D(0x10b)](this[D(0x113)]);return this[D(0x113)]['forEach'](async(f,g)=>{const E=D;f[E(0x110)]=d?.[g]?.[E(0x135)]??0x0;}),this[D(0x113)];}async[p(0xfc)](c,d=enums_1['HMSH_QUORUM_DELAY_MS'],f=0x0){const F=p;c=c[F(0x127)]();if(!await this[F(0x143)][F(0x102)]('activate',Math['ceil'](0x6*d/0x3e8)+0x1)){this[F(0x10f)][F(0x118)](F(0xf8),{'version':c}),await(0x0,utils_1['sleepFor'])(0x6*d);const l=await this[F(0x143)][F(0x133)](this[F(0x126)],!0x0);return 0x1==l?.[F(0x13b)]&&l?.[F(0xe9)]===c;}const g=await this[F(0x14a)][F(0x148)]();await this[F(0xe7)](d);const h=await this[F(0xe7)](d),j=await this[F(0xe7)](d),k=await this[F(0xe7)](d);if(h&&h===j&&j===k){if(this[F(0x10f)][F(0xde)](F(0xef),{'q1':h,'q2':j,'q3':k}),this[F(0x11d)][F(0x115)](hotmesh_1['KeyType']['QUORUM'],{'type':F(0xfc),'cache_mode':F(0x106),'until_version':c},this[F(0x126)]),await new Promise(m=>setTimeout(m,d)),await this[F(0x143)][F(0x103)]('activate'),this[F(0x14a)][F(0xfe)]===c){this[F(0x10f)][F(0xde)](F(0xed),{'version':c});const {id:m}=g,n=new compiler_1[(F(0x129))](this[F(0x143)],this[F(0x14a)][F(0xf4)],this['logger']);return await n[F(0xfc)](m,c);}throw this['logger']['error'](F(0xfd),{'version':c}),new Error('UntilVersion\x20Not\x20Received.\x20Version\x20'+c+'\x20not\x20activated');}if(this[F(0x10f)][F(0xfb)]('quorum-rollcall-error',{'q1':h,'q2':j,'q3':k,'count':f}),this[F(0x143)][F(0x103)](F(0xfc)),f<enums_1[F(0xdd)])return await this[F(0xfc)](c,0x2*d,f+0x1);throw new Error('Quorum\x20not\x20reached.\x20Version\x20'+c+F(0x114));}}function b(c,d){const e=a();return b=function(f,g){f=f-0xd9;let h=e[f];return h;},b(c,d);}exports[p(0x104)]=QuorumService;