diff options
author | Valery Piashchynski <[email protected]> | 2020-11-26 12:44:12 +0300 |
---|---|---|
committer | Valery Piashchynski <[email protected]> | 2020-11-26 12:44:12 +0300 |
commit | 574f351aaecdee1176b9700bb6d7eb61fe170906 (patch) | |
tree | 6271704950d2c89a43de3edafb677a003d50a406 | |
parent | e5313529e4293b7ad985cce72cec54b08462259d (diff) |
Remove context from worker wait function. Explicitly enable ubuntu 20.04
in the CI
-rwxr-xr-x | .github/workflows/ci-build.yml | 2 | ||||
-rwxr-xr-x | pipe_factory.go | 4 | ||||
-rwxr-xr-x | socket_factory.go | 5 | ||||
-rwxr-xr-x | sync_worker.go | 6 | ||||
-rwxr-xr-x | sync_worker_test.go | 12 | ||||
-rwxr-xr-x | worker.go | 4 | ||||
-rwxr-xr-x | worker_watcher.go | 2 |
7 files changed, 17 insertions, 18 deletions
diff --git a/.github/workflows/ci-build.yml b/.github/workflows/ci-build.yml index 416e223c..49d790f9 100755 --- a/.github/workflows/ci-build.yml +++ b/.github/workflows/ci-build.yml @@ -11,7 +11,7 @@ jobs: matrix: php: [ 7.4 ] go: [ 1.14, 1.15 ] - os: [ ubuntu-latest ] + os: [ ubuntu-20.04 ] env: GO111MODULE: on steps: diff --git a/pipe_factory.go b/pipe_factory.go index a85606d2..3e98bd4e 100755 --- a/pipe_factory.go +++ b/pipe_factory.go @@ -81,7 +81,7 @@ func (f *PipeFactory) SpawnWorkerWithContext(ctx context.Context, cmd *exec.Cmd) err = multierr.Combine( err, w.Kill(), - w.Wait(context.Background()), + w.Wait(), ) c <- SpawnResult{ w: nil, @@ -145,7 +145,7 @@ func (f *PipeFactory) SpawnWorker(cmd *exec.Cmd) (WorkerBase, error) { err = multierr.Combine( err, w.Kill(), - w.Wait(context.Background()), + w.Wait(), ) return nil, errors.E(op, err) } diff --git a/socket_factory.go b/socket_factory.go index c6120b85..472e5a05 100755 --- a/socket_factory.go +++ b/socket_factory.go @@ -110,7 +110,7 @@ func (f *SocketFactory) SpawnWorkerWithContext(ctx context.Context, cmd *exec.Cm err = multierr.Combine( err, w.Kill(), - w.Wait(context.Background()), + w.Wait(), ) c <- socketSpawn{ @@ -142,7 +142,6 @@ func (f *SocketFactory) SpawnWorkerWithContext(ctx context.Context, cmd *exec.Cm } func (f *SocketFactory) SpawnWorker(cmd *exec.Cmd) (WorkerBase, error) { - ctx := context.Background() const op = errors.Op("spawn_worker") w, err := InitBaseWorker(cmd) if err != nil { @@ -159,7 +158,7 @@ func (f *SocketFactory) SpawnWorker(cmd *exec.Cmd) (WorkerBase, error) { err = multierr.Combine( err, w.Kill(), - w.Wait(ctx), + w.Wait(), ) return nil, err } diff --git a/sync_worker.go b/sync_worker.go index 6f5b20d9..cd0f934e 100755 --- a/sync_worker.go +++ b/sync_worker.go @@ -17,7 +17,6 @@ var EmptyPayload = Payload{} type SyncWorker interface { // WorkerBase provides basic functionality for the SyncWorker WorkerBase - // Exec used to execute payload on the SyncWorker, there is no TIMEOUTS Exec(rqs Payload) (Payload, error) // ExecWithContext used to handle Exec with TTL @@ -28,6 +27,7 @@ type syncWorker struct { w WorkerBase } +// NewSyncWorker creates SyncWorker from WorkerBasa func NewSyncWorker(w WorkerBase) (SyncWorker, error) { return &syncWorker{ w: w, @@ -191,8 +191,8 @@ func (tw *syncWorker) Start() error { return tw.w.Start() } -func (tw *syncWorker) Wait(ctx context.Context) error { - return tw.w.Wait(ctx) +func (tw *syncWorker) Wait() error { + return tw.w.Wait() } func (tw *syncWorker) Stop(ctx context.Context) error { diff --git a/sync_worker_test.go b/sync_worker_test.go index db46ea6e..69e6ece9 100755 --- a/sync_worker_test.go +++ b/sync_worker_test.go @@ -24,7 +24,7 @@ func Test_Echo(t *testing.T) { t.Fatal(err) } go func() { - assert.NoError(t, w.Wait(ctx)) + assert.NoError(t, w.Wait()) }() defer func() { err := w.Stop(ctx) @@ -55,7 +55,7 @@ func Test_BadPayload(t *testing.T) { } go func() { - assert.NoError(t, w.Wait(ctx)) + assert.NoError(t, w.Wait()) }() defer func() { err := w.Stop(ctx) @@ -107,7 +107,7 @@ func Test_String(t *testing.T) { w, _ := NewPipeFactory().SpawnWorkerWithContext(ctx, cmd) go func() { - assert.NoError(t, w.Wait(ctx)) + assert.NoError(t, w.Wait()) }() defer func() { err := w.Stop(ctx) @@ -127,7 +127,7 @@ func Test_Echo_Slow(t *testing.T) { w, _ := NewPipeFactory().SpawnWorkerWithContext(ctx, cmd) go func() { - assert.NoError(t, w.Wait(ctx)) + assert.NoError(t, w.Wait()) }() defer func() { err := w.Stop(ctx) @@ -195,7 +195,7 @@ func Test_Error(t *testing.T) { w, _ := NewPipeFactory().SpawnWorkerWithContext(ctx, cmd) go func() { - assert.NoError(t, w.Wait(ctx)) + assert.NoError(t, w.Wait()) }() defer func() { @@ -227,7 +227,7 @@ func Test_NumExecs(t *testing.T) { w, _ := NewPipeFactory().SpawnWorkerWithContext(ctx, cmd) go func() { - assert.NoError(t, w.Wait(ctx)) + assert.NoError(t, w.Wait()) }() defer func() { err := w.Stop(ctx) @@ -80,7 +80,7 @@ type WorkerBase interface { // complete and will return process error (if any), if stderr is presented it's value // will be wrapped as WorkerError. Method will return error code if php process fails // to find or Start the script. - Wait(ctx context.Context) error + Wait() error // Stop sends soft termination command to the WorkerProcess and waits for process completion. Stop(ctx context.Context) error @@ -219,7 +219,7 @@ func (w *WorkerProcess) Start() error { // complete and will return process error (if any), if stderr is presented it's value // will be wrapped as WorkerError. Method will return error code if php process fails // to find or Start the script. -func (w *WorkerProcess) Wait(ctx context.Context) error { +func (w *WorkerProcess) Wait() error { const op = errors.Op("worker process wait") err := multierr.Combine(w.cmd.Wait()) // at this point according to the documentation (see cmd.Wait comment) diff --git a/worker_watcher.go b/worker_watcher.go index a617fe65..3b83c8ff 100755 --- a/worker_watcher.go +++ b/worker_watcher.go @@ -277,7 +277,7 @@ func (ww *workerWatcher) WorkersList() []WorkerBase { func (ww *workerWatcher) wait(ctx context.Context, w WorkerBase) { const op = errors.Op("process wait") - err := w.Wait(ctx) + err := w.Wait() if err != nil { ww.events.Push(WorkerEvent{ Event: EventWorkerError, |