Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename WorkContext to ExeUnit #982

Merged
merged 20 commits into from
Jun 20, 2024
Merged

Rename WorkContext to ExeUnit #982

merged 20 commits into from
Jun 20, 2024

Conversation

mgordel
Copy link
Contributor

@mgordel mgordel commented Jun 18, 2024

  • Renamed WorkContext to ExeUnit
  • Moved unit tests to related directories in src
  • Added OneOf and ManyOfOptions including setup and teardown function

BREAKING CHANGE: The API object WorkContext (ctx) has been renamed to ExeUnit. All references to WorkContext must be updated.

BREAKING CHANGE: The current use of the WorkContext.before() method
should be replaced with ExeUnit.setup()

mgordel added 3 commits June 18, 2024 12:38
Moved unit tests to related directories in src

BREAKING CHANGE: The API object WorkContext (ctx) has been renamed to ExeUnit.
All references to WorkContext must be updated.
@mgordel mgordel self-assigned this Jun 18, 2024
@mgordel mgordel marked this pull request as ready for review June 18, 2024 10:51
@mgordel mgordel marked this pull request as draft June 19, 2024 11:08
@mgordel mgordel marked this pull request as ready for review June 19, 2024 12:22
@mgordel mgordel changed the title refactor(work-context): rename WorkContext to ExeUnit Rename WorkContext to ExeUnit Jun 19, 2024
Comment on lines 45 to 58
await Promise.allSettled([
pool.withLease(async (lease) =>
lease
.getExeUnit()
.then((exe) => exe.run(`echo Hello, Golem from the first machine! 👋 ${exe.provider.name}`))
.then((res) => console.log(res.stdout)),
),
pool.withLease(async (lease) =>
lease
.getExeUnit()
.then((exe) => exe.run(`echo Hello, Golem from the second machine! 👋 ${exe.provider.name}`))
.then((res) => console.log(res.stdout)),
),
]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think a better example would be to show that if you re-use a lease the setup and teardown are only executed once (for example make w pool with concurrency 2 and run 10 tasks on it)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or we could borrow the example from TE where we upload a file, add lines to it in every task function and then display the contents at the end

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or maybe... an example with rendering... 🫣 intentionally change the name to rendering.ts, this is the original example where it is necessary to use the setup .. (?)
I added it for comparison - rendering.ts

examples/package.json Outdated Show resolved Hide resolved
@mgordel mgordel merged commit 0909f3b into beta Jun 20, 2024
8 of 14 checks passed
@mgordel mgordel deleted the mgordel/JST-984/exe-unit-rename branch June 20, 2024 12:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants