| 66 | private executionTask: Promise<dataform.IRunResult>; |
| 67 | |
| 68 | constructor( |
| 69 | private readonly dbadapter: dbadapters.IDbAdapter, |
| 70 | private readonly graph: dataform.IExecutionGraph, |
| 71 | private readonly executionOptions: IExecutionOptions = {}, |
| 72 | partiallyExecutedRunResult: dataform.IRunResult = {}, |
| 73 | private readonly runnerNotificationPeriodMillis: number = flags.runnerNotificationPeriodMillis.get() |
| 74 | ) { |
| 75 | this.allActionTargets = new Set<string>( |
| 76 | graph.actions.map(action => targetStringifier.stringify(action.target)) |
| 77 | ); |
| 78 | this.runResult = { |
| 79 | actions: [], |
| 80 | ...partiallyExecutedRunResult |
| 81 | }; |
| 82 | this.warehouseStateByTarget = new Map<string, dataform.ITableMetadata>(); |
| 83 | graph.warehouseState.tables?.forEach(tableMetadata => |
| 84 | this.warehouseStateByTarget.set( |
| 85 | targetStringifier.stringify(tableMetadata.target), |
| 86 | tableMetadata |
| 87 | ) |
| 88 | ); |
| 89 | this.executedActionTargets = new Set( |
| 90 | this.runResult.actions |
| 91 | .filter(action => action.status !== dataform.ActionResult.ExecutionStatus.RUNNING) |
| 92 | .map(action => targetStringifier.stringify(action.target)) |
| 93 | ); |
| 94 | this.successfullyExecutedActionTargets = new Set<string>( |
| 95 | this.runResult.actions |
| 96 | .filter(isSuccessfulAction) |
| 97 | .map(action => targetStringifier.stringify(action.target)) |
| 98 | ); |
| 99 | this.pendingActions = graph.actions.filter( |
| 100 | action => !this.executedActionTargets.has(targetStringifier.stringify(action.target)) |
| 101 | ); |
| 102 | this.eEmitter = new EventEmitter(); |
| 103 | // There could feasibly be thousands of listeners to this, 0 makes the limit infinite. |
| 104 | this.eEmitter.setMaxListeners(0); |
| 105 | } |
| 106 | |
| 107 | public onChange(listener: (graph: dataform.IRunResult) => void): Runner { |
| 108 | this.changeListeners.push(listener); |