@hotmeshio/hotmesh
Version:
Serverless Workflow
1 lines • 3.76 kB
JavaScript
const q=b;(function(c,d){const m=b,e=c();while(!![]){try{const f=-parseInt(m(0x188))/0x1+parseInt(m(0x194))/0x2+parseInt(m(0x191))/0x3*(parseInt(m(0x183))/0x4)+parseInt(m(0x17c))/0x5*(-parseInt(m(0x18f))/0x6)+parseInt(m(0x18e))/0x7+-parseInt(m(0x18d))/0x8+-parseInt(m(0x195))/0x9*(-parseInt(m(0x17d))/0xa);if(f===d)break;else e['push'](e['shift']());}catch(g){e['push'](e['shift']());}}}(a,0xeddea));function b(c,d){const e=a();return b=function(f,g){f=f-0x17c;let h=e[f];return h;},b(c,d);}async function deploySchema(c,d,f){const n=b,g=n(0x181)in c&&n(0x17e)in c?await c[n(0x181)]():c,h=n(0x17e)in c;try{const i=getAdvisoryLockId(d);if(!(await g[n(0x192)](n(0x19d),[i]))[n(0x198)][0x0][n(0x189)])throw new Error('Table\x20deployment\x20in\x20progress\x20by\x20another\x20process.');{await g[n(0x192)](n(0x190));const j=d[n(0x17f)](/[^a-zA-Z0-9_]/g,'_'),k=j+'.streams';await createTables(g,j,k),await g[n(0x192)]('COMMIT'),await g['query'](n(0x180),[i]);}}catch(l){throw f[n(0x199)](n(0x186),{'error':l}),l;}finally{h&&await g[n(0x17e)]();}}function a(){const r=['rows','error','\x0a\x20\x20\x20\x20\x20\x20FOR\x20VALUES\x20WITH\x20(modulus\x208,\x20remainder\x20','__esModule','CREATE\x20SCHEMA\x20IF\x20NOT\x20EXISTS\x20','SELECT\x20pg_try_advisory_lock($1)\x20AS\x20locked','abs','\x20(\x0a\x20\x20\x20\x20\x20\x20id\x20BIGSERIAL,\x0a\x20\x20\x20\x20\x20\x20stream_name\x20TEXT\x20NOT\x20NULL,\x0a\x20\x20\x20\x20\x20\x20group_name\x20TEXT\x20NOT\x20NULL\x20DEFAULT\x20\x27ENGINE\x27,\x0a\x20\x20\x20\x20\x20\x20message\x20TEXT\x20NOT\x20NULL,\x0a\x20\x20\x20\x20\x20\x20created_at\x20TIMESTAMPTZ\x20DEFAULT\x20NOW(),\x0a\x20\x20\x20\x20\x20\x20reserved_at\x20TIMESTAMPTZ,\x0a\x20\x20\x20\x20\x20\x20reserved_by\x20TEXT,\x0a\x20\x20\x20\x20\x20\x20expired_at\x20TIMESTAMPTZ,\x0a\x20\x20\x20\x20\x20\x20PRIMARY\x20KEY\x20(stream_name,\x20id)\x0a\x20\x20\x20\x20)\x20PARTITION\x20BY\x20HASH\x20(stream_name);\x0a\x20\x20','445fJhQsm','10FGSthe','release','replace','SELECT\x20pg_advisory_unlock($1)','connect','\x0a\x20\x20\x20\x20CREATE\x20INDEX\x20IF\x20NOT\x20EXISTS\x20idx_streams_expired_at\x20\x0a\x20\x20\x20\x20ON\x20','22720zAeqOr','deploySchema','\x0a\x20\x20\x20\x20CREATE\x20TABLE\x20IF\x20NOT\x20EXISTS\x20','Error\x20deploying\x20schema','length','615963umCfKL','locked','\x20(group_name,\x20stream_name,\x20reserved_at,\x20id)\x0a\x20\x20\x20\x20WHERE\x20reserved_at\x20IS\x20NULL\x20AND\x20expired_at\x20IS\x20NULL;\x0a\x20\x20','charCodeAt',');\x0a\x20\x20\x20\x20','5679472Hhquqq','3812613sejpXO','90084YBtADi','BEGIN','582JXhHOY','query','\x0a\x20\x20\x20\x20\x20\x20CREATE\x20TABLE\x20IF\x20NOT\x20EXISTS\x20','2143808RWLfnk','8261766NVUIKN','defineProperty','.streams_part_'];a=function(){return r;};return a();}function getAdvisoryLockId(c){return hashStringToInt(c);}function hashStringToInt(c){const o=b;let d=0x0;for(let f=0x0;f<c[o(0x187)];f++)d=(d<<0x5)-d+c[o(0x18b)](f),d|=0x0;return Math[o(0x19e)](d);}async function createTables(c,d,f){const p=b;await c[p(0x192)](p(0x19c)+d+';'),await c[p(0x192)](p(0x185)+f+p(0x19f));for(let g=0x0;g<0x8;g++){const h=d+p(0x197)+g;await c['query'](p(0x193)+h+'\x0a\x20\x20\x20\x20\x20\x20PARTITION\x20OF\x20'+f+p(0x19a)+g+p(0x18c));}await c['query']('\x0a\x20\x20\x20\x20CREATE\x20INDEX\x20IF\x20NOT\x20EXISTS\x20idx_streams_active_messages\x20\x0a\x20\x20\x20\x20ON\x20'+f+p(0x18a)),await c['query'](p(0x182)+f+'\x20(expired_at);\x0a\x20\x20'),await c[p(0x192)]('\x0a\x20\x20\x20\x20CREATE\x20INDEX\x20IF\x20NOT\x20EXISTS\x20idx_stream_name_expired_at\x0a\x20\x20\x20\x20ON\x20'+f+'\x20(stream_name)\x0a\x20\x20\x20\x20WHERE\x20expired_at\x20IS\x20NULL;\x0a\x20\x20');}Object[q(0x196)](exports,q(0x19b),{'value':!0x0}),exports['deploySchema']=void 0x0,exports[q(0x184)]=deploySchema;
;