suggestion: external worker api (#1928)

* Cleaner request apis.
This commit is contained in:
Alexander Stecher
2025-10-28 20:37:20 +01:00
committed by Kévin Dunglas
parent 9b8d215727
commit 1270784cd3
7 changed files with 222 additions and 207 deletions

View File

@@ -23,6 +23,8 @@ type worker struct {
threadMutex sync.RWMutex
allowPathMatching bool
maxConsecutiveFailures int
onThreadReady func(int)
onThreadShutdown func(int)
}
var (
@@ -51,12 +53,6 @@ func initWorkers(opt []workerOpt) error {
convertToWorkerThread(thread, w)
go func() {
thread.state.waitFor(stateReady)
// create a pipe from the external worker to the main worker
// note: this is locked to the initial thread size the external worker requested
if workerThread, ok := thread.handler.(*workerThread); ok && workerThread.externalWorker != nil {
go startWorker(w, workerThread.externalWorker, thread)
}
workersReady.Done()
}()
}
@@ -131,6 +127,8 @@ func newWorker(o workerOpt) (*worker, error) {
threads: make([]*phpThread, 0, o.num),
allowPathMatching: allowPathMatching,
maxConsecutiveFailures: o.maxConsecutiveFailures,
onThreadReady: o.onThreadReady,
onThreadShutdown: o.onThreadShutdown,
}
return w, nil