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