go.uber.org/cadence@v1.2.9/internal/compatibility/proto/enum.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 TaskListKind(t *shared.TaskListKind) apiv1.TaskListKind { 30 if t == nil { 31 return apiv1.TaskListKind_TASK_LIST_KIND_INVALID 32 } 33 switch *t { 34 case shared.TaskListKindNormal: 35 return apiv1.TaskListKind_TASK_LIST_KIND_NORMAL 36 case shared.TaskListKindSticky: 37 return apiv1.TaskListKind_TASK_LIST_KIND_STICKY 38 } 39 panic("unexpected enum value") 40 } 41 42 func TaskListType(t *shared.TaskListType) apiv1.TaskListType { 43 if t == nil { 44 return apiv1.TaskListType_TASK_LIST_TYPE_INVALID 45 } 46 switch *t { 47 case shared.TaskListTypeDecision: 48 return apiv1.TaskListType_TASK_LIST_TYPE_DECISION 49 case shared.TaskListTypeActivity: 50 return apiv1.TaskListType_TASK_LIST_TYPE_ACTIVITY 51 } 52 panic("unexpected enum value") 53 } 54 55 func EventFilterType(t *shared.HistoryEventFilterType) apiv1.EventFilterType { 56 if t == nil { 57 return apiv1.EventFilterType_EVENT_FILTER_TYPE_INVALID 58 } 59 switch *t { 60 case shared.HistoryEventFilterTypeAllEvent: 61 return apiv1.EventFilterType_EVENT_FILTER_TYPE_ALL_EVENT 62 case shared.HistoryEventFilterTypeCloseEvent: 63 return apiv1.EventFilterType_EVENT_FILTER_TYPE_CLOSE_EVENT 64 } 65 panic("unexpected enum value") 66 } 67 68 func QueryRejectCondition(t *shared.QueryRejectCondition) apiv1.QueryRejectCondition { 69 if t == nil { 70 return apiv1.QueryRejectCondition_QUERY_REJECT_CONDITION_INVALID 71 } 72 switch *t { 73 case shared.QueryRejectConditionNotOpen: 74 return apiv1.QueryRejectCondition_QUERY_REJECT_CONDITION_NOT_OPEN 75 case shared.QueryRejectConditionNotCompletedCleanly: 76 return apiv1.QueryRejectCondition_QUERY_REJECT_CONDITION_NOT_COMPLETED_CLEANLY 77 } 78 panic("unexpected enum value") 79 } 80 81 func QueryConsistencyLevel(t *shared.QueryConsistencyLevel) apiv1.QueryConsistencyLevel { 82 if t == nil { 83 return apiv1.QueryConsistencyLevel_QUERY_CONSISTENCY_LEVEL_INVALID 84 } 85 switch *t { 86 case shared.QueryConsistencyLevelEventual: 87 return apiv1.QueryConsistencyLevel_QUERY_CONSISTENCY_LEVEL_EVENTUAL 88 case shared.QueryConsistencyLevelStrong: 89 return apiv1.QueryConsistencyLevel_QUERY_CONSISTENCY_LEVEL_STRONG 90 } 91 panic("unexpected enum value") 92 } 93 94 func ContinueAsNewInitiator(t *shared.ContinueAsNewInitiator) apiv1.ContinueAsNewInitiator { 95 if t == nil { 96 return apiv1.ContinueAsNewInitiator_CONTINUE_AS_NEW_INITIATOR_INVALID 97 } 98 switch *t { 99 case shared.ContinueAsNewInitiatorDecider: 100 return apiv1.ContinueAsNewInitiator_CONTINUE_AS_NEW_INITIATOR_DECIDER 101 case shared.ContinueAsNewInitiatorRetryPolicy: 102 return apiv1.ContinueAsNewInitiator_CONTINUE_AS_NEW_INITIATOR_RETRY_POLICY 103 case shared.ContinueAsNewInitiatorCronSchedule: 104 return apiv1.ContinueAsNewInitiator_CONTINUE_AS_NEW_INITIATOR_CRON_SCHEDULE 105 } 106 panic("unexpected enum value") 107 } 108 109 func WorkflowIdReusePolicy(t *shared.WorkflowIdReusePolicy) apiv1.WorkflowIdReusePolicy { 110 if t == nil { 111 return apiv1.WorkflowIdReusePolicy_WORKFLOW_ID_REUSE_POLICY_INVALID 112 } 113 switch *t { 114 case shared.WorkflowIdReusePolicyAllowDuplicateFailedOnly: 115 return apiv1.WorkflowIdReusePolicy_WORKFLOW_ID_REUSE_POLICY_ALLOW_DUPLICATE_FAILED_ONLY 116 case shared.WorkflowIdReusePolicyAllowDuplicate: 117 return apiv1.WorkflowIdReusePolicy_WORKFLOW_ID_REUSE_POLICY_ALLOW_DUPLICATE 118 case shared.WorkflowIdReusePolicyRejectDuplicate: 119 return apiv1.WorkflowIdReusePolicy_WORKFLOW_ID_REUSE_POLICY_REJECT_DUPLICATE 120 case shared.WorkflowIdReusePolicyTerminateIfRunning: 121 return apiv1.WorkflowIdReusePolicy_WORKFLOW_ID_REUSE_POLICY_TERMINATE_IF_RUNNING 122 } 123 panic("unexpected enum value") 124 } 125 126 func QueryResultType(t *shared.QueryResultType) apiv1.QueryResultType { 127 if t == nil { 128 return apiv1.QueryResultType_QUERY_RESULT_TYPE_INVALID 129 } 130 switch *t { 131 case shared.QueryResultTypeAnswered: 132 return apiv1.QueryResultType_QUERY_RESULT_TYPE_ANSWERED 133 case shared.QueryResultTypeFailed: 134 return apiv1.QueryResultType_QUERY_RESULT_TYPE_FAILED 135 } 136 panic("unexpected enum value") 137 } 138 139 func ArchivalStatus(t *shared.ArchivalStatus) apiv1.ArchivalStatus { 140 if t == nil { 141 return apiv1.ArchivalStatus_ARCHIVAL_STATUS_INVALID 142 } 143 switch *t { 144 case shared.ArchivalStatusDisabled: 145 return apiv1.ArchivalStatus_ARCHIVAL_STATUS_DISABLED 146 case shared.ArchivalStatusEnabled: 147 return apiv1.ArchivalStatus_ARCHIVAL_STATUS_ENABLED 148 } 149 panic("unexpected enum value") 150 } 151 152 func ParentClosePolicy(t *shared.ParentClosePolicy) apiv1.ParentClosePolicy { 153 if t == nil { 154 return apiv1.ParentClosePolicy_PARENT_CLOSE_POLICY_INVALID 155 } 156 switch *t { 157 case shared.ParentClosePolicyAbandon: 158 return apiv1.ParentClosePolicy_PARENT_CLOSE_POLICY_ABANDON 159 case shared.ParentClosePolicyRequestCancel: 160 return apiv1.ParentClosePolicy_PARENT_CLOSE_POLICY_REQUEST_CANCEL 161 case shared.ParentClosePolicyTerminate: 162 return apiv1.ParentClosePolicy_PARENT_CLOSE_POLICY_TERMINATE 163 } 164 panic("unexpected enum value") 165 } 166 167 func DecisionTaskFailedCause(t *shared.DecisionTaskFailedCause) apiv1.DecisionTaskFailedCause { 168 if t == nil { 169 return apiv1.DecisionTaskFailedCause_DECISION_TASK_FAILED_CAUSE_INVALID 170 } 171 switch *t { 172 case shared.DecisionTaskFailedCauseUnhandledDecision: 173 return apiv1.DecisionTaskFailedCause_DECISION_TASK_FAILED_CAUSE_UNHANDLED_DECISION 174 case shared.DecisionTaskFailedCauseBadScheduleActivityAttributes: 175 return apiv1.DecisionTaskFailedCause_DECISION_TASK_FAILED_CAUSE_BAD_SCHEDULE_ACTIVITY_ATTRIBUTES 176 case shared.DecisionTaskFailedCauseBadRequestCancelActivityAttributes: 177 return apiv1.DecisionTaskFailedCause_DECISION_TASK_FAILED_CAUSE_BAD_REQUEST_CANCEL_ACTIVITY_ATTRIBUTES 178 case shared.DecisionTaskFailedCauseBadStartTimerAttributes: 179 return apiv1.DecisionTaskFailedCause_DECISION_TASK_FAILED_CAUSE_BAD_START_TIMER_ATTRIBUTES 180 case shared.DecisionTaskFailedCauseBadCancelTimerAttributes: 181 return apiv1.DecisionTaskFailedCause_DECISION_TASK_FAILED_CAUSE_BAD_CANCEL_TIMER_ATTRIBUTES 182 case shared.DecisionTaskFailedCauseBadRecordMarkerAttributes: 183 return apiv1.DecisionTaskFailedCause_DECISION_TASK_FAILED_CAUSE_BAD_RECORD_MARKER_ATTRIBUTES 184 case shared.DecisionTaskFailedCauseBadCompleteWorkflowExecutionAttributes: 185 return apiv1.DecisionTaskFailedCause_DECISION_TASK_FAILED_CAUSE_BAD_COMPLETE_WORKFLOW_EXECUTION_ATTRIBUTES 186 case shared.DecisionTaskFailedCauseBadFailWorkflowExecutionAttributes: 187 return apiv1.DecisionTaskFailedCause_DECISION_TASK_FAILED_CAUSE_BAD_FAIL_WORKFLOW_EXECUTION_ATTRIBUTES 188 case shared.DecisionTaskFailedCauseBadCancelWorkflowExecutionAttributes: 189 return apiv1.DecisionTaskFailedCause_DECISION_TASK_FAILED_CAUSE_BAD_CANCEL_WORKFLOW_EXECUTION_ATTRIBUTES 190 case shared.DecisionTaskFailedCauseBadRequestCancelExternalWorkflowExecutionAttributes: 191 return apiv1.DecisionTaskFailedCause_DECISION_TASK_FAILED_CAUSE_BAD_REQUEST_CANCEL_EXTERNAL_WORKFLOW_EXECUTION_ATTRIBUTES 192 case shared.DecisionTaskFailedCauseBadContinueAsNewAttributes: 193 return apiv1.DecisionTaskFailedCause_DECISION_TASK_FAILED_CAUSE_BAD_CONTINUE_AS_NEW_ATTRIBUTES 194 case shared.DecisionTaskFailedCauseStartTimerDuplicateID: 195 return apiv1.DecisionTaskFailedCause_DECISION_TASK_FAILED_CAUSE_START_TIMER_DUPLICATE_ID 196 case shared.DecisionTaskFailedCauseResetStickyTasklist: 197 return apiv1.DecisionTaskFailedCause_DECISION_TASK_FAILED_CAUSE_RESET_STICKY_TASK_LIST 198 case shared.DecisionTaskFailedCauseWorkflowWorkerUnhandledFailure: 199 return apiv1.DecisionTaskFailedCause_DECISION_TASK_FAILED_CAUSE_WORKFLOW_WORKER_UNHANDLED_FAILURE 200 case shared.DecisionTaskFailedCauseBadSignalWorkflowExecutionAttributes: 201 return apiv1.DecisionTaskFailedCause_DECISION_TASK_FAILED_CAUSE_BAD_SIGNAL_WORKFLOW_EXECUTION_ATTRIBUTES 202 case shared.DecisionTaskFailedCauseBadStartChildExecutionAttributes: 203 return apiv1.DecisionTaskFailedCause_DECISION_TASK_FAILED_CAUSE_BAD_START_CHILD_EXECUTION_ATTRIBUTES 204 case shared.DecisionTaskFailedCauseForceCloseDecision: 205 return apiv1.DecisionTaskFailedCause_DECISION_TASK_FAILED_CAUSE_FORCE_CLOSE_DECISION 206 case shared.DecisionTaskFailedCauseFailoverCloseDecision: 207 return apiv1.DecisionTaskFailedCause_DECISION_TASK_FAILED_CAUSE_FAILOVER_CLOSE_DECISION 208 case shared.DecisionTaskFailedCauseBadSignalInputSize: 209 return apiv1.DecisionTaskFailedCause_DECISION_TASK_FAILED_CAUSE_BAD_SIGNAL_INPUT_SIZE 210 case shared.DecisionTaskFailedCauseResetWorkflow: 211 return apiv1.DecisionTaskFailedCause_DECISION_TASK_FAILED_CAUSE_RESET_WORKFLOW 212 case shared.DecisionTaskFailedCauseBadBinary: 213 return apiv1.DecisionTaskFailedCause_DECISION_TASK_FAILED_CAUSE_BAD_BINARY 214 case shared.DecisionTaskFailedCauseScheduleActivityDuplicateID: 215 return apiv1.DecisionTaskFailedCause_DECISION_TASK_FAILED_CAUSE_SCHEDULE_ACTIVITY_DUPLICATE_ID 216 case shared.DecisionTaskFailedCauseBadSearchAttributes: 217 return apiv1.DecisionTaskFailedCause_DECISION_TASK_FAILED_CAUSE_BAD_SEARCH_ATTRIBUTES 218 } 219 panic("unexpected enum value") 220 } 221 222 func WorkflowExecutionCloseStatus(t *shared.WorkflowExecutionCloseStatus) apiv1.WorkflowExecutionCloseStatus { 223 if t == nil { 224 return apiv1.WorkflowExecutionCloseStatus_WORKFLOW_EXECUTION_CLOSE_STATUS_INVALID 225 } 226 switch *t { 227 case shared.WorkflowExecutionCloseStatusCompleted: 228 return apiv1.WorkflowExecutionCloseStatus_WORKFLOW_EXECUTION_CLOSE_STATUS_COMPLETED 229 case shared.WorkflowExecutionCloseStatusFailed: 230 return apiv1.WorkflowExecutionCloseStatus_WORKFLOW_EXECUTION_CLOSE_STATUS_FAILED 231 case shared.WorkflowExecutionCloseStatusCanceled: 232 return apiv1.WorkflowExecutionCloseStatus_WORKFLOW_EXECUTION_CLOSE_STATUS_CANCELED 233 case shared.WorkflowExecutionCloseStatusTerminated: 234 return apiv1.WorkflowExecutionCloseStatus_WORKFLOW_EXECUTION_CLOSE_STATUS_TERMINATED 235 case shared.WorkflowExecutionCloseStatusContinuedAsNew: 236 return apiv1.WorkflowExecutionCloseStatus_WORKFLOW_EXECUTION_CLOSE_STATUS_CONTINUED_AS_NEW 237 case shared.WorkflowExecutionCloseStatusTimedOut: 238 return apiv1.WorkflowExecutionCloseStatus_WORKFLOW_EXECUTION_CLOSE_STATUS_TIMED_OUT 239 } 240 panic("unexpected enum value") 241 } 242 243 func QueryTaskCompletedType(t *shared.QueryTaskCompletedType) apiv1.QueryResultType { 244 if t == nil { 245 return apiv1.QueryResultType_QUERY_RESULT_TYPE_INVALID 246 } 247 switch *t { 248 case shared.QueryTaskCompletedTypeCompleted: 249 return apiv1.QueryResultType_QUERY_RESULT_TYPE_ANSWERED 250 case shared.QueryTaskCompletedTypeFailed: 251 return apiv1.QueryResultType_QUERY_RESULT_TYPE_FAILED 252 } 253 panic("unexpected enum value") 254 } 255 256 func DomainStatus(t *shared.DomainStatus) apiv1.DomainStatus { 257 if t == nil { 258 return apiv1.DomainStatus_DOMAIN_STATUS_INVALID 259 } 260 switch *t { 261 case shared.DomainStatusRegistered: 262 return apiv1.DomainStatus_DOMAIN_STATUS_REGISTERED 263 case shared.DomainStatusDeprecated: 264 return apiv1.DomainStatus_DOMAIN_STATUS_DEPRECATED 265 case shared.DomainStatusDeleted: 266 return apiv1.DomainStatus_DOMAIN_STATUS_DELETED 267 } 268 panic("unexpected enum value") 269 } 270 271 func PendingActivityState(t *shared.PendingActivityState) apiv1.PendingActivityState { 272 if t == nil { 273 return apiv1.PendingActivityState_PENDING_ACTIVITY_STATE_INVALID 274 } 275 switch *t { 276 case shared.PendingActivityStateScheduled: 277 return apiv1.PendingActivityState_PENDING_ACTIVITY_STATE_SCHEDULED 278 case shared.PendingActivityStateStarted: 279 return apiv1.PendingActivityState_PENDING_ACTIVITY_STATE_STARTED 280 case shared.PendingActivityStateCancelRequested: 281 return apiv1.PendingActivityState_PENDING_ACTIVITY_STATE_CANCEL_REQUESTED 282 } 283 panic("unexpected enum value") 284 } 285 286 func PendingDecisionState(t *shared.PendingDecisionState) apiv1.PendingDecisionState { 287 if t == nil { 288 return apiv1.PendingDecisionState_PENDING_DECISION_STATE_INVALID 289 } 290 switch *t { 291 case shared.PendingDecisionStateScheduled: 292 return apiv1.PendingDecisionState_PENDING_DECISION_STATE_SCHEDULED 293 case shared.PendingDecisionStateStarted: 294 return apiv1.PendingDecisionState_PENDING_DECISION_STATE_STARTED 295 } 296 panic("unexpected enum value") 297 } 298 299 func IndexedValueType(t shared.IndexedValueType) apiv1.IndexedValueType { 300 switch t { 301 case shared.IndexedValueTypeString: 302 return apiv1.IndexedValueType_INDEXED_VALUE_TYPE_STRING 303 case shared.IndexedValueTypeKeyword: 304 return apiv1.IndexedValueType_INDEXED_VALUE_TYPE_KEYWORD 305 case shared.IndexedValueTypeInt: 306 return apiv1.IndexedValueType_INDEXED_VALUE_TYPE_INT 307 case shared.IndexedValueTypeDouble: 308 return apiv1.IndexedValueType_INDEXED_VALUE_TYPE_DOUBLE 309 case shared.IndexedValueTypeBool: 310 return apiv1.IndexedValueType_INDEXED_VALUE_TYPE_BOOL 311 case shared.IndexedValueTypeDatetime: 312 return apiv1.IndexedValueType_INDEXED_VALUE_TYPE_DATETIME 313 } 314 panic("unexpected enum value") 315 } 316 317 func EncodingType(t *shared.EncodingType) apiv1.EncodingType { 318 if t == nil { 319 return apiv1.EncodingType_ENCODING_TYPE_INVALID 320 } 321 switch *t { 322 case shared.EncodingTypeThriftRW: 323 return apiv1.EncodingType_ENCODING_TYPE_THRIFTRW 324 case shared.EncodingTypeJSON: 325 return apiv1.EncodingType_ENCODING_TYPE_JSON 326 } 327 panic("unexpected enum value") 328 } 329 330 func TimeoutType(t *shared.TimeoutType) apiv1.TimeoutType { 331 if t == nil { 332 return apiv1.TimeoutType_TIMEOUT_TYPE_INVALID 333 } 334 switch *t { 335 case shared.TimeoutTypeStartToClose: 336 return apiv1.TimeoutType_TIMEOUT_TYPE_START_TO_CLOSE 337 case shared.TimeoutTypeScheduleToStart: 338 return apiv1.TimeoutType_TIMEOUT_TYPE_SCHEDULE_TO_START 339 case shared.TimeoutTypeScheduleToClose: 340 return apiv1.TimeoutType_TIMEOUT_TYPE_SCHEDULE_TO_CLOSE 341 case shared.TimeoutTypeHeartbeat: 342 return apiv1.TimeoutType_TIMEOUT_TYPE_HEARTBEAT 343 } 344 panic("unexpected enum value") 345 } 346 347 func DecisionTaskTimedOutCause(t *shared.DecisionTaskTimedOutCause) apiv1.DecisionTaskTimedOutCause { 348 if t == nil { 349 return apiv1.DecisionTaskTimedOutCause_DECISION_TASK_TIMED_OUT_CAUSE_INVALID 350 } 351 switch *t { 352 case shared.DecisionTaskTimedOutCauseTimeout: 353 return apiv1.DecisionTaskTimedOutCause_DECISION_TASK_TIMED_OUT_CAUSE_TIMEOUT 354 case shared.DecisionTaskTimedOutCauseReset: 355 return apiv1.DecisionTaskTimedOutCause_DECISION_TASK_TIMED_OUT_CAUSE_RESET 356 } 357 panic("unexpected enum value") 358 } 359 360 func CancelExternalWorkflowExecutionFailedCause(t *shared.CancelExternalWorkflowExecutionFailedCause) apiv1.CancelExternalWorkflowExecutionFailedCause { 361 if t == nil { 362 return apiv1.CancelExternalWorkflowExecutionFailedCause_CANCEL_EXTERNAL_WORKFLOW_EXECUTION_FAILED_CAUSE_INVALID 363 } 364 switch *t { 365 case shared.CancelExternalWorkflowExecutionFailedCauseUnknownExternalWorkflowExecution: 366 return apiv1.CancelExternalWorkflowExecutionFailedCause_CANCEL_EXTERNAL_WORKFLOW_EXECUTION_FAILED_CAUSE_UNKNOWN_EXTERNAL_WORKFLOW_EXECUTION 367 } 368 panic("unexpected enum value") 369 } 370 371 func SignalExternalWorkflowExecutionFailedCause(t *shared.SignalExternalWorkflowExecutionFailedCause) apiv1.SignalExternalWorkflowExecutionFailedCause { 372 if t == nil { 373 return apiv1.SignalExternalWorkflowExecutionFailedCause_SIGNAL_EXTERNAL_WORKFLOW_EXECUTION_FAILED_CAUSE_INVALID 374 } 375 switch *t { 376 case shared.SignalExternalWorkflowExecutionFailedCauseUnknownExternalWorkflowExecution: 377 return apiv1.SignalExternalWorkflowExecutionFailedCause_SIGNAL_EXTERNAL_WORKFLOW_EXECUTION_FAILED_CAUSE_UNKNOWN_EXTERNAL_WORKFLOW_EXECUTION 378 } 379 panic("unexpected enum value") 380 } 381 382 func ChildWorkflowExecutionFailedCause(t *shared.ChildWorkflowExecutionFailedCause) apiv1.ChildWorkflowExecutionFailedCause { 383 if t == nil { 384 return apiv1.ChildWorkflowExecutionFailedCause_CHILD_WORKFLOW_EXECUTION_FAILED_CAUSE_INVALID 385 } 386 switch *t { 387 case shared.ChildWorkflowExecutionFailedCauseWorkflowAlreadyRunning: 388 return apiv1.ChildWorkflowExecutionFailedCause_CHILD_WORKFLOW_EXECUTION_FAILED_CAUSE_WORKFLOW_ALREADY_RUNNING 389 } 390 panic("unexpected enum value") 391 }