From 28b7fc356ac61c0559c4fc8a170704ca4486c2b9 Mon Sep 17 00:00:00 2001 From: lwolczynski Date: Wed, 13 Nov 2024 11:08:22 -0600 Subject: [PATCH] IWF-254: Override WorkflowConfig field by field --- service/api/service.go | 31 ++++++++++++++++++++++++++++++- service/const.go | 5 +++++ 2 files changed, 35 insertions(+), 1 deletion(-) 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