Relocate ProcessIO to ContainerClient. by jglogan · Pull Request #681 · apple/container
- Makes ProcessIO more generally available.
Application.handleProcess(processIO:process:)becomesprocessIO.handleProcess(process:log:).
Type of Change
- Bug fix
- New feature
- Breaking change
- Documentation update
Motivation and Context
This code shouldn't be in the CLI, it should be part of ContainerClient.
Testing
- Tested locally
- Added/updated tests
- Added/updated docs
| ) | ||
| } | ||
|
|
||
| public static func handleProcess(io: ProcessIO, process: ClientProcess) async throws -> Int32 { |
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this becomes an instance function in ProcessIO.swift()
| ) | ||
| } | ||
|
|
||
| public func handleProcess(process: ClientProcess, log: Logger) async throws -> Int32 { |
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
relocated from Application.swift:
- now an instance function so the
ioparameter just becomesself - was using the
logmember from Application before, the caller now passeslogin
| @@ -0,0 +1,381 @@ | |||
| //===----------------------------------------------------------------------===// | |||
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extracted from ContainerRun in the ContainerCommands target to this file in the ContainerClient target
| case table | ||
| } | ||
|
|
||
| static let signalSet: [Int32] = [ |
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These were only used by handleProcess so they've also moved to ProcessIO
| let stderr: Pipe? | ||
| var ioTracker: IoTracker? | ||
|
|
||
| static let signalSet: [Int32] = [ |
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
moved to here from Application.swift
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All of this is now down in ProcessIO.swift in ContainerClient.
- Makes ProcessIO more generally available. - `Application.handleProcess(processIO:process:)` becomes `processIO.handleProcess(process:log:)`.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. The annotations were very helpful, thank you for adding those :)
| ) | ||
| } | ||
|
|
||
| public func handleProcess(process: ClientProcess, log: Logger) async throws -> Int32 { |
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the ProcessIO move, but I'm not as big of a fan about this method on here. To me anything that would call start() or handle process lifecycle makes more sense on the ClientProcess type itself. A run() method on ClientProcess might be a decent naming, as that's essentially what this is. We start + wait + consume IO until completion.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thinking more about this, not entirely related but, to even be able to get a ClientProcess object we need to pass the io type into bootstrap() or createProcess(), why don't we just have ClientProcess manage the IO type directly? e.g. it can call closeAfterStart() inside the type and not burden the caller with doing it. Additionally, in process.wait() we can do the try await io.wait() just as we do in handleProcess right now. Seems like it'd clean things up a bit.
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