Skip to content

Commit

Permalink
remove defaul
Browse files Browse the repository at this point in the history
  • Loading branch information
longquanzheng committed Mar 16, 2024
1 parent bd4c00f commit ee1506f
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 15 deletions.
2 changes: 1 addition & 1 deletion integ/locking_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func doTestLockingWorkflow(t *testing.T, backendType service.BackendType, config
_, closeFunc2 := startIwfServiceByConfig(IwfServiceTestConfig{
BackendType: backendType,
DisableFailAtMemoIncompatibility: true,
OptimizationVersion: ptr.Any(config2.OptimizationVersionNone),
OptimizationVersion: ptr.Any(config2.OptimizationVersionV1),
})
defer closeFunc2()

Expand Down
6 changes: 4 additions & 2 deletions integ/persistence_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package integ
import (
"context"
"fmt"
config2 "github.com/indeedeng/iwf/service/common/config"
"github.com/indeedeng/iwf/service/common/ptr"
"github.com/indeedeng/iwf/service/common/timeparser"
"log"
Expand Down Expand Up @@ -105,8 +106,9 @@ func doTestPersistenceWorkflow(
defer closeFunc1()

uclient, closeFunc2 := startIwfServiceByConfig(IwfServiceTestConfig{
BackendType: backendType,
MemoEncryption: memoEncryption,
BackendType: backendType,
MemoEncryption: memoEncryption,
OptimizationVersion: ptr.Any(config2.OptimizationVersionV1),
})
defer closeFunc2()

Expand Down
9 changes: 2 additions & 7 deletions service/api/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,8 @@ func (s *serviceImpl) ApiV1WorkflowStartPost(
) (wresp *iwfidl.WorkflowStartResponse, retError *errors.ErrorAndStatus) {
defer func() { log.CapturePanic(recover(), s.logger, &retError) }()

optimizationVersion := config.DefaultOptimizationVersion
if s.config.Api.OptimizationVersion != nil {
optimizationVersion = *s.config.Api.OptimizationVersion
}

var sysSAs map[string]interface{}
if config.IsVersioningOptimized(optimizationVersion) {
if config.IsVersioningOptimized(s.config.Api.OptimizationVersion) {
sysSAs = map[string]interface{}{
service.SearchAttributeIwfWorkflowType: req.IwfWorkflowType,
service.SearchAttributeGlobalVersion: versions.MaxOfAllVersions,
Expand Down Expand Up @@ -131,7 +126,7 @@ func (s *serviceImpl) ApiV1WorkflowStartPost(
Config: workflowConfig,
UseMemoForDataAttributes: useMemo,
WaitForCompletionStateExecutionIds: req.GetWaitForCompletionStateExecutionIds(),
OptimizationVersion: optimizationVersion,
OptimizationVersion: s.config.Api.OptimizationVersion,
}

runId, err := s.client.StartInterpreterWorkflow(ctx, workflowOptions, input)
Expand Down
8 changes: 4 additions & 4 deletions service/common/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,14 @@ type (
)

const (
// OptimizationVersionNone is not doing any optimization. This is the default optimization version
OptimizationVersionNone = 0
// OptimizationVersionV1 is for optimizing the workflow actions(version marker, upsertSearchAttribute)
OptimizationVersionV1 = 1
DefaultOptimizationVersion = OptimizationVersionV1
OptimizationVersionV1 = 1
)

func IsVersioningOptimized(version int) bool {
return version >= OptimizationVersionV1
func IsVersioningOptimized(version *int) bool {
return version != nil && *version >= OptimizationVersionV1
}

var DefaultWorkflowConfig = &iwfidl.WorkflowConfig{
Expand Down
2 changes: 1 addition & 1 deletion service/interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ type (

ContinueAsNewInput *ContinueAsNewInput `json:"continueAsNewInput,omitempty"`

OptimizationVersion int `json:"optmn,omitempty"`
OptimizationVersion *int `json:"optmn,omitempty"`
}

ContinueAsNewInput struct {
Expand Down

0 comments on commit ee1506f

Please sign in to comment.