-
Notifications
You must be signed in to change notification settings - Fork 425
feat(worker): make maximum consecutive failures configurable #1692
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
feat(worker): make maximum consecutive failures configurable #1692
Conversation
eef1c5c to
f37aaf8
Compare
8ac24e5 to
95c4fdd
Compare
|
I think workers will only fail on startup, so not sure if there's much benefit to fine-tuning that failure limit. I would agree though that disabling the failing entirely might be a valid use case. Also, it would be nice to have something like a frankenphp.WithWorkers(
fileName,
num,
WithWorkerEnv(...),
WithWorkerWatchMode(...),
WithWorkerMaxFailures(...),
) |
3d3d831 to
0b512db
Compare
|
Good idea, I implemented functional options |
0b512db to
03ce7e2
Compare
frankenphp_test.go
Outdated
| workerOpts := []frankenphp.WorkerOption{ | ||
| frankenphp.WithWorkerEnv(opts.env), | ||
| frankenphp.WithWorkerWatchMode(opts.watch), | ||
| frankenphp.WithWorkerMaxFailures(6), |
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.
| frankenphp.WithWorkerMaxFailures(6), |
options.go
Outdated
| func WithWorkerMaxFailures(maxFailures int) WorkerOption { | ||
| return func(w *workerOpt) { | ||
| if maxFailures < -1 { | ||
| maxFailures = DefaultMaxConsecutiveFailures |
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.
We should return an error here instead of silently ignoring the invalid value
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.
Alright, I updated all functions to return an error
phpmainthread_test.go
Outdated
| workers = make(map[string]*worker) | ||
| _, err1 := newWorker(workerOpt{fileName: "filename.php"}) | ||
| _, err2 := newWorker(workerOpt{fileName: "filename.php"}) | ||
| _, err1 := newWorker(workerOpt{fileName: "filename.php", maxConsecutiveFailures: 6}) |
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.
| _, err1 := newWorker(workerOpt{fileName: "filename.php", maxConsecutiveFailures: 6}) | |
| _, err1 := newWorker(workerOpt{fileName: "filename.php", maxConsecutiveFailures: DefaultMaxConsecutiveFailures}) |
phpmainthread_test.go
Outdated
| _, err1 := newWorker(workerOpt{fileName: "filename.php"}) | ||
| _, err2 := newWorker(workerOpt{fileName: "filename.php"}) | ||
| _, err1 := newWorker(workerOpt{fileName: "filename.php", maxConsecutiveFailures: 6}) | ||
| _, err2 := newWorker(workerOpt{fileName: "filename.php", maxConsecutiveFailures: 6}) |
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.
| _, err2 := newWorker(workerOpt{fileName: "filename.php", maxConsecutiveFailures: 6}) | |
| _, err2 := newWorker(workerOpt{fileName: "filename.php", maxConsecutiveFailures: DefaultMaxConsecutiveFailures}) |
phpmainthread_test.go
Outdated
| _, err1 := newWorker(workerOpt{fileName: "filename.php", name: "workername", maxConsecutiveFailures: 6}) | ||
| _, err2 := newWorker(workerOpt{fileName: "filename2.php", name: "workername", maxConsecutiveFailures: 6}) |
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.
| _, err1 := newWorker(workerOpt{fileName: "filename.php", name: "workername", maxConsecutiveFailures: 6}) | |
| _, err2 := newWorker(workerOpt{fileName: "filename2.php", name: "workername", maxConsecutiveFailures: 6}) | |
| _, err1 := newWorker(workerOpt{fileName: "filename.php", name: "workername", maxConsecutiveFailures: DefaultMaxConsecutiveFailures}) | |
| _, err2 := newWorker(workerOpt{fileName: "filename2.php", name: "workername", maxConsecutiveFailures: DefaultMaxConsecutiveFailures}) |
phpmainthread_test.go
Outdated
| num: 1, | ||
| fileName: testDataPath + "/" + fileName, | ||
| num: 1, | ||
| maxConsecutiveFailures: 6, |
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.
| maxConsecutiveFailures: 6, | |
| maxConsecutiveFailures: DefaultMaxConsecutiveFailures, |
options.go
Outdated
| ) | ||
|
|
||
| // DefaultMaxConsecutiveFailures is the default maximum number of consecutive failures before panicking | ||
| const DefaultMaxConsecutiveFailures = 6 |
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.
This could be unexported, this isn't used outside of the frankenphp package
03ce7e2 to
648196f
Compare
|
Thanks! |
This adds a new configuration key to configure max consecutive failures for workers: