Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use omitempty for start workflow input #370

Merged
merged 2 commits into from
Feb 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions service/api/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ func (s *serviceImpl) ApiV1WorkflowStartPost(
IwfWorkflowType: req.GetIwfWorkflowType(),
IwfWorkerUrl: req.GetIwfWorkerUrl(),
StartStateId: req.StartStateId,
StateInput: req.GetStateInput(),
StateOptions: req.GetStateOptions(),
StateInput: req.StateInput,
StateOptions: req.StateOptions,
InitSearchAttributes: initCustomSAs,
Config: workflowConfig,
UseMemoForDataAttributes: useMemo,
Expand Down
18 changes: 8 additions & 10 deletions service/interfaces.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package service

import (
"time"

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

Expand All @@ -16,23 +14,21 @@ type (

WaitForCompletionStateExecutionIds []string `json:"waitForCompletionStateExecutionIds,omitempty"`

StateInput iwfidl.EncodedObject `json:"stateInput,omitempty"`
StateInput *iwfidl.EncodedObject `json:"stateInput,omitempty"`

StateOptions iwfidl.WorkflowStateOptions `json:"stateOptions,omitempty"`
StateOptions *iwfidl.WorkflowStateOptions `json:"stateOptions,omitempty"`

InitSearchAttributes []iwfidl.SearchAttribute `json:"initSearchAttributes,omitempty"`

UseMemoForDataAttributes bool `json:"useMemoForDataAttributes"`
UseMemoForDataAttributes bool `json:"useMemoForDataAttributes,omitempty"`

Config iwfidl.WorkflowConfig `json:"config,omitempty"`

// IsResumeFromContinueAsNew indicate this is input for continueAsNew
// when true, will ignore StartStateId, StateInput, StateOptions, InitSearchAttributes
IsResumeFromContinueAsNew bool `json:"isResumeFromContinueAsNew"`

ContinueAsNewInput ContinueAsNewInput `json:"continueAsNewInput"`
IsResumeFromContinueAsNew bool `json:"isResumeFromContinueAsNew,omitempty"`

WorkflowExecutionTimeout time.Duration
ContinueAsNewInput *ContinueAsNewInput `json:"continueAsNewInput,omitempty"`
}

ContinueAsNewInput struct {
Expand Down Expand Up @@ -178,7 +174,9 @@ const (
// ValidateTimerSkipRequest validates if the skip timer request is valid
// return true if it's valid, along with the timer pointer
// use timerIdx if timerId is not empty
func ValidateTimerSkipRequest(stateExeTimerInfos map[string][]*TimerInfo, stateExeId, timerId string, timerIdx int) (*TimerInfo, bool) {
func ValidateTimerSkipRequest(
stateExeTimerInfos map[string][]*TimerInfo, stateExeId, timerId string, timerIdx int,
) (*TimerInfo, bool) {
timerInfos := stateExeTimerInfos[stateExeId]
if len(timerInfos) == 0 {
return nil, false
Expand Down
10 changes: 7 additions & 3 deletions service/interpreter/workflowImpl.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ func InterpreterImpl(
if input.StartStateId != nil {
startingState := iwfidl.StateMovement{
StateId: *input.StartStateId,
StateOptions: &input.StateOptions,
StateInput: &input.StateInput,
StateOptions: input.StateOptions,
StateInput: input.StateInput,
}
stateRequestQueue.AddStateStartRequests([]iwfidl.StateMovement{startingState})
}
Expand Down Expand Up @@ -302,9 +302,13 @@ func InterpreterImpl(
// last update config, do it here because we use input to carry over config, not continueAsNewer query
input.Config = workflowConfiger.Get() // update config to the lastest before continueAsNew to carry over
input.IsResumeFromContinueAsNew = true
input.ContinueAsNewInput = service.ContinueAsNewInput{
input.ContinueAsNewInput = &service.ContinueAsNewInput{
PreviousInternalRunId: provider.GetWorkflowInfo(ctx).WorkflowExecution.RunID,
}
// nix the unused data
input.StateInput = nil
input.StateOptions = nil
input.StartStateId = nil
return nil, provider.NewInterpreterContinueAsNewError(ctx, input)
}
} // end main loop
Expand Down
Loading