go.uber.org/cadence@v1.2.9/internal/compatibility/thrift/response.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 26 apiv1 "github.com/uber/cadence-idl/go/proto/api/v1" 27 ) 28 29 func CountWorkflowExecutionsResponse(t *apiv1.CountWorkflowExecutionsResponse) *shared.CountWorkflowExecutionsResponse { 30 if t == nil { 31 return nil 32 } 33 return &shared.CountWorkflowExecutionsResponse{ 34 Count: &t.Count, 35 } 36 } 37 38 func DescribeDomainResponse(t *apiv1.DescribeDomainResponse) *shared.DescribeDomainResponse { 39 if t == nil || t.Domain == nil { 40 return nil 41 } 42 return &shared.DescribeDomainResponse{ 43 DomainInfo: &shared.DomainInfo{ 44 Name: &t.Domain.Name, 45 Status: DomainStatus(t.Domain.Status), 46 Description: &t.Domain.Description, 47 OwnerEmail: &t.Domain.OwnerEmail, 48 Data: t.Domain.Data, 49 UUID: &t.Domain.Id, 50 }, 51 Configuration: &shared.DomainConfiguration{ 52 WorkflowExecutionRetentionPeriodInDays: durationToDays(t.Domain.WorkflowExecutionRetentionPeriod), 53 EmitMetric: boolPtr(true), 54 BadBinaries: BadBinaries(t.Domain.BadBinaries), 55 HistoryArchivalStatus: ArchivalStatus(t.Domain.HistoryArchivalStatus), 56 HistoryArchivalURI: &t.Domain.HistoryArchivalUri, 57 VisibilityArchivalStatus: ArchivalStatus(t.Domain.VisibilityArchivalStatus), 58 VisibilityArchivalURI: &t.Domain.VisibilityArchivalUri, 59 }, 60 ReplicationConfiguration: &shared.DomainReplicationConfiguration{ 61 ActiveClusterName: &t.Domain.ActiveClusterName, 62 Clusters: ClusterReplicationConfigurationArray(t.Domain.Clusters), 63 }, 64 FailoverVersion: &t.Domain.FailoverVersion, 65 IsGlobalDomain: &t.Domain.IsGlobalDomain, 66 } 67 } 68 69 func DescribeTaskListResponse(t *apiv1.DescribeTaskListResponse) *shared.DescribeTaskListResponse { 70 if t == nil { 71 return nil 72 } 73 return &shared.DescribeTaskListResponse{ 74 Pollers: PollerInfoArray(t.Pollers), 75 TaskListStatus: TaskListStatus(t.TaskListStatus), 76 } 77 } 78 79 func DescribeWorkflowExecutionResponse(t *apiv1.DescribeWorkflowExecutionResponse) *shared.DescribeWorkflowExecutionResponse { 80 if t == nil { 81 return nil 82 } 83 return &shared.DescribeWorkflowExecutionResponse{ 84 ExecutionConfiguration: WorkflowExecutionConfiguration(t.ExecutionConfiguration), 85 WorkflowExecutionInfo: WorkflowExecutionInfo(t.WorkflowExecutionInfo), 86 PendingActivities: PendingActivityInfoArray(t.PendingActivities), 87 PendingChildren: PendingChildExecutionInfoArray(t.PendingChildren), 88 PendingDecision: PendingDecisionInfo(t.PendingDecision), 89 } 90 } 91 92 func GetClusterInfoResponse(t *apiv1.GetClusterInfoResponse) *shared.ClusterInfo { 93 if t == nil { 94 return nil 95 } 96 return &shared.ClusterInfo{ 97 SupportedClientVersions: SupportedClientVersions(t.SupportedClientVersions), 98 } 99 } 100 101 func GetSearchAttributesResponse(t *apiv1.GetSearchAttributesResponse) *shared.GetSearchAttributesResponse { 102 if t == nil { 103 return nil 104 } 105 return &shared.GetSearchAttributesResponse{ 106 Keys: IndexedValueTypeMap(t.Keys), 107 } 108 } 109 110 func GetWorkflowExecutionHistoryResponse(t *apiv1.GetWorkflowExecutionHistoryResponse) *shared.GetWorkflowExecutionHistoryResponse { 111 if t == nil { 112 return nil 113 } 114 return &shared.GetWorkflowExecutionHistoryResponse{ 115 History: History(t.History), 116 RawHistory: DataBlobArray(t.RawHistory), 117 NextPageToken: t.NextPageToken, 118 Archived: &t.Archived, 119 } 120 } 121 122 func ListArchivedWorkflowExecutionsResponse(t *apiv1.ListArchivedWorkflowExecutionsResponse) *shared.ListArchivedWorkflowExecutionsResponse { 123 if t == nil { 124 return nil 125 } 126 return &shared.ListArchivedWorkflowExecutionsResponse{ 127 Executions: WorkflowExecutionInfoArray(t.Executions), 128 NextPageToken: t.NextPageToken, 129 } 130 } 131 132 func ListClosedWorkflowExecutionsResponse(t *apiv1.ListClosedWorkflowExecutionsResponse) *shared.ListClosedWorkflowExecutionsResponse { 133 if t == nil { 134 return nil 135 } 136 return &shared.ListClosedWorkflowExecutionsResponse{ 137 Executions: WorkflowExecutionInfoArray(t.Executions), 138 NextPageToken: t.NextPageToken, 139 } 140 } 141 142 func ListDomainsResponse(t *apiv1.ListDomainsResponse) *shared.ListDomainsResponse { 143 if t == nil { 144 return nil 145 } 146 return &shared.ListDomainsResponse{ 147 Domains: DescribeDomainResponseArray(t.Domains), 148 NextPageToken: t.NextPageToken, 149 } 150 } 151 152 func ListOpenWorkflowExecutionsResponse(t *apiv1.ListOpenWorkflowExecutionsResponse) *shared.ListOpenWorkflowExecutionsResponse { 153 if t == nil { 154 return nil 155 } 156 return &shared.ListOpenWorkflowExecutionsResponse{ 157 Executions: WorkflowExecutionInfoArray(t.Executions), 158 NextPageToken: t.NextPageToken, 159 } 160 } 161 162 func ListTaskListPartitionsResponse(t *apiv1.ListTaskListPartitionsResponse) *shared.ListTaskListPartitionsResponse { 163 if t == nil { 164 return nil 165 } 166 return &shared.ListTaskListPartitionsResponse{ 167 ActivityTaskListPartitions: TaskListPartitionMetadataArray(t.ActivityTaskListPartitions), 168 DecisionTaskListPartitions: TaskListPartitionMetadataArray(t.DecisionTaskListPartitions), 169 } 170 } 171 172 func ListWorkflowExecutionsResponse(t *apiv1.ListWorkflowExecutionsResponse) *shared.ListWorkflowExecutionsResponse { 173 if t == nil { 174 return nil 175 } 176 return &shared.ListWorkflowExecutionsResponse{ 177 Executions: WorkflowExecutionInfoArray(t.Executions), 178 NextPageToken: t.NextPageToken, 179 } 180 } 181 182 func PollForActivityTaskResponse(t *apiv1.PollForActivityTaskResponse) *shared.PollForActivityTaskResponse { 183 if t == nil { 184 return nil 185 } 186 return &shared.PollForActivityTaskResponse{ 187 TaskToken: t.TaskToken, 188 WorkflowExecution: WorkflowExecution(t.WorkflowExecution), 189 ActivityId: &t.ActivityId, 190 ActivityType: ActivityType(t.ActivityType), 191 Input: Payload(t.Input), 192 ScheduledTimestamp: timeToUnixNano(t.ScheduledTime), 193 StartedTimestamp: timeToUnixNano(t.StartedTime), 194 ScheduleToCloseTimeoutSeconds: durationToSeconds(t.ScheduleToCloseTimeout), 195 StartToCloseTimeoutSeconds: durationToSeconds(t.StartToCloseTimeout), 196 HeartbeatTimeoutSeconds: durationToSeconds(t.HeartbeatTimeout), 197 Attempt: &t.Attempt, 198 ScheduledTimestampOfThisAttempt: timeToUnixNano(t.ScheduledTimeOfThisAttempt), 199 HeartbeatDetails: Payload(t.HeartbeatDetails), 200 WorkflowType: WorkflowType(t.WorkflowType), 201 WorkflowDomain: &t.WorkflowDomain, 202 Header: Header(t.Header), 203 } 204 } 205 206 func PollForDecisionTaskResponse(t *apiv1.PollForDecisionTaskResponse) *shared.PollForDecisionTaskResponse { 207 if t == nil { 208 return nil 209 } 210 return &shared.PollForDecisionTaskResponse{ 211 TaskToken: t.TaskToken, 212 WorkflowExecution: WorkflowExecution(t.WorkflowExecution), 213 WorkflowType: WorkflowType(t.WorkflowType), 214 PreviousStartedEventId: toInt64Value(t.PreviousStartedEventId), 215 StartedEventId: &t.StartedEventId, 216 Attempt: &t.Attempt, 217 BacklogCountHint: &t.BacklogCountHint, 218 History: History(t.History), 219 NextPageToken: t.NextPageToken, 220 Query: WorkflowQuery(t.Query), 221 WorkflowExecutionTaskList: TaskList(t.WorkflowExecutionTaskList), 222 ScheduledTimestamp: timeToUnixNano(t.ScheduledTime), 223 StartedTimestamp: timeToUnixNano(t.StartedTime), 224 Queries: WorkflowQueryMap(t.Queries), 225 NextEventId: &t.NextEventId, 226 TotalHistoryBytes: &t.TotalHistoryBytes, 227 } 228 } 229 230 func QueryWorkflowResponse(t *apiv1.QueryWorkflowResponse) *shared.QueryWorkflowResponse { 231 if t == nil { 232 return nil 233 } 234 return &shared.QueryWorkflowResponse{ 235 QueryResult: Payload(t.QueryResult), 236 QueryRejected: QueryRejected(t.QueryRejected), 237 } 238 } 239 240 func RecordActivityTaskHeartbeatByIdResponse(t *apiv1.RecordActivityTaskHeartbeatByIDResponse) *shared.RecordActivityTaskHeartbeatResponse { 241 if t == nil { 242 return nil 243 } 244 return &shared.RecordActivityTaskHeartbeatResponse{ 245 CancelRequested: &t.CancelRequested, 246 } 247 } 248 249 func RecordActivityTaskHeartbeatResponse(t *apiv1.RecordActivityTaskHeartbeatResponse) *shared.RecordActivityTaskHeartbeatResponse { 250 if t == nil { 251 return nil 252 } 253 return &shared.RecordActivityTaskHeartbeatResponse{ 254 CancelRequested: &t.CancelRequested, 255 } 256 } 257 258 func ResetWorkflowExecutionResponse(t *apiv1.ResetWorkflowExecutionResponse) *shared.ResetWorkflowExecutionResponse { 259 if t == nil { 260 return nil 261 } 262 return &shared.ResetWorkflowExecutionResponse{ 263 RunId: &t.RunId, 264 } 265 } 266 267 func RespondDecisionTaskCompletedResponse(t *apiv1.RespondDecisionTaskCompletedResponse) *shared.RespondDecisionTaskCompletedResponse { 268 if t == nil { 269 return nil 270 } 271 return &shared.RespondDecisionTaskCompletedResponse{ 272 DecisionTask: PollForDecisionTaskResponse(t.DecisionTask), 273 ActivitiesToDispatchLocally: ActivityLocalDispatchInfoMap(t.ActivitiesToDispatchLocally), 274 } 275 } 276 277 func ScanWorkflowExecutionsResponse(t *apiv1.ScanWorkflowExecutionsResponse) *shared.ListWorkflowExecutionsResponse { 278 if t == nil { 279 return nil 280 } 281 return &shared.ListWorkflowExecutionsResponse{ 282 Executions: WorkflowExecutionInfoArray(t.Executions), 283 NextPageToken: t.NextPageToken, 284 } 285 } 286 287 func SignalWithStartWorkflowExecutionResponse(t *apiv1.SignalWithStartWorkflowExecutionResponse) *shared.StartWorkflowExecutionResponse { 288 if t == nil { 289 return nil 290 } 291 return &shared.StartWorkflowExecutionResponse{ 292 RunId: &t.RunId, 293 } 294 } 295 296 func StartWorkflowExecutionResponse(t *apiv1.StartWorkflowExecutionResponse) *shared.StartWorkflowExecutionResponse { 297 if t == nil { 298 return nil 299 } 300 return &shared.StartWorkflowExecutionResponse{ 301 RunId: &t.RunId, 302 } 303 } 304 305 func UpdateDomainResponse(t *apiv1.UpdateDomainResponse) *shared.UpdateDomainResponse { 306 if t == nil || t.Domain == nil { 307 return nil 308 } 309 return &shared.UpdateDomainResponse{ 310 DomainInfo: &shared.DomainInfo{ 311 Name: &t.Domain.Name, 312 Status: DomainStatus(t.Domain.Status), 313 Description: &t.Domain.Description, 314 OwnerEmail: &t.Domain.OwnerEmail, 315 Data: t.Domain.Data, 316 UUID: &t.Domain.Id, 317 }, 318 Configuration: &shared.DomainConfiguration{ 319 WorkflowExecutionRetentionPeriodInDays: durationToDays(t.Domain.WorkflowExecutionRetentionPeriod), 320 EmitMetric: boolPtr(true), 321 BadBinaries: BadBinaries(t.Domain.BadBinaries), 322 HistoryArchivalStatus: ArchivalStatus(t.Domain.HistoryArchivalStatus), 323 HistoryArchivalURI: &t.Domain.HistoryArchivalUri, 324 VisibilityArchivalStatus: ArchivalStatus(t.Domain.VisibilityArchivalStatus), 325 VisibilityArchivalURI: &t.Domain.VisibilityArchivalUri, 326 }, 327 ReplicationConfiguration: &shared.DomainReplicationConfiguration{ 328 ActiveClusterName: &t.Domain.ActiveClusterName, 329 Clusters: ClusterReplicationConfigurationArray(t.Domain.Clusters), 330 }, 331 FailoverVersion: &t.Domain.FailoverVersion, 332 IsGlobalDomain: &t.Domain.IsGlobalDomain, 333 } 334 } 335 336 func RestartWorkflowExecutionResponse(t *apiv1.RestartWorkflowExecutionResponse) *shared.RestartWorkflowExecutionResponse { 337 if t == nil { 338 return nil 339 } 340 341 return &shared.RestartWorkflowExecutionResponse{ 342 RunId: &t.RunId, 343 } 344 }