Created
January 7, 2021 21:37
-
-
Save itshaadi/d8e4f5db8ae0ad1344b271741d5c8f98 to your computer and use it in GitHub Desktop.
Definition of a pipeline executor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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