Skip to content

Commit

Permalink
feat(kitmw): fix race condition
Browse files Browse the repository at this point in the history
  • Loading branch information
Reasno committed Mar 10, 2021
1 parent aad54e7 commit 27e5f4c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions kitmw/async.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ func MakeAsyncMiddleware(logger log.Logger, concurrency int) endpoint.Middleware
defer func() {
limit <- struct{}{}
}()
var err error
ctx := opentracing.ContextWithSpan(context.Background(), span)
_, err = next(ctx, request)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion kitmw/async_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func TestMakeAsyncMiddleware(t *testing.T) {
m := MakeAsyncMiddleware(log.NewNopLogger(), 5)
f := m(func(ctx context.Context, request interface{}) (response interface{}, err error) {
c.Inc()
assert.Less(t, c.Load(), 5)
assert.Less(t, int(c.Load()), 5)
time.Sleep(time.Duration(rand.Float64()) * time.Second)
c.Dec()
return nil, nil
Expand Down

0 comments on commit 27e5f4c

Please sign in to comment.