go.uber.org/cadence@v1.2.9/internal/compatibility/thrift/history.go (about) 1 // Copyright (c) 2021 Uber Technologies, Inc. 2 // 3 // Permission is hereby granted, free of charge, to any person obtaining a copy 4 // of this software and associated documentation files (the "Software"), to deal 5 // in the Software without restriction, including without limitation the rights 6 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 // copies of the Software, and to permit persons to whom the Software is 8 // furnished to do so, subject to the following conditions: 9 // 10 // The above copyright notice and this permission notice shall be included in 11 // all copies or substantial portions of the Software. 12 // 13 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 // THE SOFTWARE. 20 21 package thrift 22 23 import ( 24 "go.uber.org/cadence/.gen/go/shared" 25 "go.uber.org/cadence/internal/common" 26 27 apiv1 "github.com/uber/cadence-idl/go/proto/api/v1" 28 ) 29 30 func History(t *apiv1.History) *shared.History { 31 if t == nil { 32 return nil 33 } 34 return &shared.History{ 35 Events: HistoryEventArray(t.Events), 36 } 37 } 38 39 func HistoryEventArray(t []*apiv1.HistoryEvent) []*shared.HistoryEvent { 40 if t == nil { 41 return nil 42 } 43 v := make([]*shared.HistoryEvent, len(t)) 44 for i := range t { 45 v[i] = HistoryEvent(t[i]) 46 } 47 return v 48 } 49 50 func HistoryEvent(e *apiv1.HistoryEvent) *shared.HistoryEvent { 51 if e == nil { 52 return nil 53 } 54 event := shared.HistoryEvent{ 55 EventId: &e.EventId, 56 Timestamp: timeToUnixNano(e.EventTime), 57 Version: &e.Version, 58 TaskId: &e.TaskId, 59 } 60 switch attr := e.Attributes.(type) { 61 case *apiv1.HistoryEvent_WorkflowExecutionStartedEventAttributes: 62 event.EventType = shared.EventTypeWorkflowExecutionStarted.Ptr() 63 event.WorkflowExecutionStartedEventAttributes = WorkflowExecutionStartedEventAttributes(attr.WorkflowExecutionStartedEventAttributes) 64 case *apiv1.HistoryEvent_WorkflowExecutionCompletedEventAttributes: 65 event.EventType = shared.EventTypeWorkflowExecutionCompleted.Ptr() 66 event.WorkflowExecutionCompletedEventAttributes = WorkflowExecutionCompletedEventAttributes(attr.WorkflowExecutionCompletedEventAttributes) 67 case *apiv1.HistoryEvent_WorkflowExecutionFailedEventAttributes: 68 event.EventType = shared.EventTypeWorkflowExecutionFailed.Ptr() 69 event.WorkflowExecutionFailedEventAttributes = WorkflowExecutionFailedEventAttributes(attr.WorkflowExecutionFailedEventAttributes) 70 case *apiv1.HistoryEvent_WorkflowExecutionTimedOutEventAttributes: 71 event.EventType = shared.EventTypeWorkflowExecutionTimedOut.Ptr() 72 event.WorkflowExecutionTimedOutEventAttributes = WorkflowExecutionTimedOutEventAttributes(attr.WorkflowExecutionTimedOutEventAttributes) 73 case *apiv1.HistoryEvent_DecisionTaskScheduledEventAttributes: 74 event.EventType = shared.EventTypeDecisionTaskScheduled.Ptr() 75 event.DecisionTaskScheduledEventAttributes = DecisionTaskScheduledEventAttributes(attr.DecisionTaskScheduledEventAttributes) 76 case *apiv1.HistoryEvent_DecisionTaskStartedEventAttributes: 77 event.EventType = shared.EventTypeDecisionTaskStarted.Ptr() 78 event.DecisionTaskStartedEventAttributes = DecisionTaskStartedEventAttributes(attr.DecisionTaskStartedEventAttributes) 79 case *apiv1.HistoryEvent_DecisionTaskCompletedEventAttributes: 80 event.EventType = shared.EventTypeDecisionTaskCompleted.Ptr() 81 event.DecisionTaskCompletedEventAttributes = DecisionTaskCompletedEventAttributes(attr.DecisionTaskCompletedEventAttributes) 82 case *apiv1.HistoryEvent_DecisionTaskTimedOutEventAttributes: 83 event.EventType = shared.EventTypeDecisionTaskTimedOut.Ptr() 84 event.DecisionTaskTimedOutEventAttributes = DecisionTaskTimedOutEventAttributes(attr.DecisionTaskTimedOutEventAttributes) 85 case *apiv1.HistoryEvent_DecisionTaskFailedEventAttributes: 86 event.EventType = shared.EventTypeDecisionTaskFailed.Ptr() 87 event.DecisionTaskFailedEventAttributes = DecisionTaskFailedEventAttributes(attr.DecisionTaskFailedEventAttributes) 88 case *apiv1.HistoryEvent_ActivityTaskScheduledEventAttributes: 89 event.EventType = shared.EventTypeActivityTaskScheduled.Ptr() 90 event.ActivityTaskScheduledEventAttributes = ActivityTaskScheduledEventAttributes(attr.ActivityTaskScheduledEventAttributes) 91 case *apiv1.HistoryEvent_ActivityTaskStartedEventAttributes: 92 event.EventType = shared.EventTypeActivityTaskStarted.Ptr() 93 event.ActivityTaskStartedEventAttributes = ActivityTaskStartedEventAttributes(attr.ActivityTaskStartedEventAttributes) 94 case *apiv1.HistoryEvent_ActivityTaskCompletedEventAttributes: 95 event.EventType = shared.EventTypeActivityTaskCompleted.Ptr() 96 event.ActivityTaskCompletedEventAttributes = ActivityTaskCompletedEventAttributes(attr.ActivityTaskCompletedEventAttributes) 97 case *apiv1.HistoryEvent_ActivityTaskFailedEventAttributes: 98 event.EventType = shared.EventTypeActivityTaskFailed.Ptr() 99 event.ActivityTaskFailedEventAttributes = ActivityTaskFailedEventAttributes(attr.ActivityTaskFailedEventAttributes) 100 case *apiv1.HistoryEvent_ActivityTaskTimedOutEventAttributes: 101 event.EventType = shared.EventTypeActivityTaskTimedOut.Ptr() 102 event.ActivityTaskTimedOutEventAttributes = ActivityTaskTimedOutEventAttributes(attr.ActivityTaskTimedOutEventAttributes) 103 case *apiv1.HistoryEvent_TimerStartedEventAttributes: 104 event.EventType = shared.EventTypeTimerStarted.Ptr() 105 event.TimerStartedEventAttributes = TimerStartedEventAttributes(attr.TimerStartedEventAttributes) 106 case *apiv1.HistoryEvent_TimerFiredEventAttributes: 107 event.EventType = shared.EventTypeTimerFired.Ptr() 108 event.TimerFiredEventAttributes = TimerFiredEventAttributes(attr.TimerFiredEventAttributes) 109 case *apiv1.HistoryEvent_ActivityTaskCancelRequestedEventAttributes: 110 event.EventType = shared.EventTypeActivityTaskCancelRequested.Ptr() 111 event.ActivityTaskCancelRequestedEventAttributes = ActivityTaskCancelRequestedEventAttributes(attr.ActivityTaskCancelRequestedEventAttributes) 112 case *apiv1.HistoryEvent_RequestCancelActivityTaskFailedEventAttributes: 113 event.EventType = shared.EventTypeRequestCancelActivityTaskFailed.Ptr() 114 event.RequestCancelActivityTaskFailedEventAttributes = RequestCancelActivityTaskFailedEventAttributes(attr.RequestCancelActivityTaskFailedEventAttributes) 115 case *apiv1.HistoryEvent_ActivityTaskCanceledEventAttributes: 116 event.EventType = shared.EventTypeActivityTaskCanceled.Ptr() 117 event.ActivityTaskCanceledEventAttributes = ActivityTaskCanceledEventAttributes(attr.ActivityTaskCanceledEventAttributes) 118 case *apiv1.HistoryEvent_TimerCanceledEventAttributes: 119 event.EventType = shared.EventTypeTimerCanceled.Ptr() 120 event.TimerCanceledEventAttributes = TimerCanceledEventAttributes(attr.TimerCanceledEventAttributes) 121 case *apiv1.HistoryEvent_CancelTimerFailedEventAttributes: 122 event.EventType = shared.EventTypeCancelTimerFailed.Ptr() 123 event.CancelTimerFailedEventAttributes = CancelTimerFailedEventAttributes(attr.CancelTimerFailedEventAttributes) 124 case *apiv1.HistoryEvent_MarkerRecordedEventAttributes: 125 event.EventType = shared.EventTypeMarkerRecorded.Ptr() 126 event.MarkerRecordedEventAttributes = MarkerRecordedEventAttributes(attr.MarkerRecordedEventAttributes) 127 case *apiv1.HistoryEvent_WorkflowExecutionSignaledEventAttributes: 128 event.EventType = shared.EventTypeWorkflowExecutionSignaled.Ptr() 129 event.WorkflowExecutionSignaledEventAttributes = WorkflowExecutionSignaledEventAttributes(attr.WorkflowExecutionSignaledEventAttributes) 130 case *apiv1.HistoryEvent_WorkflowExecutionTerminatedEventAttributes: 131 event.EventType = shared.EventTypeWorkflowExecutionTerminated.Ptr() 132 event.WorkflowExecutionTerminatedEventAttributes = WorkflowExecutionTerminatedEventAttributes(attr.WorkflowExecutionTerminatedEventAttributes) 133 case *apiv1.HistoryEvent_WorkflowExecutionCancelRequestedEventAttributes: 134 event.EventType = shared.EventTypeWorkflowExecutionCancelRequested.Ptr() 135 event.WorkflowExecutionCancelRequestedEventAttributes = WorkflowExecutionCancelRequestedEventAttributes(attr.WorkflowExecutionCancelRequestedEventAttributes) 136 case *apiv1.HistoryEvent_WorkflowExecutionCanceledEventAttributes: 137 event.EventType = shared.EventTypeWorkflowExecutionCanceled.Ptr() 138 event.WorkflowExecutionCanceledEventAttributes = WorkflowExecutionCanceledEventAttributes(attr.WorkflowExecutionCanceledEventAttributes) 139 case *apiv1.HistoryEvent_RequestCancelExternalWorkflowExecutionInitiatedEventAttributes: 140 event.EventType = shared.EventTypeRequestCancelExternalWorkflowExecutionInitiated.Ptr() 141 event.RequestCancelExternalWorkflowExecutionInitiatedEventAttributes = RequestCancelExternalWorkflowExecutionInitiatedEventAttributes(attr.RequestCancelExternalWorkflowExecutionInitiatedEventAttributes) 142 case *apiv1.HistoryEvent_RequestCancelExternalWorkflowExecutionFailedEventAttributes: 143 event.EventType = shared.EventTypeRequestCancelExternalWorkflowExecutionFailed.Ptr() 144 event.RequestCancelExternalWorkflowExecutionFailedEventAttributes = RequestCancelExternalWorkflowExecutionFailedEventAttributes(attr.RequestCancelExternalWorkflowExecutionFailedEventAttributes) 145 case *apiv1.HistoryEvent_ExternalWorkflowExecutionCancelRequestedEventAttributes: 146 event.EventType = shared.EventTypeExternalWorkflowExecutionCancelRequested.Ptr() 147 event.ExternalWorkflowExecutionCancelRequestedEventAttributes = ExternalWorkflowExecutionCancelRequestedEventAttributes(attr.ExternalWorkflowExecutionCancelRequestedEventAttributes) 148 case *apiv1.HistoryEvent_WorkflowExecutionContinuedAsNewEventAttributes: 149 event.EventType = shared.EventTypeWorkflowExecutionContinuedAsNew.Ptr() 150 event.WorkflowExecutionContinuedAsNewEventAttributes = WorkflowExecutionContinuedAsNewEventAttributes(attr.WorkflowExecutionContinuedAsNewEventAttributes) 151 case *apiv1.HistoryEvent_StartChildWorkflowExecutionInitiatedEventAttributes: 152 event.EventType = shared.EventTypeStartChildWorkflowExecutionInitiated.Ptr() 153 event.StartChildWorkflowExecutionInitiatedEventAttributes = StartChildWorkflowExecutionInitiatedEventAttributes(attr.StartChildWorkflowExecutionInitiatedEventAttributes) 154 case *apiv1.HistoryEvent_StartChildWorkflowExecutionFailedEventAttributes: 155 event.EventType = shared.EventTypeStartChildWorkflowExecutionFailed.Ptr() 156 event.StartChildWorkflowExecutionFailedEventAttributes = StartChildWorkflowExecutionFailedEventAttributes(attr.StartChildWorkflowExecutionFailedEventAttributes) 157 case *apiv1.HistoryEvent_ChildWorkflowExecutionStartedEventAttributes: 158 event.EventType = shared.EventTypeChildWorkflowExecutionStarted.Ptr() 159 event.ChildWorkflowExecutionStartedEventAttributes = ChildWorkflowExecutionStartedEventAttributes(attr.ChildWorkflowExecutionStartedEventAttributes) 160 case *apiv1.HistoryEvent_ChildWorkflowExecutionCompletedEventAttributes: 161 event.EventType = shared.EventTypeChildWorkflowExecutionCompleted.Ptr() 162 event.ChildWorkflowExecutionCompletedEventAttributes = ChildWorkflowExecutionCompletedEventAttributes(attr.ChildWorkflowExecutionCompletedEventAttributes) 163 case *apiv1.HistoryEvent_ChildWorkflowExecutionFailedEventAttributes: 164 event.EventType = shared.EventTypeChildWorkflowExecutionFailed.Ptr() 165 event.ChildWorkflowExecutionFailedEventAttributes = ChildWorkflowExecutionFailedEventAttributes(attr.ChildWorkflowExecutionFailedEventAttributes) 166 case *apiv1.HistoryEvent_ChildWorkflowExecutionCanceledEventAttributes: 167 event.EventType = shared.EventTypeChildWorkflowExecutionCanceled.Ptr() 168 event.ChildWorkflowExecutionCanceledEventAttributes = ChildWorkflowExecutionCanceledEventAttributes(attr.ChildWorkflowExecutionCanceledEventAttributes) 169 case *apiv1.HistoryEvent_ChildWorkflowExecutionTimedOutEventAttributes: 170 event.EventType = shared.EventTypeChildWorkflowExecutionTimedOut.Ptr() 171 event.ChildWorkflowExecutionTimedOutEventAttributes = ChildWorkflowExecutionTimedOutEventAttributes(attr.ChildWorkflowExecutionTimedOutEventAttributes) 172 case *apiv1.HistoryEvent_ChildWorkflowExecutionTerminatedEventAttributes: 173 event.EventType = shared.EventTypeChildWorkflowExecutionTerminated.Ptr() 174 event.ChildWorkflowExecutionTerminatedEventAttributes = ChildWorkflowExecutionTerminatedEventAttributes(attr.ChildWorkflowExecutionTerminatedEventAttributes) 175 case *apiv1.HistoryEvent_SignalExternalWorkflowExecutionInitiatedEventAttributes: 176 event.EventType = shared.EventTypeSignalExternalWorkflowExecutionInitiated.Ptr() 177 event.SignalExternalWorkflowExecutionInitiatedEventAttributes = SignalExternalWorkflowExecutionInitiatedEventAttributes(attr.SignalExternalWorkflowExecutionInitiatedEventAttributes) 178 case *apiv1.HistoryEvent_SignalExternalWorkflowExecutionFailedEventAttributes: 179 event.EventType = shared.EventTypeSignalExternalWorkflowExecutionFailed.Ptr() 180 event.SignalExternalWorkflowExecutionFailedEventAttributes = SignalExternalWorkflowExecutionFailedEventAttributes(attr.SignalExternalWorkflowExecutionFailedEventAttributes) 181 case *apiv1.HistoryEvent_ExternalWorkflowExecutionSignaledEventAttributes: 182 event.EventType = shared.EventTypeExternalWorkflowExecutionSignaled.Ptr() 183 event.ExternalWorkflowExecutionSignaledEventAttributes = ExternalWorkflowExecutionSignaledEventAttributes(attr.ExternalWorkflowExecutionSignaledEventAttributes) 184 case *apiv1.HistoryEvent_UpsertWorkflowSearchAttributesEventAttributes: 185 event.EventType = shared.EventTypeUpsertWorkflowSearchAttributes.Ptr() 186 event.UpsertWorkflowSearchAttributesEventAttributes = UpsertWorkflowSearchAttributesEventAttributes(attr.UpsertWorkflowSearchAttributesEventAttributes) 187 default: 188 panic("unknown event type") 189 } 190 191 return &event 192 } 193 194 func ActivityTaskCancelRequestedEventAttributes(t *apiv1.ActivityTaskCancelRequestedEventAttributes) *shared.ActivityTaskCancelRequestedEventAttributes { 195 if t == nil { 196 return nil 197 } 198 return &shared.ActivityTaskCancelRequestedEventAttributes{ 199 ActivityId: &t.ActivityId, 200 DecisionTaskCompletedEventId: &t.DecisionTaskCompletedEventId, 201 } 202 } 203 204 func ActivityTaskCanceledEventAttributes(t *apiv1.ActivityTaskCanceledEventAttributes) *shared.ActivityTaskCanceledEventAttributes { 205 if t == nil { 206 return nil 207 } 208 return &shared.ActivityTaskCanceledEventAttributes{ 209 Details: Payload(t.Details), 210 LatestCancelRequestedEventId: &t.LatestCancelRequestedEventId, 211 ScheduledEventId: &t.ScheduledEventId, 212 StartedEventId: &t.StartedEventId, 213 Identity: &t.Identity, 214 } 215 } 216 217 func ActivityTaskCompletedEventAttributes(t *apiv1.ActivityTaskCompletedEventAttributes) *shared.ActivityTaskCompletedEventAttributes { 218 if t == nil { 219 return nil 220 } 221 return &shared.ActivityTaskCompletedEventAttributes{ 222 Result: Payload(t.Result), 223 ScheduledEventId: &t.ScheduledEventId, 224 StartedEventId: &t.StartedEventId, 225 Identity: &t.Identity, 226 } 227 } 228 229 func ActivityTaskFailedEventAttributes(t *apiv1.ActivityTaskFailedEventAttributes) *shared.ActivityTaskFailedEventAttributes { 230 if t == nil { 231 return nil 232 } 233 return &shared.ActivityTaskFailedEventAttributes{ 234 Reason: FailureReason(t.Failure), 235 Details: FailureDetails(t.Failure), 236 ScheduledEventId: &t.ScheduledEventId, 237 StartedEventId: &t.StartedEventId, 238 Identity: &t.Identity, 239 } 240 } 241 242 func ActivityTaskScheduledEventAttributes(t *apiv1.ActivityTaskScheduledEventAttributes) *shared.ActivityTaskScheduledEventAttributes { 243 if t == nil { 244 return nil 245 } 246 return &shared.ActivityTaskScheduledEventAttributes{ 247 ActivityId: &t.ActivityId, 248 ActivityType: ActivityType(t.ActivityType), 249 Domain: &t.Domain, 250 TaskList: TaskList(t.TaskList), 251 Input: Payload(t.Input), 252 ScheduleToCloseTimeoutSeconds: durationToSeconds(t.ScheduleToCloseTimeout), 253 ScheduleToStartTimeoutSeconds: durationToSeconds(t.ScheduleToStartTimeout), 254 StartToCloseTimeoutSeconds: durationToSeconds(t.StartToCloseTimeout), 255 HeartbeatTimeoutSeconds: durationToSeconds(t.HeartbeatTimeout), 256 DecisionTaskCompletedEventId: &t.DecisionTaskCompletedEventId, 257 RetryPolicy: RetryPolicy(t.RetryPolicy), 258 Header: Header(t.Header), 259 } 260 } 261 262 func ActivityTaskStartedEventAttributes(t *apiv1.ActivityTaskStartedEventAttributes) *shared.ActivityTaskStartedEventAttributes { 263 if t == nil { 264 return nil 265 } 266 return &shared.ActivityTaskStartedEventAttributes{ 267 ScheduledEventId: &t.ScheduledEventId, 268 Identity: &t.Identity, 269 RequestId: &t.RequestId, 270 Attempt: &t.Attempt, 271 LastFailureReason: FailureReason(t.LastFailure), 272 LastFailureDetails: FailureDetails(t.LastFailure), 273 } 274 } 275 276 func ActivityTaskTimedOutEventAttributes(t *apiv1.ActivityTaskTimedOutEventAttributes) *shared.ActivityTaskTimedOutEventAttributes { 277 if t == nil { 278 return nil 279 } 280 return &shared.ActivityTaskTimedOutEventAttributes{ 281 Details: Payload(t.Details), 282 ScheduledEventId: &t.ScheduledEventId, 283 StartedEventId: &t.StartedEventId, 284 TimeoutType: TimeoutType(t.TimeoutType), 285 LastFailureReason: FailureReason(t.LastFailure), 286 LastFailureDetails: FailureDetails(t.LastFailure), 287 } 288 } 289 290 func CancelTimerFailedEventAttributes(t *apiv1.CancelTimerFailedEventAttributes) *shared.CancelTimerFailedEventAttributes { 291 if t == nil { 292 return nil 293 } 294 return &shared.CancelTimerFailedEventAttributes{ 295 TimerId: &t.TimerId, 296 Cause: &t.Cause, 297 DecisionTaskCompletedEventId: &t.DecisionTaskCompletedEventId, 298 Identity: &t.Identity, 299 } 300 } 301 302 func ChildWorkflowExecutionCanceledEventAttributes(t *apiv1.ChildWorkflowExecutionCanceledEventAttributes) *shared.ChildWorkflowExecutionCanceledEventAttributes { 303 if t == nil { 304 return nil 305 } 306 return &shared.ChildWorkflowExecutionCanceledEventAttributes{ 307 Domain: &t.Domain, 308 WorkflowExecution: WorkflowExecution(t.WorkflowExecution), 309 WorkflowType: WorkflowType(t.WorkflowType), 310 InitiatedEventId: &t.InitiatedEventId, 311 StartedEventId: &t.StartedEventId, 312 Details: Payload(t.Details), 313 } 314 } 315 316 func ChildWorkflowExecutionCompletedEventAttributes(t *apiv1.ChildWorkflowExecutionCompletedEventAttributes) *shared.ChildWorkflowExecutionCompletedEventAttributes { 317 if t == nil { 318 return nil 319 } 320 return &shared.ChildWorkflowExecutionCompletedEventAttributes{ 321 Domain: &t.Domain, 322 WorkflowExecution: WorkflowExecution(t.WorkflowExecution), 323 WorkflowType: WorkflowType(t.WorkflowType), 324 InitiatedEventId: &t.InitiatedEventId, 325 StartedEventId: &t.StartedEventId, 326 Result: Payload(t.Result), 327 } 328 } 329 330 func ChildWorkflowExecutionFailedEventAttributes(t *apiv1.ChildWorkflowExecutionFailedEventAttributes) *shared.ChildWorkflowExecutionFailedEventAttributes { 331 if t == nil { 332 return nil 333 } 334 return &shared.ChildWorkflowExecutionFailedEventAttributes{ 335 Domain: &t.Domain, 336 WorkflowExecution: WorkflowExecution(t.WorkflowExecution), 337 WorkflowType: WorkflowType(t.WorkflowType), 338 InitiatedEventId: &t.InitiatedEventId, 339 StartedEventId: &t.StartedEventId, 340 Reason: FailureReason(t.Failure), 341 Details: FailureDetails(t.Failure), 342 } 343 } 344 345 func ChildWorkflowExecutionStartedEventAttributes(t *apiv1.ChildWorkflowExecutionStartedEventAttributes) *shared.ChildWorkflowExecutionStartedEventAttributes { 346 if t == nil { 347 return nil 348 } 349 return &shared.ChildWorkflowExecutionStartedEventAttributes{ 350 Domain: &t.Domain, 351 WorkflowExecution: WorkflowExecution(t.WorkflowExecution), 352 WorkflowType: WorkflowType(t.WorkflowType), 353 InitiatedEventId: &t.InitiatedEventId, 354 Header: Header(t.Header), 355 } 356 } 357 358 func ChildWorkflowExecutionTerminatedEventAttributes(t *apiv1.ChildWorkflowExecutionTerminatedEventAttributes) *shared.ChildWorkflowExecutionTerminatedEventAttributes { 359 if t == nil { 360 return nil 361 } 362 return &shared.ChildWorkflowExecutionTerminatedEventAttributes{ 363 Domain: &t.Domain, 364 WorkflowExecution: WorkflowExecution(t.WorkflowExecution), 365 WorkflowType: WorkflowType(t.WorkflowType), 366 InitiatedEventId: &t.InitiatedEventId, 367 StartedEventId: &t.StartedEventId, 368 } 369 } 370 371 func ChildWorkflowExecutionTimedOutEventAttributes(t *apiv1.ChildWorkflowExecutionTimedOutEventAttributes) *shared.ChildWorkflowExecutionTimedOutEventAttributes { 372 if t == nil { 373 return nil 374 } 375 return &shared.ChildWorkflowExecutionTimedOutEventAttributes{ 376 Domain: &t.Domain, 377 WorkflowExecution: WorkflowExecution(t.WorkflowExecution), 378 WorkflowType: WorkflowType(t.WorkflowType), 379 InitiatedEventId: &t.InitiatedEventId, 380 StartedEventId: &t.StartedEventId, 381 TimeoutType: TimeoutType(t.TimeoutType), 382 } 383 } 384 385 func DecisionTaskFailedEventAttributes(t *apiv1.DecisionTaskFailedEventAttributes) *shared.DecisionTaskFailedEventAttributes { 386 if t == nil { 387 return nil 388 } 389 return &shared.DecisionTaskFailedEventAttributes{ 390 ScheduledEventId: &t.ScheduledEventId, 391 StartedEventId: &t.StartedEventId, 392 Cause: DecisionTaskFailedCause(t.Cause), 393 Reason: FailureReason(t.Failure), 394 Details: FailureDetails(t.Failure), 395 Identity: &t.Identity, 396 BaseRunId: &t.BaseRunId, 397 NewRunId: &t.NewRunId, 398 ForkEventVersion: &t.ForkEventVersion, 399 BinaryChecksum: &t.BinaryChecksum, 400 } 401 } 402 403 func DecisionTaskScheduledEventAttributes(t *apiv1.DecisionTaskScheduledEventAttributes) *shared.DecisionTaskScheduledEventAttributes { 404 if t == nil { 405 return nil 406 } 407 return &shared.DecisionTaskScheduledEventAttributes{ 408 TaskList: TaskList(t.TaskList), 409 StartToCloseTimeoutSeconds: durationToSeconds(t.StartToCloseTimeout), 410 Attempt: common.Int64Ptr(int64(t.Attempt)), 411 } 412 } 413 414 func DecisionTaskStartedEventAttributes(t *apiv1.DecisionTaskStartedEventAttributes) *shared.DecisionTaskStartedEventAttributes { 415 if t == nil { 416 return nil 417 } 418 return &shared.DecisionTaskStartedEventAttributes{ 419 ScheduledEventId: &t.ScheduledEventId, 420 Identity: &t.Identity, 421 RequestId: &t.RequestId, 422 } 423 } 424 425 func DecisionTaskCompletedEventAttributes(t *apiv1.DecisionTaskCompletedEventAttributes) *shared.DecisionTaskCompletedEventAttributes { 426 if t == nil { 427 return nil 428 } 429 return &shared.DecisionTaskCompletedEventAttributes{ 430 ScheduledEventId: &t.ScheduledEventId, 431 StartedEventId: &t.StartedEventId, 432 Identity: &t.Identity, 433 BinaryChecksum: &t.BinaryChecksum, 434 ExecutionContext: t.ExecutionContext, 435 } 436 } 437 438 func DecisionTaskTimedOutEventAttributes(t *apiv1.DecisionTaskTimedOutEventAttributes) *shared.DecisionTaskTimedOutEventAttributes { 439 if t == nil { 440 return nil 441 } 442 return &shared.DecisionTaskTimedOutEventAttributes{ 443 ScheduledEventId: &t.ScheduledEventId, 444 StartedEventId: &t.StartedEventId, 445 TimeoutType: TimeoutType(t.TimeoutType), 446 BaseRunId: &t.BaseRunId, 447 NewRunId: &t.NewRunId, 448 ForkEventVersion: &t.ForkEventVersion, 449 Reason: &t.Reason, 450 Cause: DecisionTaskTimedOutCause(t.Cause), 451 } 452 } 453 454 func ExternalWorkflowExecutionCancelRequestedEventAttributes(t *apiv1.ExternalWorkflowExecutionCancelRequestedEventAttributes) *shared.ExternalWorkflowExecutionCancelRequestedEventAttributes { 455 if t == nil { 456 return nil 457 } 458 return &shared.ExternalWorkflowExecutionCancelRequestedEventAttributes{ 459 InitiatedEventId: &t.InitiatedEventId, 460 Domain: &t.Domain, 461 WorkflowExecution: WorkflowExecution(t.WorkflowExecution), 462 } 463 } 464 465 func ExternalWorkflowExecutionSignaledEventAttributes(t *apiv1.ExternalWorkflowExecutionSignaledEventAttributes) *shared.ExternalWorkflowExecutionSignaledEventAttributes { 466 if t == nil { 467 return nil 468 } 469 return &shared.ExternalWorkflowExecutionSignaledEventAttributes{ 470 InitiatedEventId: &t.InitiatedEventId, 471 Domain: &t.Domain, 472 WorkflowExecution: WorkflowExecution(t.WorkflowExecution), 473 Control: t.Control, 474 } 475 } 476 477 func MarkerRecordedEventAttributes(t *apiv1.MarkerRecordedEventAttributes) *shared.MarkerRecordedEventAttributes { 478 if t == nil { 479 return nil 480 } 481 return &shared.MarkerRecordedEventAttributes{ 482 MarkerName: &t.MarkerName, 483 Details: Payload(t.Details), 484 DecisionTaskCompletedEventId: &t.DecisionTaskCompletedEventId, 485 Header: Header(t.Header), 486 } 487 } 488 489 func RequestCancelActivityTaskFailedEventAttributes(t *apiv1.RequestCancelActivityTaskFailedEventAttributes) *shared.RequestCancelActivityTaskFailedEventAttributes { 490 if t == nil { 491 return nil 492 } 493 return &shared.RequestCancelActivityTaskFailedEventAttributes{ 494 ActivityId: &t.ActivityId, 495 Cause: &t.Cause, 496 DecisionTaskCompletedEventId: &t.DecisionTaskCompletedEventId, 497 } 498 } 499 500 func RequestCancelExternalWorkflowExecutionFailedEventAttributes(t *apiv1.RequestCancelExternalWorkflowExecutionFailedEventAttributes) *shared.RequestCancelExternalWorkflowExecutionFailedEventAttributes { 501 if t == nil { 502 return nil 503 } 504 return &shared.RequestCancelExternalWorkflowExecutionFailedEventAttributes{ 505 Cause: CancelExternalWorkflowExecutionFailedCause(t.Cause), 506 DecisionTaskCompletedEventId: &t.DecisionTaskCompletedEventId, 507 Domain: &t.Domain, 508 WorkflowExecution: WorkflowExecution(t.WorkflowExecution), 509 InitiatedEventId: &t.InitiatedEventId, 510 Control: t.Control, 511 } 512 } 513 514 func RequestCancelExternalWorkflowExecutionInitiatedEventAttributes(t *apiv1.RequestCancelExternalWorkflowExecutionInitiatedEventAttributes) *shared.RequestCancelExternalWorkflowExecutionInitiatedEventAttributes { 515 if t == nil { 516 return nil 517 } 518 return &shared.RequestCancelExternalWorkflowExecutionInitiatedEventAttributes{ 519 DecisionTaskCompletedEventId: &t.DecisionTaskCompletedEventId, 520 Domain: &t.Domain, 521 WorkflowExecution: WorkflowExecution(t.WorkflowExecution), 522 Control: t.Control, 523 ChildWorkflowOnly: &t.ChildWorkflowOnly, 524 } 525 } 526 527 func SignalExternalWorkflowExecutionFailedEventAttributes(t *apiv1.SignalExternalWorkflowExecutionFailedEventAttributes) *shared.SignalExternalWorkflowExecutionFailedEventAttributes { 528 if t == nil { 529 return nil 530 } 531 return &shared.SignalExternalWorkflowExecutionFailedEventAttributes{ 532 Cause: SignalExternalWorkflowExecutionFailedCause(t.Cause), 533 DecisionTaskCompletedEventId: &t.DecisionTaskCompletedEventId, 534 Domain: &t.Domain, 535 WorkflowExecution: WorkflowExecution(t.WorkflowExecution), 536 InitiatedEventId: &t.InitiatedEventId, 537 Control: t.Control, 538 } 539 } 540 541 func SignalExternalWorkflowExecutionInitiatedEventAttributes(t *apiv1.SignalExternalWorkflowExecutionInitiatedEventAttributes) *shared.SignalExternalWorkflowExecutionInitiatedEventAttributes { 542 if t == nil { 543 return nil 544 } 545 return &shared.SignalExternalWorkflowExecutionInitiatedEventAttributes{ 546 DecisionTaskCompletedEventId: &t.DecisionTaskCompletedEventId, 547 Domain: &t.Domain, 548 WorkflowExecution: WorkflowExecution(t.WorkflowExecution), 549 SignalName: &t.SignalName, 550 Input: Payload(t.Input), 551 Control: t.Control, 552 ChildWorkflowOnly: &t.ChildWorkflowOnly, 553 } 554 } 555 556 func StartChildWorkflowExecutionFailedEventAttributes(t *apiv1.StartChildWorkflowExecutionFailedEventAttributes) *shared.StartChildWorkflowExecutionFailedEventAttributes { 557 if t == nil { 558 return nil 559 } 560 return &shared.StartChildWorkflowExecutionFailedEventAttributes{ 561 Domain: &t.Domain, 562 WorkflowId: &t.WorkflowId, 563 WorkflowType: WorkflowType(t.WorkflowType), 564 Cause: ChildWorkflowExecutionFailedCause(t.Cause), 565 Control: t.Control, 566 InitiatedEventId: &t.InitiatedEventId, 567 DecisionTaskCompletedEventId: &t.DecisionTaskCompletedEventId, 568 } 569 } 570 571 func StartChildWorkflowExecutionInitiatedEventAttributes(t *apiv1.StartChildWorkflowExecutionInitiatedEventAttributes) *shared.StartChildWorkflowExecutionInitiatedEventAttributes { 572 if t == nil { 573 return nil 574 } 575 return &shared.StartChildWorkflowExecutionInitiatedEventAttributes{ 576 Domain: &t.Domain, 577 WorkflowId: &t.WorkflowId, 578 WorkflowType: WorkflowType(t.WorkflowType), 579 TaskList: TaskList(t.TaskList), 580 Input: Payload(t.Input), 581 ExecutionStartToCloseTimeoutSeconds: durationToSeconds(t.ExecutionStartToCloseTimeout), 582 TaskStartToCloseTimeoutSeconds: durationToSeconds(t.TaskStartToCloseTimeout), 583 ParentClosePolicy: ParentClosePolicy(t.ParentClosePolicy), 584 Control: t.Control, 585 DecisionTaskCompletedEventId: &t.DecisionTaskCompletedEventId, 586 WorkflowIdReusePolicy: WorkflowIdReusePolicy(t.WorkflowIdReusePolicy), 587 RetryPolicy: RetryPolicy(t.RetryPolicy), 588 CronSchedule: &t.CronSchedule, 589 Header: Header(t.Header), 590 Memo: Memo(t.Memo), 591 SearchAttributes: SearchAttributes(t.SearchAttributes), 592 DelayStartSeconds: durationToSeconds(t.DelayStart), 593 JitterStartSeconds: durationToSeconds(t.JitterStart), 594 } 595 } 596 597 func TimerCanceledEventAttributes(t *apiv1.TimerCanceledEventAttributes) *shared.TimerCanceledEventAttributes { 598 if t == nil { 599 return nil 600 } 601 return &shared.TimerCanceledEventAttributes{ 602 TimerId: &t.TimerId, 603 StartedEventId: &t.StartedEventId, 604 DecisionTaskCompletedEventId: &t.DecisionTaskCompletedEventId, 605 Identity: &t.Identity, 606 } 607 } 608 609 func TimerFiredEventAttributes(t *apiv1.TimerFiredEventAttributes) *shared.TimerFiredEventAttributes { 610 if t == nil { 611 return nil 612 } 613 return &shared.TimerFiredEventAttributes{ 614 TimerId: &t.TimerId, 615 StartedEventId: &t.StartedEventId, 616 } 617 } 618 619 func TimerStartedEventAttributes(t *apiv1.TimerStartedEventAttributes) *shared.TimerStartedEventAttributes { 620 if t == nil { 621 return nil 622 } 623 return &shared.TimerStartedEventAttributes{ 624 TimerId: &t.TimerId, 625 StartToFireTimeoutSeconds: int32To64(durationToSeconds(t.StartToFireTimeout)), 626 DecisionTaskCompletedEventId: &t.DecisionTaskCompletedEventId, 627 } 628 } 629 630 func UpsertWorkflowSearchAttributesEventAttributes(t *apiv1.UpsertWorkflowSearchAttributesEventAttributes) *shared.UpsertWorkflowSearchAttributesEventAttributes { 631 if t == nil { 632 return nil 633 } 634 return &shared.UpsertWorkflowSearchAttributesEventAttributes{ 635 DecisionTaskCompletedEventId: &t.DecisionTaskCompletedEventId, 636 SearchAttributes: SearchAttributes(t.SearchAttributes), 637 } 638 } 639 640 func WorkflowExecutionCancelRequestedEventAttributes(t *apiv1.WorkflowExecutionCancelRequestedEventAttributes) *shared.WorkflowExecutionCancelRequestedEventAttributes { 641 if t == nil { 642 return nil 643 } 644 return &shared.WorkflowExecutionCancelRequestedEventAttributes{ 645 Cause: &t.Cause, 646 ExternalInitiatedEventId: ExternalInitiatedId(t.ExternalExecutionInfo), 647 ExternalWorkflowExecution: ExternalWorkflowExecution(t.ExternalExecutionInfo), 648 Identity: &t.Identity, 649 } 650 } 651 652 func WorkflowExecutionCanceledEventAttributes(t *apiv1.WorkflowExecutionCanceledEventAttributes) *shared.WorkflowExecutionCanceledEventAttributes { 653 if t == nil { 654 return nil 655 } 656 return &shared.WorkflowExecutionCanceledEventAttributes{ 657 DecisionTaskCompletedEventId: &t.DecisionTaskCompletedEventId, 658 Details: Payload(t.Details), 659 } 660 } 661 662 func WorkflowExecutionCompletedEventAttributes(t *apiv1.WorkflowExecutionCompletedEventAttributes) *shared.WorkflowExecutionCompletedEventAttributes { 663 if t == nil { 664 return nil 665 } 666 return &shared.WorkflowExecutionCompletedEventAttributes{ 667 Result: Payload(t.Result), 668 DecisionTaskCompletedEventId: &t.DecisionTaskCompletedEventId, 669 } 670 } 671 672 func WorkflowExecutionContinuedAsNewEventAttributes(t *apiv1.WorkflowExecutionContinuedAsNewEventAttributes) *shared.WorkflowExecutionContinuedAsNewEventAttributes { 673 if t == nil { 674 return nil 675 } 676 return &shared.WorkflowExecutionContinuedAsNewEventAttributes{ 677 NewExecutionRunId: &t.NewExecutionRunId, 678 WorkflowType: WorkflowType(t.WorkflowType), 679 TaskList: TaskList(t.TaskList), 680 Input: Payload(t.Input), 681 ExecutionStartToCloseTimeoutSeconds: durationToSeconds(t.ExecutionStartToCloseTimeout), 682 TaskStartToCloseTimeoutSeconds: durationToSeconds(t.TaskStartToCloseTimeout), 683 DecisionTaskCompletedEventId: &t.DecisionTaskCompletedEventId, 684 BackoffStartIntervalInSeconds: durationToSeconds(t.BackoffStartInterval), 685 Initiator: ContinueAsNewInitiator(t.Initiator), 686 FailureReason: FailureReason(t.Failure), 687 FailureDetails: FailureDetails(t.Failure), 688 LastCompletionResult: Payload(t.LastCompletionResult), 689 Header: Header(t.Header), 690 Memo: Memo(t.Memo), 691 SearchAttributes: SearchAttributes(t.SearchAttributes), 692 } 693 } 694 695 func WorkflowExecutionFailedEventAttributes(t *apiv1.WorkflowExecutionFailedEventAttributes) *shared.WorkflowExecutionFailedEventAttributes { 696 if t == nil { 697 return nil 698 } 699 return &shared.WorkflowExecutionFailedEventAttributes{ 700 Reason: FailureReason(t.Failure), 701 Details: FailureDetails(t.Failure), 702 DecisionTaskCompletedEventId: &t.DecisionTaskCompletedEventId, 703 } 704 } 705 706 func WorkflowExecutionSignaledEventAttributes(t *apiv1.WorkflowExecutionSignaledEventAttributes) *shared.WorkflowExecutionSignaledEventAttributes { 707 if t == nil { 708 return nil 709 } 710 return &shared.WorkflowExecutionSignaledEventAttributes{ 711 SignalName: &t.SignalName, 712 Input: Payload(t.Input), 713 Identity: &t.Identity, 714 } 715 } 716 717 func WorkflowExecutionStartedEventAttributes(t *apiv1.WorkflowExecutionStartedEventAttributes) *shared.WorkflowExecutionStartedEventAttributes { 718 if t == nil { 719 return nil 720 } 721 return &shared.WorkflowExecutionStartedEventAttributes{ 722 WorkflowType: WorkflowType(t.WorkflowType), 723 ParentWorkflowDomain: ParentDomainName(t.ParentExecutionInfo), 724 ParentWorkflowExecution: ParentWorkflowExecution(t.ParentExecutionInfo), 725 ParentInitiatedEventId: ParentInitiatedId(t.ParentExecutionInfo), 726 TaskList: TaskList(t.TaskList), 727 Input: Payload(t.Input), 728 ExecutionStartToCloseTimeoutSeconds: durationToSeconds(t.ExecutionStartToCloseTimeout), 729 TaskStartToCloseTimeoutSeconds: durationToSeconds(t.TaskStartToCloseTimeout), 730 ContinuedExecutionRunId: &t.ContinuedExecutionRunId, 731 Initiator: ContinueAsNewInitiator(t.Initiator), 732 ContinuedFailureReason: FailureReason(t.ContinuedFailure), 733 ContinuedFailureDetails: FailureDetails(t.ContinuedFailure), 734 LastCompletionResult: Payload(t.LastCompletionResult), 735 OriginalExecutionRunId: &t.OriginalExecutionRunId, 736 Identity: &t.Identity, 737 FirstExecutionRunId: &t.FirstExecutionRunId, 738 RetryPolicy: RetryPolicy(t.RetryPolicy), 739 Attempt: &t.Attempt, 740 ExpirationTimestamp: timeToUnixNano(t.ExpirationTime), 741 CronSchedule: &t.CronSchedule, 742 FirstDecisionTaskBackoffSeconds: durationToSeconds(t.FirstDecisionTaskBackoff), 743 Memo: Memo(t.Memo), 744 SearchAttributes: SearchAttributes(t.SearchAttributes), 745 PrevAutoResetPoints: ResetPoints(t.PrevAutoResetPoints), 746 Header: Header(t.Header), 747 } 748 } 749 750 func WorkflowExecutionTerminatedEventAttributes(t *apiv1.WorkflowExecutionTerminatedEventAttributes) *shared.WorkflowExecutionTerminatedEventAttributes { 751 if t == nil { 752 return nil 753 } 754 return &shared.WorkflowExecutionTerminatedEventAttributes{ 755 Reason: &t.Reason, 756 Details: Payload(t.Details), 757 Identity: &t.Identity, 758 } 759 } 760 761 func WorkflowExecutionTimedOutEventAttributes(t *apiv1.WorkflowExecutionTimedOutEventAttributes) *shared.WorkflowExecutionTimedOutEventAttributes { 762 if t == nil { 763 return nil 764 } 765 return &shared.WorkflowExecutionTimedOutEventAttributes{ 766 TimeoutType: TimeoutType(t.TimeoutType), 767 } 768 }