Skip to content
This repository has been archived by the owner on Jun 27, 2024. It is now read-only.

feature: streaming support #82

Merged
merged 4 commits into from
Aug 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ linters-settings:
confidence: 0.8
errorCode: 0
warningCode: 0
gocyclo:
min-complexity: 15
godot:
scope: declarations
capital: true
Expand Down Expand Up @@ -50,7 +48,6 @@ linters: # All available linters list: <https://golangci-lint.run/usage/linters/
- exhaustive # check exhaustiveness of enum switch statements
- exportloopref # checks for pointers to enclosing loop variables
- gochecknoinits # Checks that no init functions are present in Go code
- gocognit # Computes and checks the cognitive complexity of functions
- goconst # Finds repeated strings that could be replaced by a constant
- gocritic # The most opinionated Go source code linter
- gofmt # Gofmt checks whether code was gofmt-ed. By default this tool runs with -s option to check for code simplification
Expand Down
17 changes: 17 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"cSpell.words": [
"allocs",
"errgroup",
"Failboot",
"goridge",
"memleak",
"nolint",
"pexec",
"pldd",
"serv",
"stretchr",
"stylecheck",
"wexec",
"wrks"
]
}
6 changes: 2 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ require (
github.com/roadrunner-server/tcplisten v1.3.0
github.com/shirou/gopsutil v3.21.11+incompatible
github.com/stretchr/testify v1.8.4
go.uber.org/zap v1.24.0
go.uber.org/zap v1.25.0
golang.org/x/sync v0.3.0
)

