Skip to content

Instantly share code, notes, and snippets.

@itshaadi
Created January 7, 2021 21:37
Show Gist options
  • Save itshaadi/d8e4f5db8ae0ad1344b271741d5c8f98 to your computer and use it in GitHub Desktop.
Save itshaadi/d8e4f5db8ae0ad1344b271741d5c8f98 to your computer and use it in GitHub Desktop.
Definition of a pipeline executor
class PipelineExecutor {
private headOfExecutionChain: ExecutionUnit;
constructor(units: ExecutionUnit[]) {
const totalUnits = units.length;
for (let i = 0; i <= totalUnits; i++) {
if (i < totalUnits - 1) {
units[i].setNext(units[i + 1]);
}
}
this.headOfExecutionChain = units[0];
}
async exec(req: Request, res: Response): Promise<void | never> {
await this.headOfExecutionChain.exec(req, res);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment