Skip to content

Commit

Permalink
refactor(exe-unit): renamed before method to setup and added `tea…
Browse files Browse the repository at this point in the history
…rdown` method

BREAKING CHANGE: The current use of the `WorkContext.before()` method
should be replaced with`ExeUnit.setup()`
  • Loading branch information
mgordel committed Jun 19, 2024
1 parent 387aee4 commit 1cd8f00
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions src/activity/exe-unit/exe-unit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,11 @@ export class ExeUnit {
});
}

/**
* This function initializes the exe unit by deploying the image to the remote machine
* and preparing and running the environment.
* This process also includes running setup function if the user has defined it
*/
async setup(): Promise<Result[] | void> {
try {
let state = await this.fetchState();
Expand Down Expand Up @@ -147,6 +152,16 @@ export class ExeUnit {
}
}

/**
* This function starts the teardown function if the user has defined it.
* It is run before the machine is destroyed.
*/
async teardown(): Promise<void> {
if (this.options?.teardown) {
await this.options.teardown(this);
}
}

private async deployActivity() {
const result = await this.executor
.execute(
Expand Down Expand Up @@ -204,12 +219,6 @@ export class ExeUnit {
.finally(() => clearTimeout(timeoutId));
}

async teardown(): Promise<void> {
if (this.options?.teardown) {
await this.options.teardown(this);
}
}

private async setupActivity() {
if (this.options?.setup) {
await this.options.setup(this);
Expand Down

0 comments on commit 1cd8f00

Please sign in to comment.