feat: Add pool support in process package#1215
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR introduces a process pool functionality to the Goravel framework and removes deprecated LatestOutput and LatestErrorOutput methods. The changes add concurrent process execution capabilities with configurable scheduling, timeout management, and output handling.
- Adds a comprehensive process pool implementation with builder pattern for concurrent process execution
- Removes deprecated
LatestOutputandLatestErrorOutputmethods from the Running interface and implementation - Introduces scheduling strategies and priority-based execution for pool commands
Reviewed Changes
Copilot reviewed 9 out of 10 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| process/running_unix_test.go | Removes test for deprecated LatestOutput functionality |
| process/running.go | Removes deprecated LatestOutput and LatestErrorOutput methods and helper function |
| mocks/process/Running.go | Removes mock methods for deprecated LatestOutput functionality |
| contracts/process/running.go | Removes deprecated method signatures from Running interface |
| process/pool.go | Adds complete process pool implementation with builder pattern and worker management |
| process/running_pool.go | Adds RunningPool implementation for managing active process pools |
| contracts/process/pool.go | Defines interfaces for pool builder, pool, and pool commands |
| contracts/process/running_pool.go | Defines RunningPool interface for pool lifecycle management |
| contracts/process/schedule.go | Defines scheduling interfaces and priority system for process execution |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1215 +/- ##
==========================================
+ Coverage 65.95% 66.35% +0.40%
==========================================
Files 243 244 +1
Lines 16698 16895 +197
==========================================
+ Hits 11013 11211 +198
+ Misses 5304 5302 -2
- Partials 381 382 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull Request Overview
Copilot reviewed 30 out of 30 changed files in this pull request and generated no new comments.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
hwbrzzl
left a comment
There was a problem hiding this comment.
Great, only a few nitpicks.
| return run.Wait(), nil | ||
| } | ||
|
|
||
| func (r *PoolBuilder) start(configure func(contractsprocess.Pool)) (contractsprocess.RunningPool, error) { |
There was a problem hiding this comment.
Could you add some annotations for this function logic?
| Run(builder func(Pool)) (map[string]Result, error) | ||
|
|
||
| // Start launches the pool asynchronously and returns a handle to the running | ||
| // pool, allowing for interaction with the live processes. | ||
| Start(builder func(Pool)) (RunningPool, error) |
There was a problem hiding this comment.
That would be a bit complicated and not really necessary. We could add a Pool helper and allow passing OnOutput directly in the Start method, but since most of our existing implementations already use an OnOutput callback, it’s better to stay consistent with that approach.
Below is a tidy sample that implements the PHP example in our style:
package main
func main() {
running, err := process.NewPool().
OnOutput(func(key string, typ process.OutputType, line []byte) {
// ...
}).
Start(func(p process.Pool) {
p.Command("bash", "import-1.sh").Path("./")
p.Command("bash", "import-2.sh").Path("./")
p.Command("bash", "import-3.sh").Path("./")
})
if err != nil {
os.Exit(1)
}
<-running.Done()
results := running.Wait()
_ = results
}There was a problem hiding this comment.
OnOutput is fine, can it be?
package main
func main() {
running, err := facades.Process.Pool(func(p process.Pool) {
p.Command("bash", "import-1.sh").Path("./")
p.Command("bash", "import-2.sh").Path("./")
p.Command("bash", "import-3.sh").Path("./")
}).
OnOutput(func(typ process.OutputType, line []byte, key string) {
// ...
}).
Start()
if err != nil {
os.Exit(1)
}
<-running.Done()
results := running.Wait()
_ = results
}
There was a problem hiding this comment.
nit: I updated the sort of OnOutput func(typ process.OutputType, line []byte, key string) to be consistent with Laravel.
There was a problem hiding this comment.
Yeah, I’ll think about refactoring it from a facade perspective. Still not sure how it’ll be used with facades though. I’ll raise a new PR for that and include the similar contract changes there itself.
There was a problem hiding this comment.
Thanks, it can be optimized in another PR if you want.
| Run(builder func(Pool)) (map[string]Result, error) | ||
|
|
||
| // Start launches the pool asynchronously and returns a handle to the running | ||
| // pool, allowing for interaction with the live processes. | ||
| Start(builder func(Pool)) (RunningPool, error) |
There was a problem hiding this comment.
Thanks, it can be optimized in another PR if you want.

📑 Description
RelatedTo goravel/goravel#567
This PR implements a lightweight, flexible API for managing concurrent processes in Go.
Basic Usage
Features
Examples
Limit Concurrency
Stream Output
Control Running Processes
Command Options
Notes
DisableBuffering()for commands with large output✅ Checks