Skip to content

Commit

Permalink
IWF-254: Override WorkflowConfig field by field
Browse files Browse the repository at this point in the history
  • Loading branch information
lwolczynski committed Nov 13, 2024
1 parent 9973d43 commit 28b7fc3
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
31 changes: 30 additions & 1 deletion service/api/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,8 @@ func (s *serviceImpl) ApiV1WorkflowStartPost(
initCustomSAs = startOptions.SearchAttributes
initCustomDAs = startOptions.DataAttributes
if startOptions.HasWorkflowConfigOverride() {
workflowConfig = startOptions.GetWorkflowConfigOverride()
configOverride := startOptions.GetWorkflowConfigOverride()
overrideWorkflowConfig(configOverride, workflowConfig)
}

workflowAlreadyStartedOptions := startOptions.WorkflowAlreadyStartedOptions
Expand Down Expand Up @@ -192,6 +193,34 @@ func (s *serviceImpl) ApiV1WorkflowStartPost(
}, nil
}

func overrideWorkflowConfig(configOverride iwfidl.WorkflowConfig, workflowConfig iwfidl.WorkflowConfig) {
if configOverride.ExecutingStateIdMode == nil {
*workflowConfig.ExecutingStateIdMode = service.DefaultExecutingStateIdMode
} else {
workflowConfig.ExecutingStateIdMode = configOverride.ExecutingStateIdMode
}
if configOverride.ContinueAsNewThreshold == nil {
workflowConfig.ContinueAsNewThreshold = iwfidl.PtrInt32(service.DefaultContinueAsNewThreshold)
} else {
workflowConfig.ContinueAsNewThreshold = configOverride.ContinueAsNewThreshold
}
if configOverride.ContinueAsNewPageSizeInBytes == nil {
workflowConfig.ContinueAsNewPageSizeInBytes = iwfidl.PtrInt32(service.DefaultContinueAsNewPageSizeInBytes)
} else {
workflowConfig.ContinueAsNewPageSizeInBytes = configOverride.ContinueAsNewPageSizeInBytes
}
if configOverride.DisableSystemSearchAttribute == nil {
workflowConfig.DisableSystemSearchAttribute = iwfidl.PtrBool(false)
} else {
workflowConfig.DisableSystemSearchAttribute = configOverride.DisableSystemSearchAttribute
}
if configOverride.OptimizeActivity == nil {
workflowConfig.OptimizeActivity = iwfidl.PtrBool(false)
} else {
workflowConfig.OptimizeActivity = configOverride.OptimizeActivity
}
}

func (s *serviceImpl) ApiV1WorkflowWaitForStateCompletion(
ctx context.Context, req iwfidl.WorkflowWaitForStateCompletionRequest,
) (wresp *iwfidl.WorkflowWaitForStateCompletionResponse, retError *errors.ErrorAndStatus) {
Expand Down
5 changes: 5 additions & 0 deletions service/const.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
package service

import "github.com/indeedeng/iwf/gen/iwfidl"

type (
BackendType string
)

const (
EnvNameDebugMode = "DEBUG_MODE"

// Defaults for WorkflowConfig excluding booleans
DefaultContinueAsNewPageSizeInBytes = 1024 * 1024
DefaultContinueAsNewThreshold = 100
DefaultExecutingStateIdMode = iwfidl.ENABLED_FOR_STATES_WITH_WAIT_UNTIL

// below are special unofficial code for special use case

Expand Down

0 comments on commit 28b7fc3

Please sign in to comment.