go.uber.org/cadence@v1.2.9/internal/compatibility/proto/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 proto 22 23 import ( 24 "go.uber.org/cadence/.gen/go/shared" 25 26 apiv1 "github.com/uber/cadence-idl/go/proto/api/v1" 27 ) 28 29 func History(t *shared.History) *apiv1.History { 30 if t == nil { 31 return nil 32 } 33 return &apiv1.History{ 34 Events: HistoryEventArray(t.Events), 35 } 36 } 37 38 func HistoryEventArray(t []*shared.HistoryEvent) []*apiv1.HistoryEvent { 39 if t == nil { 40 return nil 41 } 42 v := make([]*apiv1.HistoryEvent, len(t)) 43 for i := range t { 44 v[i] = HistoryEvent(t[i]) 45 } 46 return v 47 } 48 49 func HistoryEvent(e *shared.HistoryEvent) *apiv1.HistoryEvent { 50 if e == nil { 51 return nil 52 } 53 event := apiv1.HistoryEvent{ 54 EventId: e.GetEventId(), 55 EventTime: unixNanoToTime(e.Timestamp), 56 Version: e.GetVersion(), 57 TaskId: e.GetTaskId(), 58 } 59 switch *e.EventType { 60 case shared.EventTypeWorkflowExecutionStarted: 61 event.Attributes = &apiv1.HistoryEvent_WorkflowExecutionStartedEventAttributes{WorkflowExecutionStartedEventAttributes: WorkflowExecutionStartedEventAttributes(e.WorkflowExecutionStartedEventAttributes)} 62 case shared.EventTypeWorkflowExecutionCompleted: 63 event.Attributes = &apiv1.HistoryEvent_WorkflowExecutionCompletedEventAttributes{WorkflowExecutionCompletedEventAttributes: WorkflowExecutionCompletedEventAttributes(e.WorkflowExecutionCompletedEventAttributes)} 64 case shared.EventTypeWorkflowExecutionFailed: 65 event.Attributes = &apiv1.HistoryEvent_WorkflowExecutionFailedEventAttributes{WorkflowExecutionFailedEventAttributes: WorkflowExecutionFailedEventAttributes(e.WorkflowExecutionFailedEventAttributes)} 66 case shared.EventTypeWorkflowExecutionTimedOut: 67 event.Attributes = &apiv1.HistoryEvent_WorkflowExecutionTimedOutEventAttributes{WorkflowExecutionTimedOutEventAttributes: WorkflowExecutionTimedOutEventAttributes(e.WorkflowExecutionTimedOutEventAttributes)} 68 case shared.EventTypeDecisionTaskScheduled: 69 event.Attributes = &apiv1.HistoryEvent_DecisionTaskScheduledEventAttributes{DecisionTaskScheduledEventAttributes: DecisionTaskScheduledEventAttributes(e.DecisionTaskScheduledEventAttributes)} 70 case shared.EventTypeDecisionTaskStarted: 71 event.Attributes = &apiv1.HistoryEvent_DecisionTaskStartedEventAttributes{DecisionTaskStartedEventAttributes: DecisionTaskStartedEventAttributes(e.DecisionTaskStartedEventAttributes)} 72 case shared.EventTypeDecisionTaskCompleted: 73 event.Attributes = &apiv1.HistoryEvent_DecisionTaskCompletedEventAttributes{DecisionTaskCompletedEventAttributes: DecisionTaskCompletedEventAttributes(e.DecisionTaskCompletedEventAttributes)} 74 case shared.EventTypeDecisionTaskTimedOut: 75 event.Attributes = &apiv1.HistoryEvent_DecisionTaskTimedOutEventAttributes{DecisionTaskTimedOutEventAttributes: DecisionTaskTimedOutEventAttributes(e.DecisionTaskTimedOutEventAttributes)} 76 case shared.EventTypeDecisionTaskFailed: 77 event.Attributes = &apiv1.HistoryEvent_DecisionTaskFailedEventAttributes{DecisionTaskFailedEventAttributes: DecisionTaskFailedEventAttributes(e.DecisionTaskFailedEventAttributes)} 78 case shared.EventTypeActivityTaskScheduled: 79 event.Attributes = &apiv1.HistoryEvent_ActivityTaskScheduledEventAttributes{ActivityTaskScheduledEventAttributes: ActivityTaskScheduledEventAttributes(e.ActivityTaskScheduledEventAttributes)} 80 case shared.EventTypeActivityTaskStarted: 81 event.Attributes = &apiv1.HistoryEvent_ActivityTaskStartedEventAttributes{ActivityTaskStartedEventAttributes: ActivityTaskStartedEventAttributes(e.ActivityTaskStartedEventAttributes)} 82 case shared.EventTypeActivityTaskCompleted: 83 event.Attributes = &apiv1.HistoryEvent_ActivityTaskCompletedEventAttributes{ActivityTaskCompletedEventAttributes: ActivityTaskCompletedEventAttributes(e.ActivityTaskCompletedEventAttributes)} 84 case shared.EventTypeActivityTaskFailed: 85 event.Attributes = &apiv1.HistoryEvent_ActivityTaskFailedEventAttributes{ActivityTaskFailedEventAttributes: ActivityTaskFailedEventAttributes(e.ActivityTaskFailedEventAttributes)} 86 case shared.EventTypeActivityTaskTimedOut: 87 event.Attributes = &apiv1.HistoryEvent_ActivityTaskTimedOutEventAttributes{ActivityTaskTimedOutEventAttributes: ActivityTaskTimedOutEventAttributes(e.ActivityTaskTimedOutEventAttributes)} 88 case shared.EventTypeTimerStarted: 89 event.Attributes = &apiv1.HistoryEvent_TimerStartedEventAttributes{TimerStartedEventAttributes: TimerStartedEventAttributes(e.TimerStartedEventAttributes)} 90 case shared.EventTypeTimerFired: 91 event.Attributes = &apiv1.HistoryEvent_TimerFiredEventAttributes{TimerFiredEventAttributes: TimerFiredEventAttributes(e.TimerFiredEventAttributes)} 92 case shared.EventTypeActivityTaskCancelRequested: 93 event.Attributes = &apiv1.HistoryEvent_ActivityTaskCancelRequestedEventAttributes{ActivityTaskCancelRequestedEventAttributes: ActivityTaskCancelRequestedEventAttributes(e.ActivityTaskCancelRequestedEventAttributes)} 94 case shared.EventTypeRequestCancelActivityTaskFailed: 95 event.Attributes = &apiv1.HistoryEvent_RequestCancelActivityTaskFailedEventAttributes{RequestCancelActivityTaskFailedEventAttributes: RequestCancelActivityTaskFailedEventAttributes(e.RequestCancelActivityTaskFailedEventAttributes)} 96 case shared.EventTypeActivityTaskCanceled: 97 event.Attributes = &apiv1.HistoryEvent_ActivityTaskCanceledEventAttributes{ActivityTaskCanceledEventAttributes: ActivityTaskCanceledEventAttributes(e.ActivityTaskCanceledEventAttributes)} 98 case shared.EventTypeTimerCanceled: 99 event.Attributes = &apiv1.HistoryEvent_TimerCanceledEventAttributes{TimerCanceledEventAttributes: TimerCanceledEventAttributes(e.TimerCanceledEventAttributes)} 100 case shared.EventTypeCancelTimerFailed: 101 event.Attributes = &apiv1.HistoryEvent_CancelTimerFailedEventAttributes{CancelTimerFailedEventAttributes: CancelTimerFailedEventAttributes(e.CancelTimerFailedEventAttributes)} 102 case shared.EventTypeMarkerRecorded: 103 event.Attributes = &apiv1.HistoryEvent_MarkerRecordedEventAttributes{MarkerRecordedEventAttributes: MarkerRecordedEventAttributes(e.MarkerRecordedEventAttributes)} 104 case shared.EventTypeWorkflowExecutionSignaled: 105 event.Attributes = &apiv1.HistoryEvent_WorkflowExecutionSignaledEventAttributes{WorkflowExecutionSignaledEventAttributes: WorkflowExecutionSignaledEventAttributes(e.WorkflowExecutionSignaledEventAttributes)} 106 case shared.EventTypeWorkflowExecutionTerminated: 107 event.Attributes = &apiv1.HistoryEvent_WorkflowExecutionTerminatedEventAttributes{WorkflowExecutionTerminatedEventAttributes: WorkflowExecutionTerminatedEventAttributes(e.WorkflowExecutionTerminatedEventAttributes)} 108 case shared.EventTypeWorkflowExecutionCancelRequested: 109 event.Attributes = &apiv1.HistoryEvent_WorkflowExecutionCancelRequestedEventAttributes{WorkflowExecutionCancelRequestedEventAttributes: WorkflowExecutionCancelRequestedEventAttributes(e.WorkflowExecutionCancelRequestedEventAttributes)} 110 case shared.EventTypeWorkflowExecutionCanceled: 111 event.Attributes = &apiv1.HistoryEvent_WorkflowExecutionCanceledEventAttributes{WorkflowExecutionCanceledEventAttributes: WorkflowExecutionCanceledEventAttributes(e.WorkflowExecutionCanceledEventAttributes)} 112 case shared.EventTypeRequestCancelExternalWorkflowExecutionInitiated: 113 event.Attributes = &apiv1.HistoryEvent_RequestCancelExternalWorkflowExecutionInitiatedEventAttributes{RequestCancelExternalWorkflowExecutionInitiatedEventAttributes: RequestCancelExternalWorkflowExecutionInitiatedEventAttributes(e.RequestCancelExternalWorkflowExecutionInitiatedEventAttributes)} 114 case shared.EventTypeRequestCancelExternalWorkflowExecutionFailed: 115 event.Attributes = &apiv1.HistoryEvent_RequestCancelExternalWorkflowExecutionFailedEventAttributes{RequestCancelExternalWorkflowExecutionFailedEventAttributes: RequestCancelExternalWorkflowExecutionFailedEventAttributes(e.RequestCancelExternalWorkflowExecutionFailedEventAttributes)} 116 case shared.EventTypeExternalWorkflowExecutionCancelRequested: 117 event.Attributes = &apiv1.HistoryEvent_ExternalWorkflowExecutionCancelRequestedEventAttributes{ExternalWorkflowExecutionCancelRequestedEventAttributes: ExternalWorkflowExecutionCancelRequestedEventAttributes(e.ExternalWorkflowExecutionCancelRequestedEventAttributes)} 118 case shared.EventTypeWorkflowExecutionContinuedAsNew: 119 event.Attributes = &apiv1.HistoryEvent_WorkflowExecutionContinuedAsNewEventAttributes{WorkflowExecutionContinuedAsNewEventAttributes: WorkflowExecutionContinuedAsNewEventAttributes(e.WorkflowExecutionContinuedAsNewEventAttributes)} 120 case shared.EventTypeStartChildWorkflowExecutionInitiated: 121 event.Attributes = &apiv1.HistoryEvent_StartChildWorkflowExecutionInitiatedEventAttributes{StartChildWorkflowExecutionInitiatedEventAttributes: StartChildWorkflowExecutionInitiatedEventAttributes(e.StartChildWorkflowExecutionInitiatedEventAttributes)} 122 case shared.EventTypeStartChildWorkflowExecutionFailed: 123 event.Attributes = &apiv1.HistoryEvent_StartChildWorkflowExecutionFailedEventAttributes{StartChildWorkflowExecutionFailedEventAttributes: StartChildWorkflowExecutionFailedEventAttributes(e.StartChildWorkflowExecutionFailedEventAttributes)} 124 case shared.EventTypeChildWorkflowExecutionStarted: 125 event.Attributes = &apiv1.HistoryEvent_ChildWorkflowExecutionStartedEventAttributes{ChildWorkflowExecutionStartedEventAttributes: ChildWorkflowExecutionStartedEventAttributes(e.ChildWorkflowExecutionStartedEventAttributes)} 126 case shared.EventTypeChildWorkflowExecutionCompleted: 127 event.Attributes = &apiv1.HistoryEvent_ChildWorkflowExecutionCompletedEventAttributes{ChildWorkflowExecutionCompletedEventAttributes: ChildWorkflowExecutionCompletedEventAttributes(e.ChildWorkflowExecutionCompletedEventAttributes)} 128 case shared.EventTypeChildWorkflowExecutionFailed: 129 event.Attributes = &apiv1.HistoryEvent_ChildWorkflowExecutionFailedEventAttributes{ChildWorkflowExecutionFailedEventAttributes: ChildWorkflowExecutionFailedEventAttributes(e.ChildWorkflowExecutionFailedEventAttributes)} 130 case shared.EventTypeChildWorkflowExecutionCanceled: 131 event.Attributes = &apiv1.HistoryEvent_ChildWorkflowExecutionCanceledEventAttributes{ChildWorkflowExecutionCanceledEventAttributes: ChildWorkflowExecutionCanceledEventAttributes(e.ChildWorkflowExecutionCanceledEventAttributes)} 132 case shared.EventTypeChildWorkflowExecutionTimedOut: 133 event.Attributes = &apiv1.HistoryEvent_ChildWorkflowExecutionTimedOutEventAttributes{ChildWorkflowExecutionTimedOutEventAttributes: ChildWorkflowExecutionTimedOutEventAttributes(e.ChildWorkflowExecutionTimedOutEventAttributes)} 134 case shared.EventTypeChildWorkflowExecutionTerminated: 135 event.Attributes = &apiv1.HistoryEvent_ChildWorkflowExecutionTerminatedEventAttributes{ChildWorkflowExecutionTerminatedEventAttributes: ChildWorkflowExecutionTerminatedEventAttributes(e.ChildWorkflowExecutionTerminatedEventAttributes)} 136 case shared.EventTypeSignalExternalWorkflowExecutionInitiated: 137 event.Attributes = &apiv1.HistoryEvent_SignalExternalWorkflowExecutionInitiatedEventAttributes{SignalExternalWorkflowExecutionInitiatedEventAttributes: SignalExternalWorkflowExecutionInitiatedEventAttributes(e.SignalExternalWorkflowExecutionInitiatedEventAttributes)} 138 case shared.EventTypeSignalExternalWorkflowExecutionFailed: 139 event.Attributes = &apiv1.HistoryEvent_SignalExternalWorkflowExecutionFailedEventAttributes{SignalExternalWorkflowExecutionFailedEventAttributes: SignalExternalWorkflowExecutionFailedEventAttributes(e.SignalExternalWorkflowExecutionFailedEventAttributes)} 140 case shared.EventTypeExternalWorkflowExecutionSignaled: 141 event.Attributes = &apiv1.HistoryEvent_ExternalWorkflowExecutionSignaledEventAttributes{ExternalWorkflowExecutionSignaledEventAttributes: ExternalWorkflowExecutionSignaledEventAttributes(e.ExternalWorkflowExecutionSignaledEventAttributes)} 142 case shared.EventTypeUpsertWorkflowSearchAttributes: 143 event.Attributes = &apiv1.HistoryEvent_UpsertWorkflowSearchAttributesEventAttributes{UpsertWorkflowSearchAttributesEventAttributes: UpsertWorkflowSearchAttributesEventAttributes(e.UpsertWorkflowSearchAttributesEventAttributes)} 144 default: 145 panic("unknown event type") 146 } 147 return &event 148 } 149 150 func ActivityTaskCancelRequestedEventAttributes(t *shared.ActivityTaskCancelRequestedEventAttributes) *apiv1.ActivityTaskCancelRequestedEventAttributes { 151 if t == nil { 152 return nil 153 } 154 return &apiv1.ActivityTaskCancelRequestedEventAttributes{ 155 ActivityId: t.GetActivityId(), 156 DecisionTaskCompletedEventId: t.GetDecisionTaskCompletedEventId(), 157 } 158 } 159 160 func ActivityTaskCanceledEventAttributes(t *shared.ActivityTaskCanceledEventAttributes) *apiv1.ActivityTaskCanceledEventAttributes { 161 if t == nil { 162 return nil 163 } 164 return &apiv1.ActivityTaskCanceledEventAttributes{ 165 Details: Payload(t.Details), 166 LatestCancelRequestedEventId: t.GetLatestCancelRequestedEventId(), 167 ScheduledEventId: t.GetScheduledEventId(), 168 StartedEventId: t.GetStartedEventId(), 169 Identity: t.GetIdentity(), 170 } 171 } 172 173 func ActivityTaskCompletedEventAttributes(t *shared.ActivityTaskCompletedEventAttributes) *apiv1.ActivityTaskCompletedEventAttributes { 174 if t == nil { 175 return nil 176 } 177 return &apiv1.ActivityTaskCompletedEventAttributes{ 178 Result: Payload(t.Result), 179 ScheduledEventId: t.GetScheduledEventId(), 180 StartedEventId: t.GetStartedEventId(), 181 Identity: t.GetIdentity(), 182 } 183 } 184 185 func ActivityTaskFailedEventAttributes(t *shared.ActivityTaskFailedEventAttributes) *apiv1.ActivityTaskFailedEventAttributes { 186 if t == nil { 187 return nil 188 } 189 return &apiv1.ActivityTaskFailedEventAttributes{ 190 Failure: Failure(t.Reason, t.Details), 191 ScheduledEventId: t.GetScheduledEventId(), 192 StartedEventId: t.GetStartedEventId(), 193 Identity: t.GetIdentity(), 194 } 195 } 196 197 func ActivityTaskScheduledEventAttributes(t *shared.ActivityTaskScheduledEventAttributes) *apiv1.ActivityTaskScheduledEventAttributes { 198 if t == nil { 199 return nil 200 } 201 return &apiv1.ActivityTaskScheduledEventAttributes{ 202 ActivityId: t.GetActivityId(), 203 ActivityType: ActivityType(t.ActivityType), 204 Domain: t.GetDomain(), 205 TaskList: TaskList(t.TaskList), 206 Input: Payload(t.Input), 207 ScheduleToCloseTimeout: secondsToDuration(t.ScheduleToCloseTimeoutSeconds), 208 ScheduleToStartTimeout: secondsToDuration(t.ScheduleToStartTimeoutSeconds), 209 StartToCloseTimeout: secondsToDuration(t.StartToCloseTimeoutSeconds), 210 HeartbeatTimeout: secondsToDuration(t.HeartbeatTimeoutSeconds), 211 DecisionTaskCompletedEventId: t.GetDecisionTaskCompletedEventId(), 212 RetryPolicy: RetryPolicy(t.RetryPolicy), 213 Header: Header(t.Header), 214 } 215 } 216 217 func ActivityTaskStartedEventAttributes(t *shared.ActivityTaskStartedEventAttributes) *apiv1.ActivityTaskStartedEventAttributes { 218 if t == nil { 219 return nil 220 } 221 return &apiv1.ActivityTaskStartedEventAttributes{ 222 ScheduledEventId: t.GetScheduledEventId(), 223 Identity: t.GetIdentity(), 224 RequestId: t.GetRequestId(), 225 Attempt: t.GetAttempt(), 226 LastFailure: Failure(t.LastFailureReason, t.LastFailureDetails), 227 } 228 } 229 230 func ActivityTaskTimedOutEventAttributes(t *shared.ActivityTaskTimedOutEventAttributes) *apiv1.ActivityTaskTimedOutEventAttributes { 231 if t == nil { 232 return nil 233 } 234 return &apiv1.ActivityTaskTimedOutEventAttributes{ 235 Details: Payload(t.Details), 236 ScheduledEventId: t.GetScheduledEventId(), 237 StartedEventId: t.GetStartedEventId(), 238 TimeoutType: TimeoutType(t.TimeoutType), 239 LastFailure: Failure(t.LastFailureReason, t.LastFailureDetails), 240 } 241 } 242 243 func CancelTimerFailedEventAttributes(t *shared.CancelTimerFailedEventAttributes) *apiv1.CancelTimerFailedEventAttributes { 244 if t == nil { 245 return nil 246 } 247 return &apiv1.CancelTimerFailedEventAttributes{ 248 TimerId: t.GetTimerId(), 249 Cause: t.GetCause(), 250 DecisionTaskCompletedEventId: t.GetDecisionTaskCompletedEventId(), 251 Identity: t.GetIdentity(), 252 } 253 } 254 255 func ChildWorkflowExecutionCanceledEventAttributes(t *shared.ChildWorkflowExecutionCanceledEventAttributes) *apiv1.ChildWorkflowExecutionCanceledEventAttributes { 256 if t == nil { 257 return nil 258 } 259 return &apiv1.ChildWorkflowExecutionCanceledEventAttributes{ 260 Domain: t.GetDomain(), 261 WorkflowExecution: WorkflowExecution(t.WorkflowExecution), 262 WorkflowType: WorkflowType(t.WorkflowType), 263 InitiatedEventId: t.GetInitiatedEventId(), 264 StartedEventId: t.GetStartedEventId(), 265 Details: Payload(t.Details), 266 } 267 } 268 269 func ChildWorkflowExecutionCompletedEventAttributes(t *shared.ChildWorkflowExecutionCompletedEventAttributes) *apiv1.ChildWorkflowExecutionCompletedEventAttributes { 270 if t == nil { 271 return nil 272 } 273 return &apiv1.ChildWorkflowExecutionCompletedEventAttributes{ 274 Domain: t.GetDomain(), 275 WorkflowExecution: WorkflowExecution(t.WorkflowExecution), 276 WorkflowType: WorkflowType(t.WorkflowType), 277 InitiatedEventId: t.GetInitiatedEventId(), 278 StartedEventId: t.GetStartedEventId(), 279 Result: Payload(t.Result), 280 } 281 } 282 283 func ChildWorkflowExecutionFailedEventAttributes(t *shared.ChildWorkflowExecutionFailedEventAttributes) *apiv1.ChildWorkflowExecutionFailedEventAttributes { 284 if t == nil { 285 return nil 286 } 287 return &apiv1.ChildWorkflowExecutionFailedEventAttributes{ 288 Domain: t.GetDomain(), 289 WorkflowExecution: WorkflowExecution(t.WorkflowExecution), 290 WorkflowType: WorkflowType(t.WorkflowType), 291 InitiatedEventId: t.GetInitiatedEventId(), 292 StartedEventId: t.GetStartedEventId(), 293 Failure: Failure(t.Reason, t.Details), 294 } 295 } 296 297 func ChildWorkflowExecutionStartedEventAttributes(t *shared.ChildWorkflowExecutionStartedEventAttributes) *apiv1.ChildWorkflowExecutionStartedEventAttributes { 298 if t == nil { 299 return nil 300 } 301 return &apiv1.ChildWorkflowExecutionStartedEventAttributes{ 302 Domain: t.GetDomain(), 303 WorkflowExecution: WorkflowExecution(t.WorkflowExecution), 304 WorkflowType: WorkflowType(t.WorkflowType), 305 InitiatedEventId: t.GetInitiatedEventId(), 306 Header: Header(t.Header), 307 } 308 } 309 310 func ChildWorkflowExecutionTerminatedEventAttributes(t *shared.ChildWorkflowExecutionTerminatedEventAttributes) *apiv1.ChildWorkflowExecutionTerminatedEventAttributes { 311 if t == nil { 312 return nil 313 } 314 return &apiv1.ChildWorkflowExecutionTerminatedEventAttributes{ 315 Domain: t.GetDomain(), 316 WorkflowExecution: WorkflowExecution(t.WorkflowExecution), 317 WorkflowType: WorkflowType(t.WorkflowType), 318 InitiatedEventId: t.GetInitiatedEventId(), 319 StartedEventId: t.GetStartedEventId(), 320 } 321 } 322 323 func ChildWorkflowExecutionTimedOutEventAttributes(t *shared.ChildWorkflowExecutionTimedOutEventAttributes) *apiv1.ChildWorkflowExecutionTimedOutEventAttributes { 324 if t == nil { 325 return nil 326 } 327 return &apiv1.ChildWorkflowExecutionTimedOutEventAttributes{ 328 Domain: t.GetDomain(), 329 WorkflowExecution: WorkflowExecution(t.WorkflowExecution), 330 WorkflowType: WorkflowType(t.WorkflowType), 331 InitiatedEventId: t.GetInitiatedEventId(), 332 StartedEventId: t.GetStartedEventId(), 333 TimeoutType: TimeoutType(t.TimeoutType), 334 } 335 } 336 337 func DecisionTaskFailedEventAttributes(t *shared.DecisionTaskFailedEventAttributes) *apiv1.DecisionTaskFailedEventAttributes { 338 if t == nil { 339 return nil 340 } 341 return &apiv1.DecisionTaskFailedEventAttributes{ 342 ScheduledEventId: t.GetScheduledEventId(), 343 StartedEventId: t.GetStartedEventId(), 344 Cause: DecisionTaskFailedCause(t.Cause), 345 Failure: Failure(t.Reason, t.Details), 346 Identity: t.GetIdentity(), 347 BaseRunId: t.GetBaseRunId(), 348 NewRunId: t.GetNewRunId(), 349 ForkEventVersion: t.GetForkEventVersion(), 350 BinaryChecksum: t.GetBinaryChecksum(), 351 } 352 } 353 354 func DecisionTaskScheduledEventAttributes(t *shared.DecisionTaskScheduledEventAttributes) *apiv1.DecisionTaskScheduledEventAttributes { 355 if t == nil { 356 return nil 357 } 358 return &apiv1.DecisionTaskScheduledEventAttributes{ 359 TaskList: TaskList(t.TaskList), 360 StartToCloseTimeout: secondsToDuration(t.StartToCloseTimeoutSeconds), 361 Attempt: int32(t.GetAttempt()), 362 } 363 } 364 365 func DecisionTaskStartedEventAttributes(t *shared.DecisionTaskStartedEventAttributes) *apiv1.DecisionTaskStartedEventAttributes { 366 if t == nil { 367 return nil 368 } 369 return &apiv1.DecisionTaskStartedEventAttributes{ 370 ScheduledEventId: t.GetScheduledEventId(), 371 Identity: t.GetIdentity(), 372 RequestId: t.GetRequestId(), 373 } 374 } 375 376 func DecisionTaskCompletedEventAttributes(t *shared.DecisionTaskCompletedEventAttributes) *apiv1.DecisionTaskCompletedEventAttributes { 377 if t == nil { 378 return nil 379 } 380 return &apiv1.DecisionTaskCompletedEventAttributes{ 381 ScheduledEventId: t.GetScheduledEventId(), 382 StartedEventId: t.GetStartedEventId(), 383 Identity: t.GetIdentity(), 384 BinaryChecksum: t.GetBinaryChecksum(), 385 ExecutionContext: t.ExecutionContext, 386 } 387 } 388 389 func DecisionTaskTimedOutEventAttributes(t *shared.DecisionTaskTimedOutEventAttributes) *apiv1.DecisionTaskTimedOutEventAttributes { 390 if t == nil { 391 return nil 392 } 393 return &apiv1.DecisionTaskTimedOutEventAttributes{ 394 ScheduledEventId: t.GetScheduledEventId(), 395 StartedEventId: t.GetStartedEventId(), 396 TimeoutType: TimeoutType(t.TimeoutType), 397 BaseRunId: t.GetBaseRunId(), 398 NewRunId: t.GetNewRunId(), 399 ForkEventVersion: t.GetForkEventVersion(), 400 Reason: t.GetReason(), 401 Cause: DecisionTaskTimedOutCause(t.Cause), 402 } 403 } 404 405 func ExternalWorkflowExecutionCancelRequestedEventAttributes(t *shared.ExternalWorkflowExecutionCancelRequestedEventAttributes) *apiv1.ExternalWorkflowExecutionCancelRequestedEventAttributes { 406 if t == nil { 407 return nil 408 } 409 return &apiv1.ExternalWorkflowExecutionCancelRequestedEventAttributes{ 410 InitiatedEventId: t.GetInitiatedEventId(), 411 Domain: t.GetDomain(), 412 WorkflowExecution: WorkflowExecution(t.WorkflowExecution), 413 } 414 } 415 416 func ExternalWorkflowExecutionSignaledEventAttributes(t *shared.ExternalWorkflowExecutionSignaledEventAttributes) *apiv1.ExternalWorkflowExecutionSignaledEventAttributes { 417 if t == nil { 418 return nil 419 } 420 return &apiv1.ExternalWorkflowExecutionSignaledEventAttributes{ 421 InitiatedEventId: t.GetInitiatedEventId(), 422 Domain: t.GetDomain(), 423 WorkflowExecution: WorkflowExecution(t.WorkflowExecution), 424 Control: t.Control, 425 } 426 } 427 428 func MarkerRecordedEventAttributes(t *shared.MarkerRecordedEventAttributes) *apiv1.MarkerRecordedEventAttributes { 429 if t == nil { 430 return nil 431 } 432 return &apiv1.MarkerRecordedEventAttributes{ 433 MarkerName: t.GetMarkerName(), 434 Details: Payload(t.Details), 435 DecisionTaskCompletedEventId: t.GetDecisionTaskCompletedEventId(), 436 Header: Header(t.Header), 437 } 438 } 439 440 func RequestCancelActivityTaskFailedEventAttributes(t *shared.RequestCancelActivityTaskFailedEventAttributes) *apiv1.RequestCancelActivityTaskFailedEventAttributes { 441 if t == nil { 442 return nil 443 } 444 return &apiv1.RequestCancelActivityTaskFailedEventAttributes{ 445 ActivityId: t.GetActivityId(), 446 Cause: t.GetCause(), 447 DecisionTaskCompletedEventId: t.GetDecisionTaskCompletedEventId(), 448 } 449 } 450 451 func RequestCancelExternalWorkflowExecutionFailedEventAttributes(t *shared.RequestCancelExternalWorkflowExecutionFailedEventAttributes) *apiv1.RequestCancelExternalWorkflowExecutionFailedEventAttributes { 452 if t == nil { 453 return nil 454 } 455 return &apiv1.RequestCancelExternalWorkflowExecutionFailedEventAttributes{ 456 Cause: CancelExternalWorkflowExecutionFailedCause(t.Cause), 457 DecisionTaskCompletedEventId: t.GetDecisionTaskCompletedEventId(), 458 Domain: t.GetDomain(), 459 WorkflowExecution: WorkflowExecution(t.WorkflowExecution), 460 InitiatedEventId: t.GetInitiatedEventId(), 461 Control: t.Control, 462 } 463 } 464 465 func RequestCancelExternalWorkflowExecutionInitiatedEventAttributes(t *shared.RequestCancelExternalWorkflowExecutionInitiatedEventAttributes) *apiv1.RequestCancelExternalWorkflowExecutionInitiatedEventAttributes { 466 if t == nil { 467 return nil 468 } 469 return &apiv1.RequestCancelExternalWorkflowExecutionInitiatedEventAttributes{ 470 DecisionTaskCompletedEventId: t.GetDecisionTaskCompletedEventId(), 471 Domain: t.GetDomain(), 472 WorkflowExecution: WorkflowExecution(t.WorkflowExecution), 473 Control: t.Control, 474 ChildWorkflowOnly: t.GetChildWorkflowOnly(), 475 } 476 } 477 478 func SignalExternalWorkflowExecutionFailedEventAttributes(t *shared.SignalExternalWorkflowExecutionFailedEventAttributes) *apiv1.SignalExternalWorkflowExecutionFailedEventAttributes { 479 if t == nil { 480 return nil 481 } 482 return &apiv1.SignalExternalWorkflowExecutionFailedEventAttributes{ 483 Cause: SignalExternalWorkflowExecutionFailedCause(t.Cause), 484 DecisionTaskCompletedEventId: t.GetDecisionTaskCompletedEventId(), 485 Domain: t.GetDomain(), 486 WorkflowExecution: WorkflowExecution(t.WorkflowExecution), 487 InitiatedEventId: t.GetInitiatedEventId(), 488 Control: t.Control, 489 } 490 } 491 492 func SignalExternalWorkflowExecutionInitiatedEventAttributes(t *shared.SignalExternalWorkflowExecutionInitiatedEventAttributes) *apiv1.SignalExternalWorkflowExecutionInitiatedEventAttributes { 493 if t == nil { 494 return nil 495 } 496 return &apiv1.SignalExternalWorkflowExecutionInitiatedEventAttributes{ 497 DecisionTaskCompletedEventId: t.GetDecisionTaskCompletedEventId(), 498 Domain: t.GetDomain(), 499 WorkflowExecution: WorkflowExecution(t.WorkflowExecution), 500 SignalName: t.GetSignalName(), 501 Input: Payload(t.Input), 502 Control: t.Control, 503 ChildWorkflowOnly: t.GetChildWorkflowOnly(), 504 } 505 } 506 507 func StartChildWorkflowExecutionFailedEventAttributes(t *shared.StartChildWorkflowExecutionFailedEventAttributes) *apiv1.StartChildWorkflowExecutionFailedEventAttributes { 508 if t == nil { 509 return nil 510 } 511 return &apiv1.StartChildWorkflowExecutionFailedEventAttributes{ 512 Domain: t.GetDomain(), 513 WorkflowId: t.GetWorkflowId(), 514 WorkflowType: WorkflowType(t.WorkflowType), 515 Cause: ChildWorkflowExecutionFailedCause(t.Cause), 516 Control: t.Control, 517 InitiatedEventId: t.GetInitiatedEventId(), 518 DecisionTaskCompletedEventId: t.GetDecisionTaskCompletedEventId(), 519 } 520 } 521 522 func StartChildWorkflowExecutionInitiatedEventAttributes(t *shared.StartChildWorkflowExecutionInitiatedEventAttributes) *apiv1.StartChildWorkflowExecutionInitiatedEventAttributes { 523 if t == nil { 524 return nil 525 } 526 return &apiv1.StartChildWorkflowExecutionInitiatedEventAttributes{ 527 Domain: t.GetDomain(), 528 WorkflowId: t.GetWorkflowId(), 529 WorkflowType: WorkflowType(t.WorkflowType), 530 TaskList: TaskList(t.TaskList), 531 Input: Payload(t.Input), 532 ExecutionStartToCloseTimeout: secondsToDuration(t.ExecutionStartToCloseTimeoutSeconds), 533 TaskStartToCloseTimeout: secondsToDuration(t.TaskStartToCloseTimeoutSeconds), 534 ParentClosePolicy: ParentClosePolicy(t.ParentClosePolicy), 535 Control: t.Control, 536 DecisionTaskCompletedEventId: t.GetDecisionTaskCompletedEventId(), 537 WorkflowIdReusePolicy: WorkflowIdReusePolicy(t.WorkflowIdReusePolicy), 538 RetryPolicy: RetryPolicy(t.RetryPolicy), 539 CronSchedule: t.GetCronSchedule(), 540 Header: Header(t.Header), 541 Memo: Memo(t.Memo), 542 SearchAttributes: SearchAttributes(t.SearchAttributes), 543 DelayStart: secondsToDuration(t.DelayStartSeconds), 544 JitterStart: secondsToDuration(t.JitterStartSeconds), 545 } 546 } 547 548 func TimerCanceledEventAttributes(t *shared.TimerCanceledEventAttributes) *apiv1.TimerCanceledEventAttributes { 549 if t == nil { 550 return nil 551 } 552 return &apiv1.TimerCanceledEventAttributes{ 553 TimerId: t.GetTimerId(), 554 StartedEventId: t.GetStartedEventId(), 555 DecisionTaskCompletedEventId: t.GetDecisionTaskCompletedEventId(), 556 Identity: t.GetIdentity(), 557 } 558 } 559 560 func TimerFiredEventAttributes(t *shared.TimerFiredEventAttributes) *apiv1.TimerFiredEventAttributes { 561 if t == nil { 562 return nil 563 } 564 return &apiv1.TimerFiredEventAttributes{ 565 TimerId: t.GetTimerId(), 566 StartedEventId: t.GetStartedEventId(), 567 } 568 } 569 570 func TimerStartedEventAttributes(t *shared.TimerStartedEventAttributes) *apiv1.TimerStartedEventAttributes { 571 if t == nil { 572 return nil 573 } 574 return &apiv1.TimerStartedEventAttributes{ 575 TimerId: t.GetTimerId(), 576 StartToFireTimeout: secondsToDuration(int64To32(t.StartToFireTimeoutSeconds)), 577 DecisionTaskCompletedEventId: t.GetDecisionTaskCompletedEventId(), 578 } 579 } 580 581 func UpsertWorkflowSearchAttributesEventAttributes(t *shared.UpsertWorkflowSearchAttributesEventAttributes) *apiv1.UpsertWorkflowSearchAttributesEventAttributes { 582 if t == nil { 583 return nil 584 } 585 return &apiv1.UpsertWorkflowSearchAttributesEventAttributes{ 586 DecisionTaskCompletedEventId: t.GetDecisionTaskCompletedEventId(), 587 SearchAttributes: SearchAttributes(t.SearchAttributes), 588 } 589 } 590 591 func WorkflowExecutionCancelRequestedEventAttributes(t *shared.WorkflowExecutionCancelRequestedEventAttributes) *apiv1.WorkflowExecutionCancelRequestedEventAttributes { 592 if t == nil { 593 return nil 594 } 595 return &apiv1.WorkflowExecutionCancelRequestedEventAttributes{ 596 Cause: t.GetCause(), 597 ExternalExecutionInfo: ExternalExecutionInfo(t.ExternalWorkflowExecution, t.ExternalInitiatedEventId), 598 Identity: t.GetIdentity(), 599 } 600 } 601 602 func WorkflowExecutionCanceledEventAttributes(t *shared.WorkflowExecutionCanceledEventAttributes) *apiv1.WorkflowExecutionCanceledEventAttributes { 603 if t == nil { 604 return nil 605 } 606 return &apiv1.WorkflowExecutionCanceledEventAttributes{ 607 DecisionTaskCompletedEventId: t.GetDecisionTaskCompletedEventId(), 608 Details: Payload(t.Details), 609 } 610 } 611 612 func WorkflowExecutionCompletedEventAttributes(t *shared.WorkflowExecutionCompletedEventAttributes) *apiv1.WorkflowExecutionCompletedEventAttributes { 613 if t == nil { 614 return nil 615 } 616 return &apiv1.WorkflowExecutionCompletedEventAttributes{ 617 Result: Payload(t.Result), 618 DecisionTaskCompletedEventId: t.GetDecisionTaskCompletedEventId(), 619 } 620 } 621 622 func WorkflowExecutionContinuedAsNewEventAttributes(t *shared.WorkflowExecutionContinuedAsNewEventAttributes) *apiv1.WorkflowExecutionContinuedAsNewEventAttributes { 623 if t == nil { 624 return nil 625 } 626 return &apiv1.WorkflowExecutionContinuedAsNewEventAttributes{ 627 NewExecutionRunId: t.GetNewExecutionRunId(), 628 WorkflowType: WorkflowType(t.WorkflowType), 629 TaskList: TaskList(t.TaskList), 630 Input: Payload(t.Input), 631 ExecutionStartToCloseTimeout: secondsToDuration(t.ExecutionStartToCloseTimeoutSeconds), 632 TaskStartToCloseTimeout: secondsToDuration(t.TaskStartToCloseTimeoutSeconds), 633 DecisionTaskCompletedEventId: t.GetDecisionTaskCompletedEventId(), 634 BackoffStartInterval: secondsToDuration(t.BackoffStartIntervalInSeconds), 635 Initiator: ContinueAsNewInitiator(t.Initiator), 636 Failure: Failure(t.FailureReason, t.FailureDetails), 637 LastCompletionResult: Payload(t.LastCompletionResult), 638 Header: Header(t.Header), 639 Memo: Memo(t.Memo), 640 SearchAttributes: SearchAttributes(t.SearchAttributes), 641 } 642 } 643 644 func WorkflowExecutionFailedEventAttributes(t *shared.WorkflowExecutionFailedEventAttributes) *apiv1.WorkflowExecutionFailedEventAttributes { 645 if t == nil { 646 return nil 647 } 648 return &apiv1.WorkflowExecutionFailedEventAttributes{ 649 Failure: Failure(t.Reason, t.Details), 650 DecisionTaskCompletedEventId: t.GetDecisionTaskCompletedEventId(), 651 } 652 } 653 654 func WorkflowExecutionSignaledEventAttributes(t *shared.WorkflowExecutionSignaledEventAttributes) *apiv1.WorkflowExecutionSignaledEventAttributes { 655 if t == nil { 656 return nil 657 } 658 return &apiv1.WorkflowExecutionSignaledEventAttributes{ 659 SignalName: t.GetSignalName(), 660 Input: Payload(t.Input), 661 Identity: t.GetIdentity(), 662 } 663 } 664 665 func WorkflowExecutionStartedEventAttributes(t *shared.WorkflowExecutionStartedEventAttributes) *apiv1.WorkflowExecutionStartedEventAttributes { 666 if t == nil { 667 return nil 668 } 669 return &apiv1.WorkflowExecutionStartedEventAttributes{ 670 WorkflowType: WorkflowType(t.WorkflowType), 671 ParentExecutionInfo: ParentExecutionInfo(nil, t.ParentWorkflowDomain, t.ParentWorkflowExecution, t.ParentInitiatedEventId), 672 TaskList: TaskList(t.TaskList), 673 Input: Payload(t.Input), 674 ExecutionStartToCloseTimeout: secondsToDuration(t.ExecutionStartToCloseTimeoutSeconds), 675 TaskStartToCloseTimeout: secondsToDuration(t.TaskStartToCloseTimeoutSeconds), 676 ContinuedExecutionRunId: t.GetContinuedExecutionRunId(), 677 Initiator: ContinueAsNewInitiator(t.Initiator), 678 ContinuedFailure: Failure(t.ContinuedFailureReason, t.ContinuedFailureDetails), 679 LastCompletionResult: Payload(t.LastCompletionResult), 680 OriginalExecutionRunId: t.GetOriginalExecutionRunId(), 681 Identity: t.GetIdentity(), 682 FirstExecutionRunId: t.GetFirstExecutionRunId(), 683 RetryPolicy: RetryPolicy(t.RetryPolicy), 684 Attempt: t.GetAttempt(), 685 ExpirationTime: unixNanoToTime(t.ExpirationTimestamp), 686 CronSchedule: t.GetCronSchedule(), 687 FirstDecisionTaskBackoff: secondsToDuration(t.FirstDecisionTaskBackoffSeconds), 688 Memo: Memo(t.Memo), 689 SearchAttributes: SearchAttributes(t.SearchAttributes), 690 PrevAutoResetPoints: ResetPoints(t.PrevAutoResetPoints), 691 Header: Header(t.Header), 692 } 693 } 694 695 func WorkflowExecutionTerminatedEventAttributes(t *shared.WorkflowExecutionTerminatedEventAttributes) *apiv1.WorkflowExecutionTerminatedEventAttributes { 696 if t == nil { 697 return nil 698 } 699 return &apiv1.WorkflowExecutionTerminatedEventAttributes{ 700 Reason: t.GetReason(), 701 Details: Payload(t.Details), 702 Identity: t.GetIdentity(), 703 } 704 } 705 706 func WorkflowExecutionTimedOutEventAttributes(t *shared.WorkflowExecutionTimedOutEventAttributes) *apiv1.WorkflowExecutionTimedOutEventAttributes { 707 if t == nil { 708 return nil 709 } 710 return &apiv1.WorkflowExecutionTimedOutEventAttributes{ 711 TimeoutType: TimeoutType(t.TimeoutType), 712 } 713 }