diff --git a/service/api/service.go b/service/api/service.go index 9c043182..3266af25 100644 --- a/service/api/service.go +++ b/service/api/service.go @@ -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 @@ -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) { diff --git a/service/const.go b/service/const.go index a7014884..e2835ba2 100644 --- a/service/const.go +++ b/service/const.go @@ -1,5 +1,7 @@ package service +import "github.com/indeedeng/iwf/gen/iwfidl" + type ( BackendType string ) @@ -7,7 +9,10 @@ type ( 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