Skip to content

Commit

Permalink
Drop pointer for cron schedule fields (#3936)
Browse files Browse the repository at this point in the history
  • Loading branch information
vytautas-karpavicius authored Jan 29, 2021
1 parent 4f45930 commit b846ad1
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 38 deletions.
24 changes: 12 additions & 12 deletions common/types/mapper/thrift/shared.go
Original file line number Diff line number Diff line change
Expand Up @@ -871,7 +871,7 @@ func FromContinueAsNewWorkflowExecutionDecisionAttributes(t *types.ContinueAsNew
FailureReason: t.FailureReason,
FailureDetails: t.FailureDetails,
LastCompletionResult: t.LastCompletionResult,
CronSchedule: t.CronSchedule,
CronSchedule: &t.CronSchedule,
Header: FromHeader(t.Header),
Memo: FromMemo(t.Memo),
SearchAttributes: FromSearchAttributes(t.SearchAttributes),
Expand All @@ -895,7 +895,7 @@ func ToContinueAsNewWorkflowExecutionDecisionAttributes(t *shared.ContinueAsNewW
FailureReason: t.FailureReason,
FailureDetails: t.FailureDetails,
LastCompletionResult: t.LastCompletionResult,
CronSchedule: t.CronSchedule,
CronSchedule: t.GetCronSchedule(),
Header: ToHeader(t.Header),
Memo: ToMemo(t.Memo),
SearchAttributes: ToSearchAttributes(t.SearchAttributes),
Expand Down Expand Up @@ -4778,7 +4778,7 @@ func FromSignalWithStartWorkflowExecutionRequest(t *types.SignalWithStartWorkflo
SignalInput: t.SignalInput,
Control: t.Control,
RetryPolicy: FromRetryPolicy(t.RetryPolicy),
CronSchedule: t.CronSchedule,
CronSchedule: &t.CronSchedule,
Memo: FromMemo(t.Memo),
SearchAttributes: FromSearchAttributes(t.SearchAttributes),
Header: FromHeader(t.Header),
Expand All @@ -4805,7 +4805,7 @@ func ToSignalWithStartWorkflowExecutionRequest(t *shared.SignalWithStartWorkflow
SignalInput: t.SignalInput,
Control: t.Control,
RetryPolicy: ToRetryPolicy(t.RetryPolicy),
CronSchedule: t.CronSchedule,
CronSchedule: t.GetCronSchedule(),
Memo: ToMemo(t.Memo),
SearchAttributes: ToSearchAttributes(t.SearchAttributes),
Header: ToHeader(t.Header),
Expand Down Expand Up @@ -4861,7 +4861,7 @@ func FromStartChildWorkflowExecutionDecisionAttributes(t *types.StartChildWorkfl
Control: t.Control,
WorkflowIdReusePolicy: FromWorkflowIDReusePolicy(t.WorkflowIDReusePolicy),
RetryPolicy: FromRetryPolicy(t.RetryPolicy),
CronSchedule: t.CronSchedule,
CronSchedule: &t.CronSchedule,
Header: FromHeader(t.Header),
Memo: FromMemo(t.Memo),
SearchAttributes: FromSearchAttributes(t.SearchAttributes),
Expand All @@ -4885,7 +4885,7 @@ func ToStartChildWorkflowExecutionDecisionAttributes(t *shared.StartChildWorkflo
Control: t.Control,
WorkflowIDReusePolicy: ToWorkflowIDReusePolicy(t.WorkflowIdReusePolicy),
RetryPolicy: ToRetryPolicy(t.RetryPolicy),
CronSchedule: t.CronSchedule,
CronSchedule: t.GetCronSchedule(),
Header: ToHeader(t.Header),
Memo: ToMemo(t.Memo),
SearchAttributes: ToSearchAttributes(t.SearchAttributes),
Expand Down Expand Up @@ -4942,7 +4942,7 @@ func FromStartChildWorkflowExecutionInitiatedEventAttributes(t *types.StartChild
DecisionTaskCompletedEventId: t.DecisionTaskCompletedEventID,
WorkflowIdReusePolicy: FromWorkflowIDReusePolicy(t.WorkflowIDReusePolicy),
RetryPolicy: FromRetryPolicy(t.RetryPolicy),
CronSchedule: t.CronSchedule,
CronSchedule: &t.CronSchedule,
Header: FromHeader(t.Header),
Memo: FromMemo(t.Memo),
SearchAttributes: FromSearchAttributes(t.SearchAttributes),
Expand All @@ -4967,7 +4967,7 @@ func ToStartChildWorkflowExecutionInitiatedEventAttributes(t *shared.StartChildW
DecisionTaskCompletedEventID: t.DecisionTaskCompletedEventId,
WorkflowIDReusePolicy: ToWorkflowIDReusePolicy(t.WorkflowIdReusePolicy),
RetryPolicy: ToRetryPolicy(t.RetryPolicy),
CronSchedule: t.CronSchedule,
CronSchedule: t.GetCronSchedule(),
Header: ToHeader(t.Header),
Memo: ToMemo(t.Memo),
SearchAttributes: ToSearchAttributes(t.SearchAttributes),
Expand Down Expand Up @@ -5035,7 +5035,7 @@ func FromStartWorkflowExecutionRequest(t *types.StartWorkflowExecutionRequest) *
RequestId: &t.RequestID,
WorkflowIdReusePolicy: FromWorkflowIDReusePolicy(t.WorkflowIDReusePolicy),
RetryPolicy: FromRetryPolicy(t.RetryPolicy),
CronSchedule: t.CronSchedule,
CronSchedule: &t.CronSchedule,
Memo: FromMemo(t.Memo),
SearchAttributes: FromSearchAttributes(t.SearchAttributes),
Header: FromHeader(t.Header),
Expand All @@ -5059,7 +5059,7 @@ func ToStartWorkflowExecutionRequest(t *shared.StartWorkflowExecutionRequest) *t
RequestID: t.GetRequestId(),
WorkflowIDReusePolicy: ToWorkflowIDReusePolicy(t.WorkflowIdReusePolicy),
RetryPolicy: ToRetryPolicy(t.RetryPolicy),
CronSchedule: t.CronSchedule,
CronSchedule: t.GetCronSchedule(),
Memo: ToMemo(t.Memo),
SearchAttributes: ToSearchAttributes(t.SearchAttributes),
Header: ToHeader(t.Header),
Expand Down Expand Up @@ -6071,7 +6071,7 @@ func FromWorkflowExecutionStartedEventAttributes(t *types.WorkflowExecutionStart
RetryPolicy: FromRetryPolicy(t.RetryPolicy),
Attempt: t.Attempt,
ExpirationTimestamp: t.ExpirationTimestamp,
CronSchedule: t.CronSchedule,
CronSchedule: &t.CronSchedule,
FirstDecisionTaskBackoffSeconds: t.FirstDecisionTaskBackoffSeconds,
Memo: FromMemo(t.Memo),
SearchAttributes: FromSearchAttributes(t.SearchAttributes),
Expand Down Expand Up @@ -6105,7 +6105,7 @@ func ToWorkflowExecutionStartedEventAttributes(t *shared.WorkflowExecutionStarte
RetryPolicy: ToRetryPolicy(t.RetryPolicy),
Attempt: t.Attempt,
ExpirationTimestamp: t.ExpirationTimestamp,
CronSchedule: t.CronSchedule,
CronSchedule: t.GetCronSchedule(),
FirstDecisionTaskBackoffSeconds: t.FirstDecisionTaskBackoffSeconds,
Memo: ToMemo(t.Memo),
SearchAttributes: ToSearchAttributes(t.SearchAttributes),
Expand Down
37 changes: 19 additions & 18 deletions common/types/shared.go
Original file line number Diff line number Diff line change
Expand Up @@ -1257,7 +1257,7 @@ type ContinueAsNewWorkflowExecutionDecisionAttributes struct {
FailureReason *string `json:"failureReason,omitempty"`
FailureDetails []byte `json:"failureDetails,omitempty"`
LastCompletionResult []byte `json:"lastCompletionResult,omitempty"`
CronSchedule *string `json:"cronSchedule,omitempty"`
CronSchedule string `json:"cronSchedule,omitempty"`
Header *Header `json:"header,omitempty"`
Memo *Memo `json:"memo,omitempty"`
SearchAttributes *SearchAttributes `json:"searchAttributes,omitempty"`
Expand Down Expand Up @@ -1353,8 +1353,8 @@ func (v *ContinueAsNewWorkflowExecutionDecisionAttributes) GetLastCompletionResu

// GetCronSchedule is an internal getter (TBD...)
func (v *ContinueAsNewWorkflowExecutionDecisionAttributes) GetCronSchedule() (o string) {
if v != nil && v.CronSchedule != nil {
return *v.CronSchedule
if v != nil {
return v.CronSchedule
}
return
}
Expand Down Expand Up @@ -7514,7 +7514,7 @@ type SignalWithStartWorkflowExecutionRequest struct {
SignalInput []byte `json:"signalInput,omitempty"`
Control []byte `json:"control,omitempty"`
RetryPolicy *RetryPolicy `json:"retryPolicy,omitempty"`
CronSchedule *string `json:"cronSchedule,omitempty"`
CronSchedule string `json:"cronSchedule,omitempty"`
Memo *Memo `json:"memo,omitempty"`
SearchAttributes *SearchAttributes `json:"searchAttributes,omitempty"`
Header *Header `json:"header,omitempty"`
Expand Down Expand Up @@ -7634,8 +7634,8 @@ func (v *SignalWithStartWorkflowExecutionRequest) GetRetryPolicy() (o *RetryPoli

// GetCronSchedule is an internal getter (TBD...)
func (v *SignalWithStartWorkflowExecutionRequest) GetCronSchedule() (o string) {
if v != nil && v.CronSchedule != nil {
return *v.CronSchedule
if v != nil {
return v.CronSchedule
}
return
}
Expand Down Expand Up @@ -7744,7 +7744,7 @@ type StartChildWorkflowExecutionDecisionAttributes struct {
Control []byte `json:"control,omitempty"`
WorkflowIDReusePolicy *WorkflowIDReusePolicy `json:"workflowIdReusePolicy,omitempty"`
RetryPolicy *RetryPolicy `json:"retryPolicy,omitempty"`
CronSchedule *string `json:"cronSchedule,omitempty"`
CronSchedule string `json:"cronSchedule,omitempty"`
Header *Header `json:"header,omitempty"`
Memo *Memo `json:"memo,omitempty"`
SearchAttributes *SearchAttributes `json:"searchAttributes,omitempty"`
Expand Down Expand Up @@ -7840,8 +7840,8 @@ func (v *StartChildWorkflowExecutionDecisionAttributes) GetRetryPolicy() (o *Ret

// GetCronSchedule is an internal getter (TBD...)
func (v *StartChildWorkflowExecutionDecisionAttributes) GetCronSchedule() (o string) {
if v != nil && v.CronSchedule != nil {
return *v.CronSchedule
if v != nil {
return v.CronSchedule
}
return
}
Expand Down Expand Up @@ -7951,7 +7951,7 @@ type StartChildWorkflowExecutionInitiatedEventAttributes struct {
DecisionTaskCompletedEventID *int64 `json:"decisionTaskCompletedEventId,omitempty"`
WorkflowIDReusePolicy *WorkflowIDReusePolicy `json:"workflowIdReusePolicy,omitempty"`
RetryPolicy *RetryPolicy `json:"retryPolicy,omitempty"`
CronSchedule *string `json:"cronSchedule,omitempty"`
CronSchedule string `json:"cronSchedule,omitempty"`
Header *Header `json:"header,omitempty"`
Memo *Memo `json:"memo,omitempty"`
SearchAttributes *SearchAttributes `json:"searchAttributes,omitempty"`
Expand Down Expand Up @@ -8055,8 +8055,8 @@ func (v *StartChildWorkflowExecutionInitiatedEventAttributes) GetRetryPolicy() (

// GetCronSchedule is an internal getter (TBD...)
func (v *StartChildWorkflowExecutionInitiatedEventAttributes) GetCronSchedule() (o string) {
if v != nil && v.CronSchedule != nil {
return *v.CronSchedule
if v != nil {
return v.CronSchedule
}
return
}
Expand Down Expand Up @@ -8142,7 +8142,7 @@ type StartWorkflowExecutionRequest struct {
RequestID string `json:"requestId,omitempty"`
WorkflowIDReusePolicy *WorkflowIDReusePolicy `json:"workflowIdReusePolicy,omitempty"`
RetryPolicy *RetryPolicy `json:"retryPolicy,omitempty"`
CronSchedule *string `json:"cronSchedule,omitempty"`
CronSchedule string `json:"cronSchedule,omitempty"`
Memo *Memo `json:"memo,omitempty"`
SearchAttributes *SearchAttributes `json:"searchAttributes,omitempty"`
Header *Header `json:"header,omitempty"`
Expand Down Expand Up @@ -8238,8 +8238,8 @@ func (v *StartWorkflowExecutionRequest) GetRetryPolicy() (o *RetryPolicy) {

// GetCronSchedule is an internal getter (TBD...)
func (v *StartWorkflowExecutionRequest) GetCronSchedule() (o string) {
if v != nil && v.CronSchedule != nil {
return *v.CronSchedule
if v != nil {
return v.CronSchedule
}
return
}
Expand Down Expand Up @@ -9666,7 +9666,7 @@ type WorkflowExecutionStartedEventAttributes struct {
RetryPolicy *RetryPolicy `json:"retryPolicy,omitempty"`
Attempt *int32 `json:"attempt,omitempty"`
ExpirationTimestamp *int64 `json:"expirationTimestamp,omitempty"`
CronSchedule *string `json:"cronSchedule,omitempty"`
CronSchedule string `json:"cronSchedule,omitempty"`
FirstDecisionTaskBackoffSeconds *int32 `json:"firstDecisionTaskBackoffSeconds,omitempty"`
Memo *Memo `json:"memo,omitempty"`
SearchAttributes *SearchAttributes `json:"searchAttributes,omitempty"`
Expand Down Expand Up @@ -9828,12 +9828,13 @@ func (v *WorkflowExecutionStartedEventAttributes) GetExpirationTimestamp() (o in

// GetCronSchedule is an internal getter (TBD...)
func (v *WorkflowExecutionStartedEventAttributes) GetCronSchedule() (o string) {
if v != nil && v.CronSchedule != nil {
return *v.CronSchedule
if v != nil {
return v.CronSchedule
}
return
}

// GetFirstDecisionTaskBackoffSeconds is an internal getter (TBD...)
// GetFirstDecisionTaskBackoffSeconds is an internal getter (TBD...)
func (v *WorkflowExecutionStartedEventAttributes) GetFirstDecisionTaskBackoffSeconds() (o int32) {
if v != nil && v.FirstDecisionTaskBackoffSeconds != nil {
Expand Down
2 changes: 1 addition & 1 deletion common/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func TestCreateHistoryStartWorkflowRequest_ExpirationTimeWithCron(t *testing.T)
InitialIntervalInSeconds: Int32Ptr(60),
ExpirationIntervalInSeconds: Int32Ptr(60),
},
CronSchedule: StringPtr("@every 300s"),
CronSchedule: "@every 300s",
}
now := time.Now()
startRequest := CreateHistoryStartWorkflowRequest(domainID, request, now)
Expand Down
2 changes: 1 addition & 1 deletion host/elasticsearch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ func (s *elasticsearchIntegrationSuite) TestListWorkflow_ExecutionTime() {
s.Nil(err)

cronID := id + "-cron"
request.CronSchedule = common.StringPtr("@every 1m")
request.CronSchedule = "@every 1m"
request.WorkflowID = cronID

weCron, err := s.engine.StartWorkflowExecution(createContext(), request)
Expand Down
6 changes: 3 additions & 3 deletions host/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1044,7 +1044,7 @@ func (s *integrationSuite) TestCronWorkflow() {
ExecutionStartToCloseTimeoutSeconds: common.Int32Ptr(100),
TaskStartToCloseTimeoutSeconds: common.Int32Ptr(1),
Identity: identity,
CronSchedule: common.StringPtr(cronSchedule), //minimum interval by standard spec is 1m (* * * * *), use non-standard descriptor for short interval for test
CronSchedule: cronSchedule, //minimum interval by standard spec is 1m (* * * * *), use non-standard descriptor for short interval for test
Memo: memo,
SearchAttributes: searchAttr,
}
Expand Down Expand Up @@ -1251,7 +1251,7 @@ func (s *integrationSuite) TestCronWorkflowTimeout() {
ExecutionStartToCloseTimeoutSeconds: common.Int32Ptr(1), // set workflow timeout to 1s
TaskStartToCloseTimeoutSeconds: common.Int32Ptr(1),
Identity: identity,
CronSchedule: common.StringPtr(cronSchedule), //minimum interval by standard spec is 1m (* * * * *), use non-standard descriptor for short interval for test
CronSchedule: cronSchedule, //minimum interval by standard spec is 1m (* * * * *), use non-standard descriptor for short interval for test
Memo: memo,
SearchAttributes: searchAttr,
}
Expand Down Expand Up @@ -2132,7 +2132,7 @@ func (s *integrationSuite) TestCronChildWorkflowExecution() {
ExecutionStartToCloseTimeoutSeconds: common.Int32Ptr(200),
TaskStartToCloseTimeoutSeconds: common.Int32Ptr(2),
Control: nil,
CronSchedule: common.StringPtr(cronSchedule),
CronSchedule: cronSchedule,
},
}}, nil
}
Expand Down
2 changes: 1 addition & 1 deletion host/signalworkflow_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,7 @@ func (s *integrationSuite) TestSignalWorkflow_Cron_NoDecisionTaskCreated() {
ExecutionStartToCloseTimeoutSeconds: common.Int32Ptr(100),
TaskStartToCloseTimeoutSeconds: common.Int32Ptr(1),
Identity: identity,
CronSchedule: &cronSpec,
CronSchedule: cronSpec,
}
now := time.Now()

Expand Down
2 changes: 1 addition & 1 deletion service/history/task/timer_active_task_executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,7 @@ func (t *timerActiveTaskExecutor) executeWorkflowTimeoutTask(
RetryPolicy: startAttributes.RetryPolicy,
Initiator: continueAsNewInitiator.Ptr(),
FailureReason: common.StringPtr(timeoutReason),
CronSchedule: common.StringPtr(mutableState.GetExecutionInfo().CronSchedule),
CronSchedule: mutableState.GetExecutionInfo().CronSchedule,
Header: startAttributes.Header,
Memo: startAttributes.Memo,
SearchAttributes: startAttributes.SearchAttributes,
Expand Down
2 changes: 1 addition & 1 deletion service/history/task/transfer_active_task_executor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1993,7 +1993,7 @@ func (s *transferActiveTaskExecutorSuite) TestProcessRecordWorkflowStartedTask()
TaskList: &types.TaskList{Name: taskListName},
ExecutionStartToCloseTimeoutSeconds: common.Int32Ptr(2),
TaskStartToCloseTimeoutSeconds: common.Int32Ptr(1),
CronSchedule: common.StringPtr(cronSchedule),
CronSchedule: cronSchedule,
},
FirstDecisionTaskBackoffSeconds: common.Int32Ptr(backoffSeconds),
},
Expand Down

0 comments on commit b846ad1

Please sign in to comment.