From d295ead2d0ae658f1ce7e59ac375eddae48ae06c Mon Sep 17 00:00:00 2001 From: duoertai Date: Thu, 21 Mar 2024 00:26:35 -0700 Subject: [PATCH] Add start delay in workflow start options (#376) --- gen/iwfidl/api/openapi.yaml | 109 +++++++++++---------- gen/iwfidl/docs/WorkflowStartOptions.md | 26 +++++ gen/iwfidl/model_workflow_start_options.go | 50 ++++++++-- iwf-idl | 2 +- service/api/cadence/client.go | 4 + service/api/service.go | 4 + service/api/temporal/client.go | 4 + service/client/interfaces.go | 1 + 8 files changed, 140 insertions(+), 60 deletions(-) diff --git a/gen/iwfidl/api/openapi.yaml b/gen/iwfidl/api/openapi.yaml index 69e3fb9a..1056d5d8 100644 --- a/gen/iwfidl/api/openapi.yaml +++ b/gen/iwfidl/api/openapi.yaml @@ -436,9 +436,9 @@ components: example: stringValue: stringValue valueType: null - integerValue: 1 + integerValue: 6 boolValue: true - doubleValue: 6.84685269835264 + doubleValue: 7.457744773683766 stringArrayValue: - stringArrayValue - stringArrayValue @@ -486,9 +486,9 @@ components: WorkflowRetryPolicy: example: maximumAttempts: 1 - initialIntervalSeconds: 4 + initialIntervalSeconds: 7 maximumIntervalSeconds: 1 - backoffCoefficient: 7.386282 + backoffCoefficient: 1.2315135 properties: initialIntervalSeconds: type: integer @@ -616,31 +616,32 @@ components: type: object WorkflowStartOptions: example: + workflowStartDelaySeconds: 4 retryPolicy: maximumAttempts: 1 - initialIntervalSeconds: 4 + initialIntervalSeconds: 7 maximumIntervalSeconds: 1 - backoffCoefficient: 7.386282 + backoffCoefficient: 1.2315135 workflowConfigOverride: disableSystemSearchAttribute: true - continueAsNewThreshold: 7 - continueAsNewPageSizeInBytes: 1 + continueAsNewThreshold: 1 + continueAsNewPageSizeInBytes: 4 idReusePolicy: null searchAttributes: - stringValue: stringValue valueType: null - integerValue: 1 + integerValue: 6 boolValue: true - doubleValue: 6.84685269835264 + doubleValue: 7.457744773683766 stringArrayValue: - stringArrayValue - stringArrayValue key: key - stringValue: stringValue valueType: null - integerValue: 1 + integerValue: 6 boolValue: true - doubleValue: 6.84685269835264 + doubleValue: 7.457744773683766 stringArrayValue: - stringArrayValue - stringArrayValue @@ -653,6 +654,9 @@ components: $ref: '#/components/schemas/WorkflowIDReusePolicy' cronSchedule: type: string + workflowStartDelaySeconds: + format: int32 + type: integer retryPolicy: $ref: '#/components/schemas/WorkflowRetryPolicy' searchAttributes: @@ -818,31 +822,32 @@ components: backoffCoefficient: 5.637377 iwfWorkflowType: iwfWorkflowType workflowStartOptions: + workflowStartDelaySeconds: 4 retryPolicy: maximumAttempts: 1 - initialIntervalSeconds: 4 + initialIntervalSeconds: 7 maximumIntervalSeconds: 1 - backoffCoefficient: 7.386282 + backoffCoefficient: 1.2315135 workflowConfigOverride: disableSystemSearchAttribute: true - continueAsNewThreshold: 7 - continueAsNewPageSizeInBytes: 1 + continueAsNewThreshold: 1 + continueAsNewPageSizeInBytes: 4 idReusePolicy: null searchAttributes: - stringValue: stringValue valueType: null - integerValue: 1 + integerValue: 6 boolValue: true - doubleValue: 6.84685269835264 + doubleValue: 7.457744773683766 stringArrayValue: - stringArrayValue - stringArrayValue key: key - stringValue: stringValue valueType: null - integerValue: 1 + integerValue: 6 boolValue: true - doubleValue: 6.84685269835264 + doubleValue: 7.457744773683766 stringArrayValue: - stringArrayValue - stringArrayValue @@ -999,18 +1004,18 @@ components: searchAttributes: - stringValue: stringValue valueType: null - integerValue: 1 + integerValue: 6 boolValue: true - doubleValue: 6.84685269835264 + doubleValue: 7.457744773683766 stringArrayValue: - stringArrayValue - stringArrayValue key: key - stringValue: stringValue valueType: null - integerValue: 1 + integerValue: 6 boolValue: true - doubleValue: 6.84685269835264 + doubleValue: 7.457744773683766 stringArrayValue: - stringArrayValue - stringArrayValue @@ -1267,18 +1272,18 @@ components: searchAttributes: - stringValue: stringValue valueType: null - integerValue: 1 + integerValue: 6 boolValue: true - doubleValue: 6.84685269835264 + doubleValue: 7.457744773683766 stringArrayValue: - stringArrayValue - stringArrayValue key: key - stringValue: stringValue valueType: null - integerValue: 1 + integerValue: 6 boolValue: true - doubleValue: 6.84685269835264 + doubleValue: 7.457744773683766 stringArrayValue: - stringArrayValue - stringArrayValue @@ -1334,8 +1339,8 @@ components: example: workflowConfig: disableSystemSearchAttribute: true - continueAsNewThreshold: 7 - continueAsNewPageSizeInBytes: 1 + continueAsNewThreshold: 1 + continueAsNewPageSizeInBytes: 4 workflowRunId: workflowRunId workflowId: workflowId properties: @@ -1430,18 +1435,18 @@ components: searchAttributes: - stringValue: stringValue valueType: null - integerValue: 1 + integerValue: 6 boolValue: true - doubleValue: 6.84685269835264 + doubleValue: 7.457744773683766 stringArrayValue: - stringArrayValue - stringArrayValue key: key - stringValue: stringValue valueType: null - integerValue: 1 + integerValue: 6 boolValue: true - doubleValue: 6.84685269835264 + doubleValue: 7.457744773683766 stringArrayValue: - stringArrayValue - stringArrayValue @@ -1486,18 +1491,18 @@ components: upsertSearchAttributes: - stringValue: stringValue valueType: null - integerValue: 1 + integerValue: 6 boolValue: true - doubleValue: 6.84685269835264 + doubleValue: 7.457744773683766 stringArrayValue: - stringArrayValue - stringArrayValue key: key - stringValue: stringValue valueType: null - integerValue: 1 + integerValue: 6 boolValue: true - doubleValue: 6.84685269835264 + doubleValue: 7.457744773683766 stringArrayValue: - stringArrayValue - stringArrayValue @@ -1705,18 +1710,18 @@ components: upsertSearchAttributes: - stringValue: stringValue valueType: null - integerValue: 1 + integerValue: 6 boolValue: true - doubleValue: 6.84685269835264 + doubleValue: 7.457744773683766 stringArrayValue: - stringArrayValue - stringArrayValue key: key - stringValue: stringValue valueType: null - integerValue: 1 + integerValue: 6 boolValue: true - doubleValue: 6.84685269835264 + doubleValue: 7.457744773683766 stringArrayValue: - stringArrayValue - stringArrayValue @@ -1862,18 +1867,18 @@ components: searchAttributes: - stringValue: stringValue valueType: null - integerValue: 1 + integerValue: 6 boolValue: true - doubleValue: 6.84685269835264 + doubleValue: 7.457744773683766 stringArrayValue: - stringArrayValue - stringArrayValue key: key - stringValue: stringValue valueType: null - integerValue: 1 + integerValue: 6 boolValue: true - doubleValue: 6.84685269835264 + doubleValue: 7.457744773683766 stringArrayValue: - stringArrayValue - stringArrayValue @@ -1923,18 +1928,18 @@ components: upsertSearchAttributes: - stringValue: stringValue valueType: null - integerValue: 1 + integerValue: 6 boolValue: true - doubleValue: 6.84685269835264 + doubleValue: 7.457744773683766 stringArrayValue: - stringArrayValue - stringArrayValue key: key - stringValue: stringValue valueType: null - integerValue: 1 + integerValue: 6 boolValue: true - doubleValue: 6.84685269835264 + doubleValue: 7.457744773683766 stringArrayValue: - stringArrayValue - stringArrayValue @@ -2650,8 +2655,8 @@ components: WorkflowConfig: example: disableSystemSearchAttribute: true - continueAsNewThreshold: 7 - continueAsNewPageSizeInBytes: 1 + continueAsNewThreshold: 1 + continueAsNewPageSizeInBytes: 4 properties: disableSystemSearchAttribute: type: boolean diff --git a/gen/iwfidl/docs/WorkflowStartOptions.md b/gen/iwfidl/docs/WorkflowStartOptions.md index bbaa24a5..5036fb74 100644 --- a/gen/iwfidl/docs/WorkflowStartOptions.md +++ b/gen/iwfidl/docs/WorkflowStartOptions.md @@ -6,6 +6,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **WorkflowIDReusePolicy** | Pointer to [**WorkflowIDReusePolicy**](WorkflowIDReusePolicy.md) | | [optional] **CronSchedule** | Pointer to **string** | | [optional] +**WorkflowStartDelaySeconds** | Pointer to **int32** | | [optional] **RetryPolicy** | Pointer to [**WorkflowRetryPolicy**](WorkflowRetryPolicy.md) | | [optional] **SearchAttributes** | Pointer to [**[]SearchAttribute**](SearchAttribute.md) | | [optional] **WorkflowConfigOverride** | Pointer to [**WorkflowConfig**](WorkflowConfig.md) | | [optional] @@ -81,6 +82,31 @@ SetCronSchedule sets CronSchedule field to given value. HasCronSchedule returns a boolean if a field has been set. +### GetWorkflowStartDelaySeconds + +`func (o *WorkflowStartOptions) GetWorkflowStartDelaySeconds() int32` + +GetWorkflowStartDelaySeconds returns the WorkflowStartDelaySeconds field if non-nil, zero value otherwise. + +### GetWorkflowStartDelaySecondsOk + +`func (o *WorkflowStartOptions) GetWorkflowStartDelaySecondsOk() (*int32, bool)` + +GetWorkflowStartDelaySecondsOk returns a tuple with the WorkflowStartDelaySeconds field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetWorkflowStartDelaySeconds + +`func (o *WorkflowStartOptions) SetWorkflowStartDelaySeconds(v int32)` + +SetWorkflowStartDelaySeconds sets WorkflowStartDelaySeconds field to given value. + +### HasWorkflowStartDelaySeconds + +`func (o *WorkflowStartOptions) HasWorkflowStartDelaySeconds() bool` + +HasWorkflowStartDelaySeconds returns a boolean if a field has been set. + ### GetRetryPolicy `func (o *WorkflowStartOptions) GetRetryPolicy() WorkflowRetryPolicy` diff --git a/gen/iwfidl/model_workflow_start_options.go b/gen/iwfidl/model_workflow_start_options.go index 9f16c614..0f283da3 100644 --- a/gen/iwfidl/model_workflow_start_options.go +++ b/gen/iwfidl/model_workflow_start_options.go @@ -19,13 +19,14 @@ var _ MappedNullable = &WorkflowStartOptions{} // WorkflowStartOptions struct for WorkflowStartOptions type WorkflowStartOptions struct { - WorkflowIDReusePolicy *WorkflowIDReusePolicy `json:"workflowIDReusePolicy,omitempty"` - CronSchedule *string `json:"cronSchedule,omitempty"` - RetryPolicy *WorkflowRetryPolicy `json:"retryPolicy,omitempty"` - SearchAttributes []SearchAttribute `json:"searchAttributes,omitempty"` - WorkflowConfigOverride *WorkflowConfig `json:"workflowConfigOverride,omitempty"` - IdReusePolicy *IDReusePolicy `json:"idReusePolicy,omitempty"` - UseMemoForDataAttributes *bool `json:"useMemoForDataAttributes,omitempty"` + WorkflowIDReusePolicy *WorkflowIDReusePolicy `json:"workflowIDReusePolicy,omitempty"` + CronSchedule *string `json:"cronSchedule,omitempty"` + WorkflowStartDelaySeconds *int32 `json:"workflowStartDelaySeconds,omitempty"` + RetryPolicy *WorkflowRetryPolicy `json:"retryPolicy,omitempty"` + SearchAttributes []SearchAttribute `json:"searchAttributes,omitempty"` + WorkflowConfigOverride *WorkflowConfig `json:"workflowConfigOverride,omitempty"` + IdReusePolicy *IDReusePolicy `json:"idReusePolicy,omitempty"` + UseMemoForDataAttributes *bool `json:"useMemoForDataAttributes,omitempty"` } // NewWorkflowStartOptions instantiates a new WorkflowStartOptions object @@ -109,6 +110,38 @@ func (o *WorkflowStartOptions) SetCronSchedule(v string) { o.CronSchedule = &v } +// GetWorkflowStartDelaySeconds returns the WorkflowStartDelaySeconds field value if set, zero value otherwise. +func (o *WorkflowStartOptions) GetWorkflowStartDelaySeconds() int32 { + if o == nil || IsNil(o.WorkflowStartDelaySeconds) { + var ret int32 + return ret + } + return *o.WorkflowStartDelaySeconds +} + +// GetWorkflowStartDelaySecondsOk returns a tuple with the WorkflowStartDelaySeconds field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *WorkflowStartOptions) GetWorkflowStartDelaySecondsOk() (*int32, bool) { + if o == nil || IsNil(o.WorkflowStartDelaySeconds) { + return nil, false + } + return o.WorkflowStartDelaySeconds, true +} + +// HasWorkflowStartDelaySeconds returns a boolean if a field has been set. +func (o *WorkflowStartOptions) HasWorkflowStartDelaySeconds() bool { + if o != nil && !IsNil(o.WorkflowStartDelaySeconds) { + return true + } + + return false +} + +// SetWorkflowStartDelaySeconds gets a reference to the given int32 and assigns it to the WorkflowStartDelaySeconds field. +func (o *WorkflowStartOptions) SetWorkflowStartDelaySeconds(v int32) { + o.WorkflowStartDelaySeconds = &v +} + // GetRetryPolicy returns the RetryPolicy field value if set, zero value otherwise. func (o *WorkflowStartOptions) GetRetryPolicy() WorkflowRetryPolicy { if o == nil || IsNil(o.RetryPolicy) { @@ -285,6 +318,9 @@ func (o WorkflowStartOptions) ToMap() (map[string]interface{}, error) { if !IsNil(o.CronSchedule) { toSerialize["cronSchedule"] = o.CronSchedule } + if !IsNil(o.WorkflowStartDelaySeconds) { + toSerialize["workflowStartDelaySeconds"] = o.WorkflowStartDelaySeconds + } if !IsNil(o.RetryPolicy) { toSerialize["retryPolicy"] = o.RetryPolicy } diff --git a/iwf-idl b/iwf-idl index af1891eb..89b6a1b4 160000 --- a/iwf-idl +++ b/iwf-idl @@ -1 +1 @@ -Subproject commit af1891eb032c534b0b75894c611ead7e2954777d +Subproject commit 89b6a1b40032c1b5abd6a0f46748fbcf236b563a diff --git a/service/api/cadence/client.go b/service/api/cadence/client.go index 7908f330..a4e8d7f9 100644 --- a/service/api/cadence/client.go +++ b/service/api/cadence/client.go @@ -116,6 +116,10 @@ func (t *cadenceClient) StartInterpreterWorkflow( workflowOptions.RetryPolicy = retry.ConvertCadenceWorkflowRetryPolicy(options.RetryPolicy) } + if options.WorkflowStartDelay != nil { + workflowOptions.DelayStart = *options.WorkflowStartDelay + } + run, err := t.cClient.StartWorkflow(ctx, workflowOptions, cadence.Interpreter, args...) if err != nil { return "", err diff --git a/service/api/service.go b/service/api/service.go index e2225f40..8875f743 100644 --- a/service/api/service.go +++ b/service/api/service.go @@ -114,6 +114,10 @@ func (s *serviceImpl) ApiV1WorkflowStartPost( Data: iwfidl.PtrString("true"), } } + if startOptions.WorkflowStartDelaySeconds != nil { + workflowOptions.WorkflowStartDelay = + ptr.Any(time.Duration(*startOptions.WorkflowStartDelaySeconds) * time.Second) + } } input := service.InterpreterWorkflowInput{ diff --git a/service/api/temporal/client.go b/service/api/temporal/client.go index ac4a52ce..c5fc0322 100644 --- a/service/api/temporal/client.go +++ b/service/api/temporal/client.go @@ -142,6 +142,10 @@ func (t *temporalClient) StartInterpreterWorkflow( return "", err } + if options.WorkflowStartDelay != nil { + workflowOptions.StartDelay = *options.WorkflowStartDelay + } + run, err := t.tClient.ExecuteWorkflow(ctx, workflowOptions, temporal.Interpreter, args...) if err != nil { return "", err diff --git a/service/client/interfaces.go b/service/client/interfaces.go index 82fe289c..90e84b3d 100644 --- a/service/client/interfaces.go +++ b/service/client/interfaces.go @@ -53,6 +53,7 @@ type StartWorkflowOptions struct { RetryPolicy *iwfidl.WorkflowRetryPolicy SearchAttributes map[string]interface{} Memo map[string]interface{} + WorkflowStartDelay *time.Duration } type ListWorkflowExecutionsRequest struct {