Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Brian-McM committed Feb 27, 2025
1 parent 24f145f commit 527ddd0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions guardian/pkg/asyncutil/async.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ func NewCommandCoordinator(executors ...ExecutionController) ExecutionController
// must pause the executor, restart / fix whatever processes need restarting or fixing, then resume execution (using the
// PauseExecution and ResumeExecution functions). ResumeExecution re runs the commands that failed with EOF.
func NewCommandExecutor[C any, R any](ctx context.Context, errBuff ErrorBuffer, f func(context.Context, C) (R, error)) CommandExecutor[C, R] {
hdlr := &commandExecutor[C, R]{
executor := &commandExecutor[C, R]{
command: f,
errBuff: errBuff,
cmdChan: make(chan Command[C, R], 100),
Expand All @@ -124,8 +124,8 @@ func NewCommandExecutor[C any, R any](ctx context.Context, errBuff ErrorBuffer,
shutdownCompleteSig: NewSignaler(),
}

go hdlr.loop(ctx)
return hdlr
go executor.loop(ctx)
return executor
}

func (executor *commandExecutor[C, R]) loop(shutdownCtx context.Context) {
Expand Down
8 changes: 4 additions & 4 deletions guardian/pkg/asyncutil/async_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ func TestRequestHandlerContextCancelledInHungRequest(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()

errBuff := asyncutil.NewAsyncErrorBuffer()
errBuff := asyncutil.NewErrorBuffer()
defer errBuff.Close()

cmdExec := asyncutil.NewAsyncCommandExecutor(ctx, errBuff, func(ctx context.Context, req any) (any, error) {
cmdExec := asyncutil.NewCommandExecutor(ctx, errBuff, func(ctx context.Context, req any) (any, error) {
hungChan := make(chan struct{})
defer close(hungChan)
_, err := asyncutil.ReadWithContext(ctx, hungChan)
Expand All @@ -44,13 +44,13 @@ func TestRequestHandlerStopAndRequeue(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()

errBuff := asyncutil.NewAsyncErrorBuffer()
errBuff := asyncutil.NewErrorBuffer()
defer errBuff.Close()

pause := true
var wg sync.WaitGroup
wg.Add(2)
cmdExec := asyncutil.NewAsyncCommandExecutor(ctx, errBuff, func(ctx context.Context, req any) (any, error) {
cmdExec := asyncutil.NewCommandExecutor(ctx, errBuff, func(ctx context.Context, req any) (any, error) {
if pause {
wg.Done()

Expand Down

0 comments on commit 527ddd0

Please sign in to comment.