Skip to content

Commit

Permalink
Don't register a versioned worker for eager start (#1251)
Browse files Browse the repository at this point in the history
Don't register a versioned worker for eager start
  • Loading branch information
Quinn-With-Two-Ns authored Sep 28, 2023
1 parent 59d8488 commit 159a69f
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
2 changes: 2 additions & 0 deletions internal/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -606,6 +606,8 @@ type (

// EnableEagerStart - request eager execution for this workflow, if a local worker is available.
//
// WARNING: Do not use in combination with a versioned task queue.
//
// NOTE: Experimental
EnableEagerStart bool

Expand Down
4 changes: 4 additions & 0 deletions internal/internal_eager_workflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ type eagerWorkflowDispatcher struct {

// registerWorker registers a worker that can be used for eager workflow dispatch
func (e *eagerWorkflowDispatcher) registerWorker(worker *workflowWorker) {
// Currently eager workflow start does not work with versioning
if worker.executionParameters.UseBuildIDForVersioning {
return
}
e.lock.Lock()
defer e.lock.Unlock()
e.workersByTaskQueue[worker.executionParameters.TaskQueue] = append(e.workersByTaskQueue[worker.executionParameters.TaskQueue], worker.worker)
Expand Down
16 changes: 16 additions & 0 deletions internal/internal_eager_workflow_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,3 +114,19 @@ func TestEagerWorkflowExecutor(t *testing.T) {
exec.handleResponse(&workflowservice.PollWorkflowTaskQueueResponse{})
})
}

func TestEagerWorkflowDispatchAndVersioning(t *testing.T) {
dispatcher := &eagerWorkflowDispatcher{
workersByTaskQueue: make(map[string][]eagerWorker),
}
dispatcher.registerWorker(&workflowWorker{
executionParameters: workerExecutionParameters{TaskQueue: "task-queue", UseBuildIDForVersioning: true},
})

request := &workflowservice.StartWorkflowExecutionRequest{
TaskQueue: &taskqueuepb.TaskQueue{Name: "task-queue"},
}
exec := dispatcher.applyToRequest(request)
require.Nil(t, exec)
require.False(t, request.GetRequestEagerExecution())
}

0 comments on commit 159a69f

Please sign in to comment.