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

"switched" command runner #16792

Merged
merged 4 commits into from
Sep 7, 2022
Merged

Conversation

tdyas
Copy link
Contributor

@tdyas tdyas commented Sep 7, 2022

Introduce SwitchedCommandRunner which uses a predicate to choose between two command runners. Then use SwitchedCommandRunner to switch between the docker::CommandRunner and whatever other local command runner is configured.

This allows docker::CommandRunner to no longer know about any other command runners, thereby re-introducing better encapsulation to docker::CommandRunner.

Closes #16788

[ci skip-build-wheels]
@tdyas tdyas force-pushed the docker_switched_command_runner branch from 26a15b3 to b76e5f2 Compare September 7, 2022 22:21
@tdyas tdyas added the category:internal CI, fixes for not-yet-released features, etc. label Sep 7, 2022
Copy link
Contributor

@Eric-Arellano Eric-Arellano left a comment

Choose a reason for hiding this comment

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

Thanks!

src/rust/engine/src/context.rs Outdated Show resolved Hide resolved
Tom Dyas added 2 commits September 7, 2022 18:28
[ci skip-build-wheels]
[ci skip-build-wheels]
Copy link
Member

@stuhood stuhood left a comment

Choose a reason for hiding this comment

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

The nailgun command runner should be able to use this as well:

///
/// A command runner that can run local requests under nailgun.
///
/// It should only be invoked with local requests.
/// It will read a flag marking an `Process` as nailgunnable.
/// If that flag is set, it will connect to a running nailgun server and run the command there.
/// Otherwise, it will just delegate to the regular local runner.
///
pub struct CommandRunner {
inner: super::local::CommandRunner,
nailgun_pool: NailgunPool,
executor: Executor,
}

@tdyas tdyas enabled auto-merge (squash) September 7, 2022 22:43
@tdyas tdyas disabled auto-merge September 7, 2022 22:45
[ci skip-build-wheels]
@tdyas
Copy link
Contributor Author

tdyas commented Sep 7, 2022

I switched this to using generic types instead of Box<dyn CommandRunner>. Then I added an impl of CommandRunner for Box<T> where T: CommandRunner.

@tdyas
Copy link
Contributor Author

tdyas commented Sep 7, 2022

The nailgun command runner should be able to use this as well:

Will look into a follow-up.

@tdyas tdyas merged commit f7825e3 into pantsbuild:main Sep 7, 2022
@tdyas tdyas deleted the docker_switched_command_runner branch September 7, 2022 23:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category:internal CI, fixes for not-yet-released features, etc.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Refactor Docker command runner to use switch command runner
3 participants