Skip to content

Commit

Permalink
Disable running sessions on a versioned worker (#1241)
Browse files Browse the repository at this point in the history
  • Loading branch information
Quinn-With-Two-Ns authored Sep 24, 2023
1 parent a5ee832 commit 6039cd3
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
6 changes: 6 additions & 0 deletions internal/internal_worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -1483,6 +1483,12 @@ func NewAggregatedWorker(client *WorkflowClient, taskQueue string, options Worke
panic("cannot set MaxConcurrentWorkflowTaskExecutionSize to 1")
}

// Sessions are not currently compatible with worker versioning
// See: https://github.com/temporalio/sdk-go/issues/1227
if options.EnableSessionWorker && options.UseBuildIDForVersioning {
panic("cannot set both EnableSessionWorker and UseBuildIDForVersioning")
}

// Need reference to result for fatal error handler
var aw *AggregatedWorker
fatalErrorCallback := func(err error) {
Expand Down
11 changes: 11 additions & 0 deletions internal/internal_worker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2778,6 +2778,17 @@ func TestWorkerRegisterDisabledWorkflow(t *testing.T) {
require.Equal(t, "workflow worker disabled, cannot register workflow", recovered)
}

func TestWorkerBuildIDAndSessionPanic(t *testing.T) {
// Expect panic
var recovered interface{}
func() {
defer func() { recovered = recover() }()
worker := NewAggregatedWorker(&WorkflowClient{}, "some-task-queue", WorkerOptions{EnableSessionWorker: true, UseBuildIDForVersioning: true})
worker.RegisterWorkflow(testReplayWorkflow)
}()
require.Equal(t, "cannot set both EnableSessionWorker and UseBuildIDForVersioning", recovered)
}

func TestHistoryFromJSON(t *testing.T) {
// Load sample history and just make sure it has the right event count
r, err := os.Open("testdata/sampleHistory.json")
Expand Down
1 change: 1 addition & 0 deletions internal/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ type (
// operate on workflows it claims to be compatible with. You must set BuildID if this flag
// is true.
// NOTE: Experimental
// Note: Cannot be enabled at the same time as EnableSessionWorker
UseBuildIDForVersioning bool
}
)
Expand Down

0 comments on commit 6039cd3

Please sign in to comment.