@arcane-utils/ingestion
Version:
Ingestion utilities for Arcane
2 lines • 2.31 kB
JavaScript
var l=Object.defineProperty;var w=Object.getOwnPropertyDescriptor;var _=Object.getOwnPropertyNames;var y=Object.prototype.hasOwnProperty;var v=(e,t)=>{for(var n in t)l(e,n,{get:t[n],enumerable:!0})},D=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of _(t))!y.call(e,i)&&i!==n&&l(e,i,{get:()=>t[i],enumerable:!(o=w(t,i))||o.enumerable});return e};var S=e=>D(l({},"__esModule",{value:!0}),e);var E={};v(E,{SkipExecutionError:()=>r,handleStartExecution:()=>$,setIngestionExecutionInfoAsStart:()=>f});module.exports=S(E);var r=class extends Error{constructor(t){super(t),this.name="SkipExecutionError"}},P=e=>{let t=18e5;return e==="BIG_QUERY"||e==="HTTP"?t=90*60*1e3:e==="SHOPIFY_API"&&(t=60*60*1e3),t},f=async(e,t,n)=>{let o=t.id.toString(),i=new Date;i.setMilliseconds(0);let c={...t.execution_info??{},status:"running",timestamp:i,errors:[]};await n(o,{execution_info:c},e)},$=async(e,t,n,o,i,c,p,g=0)=>{let h=e.monitoring_id,s=parseInt(e.entity_id,10),d=e.schedule_version;if(e.manual_execution??!1)i.info(`Manual execution for entity with id ${s}. Running without checking schedule version and execution status.`);else{let a="schedule_version"in t.parameters?t.parameters.schedule_version:void 0;if(t.enabled===!1)throw i.info(`Entity with id ${s} is disabled. Skipping execution.`),new r("Entity is disabled");if(d!==a)throw i.info(`Entity with id ${s} has its schedule info. Previous version ${d} and ${a??""}`),new r(`Schedule info is outdated. Previous version ${d} and current version ${a??""}`);if(t.execution_info!=null&&"status"in t.execution_info&&t.execution_info.status==="running"){let u=t.execution_info.timestamp;if(u!=null){let m=u instanceof Date?u:new Date(u),x=Date.now()-m.getTime(),I=P(o);if(x<I)if(g>0)i.warn(`Entity with id ${s} is already running but this is a Cloud Tasks retry (retry_count=${g}). Allowing retry.`);else throw i.info(`Entity with id ${s} is already running since ${m.toISOString()}. Skipping execution.`),new r("Previous execution is still running")}}await f(n,t,p)}if(t.service!=="datalab")try{await c(t.id,h,"start",i)}catch{i.error(`Failed to publish start monitoring message for entity ${s}`)}};0&&(module.exports={SkipExecutionError,handleStartExecution,setIngestionExecutionInfoAsStart});
//# sourceMappingURL=executionHandler.cjs.map