Expand All @@ -21,16 +21,14 @@ require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/go-ole/go-ole v1.2.6 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/client_model v0.4.0 // indirect
github.com/prometheus/common v0.44.0 // indirect
github.com/prometheus/procfs v0.11.0 // indirect
github.com/prometheus/procfs v0.11.1 // indirect
github.com/tklauser/go-sysconf v0.3.11 // indirect
github.com/tklauser/numcpus v0.6.1 // indirect
github.com/yusufpapurcu/wmi v1.2.3 // indirect
go.uber.org/atomic v1.11.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/sys v0.10.0 // indirect
google.golang.org/protobuf v1.31.0 // indirect
Expand Down
27 changes: 6 additions & 21 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8=
github.com/benbjohnson/clock v1.3.0 h1:ip6w0uFQkncKQ979AypyG0ER7mqUSBdKLOgAle/AT8A=
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44=
github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/go-logfmt/logfmt v0.5.1/go.mod h1:WYhtIu8zTZfxdn5+rREduYbwxfcBr/Vr6KEVveWlfTs=
github.com/go-ole/go-ole v1.2.6 h1:/Fpf6oFPoeFik9ty7siob0G6Ke8QvQEuVcuChpwXzpY=
github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0=
github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU=
Expand All @@ -19,19 +17,10 @@ github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4=
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM=
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/matttproud/golang_protobuf_extensions v1.0.4 h1:mmDVorXM7PCGKw94cs5zkfA9PSy5pEvNWRP0ET0TIVo=
github.com/matttproud/golang_protobuf_extensions v1.0.4/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/prometheus/client_golang v1.16.0 h1:yk/hx9hDbrGHovbci4BY+pRMfSuuat626eFsHb7tmT8=
Expand All @@ -40,8 +29,8 @@ github.com/prometheus/client_model v0.4.0 h1:5lQXD3cAg1OXBf4Wq03gTrXHeaV0TQvGfUo
github.com/prometheus/client_model v0.4.0/go.mod h1:oMQmHW1/JoDwqLtg57MGgP/Fb1CJEYF2imWWhWtMkYU=
github.com/prometheus/common v0.44.0 h1:+5BrQJwiBB9xsMygAB3TNvpQKOwlkc25LbISbrdOOfY=
github.com/prometheus/common v0.44.0/go.mod h1:ofAIvZbQ1e/nugmZGz4/qCb9Ap1VoSTIO7x0VV9VvuY=
github.com/prometheus/procfs v0.11.0 h1:5EAgkfkMl659uZPbe9AS2N68a7Cc1TJbPEuGzFuRbyk=
github.com/prometheus/procfs v0.11.0/go.mod h1:nwNm2aOCAYw8uTR/9bWRREkZFxAUcWzPHWJq+XBB/FM=
github.com/prometheus/procfs v0.11.1 h1:xRC8Iq1yyca5ypa9n1EZnWZkt7dwcoRPQwX/5gwaUuI=
github.com/prometheus/procfs v0.11.1/go.mod h1:eesXgaPo1q7lBpVMoMy0ZOFTth9hBn4W/y0/p/ScXhY=
github.com/roadrunner-server/errors v1.2.0 h1:qBmNXt8Iex9QnYTjCkbJKsBZu2EtYkQCM06GUDcQBbI=
github.com/roadrunner-server/errors v1.2.0/go.mod h1:z0ECxZp/dDa5RahtMcy4mBIavVxiZ9vwE5kByl7kFtY=
github.com/roadrunner-server/goridge/v3 v3.6.3 h1:8hCuPVK9BxIE4IGyNphK6KPAy9Kg6t5tHaItBIQKh2o=
Expand All @@ -51,7 +40,6 @@ github.com/roadrunner-server/tcplisten v1.3.0/go.mod h1:VR6Ob5am0oEuLMOeLiVvQxG9
github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ=
github.com/shirou/gopsutil v3.21.11+incompatible h1:+1+c1VGhc88SSonWP6foOcLhvnKlUeu/erjjvaPEYiI=
github.com/shirou/gopsutil v3.21.11+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA=
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/tklauser/go-sysconf v0.3.11 h1:89WgdJhk5SNwJfu+GKyYveZ4IaJ7xAkecBo+KdJV0CM=
Expand All @@ -61,13 +49,11 @@ github.com/tklauser/numcpus v0.6.1 h1:ng9scYS7az0Bk4OZLvrNXNSAO2Pxr1XXRAPyjhIx+F
github.com/tklauser/numcpus v0.6.1/go.mod h1:1XfjsgE2zo8GVw7POkMbHENHzVg3GzmoZ9fESEdAacY=
github.com/yusufpapurcu/wmi v1.2.3 h1:E1ctvB7uKFMOJw3fdOW32DwGE9I7t++CRUEMKvFoFiw=
github.com/yusufpapurcu/wmi v1.2.3/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0=
go.uber.org/atomic v1.11.0 h1:ZvwS0R+56ePWxUNi+Atn9dWONBPp/AUETXlHW0DxSjE=
go.uber.org/atomic v1.11.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0=
go.uber.org/goleak v1.1.11 h1:wy28qYRKZgnJTxGxvye5/wgWr1EKjmUDGYox5mGlRlI=
go.uber.org/goleak v1.2.0 h1:xqgm/S+aQvhWFTtR0XK3Jvg7z8kGV8P4X14IzwN3Eqk=
go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
go.uber.org/zap v1.24.0 h1:FiJd5l1UOLj0wCgbSE0rwwXHzEdAZS6hiiSnxJN/D60=
go.uber.org/zap v1.24.0/go.mod h1:2kMP+WWQ8aoFoedH3T2sq6iJ2yDWpHbP0f6MQbS9Gkg=
go.uber.org/zap v1.25.0 h1:4Hvk6GtkucQ790dqmj7l1eEnRdKm3k3ZUrUMS2d5+5c=
go.uber.org/zap v1.25.0/go.mod h1:JIAUzQIH94IC4fOJQm7gMmBJP5k7wQfdcnYdPoEXJYk=
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.3.0 h1:ftCYgMx6zT/asHUrPw8BLLscYtGznsLAnjq5RH9P66E=
golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y=
Expand All @@ -83,6 +69,5 @@ google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs
google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
4 changes: 2 additions & 2 deletions ipc/pipe/pipe_factory_bench_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func Benchmark_WorkerPipeNoTTL(b *testing.B) {
b.ReportAllocs()

for i := 0; i < b.N; i++ {
res, err := w.Exec(&payload.Payload{Body: []byte("hello")})
res, err := w.Exec(context.Background(), &payload.Payload{Body: []byte("hello")})
assert.NoError(b, err)
assert.NotNil(b, res)
}
Expand All @@ -52,7 +52,7 @@ func Benchmark_WorkerPipeTTL(b *testing.B) {
b.ReportAllocs()

for i := 0; i < b.N; i++ {
res, err := w.ExecWithTTL(ctx, &payload.Payload{Body: []byte("hello")})
res, err := w.Exec(ctx, &payload.Payload{Body: []byte("hello")})
assert.NoError(b, err)
assert.NotNil(b, res)
}
Expand Down
33 changes: 16 additions & 17 deletions ipc/pipe/pipe_factory_spawn_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package pipe

import (
"context"
"os/exec"
"sync"
"testing"
Expand Down Expand Up @@ -124,7 +125,7 @@ func Test_Pipe_Echo2(t *testing.T) {
w, err := NewPipeFactory(log).SpawnWorker(cmd)
assert.NoError(t, err)

res, err := w.Exec(&payload.Payload{Body: []byte("hello")})
res, err := w.Exec(context.Background(), &payload.Payload{Body: []byte("hello")})

assert.NoError(t, err)
assert.NotNil(t, res)
Expand All @@ -148,7 +149,7 @@ func Test_Pipe_Broken2(t *testing.T) {
assert.NoError(t, err)
require.NotNil(t, w)

res, err := w.Exec(&payload.Payload{Body: []byte("hello")})
res, err := w.Exec(context.Background(), &payload.Payload{Body: []byte("hello")})
assert.Error(t, err)
assert.Nil(t, res)

Expand Down Expand Up @@ -196,7 +197,7 @@ func Benchmark_Pipe_Worker_ExecEcho2(b *testing.B) {
}()

for n := 0; n < b.N; n++ {
if _, err := w.Exec(&payload.Payload{Body: []byte("hello")}); err != nil {
if _, err := w.Exec(context.Background(), &payload.Payload{Body: []byte("hello")}); err != nil {
b.Fail()
}
}
Expand All @@ -217,7 +218,7 @@ func Benchmark_Pipe_Worker_ExecEcho4(b *testing.B) {
}()

for n := 0; n < b.N; n++ {
if _, err := w.Exec(&payload.Payload{Body: []byte("hello")}); err != nil {
if _, err := w.Exec(context.Background(), &payload.Payload{Body: []byte("hello")}); err != nil {
b.Fail()
}
}
Expand All @@ -238,7 +239,7 @@ func Benchmark_Pipe_Worker_ExecEchoWithoutContext2(b *testing.B) {
}()

for n := 0; n < b.N; n++ {
if _, err := w.Exec(&payload.Payload{Body: []byte("hello")}); err != nil {
if _, err := w.Exec(context.Background(), &payload.Payload{Body: []byte("hello")}); err != nil {
b.Fail()
}
}
Expand All @@ -262,7 +263,7 @@ func Test_Echo2(t *testing.T) {
}
}()

res, err := w.Exec(&payload.Payload{Body: []byte("hello")})
res, err := w.Exec(context.Background(), &payload.Payload{Body: []byte("hello")})

assert.Nil(t, err)
assert.NotNil(t, res)
Expand All @@ -287,11 +288,9 @@ func Test_BadPayload2(t *testing.T) {
}
}()

res, err := w.Exec(&payload.Payload{})
assert.Error(t, err)
assert.Nil(t, res)

assert.Contains(t, err.Error(), "payload can not be empty")
res, err := w.Exec(context.Background(), &payload.Payload{})
assert.NoError(t, err)
assert.NotNil(t, res)
}

func Test_String2(t *testing.T) {
Expand Down Expand Up @@ -327,7 +326,7 @@ func Test_Echo_Slow2(t *testing.T) {
}
}()

res, err := w.Exec(&payload.Payload{Body: []byte("hello")})
res, err := w.Exec(context.Background(), &payload.Payload{Body: []byte("hello")})

assert.Nil(t, err)
assert.NotNil(t, res)
Expand All @@ -345,7 +344,7 @@ func Test_Broken2(t *testing.T) {
t.Fatal(err)
}

res, err := w.Exec(&payload.Payload{Body: []byte("hello")})
res, err := w.Exec(context.Background(), &payload.Payload{Body: []byte("hello")})
assert.NotNil(t, err)
assert.Nil(t, res)

Expand All @@ -368,7 +367,7 @@ func Test_Error2(t *testing.T) {
}
}()

res, err := w.Exec(&payload.Payload{Body: []byte("hello")})
res, err := w.Exec(context.Background(), &payload.Payload{Body: []byte("hello")})
assert.NotNil(t, err)
assert.Nil(t, res)

Expand All @@ -392,19 +391,19 @@ func Test_NumExecs2(t *testing.T) {
}
}()

_, err := w.Exec(&payload.Payload{Body: []byte("hello")})
_, err := w.Exec(context.Background(), &payload.Payload{Body: []byte("hello")})
if err != nil {
t.Errorf("fail to execute payload: error %v", err)
}
assert.Equal(t, uint64(1), w.State().NumExecs())

_, err = w.Exec(&payload.Payload{Body: []byte("hello")})
_, err = w.Exec(context.Background(), &payload.Payload{Body: []byte("hello")})
if err != nil {
t.Errorf("fail to execute payload: error %v", err)
}
assert.Equal(t, uint64(2), w.State().NumExecs())

_, err = w.Exec(&payload.Payload{Body: []byte("hello")})
_, err = w.Exec(context.Background(), &payload.Payload{Body: []byte("hello")})
if err != nil {
t.Errorf("fail to execute payload: error %v", err)
}
Expand Down
31 changes: 14 additions & 17 deletions ipc/pipe/pipe_factory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ func Test_Pipe_Echo(t *testing.T) {
}
}()

res, err := w.Exec(&payload.Payload{Body: []byte("hello")})
res, err := w.Exec(context.Background(), &payload.Payload{Body: []byte("hello")})
assert.NoError(t, err)
assert.NotNil(t, res)
assert.NotNil(t, res.Body)
Expand Down Expand Up @@ -182,7 +182,7 @@ func Test_Pipe_Broken(t *testing.T) {
require.Error(t, errW)
}()

res, err := w.Exec(&payload.Payload{Body: []byte("hello")})
res, err := w.Exec(context.Background(), &payload.Payload{Body: []byte("hello")})
assert.Error(t, err)
assert.Nil(t, res)

Expand Down Expand Up @@ -230,7 +230,7 @@ func Benchmark_Pipe_Worker_ExecEcho(b *testing.B) {
}()

for n := 0; n < b.N; n++ {
if _, err := w.Exec(&payload.Payload{Body: []byte("hello")}); err != nil {
if _, err := w.Exec(context.Background(), &payload.Payload{Body: []byte("hello")}); err != nil {
b.Fail()
}
}
Expand All @@ -252,7 +252,7 @@ func Benchmark_Pipe_Worker_ExecEchoWithoutContext(b *testing.B) {
}()

for n := 0; n < b.N; n++ {
if _, err := w.Exec(&payload.Payload{Body: []byte("hello")}); err != nil {
if _, err := w.Exec(context.Background(), &payload.Payload{Body: []byte("hello")}); err != nil {
b.Fail()
}
}
Expand All @@ -278,7 +278,7 @@ func Test_Echo(t *testing.T) {
}
}()

res, err := w.Exec(&payload.Payload{Body: []byte("hello")})
res, err := w.Exec(context.Background(), &payload.Payload{Body: []byte("hello")})

assert.Nil(t, err)
assert.NotNil(t, res)
Expand All @@ -305,12 +305,9 @@ func Test_BadPayload(t *testing.T) {
}
}()

res, err := w.Exec(&payload.Payload{})

assert.Error(t, err)
assert.Nil(t, res)

assert.Contains(t, err.Error(), "payload can not be empty")
res, err := w.Exec(context.Background(), &payload.Payload{})
assert.NoError(t, err)
assert.NotNil(t, res)
}

func Test_String(t *testing.T) {
Expand Down Expand Up @@ -350,7 +347,7 @@ func Test_Echo_Slow(t *testing.T) {
}
}()

res, err := w.Exec(&payload.Payload{Body: []byte("hello")})
res, err := w.Exec(context.Background(), &payload.Payload{Body: []byte("hello")})

assert.Nil(t, err)
assert.NotNil(t, res)
Expand All @@ -369,7 +366,7 @@ func Test_Broken(t *testing.T) {
t.Fatal(err)
}

res, err := w.Exec(&payload.Payload{Body: []byte("hello")})
res, err := w.Exec(context.Background(), &payload.Payload{Body: []byte("hello")})
assert.NotNil(t, err)
assert.Nil(t, res)

Expand All @@ -394,7 +391,7 @@ func Test_Error(t *testing.T) {
}
}()

res, err := w.Exec(&payload.Payload{Body: []byte("hello")})
res, err := w.Exec(context.Background(), &payload.Payload{Body: []byte("hello")})
assert.NotNil(t, err)
assert.Nil(t, res)

Expand All @@ -420,19 +417,19 @@ func Test_NumExecs(t *testing.T) {
}
}()

_, err := w.Exec(&payload.Payload{Body: []byte("hello")})
_, err := w.Exec(context.Background(), &payload.Payload{Body: []byte("hello")})
if err != nil {
t.Errorf("fail to execute payload: error %v", err)
}
assert.Equal(t, uint64(1), w.State().NumExecs())

_, err = w.Exec(&payload.Payload{Body: []byte("hello")})
_, err = w.Exec(context.Background(), &payload.Payload{Body: []byte("hello")})
if err != nil {
t.Errorf("fail to execute payload: error %v", err)
}
assert.Equal(t, uint64(2), w.State().NumExecs())

_, err = w.Exec(&payload.Payload{Body: []byte("hello")})
_, err = w.Exec(context.Background(), &payload.Payload{Body: []byte("hello")})
if err != nil {
t.Errorf("fail to execute payload: error %v", err)
}
Expand Down
Loading
Loading