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
Make the context used to start workers configurable for tests. #940
Merged
zach-klippenstein
merged 1 commit into
release-v0.23.x
from
zachklipp/worker-test-context
Feb 6, 2020
Merged
Make the context used to start workers configurable for tests. #940
zach-klippenstein
merged 1 commit into
release-v0.23.x
from
zachklipp/worker-test-context
Feb 6, 2020
Conversation
This file contains 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
zach-klippenstein
force-pushed
the
zachklipp/worker-test-context
branch
3 times, most recently
from
February 6, 2020 00:41
653b847
to
6c6adda
Compare
zach-klippenstein
changed the title
WIP Make the context used to start workers configurable for tests.
Make the context used to start workers configurable for tests.
Feb 6, 2020
This is helpful for tests that need to be able to control time. This functionality was covered by the test's dispatcher, but since #851 changed the dispatcher used for workers, we need to be able to configure workers' contexts separately.
zach-klippenstein
force-pushed
the
zachklipp/worker-test-context
branch
from
February 6, 2020 00:43
6c6adda
to
45fca29
Compare
tehras
approved these changes
Feb 6, 2020
): CoroutineScope = this + CoroutineName(worker.debugName(key)) + Unconfined | ||
key: String, | ||
workerContext: CoroutineContext | ||
): CoroutineScope = this + CoroutineName(worker.debugName(key)) + Unconfined + workerContext |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahh, I see what you meant when you were describing CouroutineScope
at your talk.
Armaxis
approved these changes
Feb 6, 2020
zach-klippenstein
added a commit
that referenced
this pull request
Feb 6, 2020
This is an enhancement to #940 that gives more reasonable behavior. The context parameter to the test methods are primarily used to pass in test dispatchers, and those dispatchers often really only need to be used for workers. Since I don't know of a use case for specifying context separately just for workers, this also removes the `WorkflowTestParams.workerContext` property.
zach-klippenstein
added a commit
that referenced
this pull request
Feb 6, 2020
This is an enhancement to #940 that gives more reasonable behavior. The context parameter to the test methods are primarily used to pass in test dispatchers, and those dispatchers often really only need to be used for workers. Since I don't know of a use case for specifying context separately just for workers, this also removes the `WorkflowTestParams.workerContext` property.
zach-klippenstein
added a commit
that referenced
this pull request
Feb 6, 2020
This is an enhancement to #940 that gives more reasonable behavior. The context parameter to the test methods are primarily used to pass in test dispatchers, and those dispatchers often really only need to be used for workers. Since I don't know of a use case for specifying context separately just for workers, this also removes the `WorkflowTestParams.workerContext` property.
zach-klippenstein
added a commit
that referenced
this pull request
Feb 6, 2020
This is an enhancement to #940 that gives more reasonable behavior. The context parameter to the test methods are primarily used to pass in test dispatchers, and those dispatchers often really only need to be used for workers. Since I don't know of a use case for specifying context separately just for workers, this also removes the `WorkflowTestParams.workerContext` property.
zach-klippenstein
added a commit
that referenced
this pull request
Feb 6, 2020
This is an enhancement to #940 that gives more reasonable behavior. The context parameter to the test methods are primarily used to pass in test dispatchers, and those dispatchers often really only need to be used for workers. Since I don't know of a use case for specifying context separately just for workers, this also removes the `WorkflowTestParams.workerContext` property.
2 tasks
zach-klippenstein
added a commit
to square/workflow-kotlin
that referenced
this pull request
Jun 20, 2020
First part of Kotlin implementation of square/workflow#1021. Kotlin counterpart to square/workflow#1174. This implementation intentionally does not run the side effect coroutine on the `workerContext` `CoroutineContext` that is threaded through the runtime for testing infrastructure. Initially, workers ran in the same context as the workflow runtime. The behavior of running workers on a different dispatcher by default (`Unconfined`) was introduced in square/workflow#851 as an optimization to reduce the overhead for running workers that only perform wiring tasks with other async libraries. This was a theoretical optimization, since running on the `Unconfined` dispatcher inherently involves less dispatching work, but the overhead of dispatching wiring coroutines was never actually shown to be a problem. Additionally, because tests often need to be in full control of dispatchers, the ability to override the context used for workers was introduced in square/workflow#940, which introduced `workerContext`. I am dropping that complexity here because it adds a decent amount of complexity to worker/side effect machinery without any proven value. It is also complexity that needs to be documented, and is probably just more confusing than anything. The old behavior for workers is maintained for now to reduce the risk of this change, but side effects will always run in the workflow runtime's context. This is nice and simple and unsurprising and easy to reason about.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is helpful for tests that need to be able to control time.
This functionality was covered by the test's dispatcher, but since #851 changed the dispatcher used for workers, we need to be able to configure workers' contexts separately.