From 8fff028e0c174fdf14df6520a68ce086c2b272f4 Mon Sep 17 00:00:00 2001 From: Vytautas Date: Thu, 30 Sep 2021 07:59:35 +0300 Subject: [PATCH] Added 2-way proto-thrift mapper (#1130) --- internal/compatibility/adapter.go | 338 ++- internal/compatibility/api_test.go | 946 ++++++++ internal/compatibility/enum_test.go | 334 +++ internal/compatibility/error_test.go | 64 + internal/compatibility/proto/decision.go | 189 ++ internal/compatibility/proto/enum.go | 390 ++++ internal/compatibility/proto/error.go | 84 + internal/compatibility/proto/helpers.go | 78 + internal/compatibility/proto/history.go | 711 ++++++ internal/compatibility/proto/request.go | 612 ++++++ internal/compatibility/proto/response.go | 334 +++ internal/compatibility/proto/types.go | 686 ++++++ internal/compatibility/request.go | 1270 ----------- internal/compatibility/response.go | 1923 ----------------- internal/compatibility/testdata/common.go | 345 +++ internal/compatibility/testdata/decision.go | 172 ++ internal/compatibility/testdata/domain.go | 90 + internal/compatibility/testdata/enum.go | 48 + internal/compatibility/testdata/error.go | 66 + internal/compatibility/testdata/history.go | 533 +++++ internal/compatibility/testdata/service.go | 440 ++++ internal/compatibility/thrift/decision.go | 179 ++ internal/compatibility/thrift/enum.go | 378 ++++ internal/compatibility/{ => thrift}/error.go | 6 +- .../compatibility/{ => thrift}/helpers.go | 54 +- internal/compatibility/thrift/history.go | 766 +++++++ internal/compatibility/thrift/request.go | 580 +++++ internal/compatibility/thrift/response.go | 332 +++ internal/compatibility/thrift/types.go | 690 ++++++ 29 files changed, 9334 insertions(+), 3304 deletions(-) create mode 100644 internal/compatibility/api_test.go create mode 100644 internal/compatibility/enum_test.go create mode 100644 internal/compatibility/error_test.go create mode 100644 internal/compatibility/proto/decision.go create mode 100644 internal/compatibility/proto/enum.go create mode 100644 internal/compatibility/proto/error.go create mode 100644 internal/compatibility/proto/helpers.go create mode 100644 internal/compatibility/proto/history.go create mode 100644 internal/compatibility/proto/request.go create mode 100644 internal/compatibility/proto/response.go create mode 100644 internal/compatibility/proto/types.go delete mode 100644 internal/compatibility/request.go delete mode 100644 internal/compatibility/response.go create mode 100644 internal/compatibility/testdata/common.go create mode 100644 internal/compatibility/testdata/decision.go create mode 100644 internal/compatibility/testdata/domain.go create mode 100644 internal/compatibility/testdata/enum.go create mode 100644 internal/compatibility/testdata/error.go create mode 100644 internal/compatibility/testdata/history.go create mode 100644 internal/compatibility/testdata/service.go create mode 100644 internal/compatibility/thrift/decision.go create mode 100644 internal/compatibility/thrift/enum.go rename internal/compatibility/{ => thrift}/error.go (98%) rename internal/compatibility/{ => thrift}/helpers.go (74%) create mode 100644 internal/compatibility/thrift/history.go create mode 100644 internal/compatibility/thrift/request.go create mode 100644 internal/compatibility/thrift/response.go create mode 100644 internal/compatibility/thrift/types.go diff --git a/internal/compatibility/adapter.go b/internal/compatibility/adapter.go index 6dcdc127a..0492849ee 100644 --- a/internal/compatibility/adapter.go +++ b/internal/compatibility/adapter.go @@ -26,6 +26,8 @@ import ( "go.uber.org/cadence/.gen/go/cadence/workflowserviceclient" "go.uber.org/cadence/.gen/go/shared" apiv1 "go.uber.org/cadence/.gen/proto/api/v1" + "go.uber.org/cadence/internal/compatibility/proto" + "go.uber.org/cadence/internal/compatibility/thrift" "go.uber.org/yarpc" ) @@ -46,191 +48,379 @@ func NewThrift2ProtoAdapter( } func (a thrift2protoAdapter) CountWorkflowExecutions(ctx context.Context, request *shared.CountWorkflowExecutionsRequest, opts ...yarpc.CallOption) (*shared.CountWorkflowExecutionsResponse, error) { - response, err := a.visibility.CountWorkflowExecutions(ctx, protoCountWorkflowExecutionsRequest(request), opts...) - return thriftCountWorkflowExecutionsResponse(response), thriftError(err) + response, err := a.visibility.CountWorkflowExecutions(ctx, proto.CountWorkflowExecutionsRequest(request), opts...) + return thrift.CountWorkflowExecutionsResponse(response), thrift.Error(err) } func (a thrift2protoAdapter) DeprecateDomain(ctx context.Context, request *shared.DeprecateDomainRequest, opts ...yarpc.CallOption) error { - _, err := a.domain.DeprecateDomain(ctx, protoDeprecateDomainRequest(request), opts...) - return thriftError(err) + _, err := a.domain.DeprecateDomain(ctx, proto.DeprecateDomainRequest(request), opts...) + return thrift.Error(err) } func (a thrift2protoAdapter) DescribeDomain(ctx context.Context, request *shared.DescribeDomainRequest, opts ...yarpc.CallOption) (*shared.DescribeDomainResponse, error) { - response, err := a.domain.DescribeDomain(ctx, protoDescribeDomainRequest(request), opts...) - return thriftDescribeDomainResponse(response), thriftError(err) + response, err := a.domain.DescribeDomain(ctx, proto.DescribeDomainRequest(request), opts...) + return thrift.DescribeDomainResponse(response), thrift.Error(err) } func (a thrift2protoAdapter) DescribeTaskList(ctx context.Context, request *shared.DescribeTaskListRequest, opts ...yarpc.CallOption) (*shared.DescribeTaskListResponse, error) { - response, err := a.workflow.DescribeTaskList(ctx, protoDescribeTaskListRequest(request), opts...) - return thriftDescribeTaskListResponse(response), thriftError(err) + response, err := a.workflow.DescribeTaskList(ctx, proto.DescribeTaskListRequest(request), opts...) + return thrift.DescribeTaskListResponse(response), thrift.Error(err) } func (a thrift2protoAdapter) DescribeWorkflowExecution(ctx context.Context, request *shared.DescribeWorkflowExecutionRequest, opts ...yarpc.CallOption) (*shared.DescribeWorkflowExecutionResponse, error) { - response, err := a.workflow.DescribeWorkflowExecution(ctx, protoDescribeWorkflowExecutionRequest(request), opts...) - return thriftDescribeWorkflowExecutionResponse(response), thriftError(err) + response, err := a.workflow.DescribeWorkflowExecution(ctx, proto.DescribeWorkflowExecutionRequest(request), opts...) + return thrift.DescribeWorkflowExecutionResponse(response), thrift.Error(err) } func (a thrift2protoAdapter) GetClusterInfo(ctx context.Context, opts ...yarpc.CallOption) (*shared.ClusterInfo, error) { response, err := a.workflow.GetClusterInfo(ctx, &apiv1.GetClusterInfoRequest{}, opts...) - return thriftGetClusterInfoResponse(response), thriftError(err) + return thrift.GetClusterInfoResponse(response), thrift.Error(err) } func (a thrift2protoAdapter) GetSearchAttributes(ctx context.Context, opts ...yarpc.CallOption) (*shared.GetSearchAttributesResponse, error) { response, err := a.visibility.GetSearchAttributes(ctx, &apiv1.GetSearchAttributesRequest{}, opts...) - return thriftGetSearchAttributesResponse(response), thriftError(err) + return thrift.GetSearchAttributesResponse(response), thrift.Error(err) } func (a thrift2protoAdapter) GetWorkflowExecutionHistory(ctx context.Context, request *shared.GetWorkflowExecutionHistoryRequest, opts ...yarpc.CallOption) (*shared.GetWorkflowExecutionHistoryResponse, error) { - response, err := a.workflow.GetWorkflowExecutionHistory(ctx, protoGetWorkflowExecutionHistoryRequest(request), opts...) - return thriftGetWorkflowExecutionHistoryResponse(response), thriftError(err) + response, err := a.workflow.GetWorkflowExecutionHistory(ctx, proto.GetWorkflowExecutionHistoryRequest(request), opts...) + return thrift.GetWorkflowExecutionHistoryResponse(response), thrift.Error(err) } func (a thrift2protoAdapter) ListArchivedWorkflowExecutions(ctx context.Context, request *shared.ListArchivedWorkflowExecutionsRequest, opts ...yarpc.CallOption) (*shared.ListArchivedWorkflowExecutionsResponse, error) { - response, err := a.visibility.ListArchivedWorkflowExecutions(ctx, protoListArchivedWorkflowExecutionsRequest(request), opts...) - return thriftListArchivedWorkflowExecutionsResponse(response), thriftError(err) + response, err := a.visibility.ListArchivedWorkflowExecutions(ctx, proto.ListArchivedWorkflowExecutionsRequest(request), opts...) + return thrift.ListArchivedWorkflowExecutionsResponse(response), thrift.Error(err) } func (a thrift2protoAdapter) ListClosedWorkflowExecutions(ctx context.Context, request *shared.ListClosedWorkflowExecutionsRequest, opts ...yarpc.CallOption) (*shared.ListClosedWorkflowExecutionsResponse, error) { - response, err := a.visibility.ListClosedWorkflowExecutions(ctx, protoListClosedWorkflowExecutionsRequest(request), opts...) - return thriftListClosedWorkflowExecutionsResponse(response), thriftError(err) + response, err := a.visibility.ListClosedWorkflowExecutions(ctx, proto.ListClosedWorkflowExecutionsRequest(request), opts...) + return thrift.ListClosedWorkflowExecutionsResponse(response), thrift.Error(err) } func (a thrift2protoAdapter) ListDomains(ctx context.Context, request *shared.ListDomainsRequest, opts ...yarpc.CallOption) (*shared.ListDomainsResponse, error) { - response, err := a.domain.ListDomains(ctx, protoListDomainsRequest(request), opts...) - return thriftListDomainsResponse(response), thriftError(err) + response, err := a.domain.ListDomains(ctx, proto.ListDomainsRequest(request), opts...) + return thrift.ListDomainsResponse(response), thrift.Error(err) } func (a thrift2protoAdapter) ListOpenWorkflowExecutions(ctx context.Context, request *shared.ListOpenWorkflowExecutionsRequest, opts ...yarpc.CallOption) (*shared.ListOpenWorkflowExecutionsResponse, error) { - response, err := a.visibility.ListOpenWorkflowExecutions(ctx, protoListOpenWorkflowExecutionsRequest(request), opts...) - return thriftListOpenWorkflowExecutionsResponse(response), thriftError(err) + response, err := a.visibility.ListOpenWorkflowExecutions(ctx, proto.ListOpenWorkflowExecutionsRequest(request), opts...) + return thrift.ListOpenWorkflowExecutionsResponse(response), thrift.Error(err) } func (a thrift2protoAdapter) ListTaskListPartitions(ctx context.Context, request *shared.ListTaskListPartitionsRequest, opts ...yarpc.CallOption) (*shared.ListTaskListPartitionsResponse, error) { - response, err := a.workflow.ListTaskListPartitions(ctx, protoListTaskListPartitionsRequest(request), opts...) - return thriftListTaskListPartitionsResponse(response), thriftError(err) + response, err := a.workflow.ListTaskListPartitions(ctx, proto.ListTaskListPartitionsRequest(request), opts...) + return thrift.ListTaskListPartitionsResponse(response), thrift.Error(err) } func (a thrift2protoAdapter) ListWorkflowExecutions(ctx context.Context, request *shared.ListWorkflowExecutionsRequest, opts ...yarpc.CallOption) (*shared.ListWorkflowExecutionsResponse, error) { - response, err := a.visibility.ListWorkflowExecutions(ctx, protoListWorkflowExecutionsRequest(request), opts...) - return thriftListWorkflowExecutionsResponse(response), thriftError(err) + response, err := a.visibility.ListWorkflowExecutions(ctx, proto.ListWorkflowExecutionsRequest(request), opts...) + return thrift.ListWorkflowExecutionsResponse(response), thrift.Error(err) } func (a thrift2protoAdapter) PollForActivityTask(ctx context.Context, request *shared.PollForActivityTaskRequest, opts ...yarpc.CallOption) (*shared.PollForActivityTaskResponse, error) { - response, err := a.worker.PollForActivityTask(ctx, protoPollForActivityTaskRequest(request), opts...) - return thriftPollForActivityTaskResponse(response), thriftError(err) + response, err := a.worker.PollForActivityTask(ctx, proto.PollForActivityTaskRequest(request), opts...) + return thrift.PollForActivityTaskResponse(response), thrift.Error(err) } func (a thrift2protoAdapter) PollForDecisionTask(ctx context.Context, request *shared.PollForDecisionTaskRequest, opts ...yarpc.CallOption) (*shared.PollForDecisionTaskResponse, error) { - response, err := a.worker.PollForDecisionTask(ctx, protoPollForDecisionTaskRequest(request), opts...) - return thriftPollForDecisionTaskResponse(response), thriftError(err) + response, err := a.worker.PollForDecisionTask(ctx, proto.PollForDecisionTaskRequest(request), opts...) + return thrift.PollForDecisionTaskResponse(response), thrift.Error(err) } func (a thrift2protoAdapter) QueryWorkflow(ctx context.Context, request *shared.QueryWorkflowRequest, opts ...yarpc.CallOption) (*shared.QueryWorkflowResponse, error) { - response, err := a.workflow.QueryWorkflow(ctx, protoQueryWorkflowRequest(request), opts...) - return thriftQueryWorkflowResponse(response), thriftError(err) + response, err := a.workflow.QueryWorkflow(ctx, proto.QueryWorkflowRequest(request), opts...) + return thrift.QueryWorkflowResponse(response), thrift.Error(err) } func (a thrift2protoAdapter) RecordActivityTaskHeartbeat(ctx context.Context, request *shared.RecordActivityTaskHeartbeatRequest, opts ...yarpc.CallOption) (*shared.RecordActivityTaskHeartbeatResponse, error) { - response, err := a.worker.RecordActivityTaskHeartbeat(ctx, protoRecordActivityTaskHeartbeatRequest(request), opts...) - return thriftRecordActivityTaskHeartbeatResponse(response), thriftError(err) + response, err := a.worker.RecordActivityTaskHeartbeat(ctx, proto.RecordActivityTaskHeartbeatRequest(request), opts...) + return thrift.RecordActivityTaskHeartbeatResponse(response), thrift.Error(err) } func (a thrift2protoAdapter) RecordActivityTaskHeartbeatByID(ctx context.Context, request *shared.RecordActivityTaskHeartbeatByIDRequest, opts ...yarpc.CallOption) (*shared.RecordActivityTaskHeartbeatResponse, error) { - response, err := a.worker.RecordActivityTaskHeartbeatByID(ctx, protoRecordActivityTaskHeartbeatByIdRequest(request), opts...) - return thriftRecordActivityTaskHeartbeatByIdResponse(response), thriftError(err) + response, err := a.worker.RecordActivityTaskHeartbeatByID(ctx, proto.RecordActivityTaskHeartbeatByIdRequest(request), opts...) + return thrift.RecordActivityTaskHeartbeatByIdResponse(response), thrift.Error(err) } func (a thrift2protoAdapter) RegisterDomain(ctx context.Context, request *shared.RegisterDomainRequest, opts ...yarpc.CallOption) error { - _, err := a.domain.RegisterDomain(ctx, protoRegisterDomainRequest(request), opts...) - return thriftError(err) + _, err := a.domain.RegisterDomain(ctx, proto.RegisterDomainRequest(request), opts...) + return thrift.Error(err) } func (a thrift2protoAdapter) RequestCancelWorkflowExecution(ctx context.Context, request *shared.RequestCancelWorkflowExecutionRequest, opts ...yarpc.CallOption) error { - _, err := a.workflow.RequestCancelWorkflowExecution(ctx, protoRequestCancelWorkflowExecutionRequest(request), opts...) - return thriftError(err) + _, err := a.workflow.RequestCancelWorkflowExecution(ctx, proto.RequestCancelWorkflowExecutionRequest(request), opts...) + return thrift.Error(err) } func (a thrift2protoAdapter) ResetStickyTaskList(ctx context.Context, request *shared.ResetStickyTaskListRequest, opts ...yarpc.CallOption) (*shared.ResetStickyTaskListResponse, error) { - _, err := a.worker.ResetStickyTaskList(ctx, protoResetStickyTaskListRequest(request), opts...) - return &shared.ResetStickyTaskListResponse{}, thriftError(err) + _, err := a.worker.ResetStickyTaskList(ctx, proto.ResetStickyTaskListRequest(request), opts...) + return &shared.ResetStickyTaskListResponse{}, thrift.Error(err) } func (a thrift2protoAdapter) ResetWorkflowExecution(ctx context.Context, request *shared.ResetWorkflowExecutionRequest, opts ...yarpc.CallOption) (*shared.ResetWorkflowExecutionResponse, error) { - response, err := a.workflow.ResetWorkflowExecution(ctx, protoResetWorkflowExecutionRequest(request), opts...) - return thriftResetWorkflowExecutionResponse(response), thriftError(err) + response, err := a.workflow.ResetWorkflowExecution(ctx, proto.ResetWorkflowExecutionRequest(request), opts...) + return thrift.ResetWorkflowExecutionResponse(response), thrift.Error(err) } func (a thrift2protoAdapter) RespondActivityTaskCanceled(ctx context.Context, request *shared.RespondActivityTaskCanceledRequest, opts ...yarpc.CallOption) error { - _, err := a.worker.RespondActivityTaskCanceled(ctx, protoRespondActivityTaskCanceledRequest(request), opts...) - return thriftError(err) + _, err := a.worker.RespondActivityTaskCanceled(ctx, proto.RespondActivityTaskCanceledRequest(request), opts...) + return thrift.Error(err) } func (a thrift2protoAdapter) RespondActivityTaskCanceledByID(ctx context.Context, request *shared.RespondActivityTaskCanceledByIDRequest, opts ...yarpc.CallOption) error { - _, err := a.worker.RespondActivityTaskCanceledByID(ctx, protoRespondActivityTaskCanceledByIdRequest(request), opts...) - return thriftError(err) + _, err := a.worker.RespondActivityTaskCanceledByID(ctx, proto.RespondActivityTaskCanceledByIdRequest(request), opts...) + return thrift.Error(err) } func (a thrift2protoAdapter) RespondActivityTaskCompleted(ctx context.Context, request *shared.RespondActivityTaskCompletedRequest, opts ...yarpc.CallOption) error { - _, err := a.worker.RespondActivityTaskCompleted(ctx, protoRespondActivityTaskCompletedRequest(request), opts...) - return thriftError(err) + _, err := a.worker.RespondActivityTaskCompleted(ctx, proto.RespondActivityTaskCompletedRequest(request), opts...) + return thrift.Error(err) } func (a thrift2protoAdapter) RespondActivityTaskCompletedByID(ctx context.Context, request *shared.RespondActivityTaskCompletedByIDRequest, opts ...yarpc.CallOption) error { - _, err := a.worker.RespondActivityTaskCompletedByID(ctx, protoRespondActivityTaskCompletedByIdRequest(request), opts...) - return thriftError(err) + _, err := a.worker.RespondActivityTaskCompletedByID(ctx, proto.RespondActivityTaskCompletedByIdRequest(request), opts...) + return thrift.Error(err) } func (a thrift2protoAdapter) RespondActivityTaskFailed(ctx context.Context, request *shared.RespondActivityTaskFailedRequest, opts ...yarpc.CallOption) error { - _, err := a.worker.RespondActivityTaskFailed(ctx, protoRespondActivityTaskFailedRequest(request), opts...) - return thriftError(err) + _, err := a.worker.RespondActivityTaskFailed(ctx, proto.RespondActivityTaskFailedRequest(request), opts...) + return thrift.Error(err) } func (a thrift2protoAdapter) RespondActivityTaskFailedByID(ctx context.Context, request *shared.RespondActivityTaskFailedByIDRequest, opts ...yarpc.CallOption) error { - _, err := a.worker.RespondActivityTaskFailedByID(ctx, protoRespondActivityTaskFailedByIdRequest(request), opts...) - return thriftError(err) + _, err := a.worker.RespondActivityTaskFailedByID(ctx, proto.RespondActivityTaskFailedByIdRequest(request), opts...) + return thrift.Error(err) } func (a thrift2protoAdapter) RespondDecisionTaskCompleted(ctx context.Context, request *shared.RespondDecisionTaskCompletedRequest, opts ...yarpc.CallOption) (*shared.RespondDecisionTaskCompletedResponse, error) { - response, err := a.worker.RespondDecisionTaskCompleted(ctx, protoRespondDecisionTaskCompletedRequest(request), opts...) - return thriftRespondDecisionTaskCompletedResponse(response), thriftError(err) + response, err := a.worker.RespondDecisionTaskCompleted(ctx, proto.RespondDecisionTaskCompletedRequest(request), opts...) + return thrift.RespondDecisionTaskCompletedResponse(response), thrift.Error(err) } func (a thrift2protoAdapter) RespondDecisionTaskFailed(ctx context.Context, request *shared.RespondDecisionTaskFailedRequest, opts ...yarpc.CallOption) error { - _, err := a.worker.RespondDecisionTaskFailed(ctx, protoRespondDecisionTaskFailedRequest(request), opts...) - return thriftError(err) + _, err := a.worker.RespondDecisionTaskFailed(ctx, proto.RespondDecisionTaskFailedRequest(request), opts...) + return thrift.Error(err) } func (a thrift2protoAdapter) RespondQueryTaskCompleted(ctx context.Context, request *shared.RespondQueryTaskCompletedRequest, opts ...yarpc.CallOption) error { - _, err := a.worker.RespondQueryTaskCompleted(ctx, protoRespondQueryTaskCompletedRequest(request), opts...) - return thriftError(err) + _, err := a.worker.RespondQueryTaskCompleted(ctx, proto.RespondQueryTaskCompletedRequest(request), opts...) + return thrift.Error(err) } func (a thrift2protoAdapter) ScanWorkflowExecutions(ctx context.Context, request *shared.ListWorkflowExecutionsRequest, opts ...yarpc.CallOption) (*shared.ListWorkflowExecutionsResponse, error) { - response, err := a.visibility.ScanWorkflowExecutions(ctx, protoScanWorkflowExecutionsRequest(request), opts...) - return thriftScanWorkflowExecutionsResponse(response), thriftError(err) + response, err := a.visibility.ScanWorkflowExecutions(ctx, proto.ScanWorkflowExecutionsRequest(request), opts...) + return thrift.ScanWorkflowExecutionsResponse(response), thrift.Error(err) } func (a thrift2protoAdapter) SignalWithStartWorkflowExecution(ctx context.Context, request *shared.SignalWithStartWorkflowExecutionRequest, opts ...yarpc.CallOption) (*shared.StartWorkflowExecutionResponse, error) { - response, err := a.workflow.SignalWithStartWorkflowExecution(ctx, protoSignalWithStartWorkflowExecutionRequest(request), opts...) - return thriftSignalWithStartWorkflowExecutionResponse(response), thriftError(err) + response, err := a.workflow.SignalWithStartWorkflowExecution(ctx, proto.SignalWithStartWorkflowExecutionRequest(request), opts...) + return thrift.SignalWithStartWorkflowExecutionResponse(response), thrift.Error(err) } func (a thrift2protoAdapter) SignalWorkflowExecution(ctx context.Context, request *shared.SignalWorkflowExecutionRequest, opts ...yarpc.CallOption) error { - _, err := a.workflow.SignalWorkflowExecution(ctx, protoSignalWorkflowExecutionRequest(request), opts...) - return thriftError(err) + _, err := a.workflow.SignalWorkflowExecution(ctx, proto.SignalWorkflowExecutionRequest(request), opts...) + return thrift.Error(err) } func (a thrift2protoAdapter) StartWorkflowExecution(ctx context.Context, request *shared.StartWorkflowExecutionRequest, opts ...yarpc.CallOption) (*shared.StartWorkflowExecutionResponse, error) { - response, err := a.workflow.StartWorkflowExecution(ctx, protoStartWorkflowExecutionRequest(request), opts...) - return thriftStartWorkflowExecutionResponse(response), thriftError(err) + response, err := a.workflow.StartWorkflowExecution(ctx, proto.StartWorkflowExecutionRequest(request), opts...) + return thrift.StartWorkflowExecutionResponse(response), thrift.Error(err) } func (a thrift2protoAdapter) TerminateWorkflowExecution(ctx context.Context, request *shared.TerminateWorkflowExecutionRequest, opts ...yarpc.CallOption) error { - _, err := a.workflow.TerminateWorkflowExecution(ctx, protoTerminateWorkflowExecutionRequest(request), opts...) - return thriftError(err) + _, err := a.workflow.TerminateWorkflowExecution(ctx, proto.TerminateWorkflowExecutionRequest(request), opts...) + return thrift.Error(err) } func (a thrift2protoAdapter) UpdateDomain(ctx context.Context, request *shared.UpdateDomainRequest, opts ...yarpc.CallOption) (*shared.UpdateDomainResponse, error) { - response, err := a.domain.UpdateDomain(ctx, protoUpdateDomainRequest(request), opts...) - return thriftUpdateDomainResponse(response), thriftError(err) + response, err := a.domain.UpdateDomain(ctx, proto.UpdateDomainRequest(request), opts...) + return thrift.UpdateDomainResponse(response), thrift.Error(err) +} + +type domainAPIthriftAdapter struct { + service workflowserviceclient.Interface +} + +func NewDomainAPITriftAdapter(thrift workflowserviceclient.Interface) domainAPIthriftAdapter { + return domainAPIthriftAdapter{thrift} +} + +func (a domainAPIthriftAdapter) RegisterDomain(ctx context.Context, request *apiv1.RegisterDomainRequest, opts ...yarpc.CallOption) (*apiv1.RegisterDomainResponse, error) { + err := a.service.RegisterDomain(ctx, thrift.RegisterDomainRequest(request), opts...) + return &apiv1.RegisterDomainResponse{}, proto.Error(err) +} +func (a domainAPIthriftAdapter) DescribeDomain(ctx context.Context, request *apiv1.DescribeDomainRequest, opts ...yarpc.CallOption) (*apiv1.DescribeDomainResponse, error) { + response, err := a.service.DescribeDomain(ctx, thrift.DescribeDomainRequest(request), opts...) + return proto.DescribeDomainResponse(response), proto.Error(err) +} +func (a domainAPIthriftAdapter) ListDomains(ctx context.Context, request *apiv1.ListDomainsRequest, opts ...yarpc.CallOption) (*apiv1.ListDomainsResponse, error) { + response, err := a.service.ListDomains(ctx, thrift.ListDomainsRequest(request), opts...) + return proto.ListDomainsResponse(response), proto.Error(err) +} +func (a domainAPIthriftAdapter) UpdateDomain(ctx context.Context, request *apiv1.UpdateDomainRequest, opts ...yarpc.CallOption) (*apiv1.UpdateDomainResponse, error) { + response, err := a.service.UpdateDomain(ctx, thrift.UpdateDomainRequest(request), opts...) + return proto.UpdateDomainResponse(response), proto.Error(err) +} +func (a domainAPIthriftAdapter) DeprecateDomain(ctx context.Context, request *apiv1.DeprecateDomainRequest, opts ...yarpc.CallOption) (*apiv1.DeprecateDomainResponse, error) { + err := a.service.DeprecateDomain(ctx, thrift.DeprecateDomainRequest(request), opts...) + return &apiv1.DeprecateDomainResponse{}, proto.Error(err) +} + +type workflowAPIthriftAdapter struct { + service workflowserviceclient.Interface +} + +func NewWorkflowAPITriftAdapter(thrift workflowserviceclient.Interface) workflowAPIthriftAdapter { + return workflowAPIthriftAdapter{thrift} +} + +func (a workflowAPIthriftAdapter) StartWorkflowExecution(ctx context.Context, request *apiv1.StartWorkflowExecutionRequest, opts ...yarpc.CallOption) (*apiv1.StartWorkflowExecutionResponse, error) { + response, err := a.service.StartWorkflowExecution(ctx, thrift.StartWorkflowExecutionRequest(request), opts...) + return proto.StartWorkflowExecutionResponse(response), proto.Error(err) +} +func (a workflowAPIthriftAdapter) SignalWorkflowExecution(ctx context.Context, request *apiv1.SignalWorkflowExecutionRequest, opts ...yarpc.CallOption) (*apiv1.SignalWorkflowExecutionResponse, error) { + err := a.service.SignalWorkflowExecution(ctx, thrift.SignalWorkflowExecutionRequest(request), opts...) + return &apiv1.SignalWorkflowExecutionResponse{}, proto.Error(err) +} +func (a workflowAPIthriftAdapter) SignalWithStartWorkflowExecution(ctx context.Context, request *apiv1.SignalWithStartWorkflowExecutionRequest, opts ...yarpc.CallOption) (*apiv1.SignalWithStartWorkflowExecutionResponse, error) { + response, err := a.service.SignalWithStartWorkflowExecution(ctx, thrift.SignalWithStartWorkflowExecutionRequest(request), opts...) + return proto.SignalWithStartWorkflowExecutionResponse(response), proto.Error(err) +} +func (a workflowAPIthriftAdapter) ResetWorkflowExecution(ctx context.Context, request *apiv1.ResetWorkflowExecutionRequest, opts ...yarpc.CallOption) (*apiv1.ResetWorkflowExecutionResponse, error) { + response, err := a.service.ResetWorkflowExecution(ctx, thrift.ResetWorkflowExecutionRequest(request), opts...) + return proto.ResetWorkflowExecutionResponse(response), proto.Error(err) +} +func (a workflowAPIthriftAdapter) RequestCancelWorkflowExecution(ctx context.Context, request *apiv1.RequestCancelWorkflowExecutionRequest, opts ...yarpc.CallOption) (*apiv1.RequestCancelWorkflowExecutionResponse, error) { + err := a.service.RequestCancelWorkflowExecution(ctx, thrift.RequestCancelWorkflowExecutionRequest(request), opts...) + return &apiv1.RequestCancelWorkflowExecutionResponse{}, proto.Error(err) +} +func (a workflowAPIthriftAdapter) TerminateWorkflowExecution(ctx context.Context, request *apiv1.TerminateWorkflowExecutionRequest, opts ...yarpc.CallOption) (*apiv1.TerminateWorkflowExecutionResponse, error) { + err := a.service.TerminateWorkflowExecution(ctx, thrift.TerminateWorkflowExecutionRequest(request), opts...) + return &apiv1.TerminateWorkflowExecutionResponse{}, proto.Error(err) +} +func (a workflowAPIthriftAdapter) DescribeWorkflowExecution(ctx context.Context, request *apiv1.DescribeWorkflowExecutionRequest, opts ...yarpc.CallOption) (*apiv1.DescribeWorkflowExecutionResponse, error) { + response, err := a.service.DescribeWorkflowExecution(ctx, thrift.DescribeWorkflowExecutionRequest(request), opts...) + return proto.DescribeWorkflowExecutionResponse(response), proto.Error(err) +} +func (a workflowAPIthriftAdapter) QueryWorkflow(ctx context.Context, request *apiv1.QueryWorkflowRequest, opts ...yarpc.CallOption) (*apiv1.QueryWorkflowResponse, error) { + response, err := a.service.QueryWorkflow(ctx, thrift.QueryWorkflowRequest(request), opts...) + return proto.QueryWorkflowResponse(response), proto.Error(err) +} +func (a workflowAPIthriftAdapter) DescribeTaskList(ctx context.Context, request *apiv1.DescribeTaskListRequest, opts ...yarpc.CallOption) (*apiv1.DescribeTaskListResponse, error) { + response, err := a.service.DescribeTaskList(ctx, thrift.DescribeTaskListRequest(request), opts...) + return proto.DescribeTaskListResponse(response), proto.Error(err) +} +func (a workflowAPIthriftAdapter) ListTaskListPartitions(ctx context.Context, request *apiv1.ListTaskListPartitionsRequest, opts ...yarpc.CallOption) (*apiv1.ListTaskListPartitionsResponse, error) { + response, err := a.service.ListTaskListPartitions(ctx, thrift.ListTaskListPartitionsRequest(request), opts...) + return proto.ListTaskListPartitionsResponse(response), proto.Error(err) +} +func (a workflowAPIthriftAdapter) GetClusterInfo(ctx context.Context, request *apiv1.GetClusterInfoRequest, opts ...yarpc.CallOption) (*apiv1.GetClusterInfoResponse, error) { + response, err := a.service.GetClusterInfo(ctx, opts...) + return proto.GetClusterInfoResponse(response), proto.Error(err) +} +func (a workflowAPIthriftAdapter) GetWorkflowExecutionHistory(ctx context.Context, request *apiv1.GetWorkflowExecutionHistoryRequest, opts ...yarpc.CallOption) (*apiv1.GetWorkflowExecutionHistoryResponse, error) { + response, err := a.service.GetWorkflowExecutionHistory(ctx, thrift.GetWorkflowExecutionHistoryRequest(request), opts...) + return proto.GetWorkflowExecutionHistoryResponse(response), proto.Error(err) +} + +type workerAPIthriftAdapter struct { + service workflowserviceclient.Interface +} + +func NewWorkerAPITriftAdapter(thrift workflowserviceclient.Interface) workerAPIthriftAdapter { + return workerAPIthriftAdapter{thrift} +} + +func (a workerAPIthriftAdapter) PollForDecisionTask(ctx context.Context, request *apiv1.PollForDecisionTaskRequest, opts ...yarpc.CallOption) (*apiv1.PollForDecisionTaskResponse, error) { + response, err := a.service.PollForDecisionTask(ctx, thrift.PollForDecisionTaskRequest(request), opts...) + return proto.PollForDecisionTaskResponse(response), proto.Error(err) +} +func (a workerAPIthriftAdapter) RespondDecisionTaskCompleted(ctx context.Context, request *apiv1.RespondDecisionTaskCompletedRequest, opts ...yarpc.CallOption) (*apiv1.RespondDecisionTaskCompletedResponse, error) { + response, err := a.service.RespondDecisionTaskCompleted(ctx, thrift.RespondDecisionTaskCompletedRequest(request), opts...) + return proto.RespondDecisionTaskCompletedResponse(response), proto.Error(err) +} +func (a workerAPIthriftAdapter) RespondDecisionTaskFailed(ctx context.Context, request *apiv1.RespondDecisionTaskFailedRequest, opts ...yarpc.CallOption) (*apiv1.RespondDecisionTaskFailedResponse, error) { + err := a.service.RespondDecisionTaskFailed(ctx, thrift.RespondDecisionTaskFailedRequest(request), opts...) + return &apiv1.RespondDecisionTaskFailedResponse{}, proto.Error(err) +} +func (a workerAPIthriftAdapter) PollForActivityTask(ctx context.Context, request *apiv1.PollForActivityTaskRequest, opts ...yarpc.CallOption) (*apiv1.PollForActivityTaskResponse, error) { + response, err := a.service.PollForActivityTask(ctx, thrift.PollForActivityTaskRequest(request), opts...) + return proto.PollForActivityTaskResponse(response), proto.Error(err) +} +func (a workerAPIthriftAdapter) RespondActivityTaskCompleted(ctx context.Context, request *apiv1.RespondActivityTaskCompletedRequest, opts ...yarpc.CallOption) (*apiv1.RespondActivityTaskCompletedResponse, error) { + err := a.service.RespondActivityTaskCompleted(ctx, thrift.RespondActivityTaskCompletedRequest(request), opts...) + return &apiv1.RespondActivityTaskCompletedResponse{}, proto.Error(err) +} +func (a workerAPIthriftAdapter) RespondActivityTaskCompletedByID(ctx context.Context, request *apiv1.RespondActivityTaskCompletedByIDRequest, opts ...yarpc.CallOption) (*apiv1.RespondActivityTaskCompletedByIDResponse, error) { + err := a.service.RespondActivityTaskCompletedByID(ctx, thrift.RespondActivityTaskCompletedByIdRequest(request), opts...) + return &apiv1.RespondActivityTaskCompletedByIDResponse{}, proto.Error(err) +} +func (a workerAPIthriftAdapter) RespondActivityTaskFailed(ctx context.Context, request *apiv1.RespondActivityTaskFailedRequest, opts ...yarpc.CallOption) (*apiv1.RespondActivityTaskFailedResponse, error) { + err := a.service.RespondActivityTaskFailed(ctx, thrift.RespondActivityTaskFailedRequest(request), opts...) + return &apiv1.RespondActivityTaskFailedResponse{}, proto.Error(err) +} +func (a workerAPIthriftAdapter) RespondActivityTaskFailedByID(ctx context.Context, request *apiv1.RespondActivityTaskFailedByIDRequest, opts ...yarpc.CallOption) (*apiv1.RespondActivityTaskFailedByIDResponse, error) { + err := a.service.RespondActivityTaskFailedByID(ctx, thrift.RespondActivityTaskFailedByIdRequest(request), opts...) + return &apiv1.RespondActivityTaskFailedByIDResponse{}, proto.Error(err) +} +func (a workerAPIthriftAdapter) RespondActivityTaskCanceled(ctx context.Context, request *apiv1.RespondActivityTaskCanceledRequest, opts ...yarpc.CallOption) (*apiv1.RespondActivityTaskCanceledResponse, error) { + err := a.service.RespondActivityTaskCanceled(ctx, thrift.RespondActivityTaskCanceledRequest(request), opts...) + return &apiv1.RespondActivityTaskCanceledResponse{}, proto.Error(err) +} +func (a workerAPIthriftAdapter) RespondActivityTaskCanceledByID(ctx context.Context, request *apiv1.RespondActivityTaskCanceledByIDRequest, opts ...yarpc.CallOption) (*apiv1.RespondActivityTaskCanceledByIDResponse, error) { + err := a.service.RespondActivityTaskCanceledByID(ctx, thrift.RespondActivityTaskCanceledByIdRequest(request), opts...) + return &apiv1.RespondActivityTaskCanceledByIDResponse{}, proto.Error(err) +} +func (a workerAPIthriftAdapter) RecordActivityTaskHeartbeat(ctx context.Context, request *apiv1.RecordActivityTaskHeartbeatRequest, opts ...yarpc.CallOption) (*apiv1.RecordActivityTaskHeartbeatResponse, error) { + response, err := a.service.RecordActivityTaskHeartbeat(ctx, thrift.RecordActivityTaskHeartbeatRequest(request), opts...) + return proto.RecordActivityTaskHeartbeatResponse(response), proto.Error(err) +} +func (a workerAPIthriftAdapter) RecordActivityTaskHeartbeatByID(ctx context.Context, request *apiv1.RecordActivityTaskHeartbeatByIDRequest, opts ...yarpc.CallOption) (*apiv1.RecordActivityTaskHeartbeatByIDResponse, error) { + response, err := a.service.RecordActivityTaskHeartbeatByID(ctx, thrift.RecordActivityTaskHeartbeatByIdRequest(request), opts...) + return proto.RecordActivityTaskHeartbeatByIdResponse(response), proto.Error(err) +} +func (a workerAPIthriftAdapter) RespondQueryTaskCompleted(ctx context.Context, request *apiv1.RespondQueryTaskCompletedRequest, opts ...yarpc.CallOption) (*apiv1.RespondQueryTaskCompletedResponse, error) { + err := a.service.RespondQueryTaskCompleted(ctx, thrift.RespondQueryTaskCompletedRequest(request), opts...) + return &apiv1.RespondQueryTaskCompletedResponse{}, proto.Error(err) +} +func (a workerAPIthriftAdapter) ResetStickyTaskList(ctx context.Context, request *apiv1.ResetStickyTaskListRequest, opts ...yarpc.CallOption) (*apiv1.ResetStickyTaskListResponse, error) { + _, err := a.service.ResetStickyTaskList(ctx, thrift.ResetStickyTaskListRequest(request), opts...) + return &apiv1.ResetStickyTaskListResponse{}, proto.Error(err) +} + +type visibilityAPIthriftAdapter struct { + service workflowserviceclient.Interface +} + +func NewVisibilityAPITriftAdapter(thrift workflowserviceclient.Interface) visibilityAPIthriftAdapter { + return visibilityAPIthriftAdapter{thrift} +} + +func (a visibilityAPIthriftAdapter) ListWorkflowExecutions(ctx context.Context, request *apiv1.ListWorkflowExecutionsRequest, opts ...yarpc.CallOption) (*apiv1.ListWorkflowExecutionsResponse, error) { + response, err := a.service.ListWorkflowExecutions(ctx, thrift.ListWorkflowExecutionsRequest(request), opts...) + return proto.ListWorkflowExecutionsResponse(response), proto.Error(err) +} +func (a visibilityAPIthriftAdapter) ListOpenWorkflowExecutions(ctx context.Context, request *apiv1.ListOpenWorkflowExecutionsRequest, opts ...yarpc.CallOption) (*apiv1.ListOpenWorkflowExecutionsResponse, error) { + response, err := a.service.ListOpenWorkflowExecutions(ctx, thrift.ListOpenWorkflowExecutionsRequest(request), opts...) + return proto.ListOpenWorkflowExecutionsResponse(response), proto.Error(err) +} +func (a visibilityAPIthriftAdapter) ListClosedWorkflowExecutions(ctx context.Context, request *apiv1.ListClosedWorkflowExecutionsRequest, opts ...yarpc.CallOption) (*apiv1.ListClosedWorkflowExecutionsResponse, error) { + response, err := a.service.ListClosedWorkflowExecutions(ctx, thrift.ListClosedWorkflowExecutionsRequest(request), opts...) + return proto.ListClosedWorkflowExecutionsResponse(response), proto.Error(err) +} +func (a visibilityAPIthriftAdapter) ListArchivedWorkflowExecutions(ctx context.Context, request *apiv1.ListArchivedWorkflowExecutionsRequest, opts ...yarpc.CallOption) (*apiv1.ListArchivedWorkflowExecutionsResponse, error) { + response, err := a.service.ListArchivedWorkflowExecutions(ctx, thrift.ListArchivedWorkflowExecutionsRequest(request), opts...) + return proto.ListArchivedWorkflowExecutionsResponse(response), proto.Error(err) +} +func (a visibilityAPIthriftAdapter) ScanWorkflowExecutions(ctx context.Context, request *apiv1.ScanWorkflowExecutionsRequest, opts ...yarpc.CallOption) (*apiv1.ScanWorkflowExecutionsResponse, error) { + response, err := a.service.ScanWorkflowExecutions(ctx, thrift.ScanWorkflowExecutionsRequest(request), opts...) + return proto.ScanWorkflowExecutionsResponse(response), proto.Error(err) +} +func (a visibilityAPIthriftAdapter) CountWorkflowExecutions(ctx context.Context, request *apiv1.CountWorkflowExecutionsRequest, opts ...yarpc.CallOption) (*apiv1.CountWorkflowExecutionsResponse, error) { + response, err := a.service.CountWorkflowExecutions(ctx, thrift.CountWorkflowExecutionsRequest(request), opts...) + return proto.CountWorkflowExecutionsResponse(response), proto.Error(err) +} +func (a visibilityAPIthriftAdapter) GetSearchAttributes(ctx context.Context, request *apiv1.GetSearchAttributesRequest, opts ...yarpc.CallOption) (*apiv1.GetSearchAttributesResponse, error) { + response, err := a.service.GetSearchAttributes(ctx, opts...) + return proto.GetSearchAttributesResponse(response), proto.Error(err) } diff --git a/internal/compatibility/api_test.go b/internal/compatibility/api_test.go new file mode 100644 index 000000000..bc8ca0cee --- /dev/null +++ b/internal/compatibility/api_test.go @@ -0,0 +1,946 @@ +// Copyright (c) 2021 Uber Technologies Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +package compatibility + +import ( + "testing" + + gogo "github.com/gogo/protobuf/types" + "github.com/stretchr/testify/assert" + "go.uber.org/cadence/.gen/go/shared" + apiv1 "go.uber.org/cadence/.gen/proto/api/v1" + "go.uber.org/cadence/internal/common" + "go.uber.org/cadence/internal/compatibility/proto" + "go.uber.org/cadence/internal/compatibility/testdata" + "go.uber.org/cadence/internal/compatibility/thrift" +) + +func TestActivityLocalDispatchInfo(t *testing.T) { + for _, item := range []*apiv1.ActivityLocalDispatchInfo{nil, {}, &testdata.ActivityLocalDispatchInfo} { + assert.Equal(t, item, proto.ActivityLocalDispatchInfo(thrift.ActivityLocalDispatchInfo(item))) + } +} +func TestActivityTaskCancelRequestedEventAttributes(t *testing.T) { + for _, item := range []*apiv1.ActivityTaskCancelRequestedEventAttributes{nil, {}, &testdata.ActivityTaskCancelRequestedEventAttributes} { + assert.Equal(t, item, proto.ActivityTaskCancelRequestedEventAttributes(thrift.ActivityTaskCancelRequestedEventAttributes(item))) + } +} +func TestActivityTaskCanceledEventAttributes(t *testing.T) { + for _, item := range []*apiv1.ActivityTaskCanceledEventAttributes{nil, {}, &testdata.ActivityTaskCanceledEventAttributes} { + assert.Equal(t, item, proto.ActivityTaskCanceledEventAttributes(thrift.ActivityTaskCanceledEventAttributes(item))) + } +} +func TestActivityTaskCompletedEventAttributes(t *testing.T) { + for _, item := range []*apiv1.ActivityTaskCompletedEventAttributes{nil, {}, &testdata.ActivityTaskCompletedEventAttributes} { + assert.Equal(t, item, proto.ActivityTaskCompletedEventAttributes(thrift.ActivityTaskCompletedEventAttributes(item))) + } +} +func TestActivityTaskFailedEventAttributes(t *testing.T) { + for _, item := range []*apiv1.ActivityTaskFailedEventAttributes{nil, {}, &testdata.ActivityTaskFailedEventAttributes} { + assert.Equal(t, item, proto.ActivityTaskFailedEventAttributes(thrift.ActivityTaskFailedEventAttributes(item))) + } +} +func TestActivityTaskScheduledEventAttributes(t *testing.T) { + for _, item := range []*apiv1.ActivityTaskScheduledEventAttributes{nil, {}, &testdata.ActivityTaskScheduledEventAttributes} { + assert.Equal(t, item, proto.ActivityTaskScheduledEventAttributes(thrift.ActivityTaskScheduledEventAttributes(item))) + } +} +func TestActivityTaskStartedEventAttributes(t *testing.T) { + for _, item := range []*apiv1.ActivityTaskStartedEventAttributes{nil, {}, &testdata.ActivityTaskStartedEventAttributes} { + assert.Equal(t, item, proto.ActivityTaskStartedEventAttributes(thrift.ActivityTaskStartedEventAttributes(item))) + } +} +func TestActivityTaskTimedOutEventAttributes(t *testing.T) { + for _, item := range []*apiv1.ActivityTaskTimedOutEventAttributes{nil, {}, &testdata.ActivityTaskTimedOutEventAttributes} { + assert.Equal(t, item, proto.ActivityTaskTimedOutEventAttributes(thrift.ActivityTaskTimedOutEventAttributes(item))) + } +} +func TestActivityType(t *testing.T) { + for _, item := range []*apiv1.ActivityType{nil, {}, &testdata.ActivityType} { + assert.Equal(t, item, proto.ActivityType(thrift.ActivityType(item))) + } +} +func TestBadBinaries(t *testing.T) { + for _, item := range []*apiv1.BadBinaries{nil, {}, &testdata.BadBinaries} { + assert.Equal(t, item, proto.BadBinaries(thrift.BadBinaries(item))) + } +} +func TestBadBinaryInfo(t *testing.T) { + for _, item := range []*apiv1.BadBinaryInfo{nil, {}, &testdata.BadBinaryInfo} { + assert.Equal(t, item, proto.BadBinaryInfo(thrift.BadBinaryInfo(item))) + } +} +func TestCancelTimerFailedEventAttributes(t *testing.T) { + for _, item := range []*apiv1.CancelTimerFailedEventAttributes{nil, {}, &testdata.CancelTimerFailedEventAttributes} { + assert.Equal(t, item, proto.CancelTimerFailedEventAttributes(thrift.CancelTimerFailedEventAttributes(item))) + } +} +func TestChildWorkflowExecutionCanceledEventAttributes(t *testing.T) { + for _, item := range []*apiv1.ChildWorkflowExecutionCanceledEventAttributes{nil, {}, &testdata.ChildWorkflowExecutionCanceledEventAttributes} { + assert.Equal(t, item, proto.ChildWorkflowExecutionCanceledEventAttributes(thrift.ChildWorkflowExecutionCanceledEventAttributes(item))) + } +} +func TestChildWorkflowExecutionCompletedEventAttributes(t *testing.T) { + for _, item := range []*apiv1.ChildWorkflowExecutionCompletedEventAttributes{nil, {}, &testdata.ChildWorkflowExecutionCompletedEventAttributes} { + assert.Equal(t, item, proto.ChildWorkflowExecutionCompletedEventAttributes(thrift.ChildWorkflowExecutionCompletedEventAttributes(item))) + } +} +func TestChildWorkflowExecutionFailedEventAttributes(t *testing.T) { + for _, item := range []*apiv1.ChildWorkflowExecutionFailedEventAttributes{nil, {}, &testdata.ChildWorkflowExecutionFailedEventAttributes} { + assert.Equal(t, item, proto.ChildWorkflowExecutionFailedEventAttributes(thrift.ChildWorkflowExecutionFailedEventAttributes(item))) + } +} +func TestChildWorkflowExecutionStartedEventAttributes(t *testing.T) { + for _, item := range []*apiv1.ChildWorkflowExecutionStartedEventAttributes{nil, {}, &testdata.ChildWorkflowExecutionStartedEventAttributes} { + assert.Equal(t, item, proto.ChildWorkflowExecutionStartedEventAttributes(thrift.ChildWorkflowExecutionStartedEventAttributes(item))) + } +} +func TestChildWorkflowExecutionTerminatedEventAttributes(t *testing.T) { + for _, item := range []*apiv1.ChildWorkflowExecutionTerminatedEventAttributes{nil, {}, &testdata.ChildWorkflowExecutionTerminatedEventAttributes} { + assert.Equal(t, item, proto.ChildWorkflowExecutionTerminatedEventAttributes(thrift.ChildWorkflowExecutionTerminatedEventAttributes(item))) + } +} +func TestChildWorkflowExecutionTimedOutEventAttributes(t *testing.T) { + for _, item := range []*apiv1.ChildWorkflowExecutionTimedOutEventAttributes{nil, {}, &testdata.ChildWorkflowExecutionTimedOutEventAttributes} { + assert.Equal(t, item, proto.ChildWorkflowExecutionTimedOutEventAttributes(thrift.ChildWorkflowExecutionTimedOutEventAttributes(item))) + } +} +func TestClusterReplicationConfiguration(t *testing.T) { + for _, item := range []*apiv1.ClusterReplicationConfiguration{nil, {}, &testdata.ClusterReplicationConfiguration} { + assert.Equal(t, item, proto.ClusterReplicationConfiguration(thrift.ClusterReplicationConfiguration(item))) + } +} +func TestCountWorkflowExecutionsRequest(t *testing.T) { + for _, item := range []*apiv1.CountWorkflowExecutionsRequest{nil, {}, &testdata.CountWorkflowExecutionsRequest} { + assert.Equal(t, item, proto.CountWorkflowExecutionsRequest(thrift.CountWorkflowExecutionsRequest(item))) + } +} +func TestCountWorkflowExecutionsResponse(t *testing.T) { + for _, item := range []*apiv1.CountWorkflowExecutionsResponse{nil, {}, &testdata.CountWorkflowExecutionsResponse} { + assert.Equal(t, item, proto.CountWorkflowExecutionsResponse(thrift.CountWorkflowExecutionsResponse(item))) + } +} +func TestDataBlob(t *testing.T) { + for _, item := range []*apiv1.DataBlob{nil, {}, &testdata.DataBlob} { + assert.Equal(t, item, proto.DataBlob(thrift.DataBlob(item))) + } +} +func TestDecisionTaskCompletedEventAttributes(t *testing.T) { + for _, item := range []*apiv1.DecisionTaskCompletedEventAttributes{nil, {}, &testdata.DecisionTaskCompletedEventAttributes} { + assert.Equal(t, item, proto.DecisionTaskCompletedEventAttributes(thrift.DecisionTaskCompletedEventAttributes(item))) + } +} +func TestDecisionTaskFailedEventAttributes(t *testing.T) { + for _, item := range []*apiv1.DecisionTaskFailedEventAttributes{nil, {}, &testdata.DecisionTaskFailedEventAttributes} { + assert.Equal(t, item, proto.DecisionTaskFailedEventAttributes(thrift.DecisionTaskFailedEventAttributes(item))) + } +} +func TestDecisionTaskScheduledEventAttributes(t *testing.T) { + for _, item := range []*apiv1.DecisionTaskScheduledEventAttributes{nil, {}, &testdata.DecisionTaskScheduledEventAttributes} { + assert.Equal(t, item, proto.DecisionTaskScheduledEventAttributes(thrift.DecisionTaskScheduledEventAttributes(item))) + } +} +func TestDecisionTaskStartedEventAttributes(t *testing.T) { + for _, item := range []*apiv1.DecisionTaskStartedEventAttributes{nil, {}, &testdata.DecisionTaskStartedEventAttributes} { + assert.Equal(t, item, proto.DecisionTaskStartedEventAttributes(thrift.DecisionTaskStartedEventAttributes(item))) + } +} +func TestDecisionTaskTimedOutEventAttributes(t *testing.T) { + for _, item := range []*apiv1.DecisionTaskTimedOutEventAttributes{nil, {}, &testdata.DecisionTaskTimedOutEventAttributes} { + assert.Equal(t, item, proto.DecisionTaskTimedOutEventAttributes(thrift.DecisionTaskTimedOutEventAttributes(item))) + } +} +func TestDeprecateDomainRequest(t *testing.T) { + for _, item := range []*apiv1.DeprecateDomainRequest{nil, {}, &testdata.DeprecateDomainRequest} { + assert.Equal(t, item, proto.DeprecateDomainRequest(thrift.DeprecateDomainRequest(item))) + } +} +func TestDescribeDomainRequest(t *testing.T) { + for _, item := range []*apiv1.DescribeDomainRequest{ + &testdata.DescribeDomainRequest_ID, + &testdata.DescribeDomainRequest_Name, + } { + assert.Equal(t, item, proto.DescribeDomainRequest(thrift.DescribeDomainRequest(item))) + } + assert.Nil(t, proto.DescribeDomainRequest(nil)) + assert.Nil(t, thrift.DescribeDomainRequest(nil)) + assert.Panics(t, func() { proto.DescribeDomainRequest(&shared.DescribeDomainRequest{}) }) + assert.Panics(t, func() { thrift.DescribeDomainRequest(&apiv1.DescribeDomainRequest{}) }) +} +func TestDescribeDomainResponse_Domain(t *testing.T) { + for _, item := range []*apiv1.Domain{nil, &testdata.Domain} { + assert.Equal(t, item, proto.DescribeDomainResponseDomain(thrift.DescribeDomainResponseDomain(item))) + } +} +func TestDescribeDomainResponse(t *testing.T) { + for _, item := range []*apiv1.DescribeDomainResponse{nil, &testdata.DescribeDomainResponse} { + assert.Equal(t, item, proto.DescribeDomainResponse(thrift.DescribeDomainResponse(item))) + } +} +func TestDescribeTaskListRequest(t *testing.T) { + for _, item := range []*apiv1.DescribeTaskListRequest{nil, {}, &testdata.DescribeTaskListRequest} { + assert.Equal(t, item, proto.DescribeTaskListRequest(thrift.DescribeTaskListRequest(item))) + } +} +func TestDescribeTaskListResponse(t *testing.T) { + for _, item := range []*apiv1.DescribeTaskListResponse{nil, {}, &testdata.DescribeTaskListResponse} { + assert.Equal(t, item, proto.DescribeTaskListResponse(thrift.DescribeTaskListResponse(item))) + } +} +func TestDescribeWorkflowExecutionRequest(t *testing.T) { + for _, item := range []*apiv1.DescribeWorkflowExecutionRequest{nil, {}, &testdata.DescribeWorkflowExecutionRequest} { + assert.Equal(t, item, proto.DescribeWorkflowExecutionRequest(thrift.DescribeWorkflowExecutionRequest(item))) + } +} +func TestDescribeWorkflowExecutionResponse(t *testing.T) { + for _, item := range []*apiv1.DescribeWorkflowExecutionResponse{nil, {}, &testdata.DescribeWorkflowExecutionResponse} { + assert.Equal(t, item, proto.DescribeWorkflowExecutionResponse(thrift.DescribeWorkflowExecutionResponse(item))) + } +} +func TestExternalWorkflowExecutionCancelRequestedEventAttributes(t *testing.T) { + for _, item := range []*apiv1.ExternalWorkflowExecutionCancelRequestedEventAttributes{nil, {}, &testdata.ExternalWorkflowExecutionCancelRequestedEventAttributes} { + assert.Equal(t, item, proto.ExternalWorkflowExecutionCancelRequestedEventAttributes(thrift.ExternalWorkflowExecutionCancelRequestedEventAttributes(item))) + } +} +func TestExternalWorkflowExecutionSignaledEventAttributes(t *testing.T) { + for _, item := range []*apiv1.ExternalWorkflowExecutionSignaledEventAttributes{nil, {}, &testdata.ExternalWorkflowExecutionSignaledEventAttributes} { + assert.Equal(t, item, proto.ExternalWorkflowExecutionSignaledEventAttributes(thrift.ExternalWorkflowExecutionSignaledEventAttributes(item))) + } +} +func TestGetClusterInfoResponse(t *testing.T) { + for _, item := range []*apiv1.GetClusterInfoResponse{nil, {}, &testdata.GetClusterInfoResponse} { + assert.Equal(t, item, proto.GetClusterInfoResponse(thrift.GetClusterInfoResponse(item))) + } +} +func TestGetSearchAttributesResponse(t *testing.T) { + for _, item := range []*apiv1.GetSearchAttributesResponse{nil, {}, &testdata.GetSearchAttributesResponse} { + assert.Equal(t, item, proto.GetSearchAttributesResponse(thrift.GetSearchAttributesResponse(item))) + } +} +func TestGetWorkflowExecutionHistoryRequest(t *testing.T) { + for _, item := range []*apiv1.GetWorkflowExecutionHistoryRequest{nil, {}, &testdata.GetWorkflowExecutionHistoryRequest} { + assert.Equal(t, item, proto.GetWorkflowExecutionHistoryRequest(thrift.GetWorkflowExecutionHistoryRequest(item))) + } +} +func TestGetWorkflowExecutionHistoryResponse(t *testing.T) { + for _, item := range []*apiv1.GetWorkflowExecutionHistoryResponse{nil, {}, &testdata.GetWorkflowExecutionHistoryResponse} { + assert.Equal(t, item, proto.GetWorkflowExecutionHistoryResponse(thrift.GetWorkflowExecutionHistoryResponse(item))) + } +} +func TestHeader(t *testing.T) { + for _, item := range []*apiv1.Header{nil, {}, &testdata.Header} { + assert.Equal(t, item, proto.Header(thrift.Header(item))) + } +} +func TestHistory(t *testing.T) { + for _, item := range []*apiv1.History{nil, {}, &testdata.History} { + assert.Equal(t, item, proto.History(thrift.History(item))) + } +} +func TestListArchivedWorkflowExecutionsRequest(t *testing.T) { + for _, item := range []*apiv1.ListArchivedWorkflowExecutionsRequest{nil, {}, &testdata.ListArchivedWorkflowExecutionsRequest} { + assert.Equal(t, item, proto.ListArchivedWorkflowExecutionsRequest(thrift.ListArchivedWorkflowExecutionsRequest(item))) + } +} +func TestListArchivedWorkflowExecutionsResponse(t *testing.T) { + for _, item := range []*apiv1.ListArchivedWorkflowExecutionsResponse{nil, {}, &testdata.ListArchivedWorkflowExecutionsResponse} { + assert.Equal(t, item, proto.ListArchivedWorkflowExecutionsResponse(thrift.ListArchivedWorkflowExecutionsResponse(item))) + } +} +func TestListClosedWorkflowExecutionsResponse(t *testing.T) { + for _, item := range []*apiv1.ListClosedWorkflowExecutionsResponse{nil, {}, &testdata.ListClosedWorkflowExecutionsResponse} { + assert.Equal(t, item, proto.ListClosedWorkflowExecutionsResponse(thrift.ListClosedWorkflowExecutionsResponse(item))) + } +} +func TestListDomainsRequest(t *testing.T) { + for _, item := range []*apiv1.ListDomainsRequest{nil, {}, &testdata.ListDomainsRequest} { + assert.Equal(t, item, proto.ListDomainsRequest(thrift.ListDomainsRequest(item))) + } +} +func TestListDomainsResponse(t *testing.T) { + for _, item := range []*apiv1.ListDomainsResponse{nil, {}, &testdata.ListDomainsResponse} { + assert.Equal(t, item, proto.ListDomainsResponse(thrift.ListDomainsResponse(item))) + } +} +func TestListOpenWorkflowExecutionsResponse(t *testing.T) { + for _, item := range []*apiv1.ListOpenWorkflowExecutionsResponse{nil, {}, &testdata.ListOpenWorkflowExecutionsResponse} { + assert.Equal(t, item, proto.ListOpenWorkflowExecutionsResponse(thrift.ListOpenWorkflowExecutionsResponse(item))) + } +} +func TestListTaskListPartitionsRequest(t *testing.T) { + for _, item := range []*apiv1.ListTaskListPartitionsRequest{nil, {}, &testdata.ListTaskListPartitionsRequest} { + assert.Equal(t, item, proto.ListTaskListPartitionsRequest(thrift.ListTaskListPartitionsRequest(item))) + } +} +func TestListTaskListPartitionsResponse(t *testing.T) { + for _, item := range []*apiv1.ListTaskListPartitionsResponse{nil, {}, &testdata.ListTaskListPartitionsResponse} { + assert.Equal(t, item, proto.ListTaskListPartitionsResponse(thrift.ListTaskListPartitionsResponse(item))) + } +} +func TestListWorkflowExecutionsRequest(t *testing.T) { + for _, item := range []*apiv1.ListWorkflowExecutionsRequest{nil, {}, &testdata.ListWorkflowExecutionsRequest} { + assert.Equal(t, item, proto.ListWorkflowExecutionsRequest(thrift.ListWorkflowExecutionsRequest(item))) + } +} +func TestListWorkflowExecutionsResponse(t *testing.T) { + for _, item := range []*apiv1.ListWorkflowExecutionsResponse{nil, {}, &testdata.ListWorkflowExecutionsResponse} { + assert.Equal(t, item, proto.ListWorkflowExecutionsResponse(thrift.ListWorkflowExecutionsResponse(item))) + } +} +func TestMarkerRecordedEventAttributes(t *testing.T) { + for _, item := range []*apiv1.MarkerRecordedEventAttributes{nil, {}, &testdata.MarkerRecordedEventAttributes} { + assert.Equal(t, item, proto.MarkerRecordedEventAttributes(thrift.MarkerRecordedEventAttributes(item))) + } +} +func TestMemo(t *testing.T) { + for _, item := range []*apiv1.Memo{nil, {}, &testdata.Memo} { + assert.Equal(t, item, proto.Memo(thrift.Memo(item))) + } +} +func TestPendingActivityInfo(t *testing.T) { + for _, item := range []*apiv1.PendingActivityInfo{nil, {}, &testdata.PendingActivityInfo} { + assert.Equal(t, item, proto.PendingActivityInfo(thrift.PendingActivityInfo(item))) + } +} +func TestPendingChildExecutionInfo(t *testing.T) { + for _, item := range []*apiv1.PendingChildExecutionInfo{nil, {}, &testdata.PendingChildExecutionInfo} { + assert.Equal(t, item, proto.PendingChildExecutionInfo(thrift.PendingChildExecutionInfo(item))) + } +} +func TestPendingDecisionInfo(t *testing.T) { + for _, item := range []*apiv1.PendingDecisionInfo{nil, {}, &testdata.PendingDecisionInfo} { + assert.Equal(t, item, proto.PendingDecisionInfo(thrift.PendingDecisionInfo(item))) + } +} +func TestPollForActivityTaskRequest(t *testing.T) { + for _, item := range []*apiv1.PollForActivityTaskRequest{nil, {}, &testdata.PollForActivityTaskRequest} { + assert.Equal(t, item, proto.PollForActivityTaskRequest(thrift.PollForActivityTaskRequest(item))) + } +} +func TestPollForActivityTaskResponse(t *testing.T) { + for _, item := range []*apiv1.PollForActivityTaskResponse{nil, {}, &testdata.PollForActivityTaskResponse} { + assert.Equal(t, item, proto.PollForActivityTaskResponse(thrift.PollForActivityTaskResponse(item))) + } +} +func TestPollForDecisionTaskRequest(t *testing.T) { + for _, item := range []*apiv1.PollForDecisionTaskRequest{nil, {}, &testdata.PollForDecisionTaskRequest} { + assert.Equal(t, item, proto.PollForDecisionTaskRequest(thrift.PollForDecisionTaskRequest(item))) + } +} +func TestPollForDecisionTaskResponse(t *testing.T) { + for _, item := range []*apiv1.PollForDecisionTaskResponse{nil, {}, &testdata.PollForDecisionTaskResponse} { + assert.Equal(t, item, proto.PollForDecisionTaskResponse(thrift.PollForDecisionTaskResponse(item))) + } +} +func TestPollerInfo(t *testing.T) { + for _, item := range []*apiv1.PollerInfo{nil, {}, &testdata.PollerInfo} { + assert.Equal(t, item, proto.PollerInfo(thrift.PollerInfo(item))) + } +} +func TestQueryRejected(t *testing.T) { + for _, item := range []*apiv1.QueryRejected{nil, {}, &testdata.QueryRejected} { + assert.Equal(t, item, proto.QueryRejected(thrift.QueryRejected(item))) + } +} +func TestQueryWorkflowRequest(t *testing.T) { + for _, item := range []*apiv1.QueryWorkflowRequest{nil, {}, &testdata.QueryWorkflowRequest} { + assert.Equal(t, item, proto.QueryWorkflowRequest(thrift.QueryWorkflowRequest(item))) + } +} +func TestQueryWorkflowResponse(t *testing.T) { + for _, item := range []*apiv1.QueryWorkflowResponse{nil, {}, &testdata.QueryWorkflowResponse} { + assert.Equal(t, item, proto.QueryWorkflowResponse(thrift.QueryWorkflowResponse(item))) + } +} +func TestRecordActivityTaskHeartbeatByIDRequest(t *testing.T) { + for _, item := range []*apiv1.RecordActivityTaskHeartbeatByIDRequest{nil, {}, &testdata.RecordActivityTaskHeartbeatByIDRequest} { + assert.Equal(t, item, proto.RecordActivityTaskHeartbeatByIdRequest(thrift.RecordActivityTaskHeartbeatByIdRequest(item))) + } +} +func TestRecordActivityTaskHeartbeatByIDResponse(t *testing.T) { + for _, item := range []*apiv1.RecordActivityTaskHeartbeatByIDResponse{nil, {}, &testdata.RecordActivityTaskHeartbeatByIDResponse} { + assert.Equal(t, item, proto.RecordActivityTaskHeartbeatByIdResponse(thrift.RecordActivityTaskHeartbeatByIdResponse(item))) + } +} +func TestRecordActivityTaskHeartbeatRequest(t *testing.T) { + for _, item := range []*apiv1.RecordActivityTaskHeartbeatRequest{nil, {}, &testdata.RecordActivityTaskHeartbeatRequest} { + assert.Equal(t, item, proto.RecordActivityTaskHeartbeatRequest(thrift.RecordActivityTaskHeartbeatRequest(item))) + } +} +func TestRecordActivityTaskHeartbeatResponse(t *testing.T) { + for _, item := range []*apiv1.RecordActivityTaskHeartbeatResponse{nil, {}, &testdata.RecordActivityTaskHeartbeatResponse} { + assert.Equal(t, item, proto.RecordActivityTaskHeartbeatResponse(thrift.RecordActivityTaskHeartbeatResponse(item))) + } +} +func TestRegisterDomainRequest(t *testing.T) { + for _, item := range []*apiv1.RegisterDomainRequest{nil, &testdata.RegisterDomainRequest} { + assert.Equal(t, item, proto.RegisterDomainRequest(thrift.RegisterDomainRequest(item))) + } +} +func TestRequestCancelActivityTaskFailedEventAttributes(t *testing.T) { + for _, item := range []*apiv1.RequestCancelActivityTaskFailedEventAttributes{nil, {}, &testdata.RequestCancelActivityTaskFailedEventAttributes} { + assert.Equal(t, item, proto.RequestCancelActivityTaskFailedEventAttributes(thrift.RequestCancelActivityTaskFailedEventAttributes(item))) + } +} +func TestRequestCancelExternalWorkflowExecutionFailedEventAttributes(t *testing.T) { + for _, item := range []*apiv1.RequestCancelExternalWorkflowExecutionFailedEventAttributes{nil, {}, &testdata.RequestCancelExternalWorkflowExecutionFailedEventAttributes} { + assert.Equal(t, item, proto.RequestCancelExternalWorkflowExecutionFailedEventAttributes(thrift.RequestCancelExternalWorkflowExecutionFailedEventAttributes(item))) + } +} +func TestRequestCancelExternalWorkflowExecutionInitiatedEventAttributes(t *testing.T) { + for _, item := range []*apiv1.RequestCancelExternalWorkflowExecutionInitiatedEventAttributes{nil, {}, &testdata.RequestCancelExternalWorkflowExecutionInitiatedEventAttributes} { + assert.Equal(t, item, proto.RequestCancelExternalWorkflowExecutionInitiatedEventAttributes(thrift.RequestCancelExternalWorkflowExecutionInitiatedEventAttributes(item))) + } +} +func TestRequestCancelWorkflowExecutionRequest(t *testing.T) { + for _, item := range []*apiv1.RequestCancelWorkflowExecutionRequest{nil, {}, &testdata.RequestCancelWorkflowExecutionRequest} { + assert.Equal(t, item, proto.RequestCancelWorkflowExecutionRequest(thrift.RequestCancelWorkflowExecutionRequest(item))) + } +} +func TestResetPointInfo(t *testing.T) { + for _, item := range []*apiv1.ResetPointInfo{nil, {}, &testdata.ResetPointInfo} { + assert.Equal(t, item, proto.ResetPointInfo(thrift.ResetPointInfo(item))) + } +} +func TestResetPoints(t *testing.T) { + for _, item := range []*apiv1.ResetPoints{nil, {}, &testdata.ResetPoints} { + assert.Equal(t, item, proto.ResetPoints(thrift.ResetPoints(item))) + } +} +func TestResetStickyTaskListRequest(t *testing.T) { + for _, item := range []*apiv1.ResetStickyTaskListRequest{nil, {}, &testdata.ResetStickyTaskListRequest} { + assert.Equal(t, item, proto.ResetStickyTaskListRequest(thrift.ResetStickyTaskListRequest(item))) + } +} +func TestResetWorkflowExecutionRequest(t *testing.T) { + for _, item := range []*apiv1.ResetWorkflowExecutionRequest{nil, {}, &testdata.ResetWorkflowExecutionRequest} { + assert.Equal(t, item, proto.ResetWorkflowExecutionRequest(thrift.ResetWorkflowExecutionRequest(item))) + } +} +func TestResetWorkflowExecutionResponse(t *testing.T) { + for _, item := range []*apiv1.ResetWorkflowExecutionResponse{nil, {}, &testdata.ResetWorkflowExecutionResponse} { + assert.Equal(t, item, proto.ResetWorkflowExecutionResponse(thrift.ResetWorkflowExecutionResponse(item))) + } +} +func TestRespondActivityTaskCanceledByIDRequest(t *testing.T) { + for _, item := range []*apiv1.RespondActivityTaskCanceledByIDRequest{nil, {}, &testdata.RespondActivityTaskCanceledByIDRequest} { + assert.Equal(t, item, proto.RespondActivityTaskCanceledByIdRequest(thrift.RespondActivityTaskCanceledByIdRequest(item))) + } +} +func TestRespondActivityTaskCanceledRequest(t *testing.T) { + for _, item := range []*apiv1.RespondActivityTaskCanceledRequest{nil, {}, &testdata.RespondActivityTaskCanceledRequest} { + assert.Equal(t, item, proto.RespondActivityTaskCanceledRequest(thrift.RespondActivityTaskCanceledRequest(item))) + } +} +func TestRespondActivityTaskCompletedByIDRequest(t *testing.T) { + for _, item := range []*apiv1.RespondActivityTaskCompletedByIDRequest{nil, {}, &testdata.RespondActivityTaskCompletedByIDRequest} { + assert.Equal(t, item, proto.RespondActivityTaskCompletedByIdRequest(thrift.RespondActivityTaskCompletedByIdRequest(item))) + } +} +func TestRespondActivityTaskCompletedRequest(t *testing.T) { + for _, item := range []*apiv1.RespondActivityTaskCompletedRequest{nil, {}, &testdata.RespondActivityTaskCompletedRequest} { + assert.Equal(t, item, proto.RespondActivityTaskCompletedRequest(thrift.RespondActivityTaskCompletedRequest(item))) + } +} +func TestRespondActivityTaskFailedByIDRequest(t *testing.T) { + for _, item := range []*apiv1.RespondActivityTaskFailedByIDRequest{nil, {}, &testdata.RespondActivityTaskFailedByIDRequest} { + assert.Equal(t, item, proto.RespondActivityTaskFailedByIdRequest(thrift.RespondActivityTaskFailedByIdRequest(item))) + } +} +func TestRespondActivityTaskFailedRequest(t *testing.T) { + for _, item := range []*apiv1.RespondActivityTaskFailedRequest{nil, {}, &testdata.RespondActivityTaskFailedRequest} { + assert.Equal(t, item, proto.RespondActivityTaskFailedRequest(thrift.RespondActivityTaskFailedRequest(item))) + } +} +func TestRespondDecisionTaskCompletedRequest(t *testing.T) { + for _, item := range []*apiv1.RespondDecisionTaskCompletedRequest{nil, {}, &testdata.RespondDecisionTaskCompletedRequest} { + assert.Equal(t, item, proto.RespondDecisionTaskCompletedRequest(thrift.RespondDecisionTaskCompletedRequest(item))) + } +} +func TestRespondDecisionTaskCompletedResponse(t *testing.T) { + for _, item := range []*apiv1.RespondDecisionTaskCompletedResponse{nil, {}, &testdata.RespondDecisionTaskCompletedResponse} { + assert.Equal(t, item, proto.RespondDecisionTaskCompletedResponse(thrift.RespondDecisionTaskCompletedResponse(item))) + } +} +func TestRespondDecisionTaskFailedRequest(t *testing.T) { + for _, item := range []*apiv1.RespondDecisionTaskFailedRequest{nil, {}, &testdata.RespondDecisionTaskFailedRequest} { + assert.Equal(t, item, proto.RespondDecisionTaskFailedRequest(thrift.RespondDecisionTaskFailedRequest(item))) + } +} +func TestRespondQueryTaskCompletedRequest(t *testing.T) { + for _, item := range []*apiv1.RespondQueryTaskCompletedRequest{nil, {Result: &apiv1.WorkflowQueryResult{}}, &testdata.RespondQueryTaskCompletedRequest} { + assert.Equal(t, item, proto.RespondQueryTaskCompletedRequest(thrift.RespondQueryTaskCompletedRequest(item))) + } +} +func TestRetryPolicy(t *testing.T) { + for _, item := range []*apiv1.RetryPolicy{nil, {}, &testdata.RetryPolicy} { + assert.Equal(t, item, proto.RetryPolicy(thrift.RetryPolicy(item))) + } +} +func TestScanWorkflowExecutionsRequest(t *testing.T) { + for _, item := range []*apiv1.ScanWorkflowExecutionsRequest{nil, {}, &testdata.ScanWorkflowExecutionsRequest} { + assert.Equal(t, item, proto.ScanWorkflowExecutionsRequest(thrift.ScanWorkflowExecutionsRequest(item))) + } +} +func TestScanWorkflowExecutionsResponse(t *testing.T) { + for _, item := range []*apiv1.ScanWorkflowExecutionsResponse{nil, {}, &testdata.ScanWorkflowExecutionsResponse} { + assert.Equal(t, item, proto.ScanWorkflowExecutionsResponse(thrift.ScanWorkflowExecutionsResponse(item))) + } +} +func TestSearchAttributes(t *testing.T) { + for _, item := range []*apiv1.SearchAttributes{nil, {}, &testdata.SearchAttributes} { + assert.Equal(t, item, proto.SearchAttributes(thrift.SearchAttributes(item))) + } +} +func TestSignalExternalWorkflowExecutionFailedEventAttributes(t *testing.T) { + for _, item := range []*apiv1.SignalExternalWorkflowExecutionFailedEventAttributes{nil, {}, &testdata.SignalExternalWorkflowExecutionFailedEventAttributes} { + assert.Equal(t, item, proto.SignalExternalWorkflowExecutionFailedEventAttributes(thrift.SignalExternalWorkflowExecutionFailedEventAttributes(item))) + } +} +func TestSignalExternalWorkflowExecutionInitiatedEventAttributes(t *testing.T) { + for _, item := range []*apiv1.SignalExternalWorkflowExecutionInitiatedEventAttributes{nil, {}, &testdata.SignalExternalWorkflowExecutionInitiatedEventAttributes} { + assert.Equal(t, item, proto.SignalExternalWorkflowExecutionInitiatedEventAttributes(thrift.SignalExternalWorkflowExecutionInitiatedEventAttributes(item))) + } +} +func TestSignalWithStartWorkflowExecutionRequest(t *testing.T) { + for _, item := range []*apiv1.SignalWithStartWorkflowExecutionRequest{nil, {StartRequest: &apiv1.StartWorkflowExecutionRequest{}}, &testdata.SignalWithStartWorkflowExecutionRequest} { + assert.Equal(t, item, proto.SignalWithStartWorkflowExecutionRequest(thrift.SignalWithStartWorkflowExecutionRequest(item))) + } +} +func TestSignalWithStartWorkflowExecutionResponse(t *testing.T) { + for _, item := range []*apiv1.SignalWithStartWorkflowExecutionResponse{nil, {}, &testdata.SignalWithStartWorkflowExecutionResponse} { + assert.Equal(t, item, proto.SignalWithStartWorkflowExecutionResponse(thrift.SignalWithStartWorkflowExecutionResponse(item))) + } +} +func TestSignalWorkflowExecutionRequest(t *testing.T) { + for _, item := range []*apiv1.SignalWorkflowExecutionRequest{nil, {}, &testdata.SignalWorkflowExecutionRequest} { + assert.Equal(t, item, proto.SignalWorkflowExecutionRequest(thrift.SignalWorkflowExecutionRequest(item))) + } +} +func TestStartChildWorkflowExecutionFailedEventAttributes(t *testing.T) { + for _, item := range []*apiv1.StartChildWorkflowExecutionFailedEventAttributes{nil, {}, &testdata.StartChildWorkflowExecutionFailedEventAttributes} { + assert.Equal(t, item, proto.StartChildWorkflowExecutionFailedEventAttributes(thrift.StartChildWorkflowExecutionFailedEventAttributes(item))) + } +} +func TestStartChildWorkflowExecutionInitiatedEventAttributes(t *testing.T) { + for _, item := range []*apiv1.StartChildWorkflowExecutionInitiatedEventAttributes{nil, {}, &testdata.StartChildWorkflowExecutionInitiatedEventAttributes} { + assert.Equal(t, item, proto.StartChildWorkflowExecutionInitiatedEventAttributes(thrift.StartChildWorkflowExecutionInitiatedEventAttributes(item))) + } +} +func TestStartTimeFilter(t *testing.T) { + for _, item := range []*apiv1.StartTimeFilter{nil, {}, &testdata.StartTimeFilter} { + assert.Equal(t, item, proto.StartTimeFilter(thrift.StartTimeFilter(item))) + } +} +func TestStartWorkflowExecutionRequest(t *testing.T) { + for _, item := range []*apiv1.StartWorkflowExecutionRequest{nil, {}, &testdata.StartWorkflowExecutionRequest} { + assert.Equal(t, item, proto.StartWorkflowExecutionRequest(thrift.StartWorkflowExecutionRequest(item))) + } +} +func TestStartWorkflowExecutionResponse(t *testing.T) { + for _, item := range []*apiv1.StartWorkflowExecutionResponse{nil, {}, &testdata.StartWorkflowExecutionResponse} { + assert.Equal(t, item, proto.StartWorkflowExecutionResponse(thrift.StartWorkflowExecutionResponse(item))) + } +} +func TestStatusFilter(t *testing.T) { + for _, item := range []*apiv1.StatusFilter{nil, &testdata.StatusFilter} { + assert.Equal(t, item, proto.StatusFilter(thrift.StatusFilter(item))) + } +} +func TestStickyExecutionAttributes(t *testing.T) { + for _, item := range []*apiv1.StickyExecutionAttributes{nil, {}, &testdata.StickyExecutionAttributes} { + assert.Equal(t, item, proto.StickyExecutionAttributes(thrift.StickyExecutionAttributes(item))) + } +} +func TestSupportedClientVersions(t *testing.T) { + for _, item := range []*apiv1.SupportedClientVersions{nil, {}, &testdata.SupportedClientVersions} { + assert.Equal(t, item, proto.SupportedClientVersions(thrift.SupportedClientVersions(item))) + } +} +func TestTaskIDBlock(t *testing.T) { + for _, item := range []*apiv1.TaskIDBlock{nil, {}, &testdata.TaskIDBlock} { + assert.Equal(t, item, proto.TaskIdBlock(thrift.TaskIdBlock(item))) + } +} +func TestTaskList(t *testing.T) { + for _, item := range []*apiv1.TaskList{nil, {}, &testdata.TaskList} { + assert.Equal(t, item, proto.TaskList(thrift.TaskList(item))) + } +} +func TestTaskListMetadata(t *testing.T) { + for _, item := range []*apiv1.TaskListMetadata{nil, {}, &testdata.TaskListMetadata} { + assert.Equal(t, item, proto.TaskListMetadata(thrift.TaskListMetadata(item))) + } +} +func TestTaskListPartitionMetadata(t *testing.T) { + for _, item := range []*apiv1.TaskListPartitionMetadata{nil, {}, &testdata.TaskListPartitionMetadata} { + assert.Equal(t, item, proto.TaskListPartitionMetadata(thrift.TaskListPartitionMetadata(item))) + } +} +func TestTaskListStatus(t *testing.T) { + for _, item := range []*apiv1.TaskListStatus{nil, {}, &testdata.TaskListStatus} { + assert.Equal(t, item, proto.TaskListStatus(thrift.TaskListStatus(item))) + } +} +func TestTerminateWorkflowExecutionRequest(t *testing.T) { + for _, item := range []*apiv1.TerminateWorkflowExecutionRequest{nil, {}, &testdata.TerminateWorkflowExecutionRequest} { + assert.Equal(t, item, proto.TerminateWorkflowExecutionRequest(thrift.TerminateWorkflowExecutionRequest(item))) + } +} +func TestTimerCanceledEventAttributes(t *testing.T) { + for _, item := range []*apiv1.TimerCanceledEventAttributes{nil, {}, &testdata.TimerCanceledEventAttributes} { + assert.Equal(t, item, proto.TimerCanceledEventAttributes(thrift.TimerCanceledEventAttributes(item))) + } +} +func TestTimerFiredEventAttributes(t *testing.T) { + for _, item := range []*apiv1.TimerFiredEventAttributes{nil, {}, &testdata.TimerFiredEventAttributes} { + assert.Equal(t, item, proto.TimerFiredEventAttributes(thrift.TimerFiredEventAttributes(item))) + } +} +func TestTimerStartedEventAttributes(t *testing.T) { + for _, item := range []*apiv1.TimerStartedEventAttributes{nil, {}, &testdata.TimerStartedEventAttributes} { + assert.Equal(t, item, proto.TimerStartedEventAttributes(thrift.TimerStartedEventAttributes(item))) + } +} +func TestUpdateDomainRequest(t *testing.T) { + for _, item := range []*apiv1.UpdateDomainRequest{nil, {UpdateMask: &gogo.FieldMask{}}, &testdata.UpdateDomainRequest} { + assert.Equal(t, item, proto.UpdateDomainRequest(thrift.UpdateDomainRequest(item))) + } +} +func TestUpdateDomainResponse(t *testing.T) { + for _, item := range []*apiv1.UpdateDomainResponse{nil, &testdata.UpdateDomainResponse} { + assert.Equal(t, item, proto.UpdateDomainResponse(thrift.UpdateDomainResponse(item))) + } +} +func TestUpsertWorkflowSearchAttributesEventAttributes(t *testing.T) { + for _, item := range []*apiv1.UpsertWorkflowSearchAttributesEventAttributes{nil, {}, &testdata.UpsertWorkflowSearchAttributesEventAttributes} { + assert.Equal(t, item, proto.UpsertWorkflowSearchAttributesEventAttributes(thrift.UpsertWorkflowSearchAttributesEventAttributes(item))) + } +} +func TestWorkerVersionInfo(t *testing.T) { + for _, item := range []*apiv1.WorkerVersionInfo{nil, {}, &testdata.WorkerVersionInfo} { + assert.Equal(t, item, proto.WorkerVersionInfo(thrift.WorkerVersionInfo(item))) + } +} +func TestWorkflowExecution(t *testing.T) { + for _, item := range []*apiv1.WorkflowExecution{nil, {}, &testdata.WorkflowExecution} { + assert.Equal(t, item, proto.WorkflowExecution(thrift.WorkflowExecution(item))) + } + assert.Empty(t, thrift.WorkflowId(nil)) + assert.Empty(t, thrift.RunId(nil)) +} +func TestExternalExecutionInfo(t *testing.T) { + assert.Nil(t, proto.ExternalExecutionInfo(nil, nil)) + assert.Nil(t, thrift.ExternalWorkflowExecution(nil)) + assert.Nil(t, thrift.ExternalInitiatedId(nil)) + assert.Panics(t, func() { proto.ExternalExecutionInfo(nil, common.Int64Ptr(testdata.EventID1)) }) + assert.Panics(t, func() { proto.ExternalExecutionInfo(thrift.WorkflowExecution(&testdata.WorkflowExecution), nil) }) + info := proto.ExternalExecutionInfo(thrift.WorkflowExecution(&testdata.WorkflowExecution), common.Int64Ptr(testdata.EventID1)) + assert.Equal(t, testdata.WorkflowExecution, *info.WorkflowExecution) + assert.Equal(t, testdata.EventID1, info.InitiatedId) +} +func TestWorkflowExecutionCancelRequestedEventAttributes(t *testing.T) { + for _, item := range []*apiv1.WorkflowExecutionCancelRequestedEventAttributes{nil, {}, &testdata.WorkflowExecutionCancelRequestedEventAttributes} { + assert.Equal(t, item, proto.WorkflowExecutionCancelRequestedEventAttributes(thrift.WorkflowExecutionCancelRequestedEventAttributes(item))) + } +} +func TestWorkflowExecutionCanceledEventAttributes(t *testing.T) { + for _, item := range []*apiv1.WorkflowExecutionCanceledEventAttributes{nil, {}, &testdata.WorkflowExecutionCanceledEventAttributes} { + assert.Equal(t, item, proto.WorkflowExecutionCanceledEventAttributes(thrift.WorkflowExecutionCanceledEventAttributes(item))) + } +} +func TestWorkflowExecutionCompletedEventAttributes(t *testing.T) { + for _, item := range []*apiv1.WorkflowExecutionCompletedEventAttributes{nil, {}, &testdata.WorkflowExecutionCompletedEventAttributes} { + assert.Equal(t, item, proto.WorkflowExecutionCompletedEventAttributes(thrift.WorkflowExecutionCompletedEventAttributes(item))) + } +} +func TestWorkflowExecutionConfiguration(t *testing.T) { + for _, item := range []*apiv1.WorkflowExecutionConfiguration{nil, {}, &testdata.WorkflowExecutionConfiguration} { + assert.Equal(t, item, proto.WorkflowExecutionConfiguration(thrift.WorkflowExecutionConfiguration(item))) + } +} +func TestWorkflowExecutionContinuedAsNewEventAttributes(t *testing.T) { + for _, item := range []*apiv1.WorkflowExecutionContinuedAsNewEventAttributes{nil, {}, &testdata.WorkflowExecutionContinuedAsNewEventAttributes} { + assert.Equal(t, item, proto.WorkflowExecutionContinuedAsNewEventAttributes(thrift.WorkflowExecutionContinuedAsNewEventAttributes(item))) + } +} +func TestWorkflowExecutionFailedEventAttributes(t *testing.T) { + for _, item := range []*apiv1.WorkflowExecutionFailedEventAttributes{nil, {}, &testdata.WorkflowExecutionFailedEventAttributes} { + assert.Equal(t, item, proto.WorkflowExecutionFailedEventAttributes(thrift.WorkflowExecutionFailedEventAttributes(item))) + } +} +func TestWorkflowExecutionFilter(t *testing.T) { + for _, item := range []*apiv1.WorkflowExecutionFilter{nil, {}, &testdata.WorkflowExecutionFilter} { + assert.Equal(t, item, proto.WorkflowExecutionFilter(thrift.WorkflowExecutionFilter(item))) + } +} +func TestParentExecutionInfo(t *testing.T) { + assert.Nil(t, proto.ParentExecutionInfo(nil, nil, nil, nil)) + assert.Panics(t, func() { proto.ParentExecutionInfo(nil, &testdata.ParentExecutionInfo.DomainName, nil, nil) }) + info := proto.ParentExecutionInfo(nil, + &testdata.ParentExecutionInfo.DomainName, + thrift.WorkflowExecution(testdata.ParentExecutionInfo.WorkflowExecution), + &testdata.ParentExecutionInfo.InitiatedId) + assert.Equal(t, "", info.DomainId) + assert.Equal(t, testdata.ParentExecutionInfo.DomainName, info.DomainName) + assert.Equal(t, testdata.ParentExecutionInfo.WorkflowExecution, info.WorkflowExecution) + assert.Equal(t, testdata.ParentExecutionInfo.InitiatedId, info.InitiatedId) +} + +func TestWorkflowExecutionInfo(t *testing.T) { + for _, item := range []*apiv1.WorkflowExecutionInfo{nil, {}, &testdata.WorkflowExecutionInfo} { + assert.Equal(t, item, proto.WorkflowExecutionInfo(thrift.WorkflowExecutionInfo(item))) + } +} +func TestWorkflowExecutionSignaledEventAttributes(t *testing.T) { + for _, item := range []*apiv1.WorkflowExecutionSignaledEventAttributes{nil, {}, &testdata.WorkflowExecutionSignaledEventAttributes} { + assert.Equal(t, item, proto.WorkflowExecutionSignaledEventAttributes(thrift.WorkflowExecutionSignaledEventAttributes(item))) + } +} +func TestWorkflowExecutionStartedEventAttributes(t *testing.T) { + for _, item := range []*apiv1.WorkflowExecutionStartedEventAttributes{nil, {}, &testdata.WorkflowExecutionStartedEventAttributes} { + assert.Equal(t, item, proto.WorkflowExecutionStartedEventAttributes(thrift.WorkflowExecutionStartedEventAttributes(item))) + } +} +func TestWorkflowExecutionTerminatedEventAttributes(t *testing.T) { + for _, item := range []*apiv1.WorkflowExecutionTerminatedEventAttributes{nil, {}, &testdata.WorkflowExecutionTerminatedEventAttributes} { + assert.Equal(t, item, proto.WorkflowExecutionTerminatedEventAttributes(thrift.WorkflowExecutionTerminatedEventAttributes(item))) + } +} +func TestWorkflowExecutionTimedOutEventAttributes(t *testing.T) { + for _, item := range []*apiv1.WorkflowExecutionTimedOutEventAttributes{nil, {}, &testdata.WorkflowExecutionTimedOutEventAttributes} { + assert.Equal(t, item, proto.WorkflowExecutionTimedOutEventAttributes(thrift.WorkflowExecutionTimedOutEventAttributes(item))) + } +} +func TestWorkflowQuery(t *testing.T) { + for _, item := range []*apiv1.WorkflowQuery{nil, {}, &testdata.WorkflowQuery} { + assert.Equal(t, item, proto.WorkflowQuery(thrift.WorkflowQuery(item))) + } +} +func TestWorkflowQueryResult(t *testing.T) { + for _, item := range []*apiv1.WorkflowQueryResult{nil, {}, &testdata.WorkflowQueryResult} { + assert.Equal(t, item, proto.WorkflowQueryResult(thrift.WorkflowQueryResult(item))) + } +} +func TestWorkflowType(t *testing.T) { + for _, item := range []*apiv1.WorkflowType{nil, {}, &testdata.WorkflowType} { + assert.Equal(t, item, proto.WorkflowType(thrift.WorkflowType(item))) + } +} +func TestWorkflowTypeFilter(t *testing.T) { + for _, item := range []*apiv1.WorkflowTypeFilter{nil, {}, &testdata.WorkflowTypeFilter} { + assert.Equal(t, item, proto.WorkflowTypeFilter(thrift.WorkflowTypeFilter(item))) + } +} +func TestDataBlobArray(t *testing.T) { + for _, item := range [][]*apiv1.DataBlob{nil, {}, testdata.DataBlobArray} { + assert.Equal(t, item, proto.DataBlobArray(thrift.DataBlobArray(item))) + } +} +func TestHistoryEventArray(t *testing.T) { + for _, item := range [][]*apiv1.HistoryEvent{nil, {}, testdata.HistoryEventArray} { + assert.Equal(t, item, proto.HistoryEventArray(thrift.HistoryEventArray(item))) + } +} +func TestTaskListPartitionMetadataArray(t *testing.T) { + for _, item := range [][]*apiv1.TaskListPartitionMetadata{nil, {}, testdata.TaskListPartitionMetadataArray} { + assert.Equal(t, item, proto.TaskListPartitionMetadataArray(thrift.TaskListPartitionMetadataArray(item))) + } +} +func TestDecisionArray(t *testing.T) { + for _, item := range [][]*apiv1.Decision{nil, {}, testdata.DecisionArray} { + assert.Equal(t, item, proto.DecisionArray(thrift.DecisionArray(item))) + } +} +func TestPollerInfoArray(t *testing.T) { + for _, item := range [][]*apiv1.PollerInfo{nil, {}, testdata.PollerInfoArray} { + assert.Equal(t, item, proto.PollerInfoArray(thrift.PollerInfoArray(item))) + } +} +func TestPendingChildExecutionInfoArray(t *testing.T) { + for _, item := range [][]*apiv1.PendingChildExecutionInfo{nil, {}, testdata.PendingChildExecutionInfoArray} { + assert.Equal(t, item, proto.PendingChildExecutionInfoArray(thrift.PendingChildExecutionInfoArray(item))) + } +} +func TestWorkflowExecutionInfoArray(t *testing.T) { + for _, item := range [][]*apiv1.WorkflowExecutionInfo{nil, {}, testdata.WorkflowExecutionInfoArray} { + assert.Equal(t, item, proto.WorkflowExecutionInfoArray(thrift.WorkflowExecutionInfoArray(item))) + } +} +func TestDescribeDomainResponseArray(t *testing.T) { + for _, item := range [][]*apiv1.Domain{nil, {}, testdata.DomainArray} { + assert.Equal(t, item, proto.DescribeDomainResponseArray(thrift.DescribeDomainResponseArray(item))) + } +} +func TestResetPointInfoArray(t *testing.T) { + for _, item := range [][]*apiv1.ResetPointInfo{nil, {}, testdata.ResetPointInfoArray} { + assert.Equal(t, item, proto.ResetPointInfoArray(thrift.ResetPointInfoArray(item))) + } +} +func TestPendingActivityInfoArray(t *testing.T) { + for _, item := range [][]*apiv1.PendingActivityInfo{nil, {}, testdata.PendingActivityInfoArray} { + assert.Equal(t, item, proto.PendingActivityInfoArray(thrift.PendingActivityInfoArray(item))) + } +} +func TestClusterReplicationConfigurationArray(t *testing.T) { + for _, item := range [][]*apiv1.ClusterReplicationConfiguration{nil, {}, testdata.ClusterReplicationConfigurationArray} { + assert.Equal(t, item, proto.ClusterReplicationConfigurationArray(thrift.ClusterReplicationConfigurationArray(item))) + } +} +func TestActivityLocalDispatchInfoMap(t *testing.T) { + for _, item := range []map[string]*apiv1.ActivityLocalDispatchInfo{nil, {}, testdata.ActivityLocalDispatchInfoMap} { + assert.Equal(t, item, proto.ActivityLocalDispatchInfoMap(thrift.ActivityLocalDispatchInfoMap(item))) + } +} +func TestBadBinaryInfoMap(t *testing.T) { + for _, item := range []map[string]*apiv1.BadBinaryInfo{nil, {}, testdata.BadBinaryInfoMap} { + assert.Equal(t, item, proto.BadBinaryInfoMap(thrift.BadBinaryInfoMap(item))) + } +} +func TestIndexedValueTypeMap(t *testing.T) { + for _, item := range []map[string]apiv1.IndexedValueType{nil, {}, testdata.IndexedValueTypeMap} { + assert.Equal(t, item, proto.IndexedValueTypeMap(thrift.IndexedValueTypeMap(item))) + } +} +func TestWorkflowQueryMap(t *testing.T) { + for _, item := range []map[string]*apiv1.WorkflowQuery{nil, {}, testdata.WorkflowQueryMap} { + assert.Equal(t, item, proto.WorkflowQueryMap(thrift.WorkflowQueryMap(item))) + } +} +func TestWorkflowQueryResultMap(t *testing.T) { + for _, item := range []map[string]*apiv1.WorkflowQueryResult{nil, {}, testdata.WorkflowQueryResultMap} { + assert.Equal(t, item, proto.WorkflowQueryResultMap(thrift.WorkflowQueryResultMap(item))) + } +} +func TestPayload(t *testing.T) { + for _, item := range []*apiv1.Payload{nil, &testdata.Payload1} { + assert.Equal(t, item, proto.Payload(thrift.Payload(item))) + } + + assert.Equal(t, &apiv1.Payload{Data: []byte{}}, proto.Payload(thrift.Payload(&apiv1.Payload{}))) +} +func TestPayloadMap(t *testing.T) { + for _, item := range []map[string]*apiv1.Payload{nil, {}, testdata.PayloadMap} { + assert.Equal(t, item, proto.PayloadMap(thrift.PayloadMap(item))) + } +} +func TestFailure(t *testing.T) { + assert.Nil(t, proto.Failure(nil, nil)) + assert.Nil(t, thrift.FailureReason(nil)) + assert.Nil(t, thrift.FailureDetails(nil)) + failure := proto.Failure(&testdata.FailureReason, testdata.FailureDetails) + assert.Equal(t, testdata.FailureReason, *thrift.FailureReason(failure)) + assert.Equal(t, testdata.FailureDetails, thrift.FailureDetails(failure)) +} +func TestHistoryEvent(t *testing.T) { + for _, item := range []*apiv1.HistoryEvent{ + nil, + &testdata.HistoryEvent_WorkflowExecutionStarted, + &testdata.HistoryEvent_WorkflowExecutionCompleted, + &testdata.HistoryEvent_WorkflowExecutionFailed, + &testdata.HistoryEvent_WorkflowExecutionTimedOut, + &testdata.HistoryEvent_DecisionTaskScheduled, + &testdata.HistoryEvent_DecisionTaskStarted, + &testdata.HistoryEvent_DecisionTaskCompleted, + &testdata.HistoryEvent_DecisionTaskTimedOut, + &testdata.HistoryEvent_DecisionTaskFailed, + &testdata.HistoryEvent_ActivityTaskScheduled, + &testdata.HistoryEvent_ActivityTaskStarted, + &testdata.HistoryEvent_ActivityTaskCompleted, + &testdata.HistoryEvent_ActivityTaskFailed, + &testdata.HistoryEvent_ActivityTaskTimedOut, + &testdata.HistoryEvent_ActivityTaskCancelRequested, + &testdata.HistoryEvent_RequestCancelActivityTaskFailed, + &testdata.HistoryEvent_ActivityTaskCanceled, + &testdata.HistoryEvent_TimerStarted, + &testdata.HistoryEvent_TimerFired, + &testdata.HistoryEvent_CancelTimerFailed, + &testdata.HistoryEvent_TimerCanceled, + &testdata.HistoryEvent_WorkflowExecutionCancelRequested, + &testdata.HistoryEvent_WorkflowExecutionCanceled, + &testdata.HistoryEvent_RequestCancelExternalWorkflowExecutionInitiated, + &testdata.HistoryEvent_RequestCancelExternalWorkflowExecutionFailed, + &testdata.HistoryEvent_ExternalWorkflowExecutionCancelRequested, + &testdata.HistoryEvent_MarkerRecorded, + &testdata.HistoryEvent_WorkflowExecutionSignaled, + &testdata.HistoryEvent_WorkflowExecutionTerminated, + &testdata.HistoryEvent_WorkflowExecutionContinuedAsNew, + &testdata.HistoryEvent_StartChildWorkflowExecutionInitiated, + &testdata.HistoryEvent_StartChildWorkflowExecutionFailed, + &testdata.HistoryEvent_ChildWorkflowExecutionStarted, + &testdata.HistoryEvent_ChildWorkflowExecutionCompleted, + &testdata.HistoryEvent_ChildWorkflowExecutionFailed, + &testdata.HistoryEvent_ChildWorkflowExecutionCanceled, + &testdata.HistoryEvent_ChildWorkflowExecutionTimedOut, + &testdata.HistoryEvent_ChildWorkflowExecutionTerminated, + &testdata.HistoryEvent_SignalExternalWorkflowExecutionInitiated, + &testdata.HistoryEvent_SignalExternalWorkflowExecutionFailed, + &testdata.HistoryEvent_ExternalWorkflowExecutionSignaled, + &testdata.HistoryEvent_UpsertWorkflowSearchAttributes, + } { + assert.Equal(t, item, proto.HistoryEvent(thrift.HistoryEvent(item))) + } + assert.Panics(t, func() { proto.HistoryEvent(&shared.HistoryEvent{EventType: shared.EventType(UnknownValue).Ptr()}) }) + assert.Panics(t, func() { thrift.HistoryEvent(&apiv1.HistoryEvent{}) }) +} +func TestDecision(t *testing.T) { + for _, item := range []*apiv1.Decision{ + nil, + &testdata.Decision_CancelTimer, + &testdata.Decision_CancelWorkflowExecution, + &testdata.Decision_CompleteWorkflowExecution, + &testdata.Decision_ContinueAsNewWorkflowExecution, + &testdata.Decision_FailWorkflowExecution, + &testdata.Decision_RecordMarker, + &testdata.Decision_RequestCancelActivityTask, + &testdata.Decision_RequestCancelExternalWorkflowExecution, + &testdata.Decision_ScheduleActivityTask, + &testdata.Decision_SignalExternalWorkflowExecution, + &testdata.Decision_StartChildWorkflowExecution, + &testdata.Decision_StartTimer, + &testdata.Decision_UpsertWorkflowSearchAttributes, + } { + assert.Equal(t, item, proto.Decision(thrift.Decision(item))) + } + assert.Panics(t, func() { proto.Decision(&shared.Decision{DecisionType: shared.DecisionType(UnknownValue).Ptr()}) }) + assert.Panics(t, func() { thrift.Decision(&apiv1.Decision{}) }) +} +func TestListClosedWorkflowExecutionsRequest(t *testing.T) { + for _, item := range []*apiv1.ListClosedWorkflowExecutionsRequest{ + nil, + {}, + &testdata.ListClosedWorkflowExecutionsRequest_ExecutionFilter, + &testdata.ListClosedWorkflowExecutionsRequest_StatusFilter, + &testdata.ListClosedWorkflowExecutionsRequest_TypeFilter, + } { + assert.Equal(t, item, proto.ListClosedWorkflowExecutionsRequest(thrift.ListClosedWorkflowExecutionsRequest(item))) + } +} +func TestListOpenWorkflowExecutionsRequest(t *testing.T) { + for _, item := range []*apiv1.ListOpenWorkflowExecutionsRequest{ + nil, + {}, + &testdata.ListOpenWorkflowExecutionsRequest_ExecutionFilter, + &testdata.ListOpenWorkflowExecutionsRequest_TypeFilter, + } { + assert.Equal(t, item, proto.ListOpenWorkflowExecutionsRequest(thrift.ListOpenWorkflowExecutionsRequest(item))) + } +} diff --git a/internal/compatibility/enum_test.go b/internal/compatibility/enum_test.go new file mode 100644 index 000000000..dcaf6a775 --- /dev/null +++ b/internal/compatibility/enum_test.go @@ -0,0 +1,334 @@ +// Copyright (c) 2021 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +package compatibility + +import ( + "testing" + + "github.com/stretchr/testify/assert" + "go.uber.org/cadence/.gen/go/shared" + apiv1 "go.uber.org/cadence/.gen/proto/api/v1" + "go.uber.org/cadence/internal/compatibility/proto" + "go.uber.org/cadence/internal/compatibility/thrift" +) + +const UnknownValue = 9999 + +func TestArchivalStatus(t *testing.T) { + for _, item := range []apiv1.ArchivalStatus{ + apiv1.ArchivalStatus_ARCHIVAL_STATUS_INVALID, + apiv1.ArchivalStatus_ARCHIVAL_STATUS_DISABLED, + apiv1.ArchivalStatus_ARCHIVAL_STATUS_ENABLED, + } { + assert.Equal(t, item, proto.ArchivalStatus(thrift.ArchivalStatus(item))) + } + assert.Panics(t, func() { proto.ArchivalStatus(shared.ArchivalStatus(UnknownValue).Ptr()) }) + assert.Panics(t, func() { thrift.ArchivalStatus(apiv1.ArchivalStatus(UnknownValue)) }) +} +func TestCancelExternalWorkflowExecutionFailedCause(t *testing.T) { + for _, item := range []apiv1.CancelExternalWorkflowExecutionFailedCause{ + apiv1.CancelExternalWorkflowExecutionFailedCause_CANCEL_EXTERNAL_WORKFLOW_EXECUTION_FAILED_CAUSE_INVALID, + apiv1.CancelExternalWorkflowExecutionFailedCause_CANCEL_EXTERNAL_WORKFLOW_EXECUTION_FAILED_CAUSE_UNKNOWN_EXTERNAL_WORKFLOW_EXECUTION, + } { + assert.Equal(t, item, proto.CancelExternalWorkflowExecutionFailedCause(thrift.CancelExternalWorkflowExecutionFailedCause(item))) + } + assert.Panics(t, func() { + proto.CancelExternalWorkflowExecutionFailedCause(shared.CancelExternalWorkflowExecutionFailedCause(UnknownValue).Ptr()) + }) + assert.Panics(t, func() { + thrift.CancelExternalWorkflowExecutionFailedCause(apiv1.CancelExternalWorkflowExecutionFailedCause(UnknownValue)) + }) +} +func TestChildWorkflowExecutionFailedCause(t *testing.T) { + for _, item := range []apiv1.ChildWorkflowExecutionFailedCause{ + apiv1.ChildWorkflowExecutionFailedCause_CHILD_WORKFLOW_EXECUTION_FAILED_CAUSE_INVALID, + apiv1.ChildWorkflowExecutionFailedCause_CHILD_WORKFLOW_EXECUTION_FAILED_CAUSE_WORKFLOW_ALREADY_RUNNING, + } { + assert.Equal(t, item, proto.ChildWorkflowExecutionFailedCause(thrift.ChildWorkflowExecutionFailedCause(item))) + } + assert.Panics(t, func() { + proto.ChildWorkflowExecutionFailedCause(shared.ChildWorkflowExecutionFailedCause(UnknownValue).Ptr()) + }) + assert.Panics(t, func() { + thrift.ChildWorkflowExecutionFailedCause(apiv1.ChildWorkflowExecutionFailedCause(UnknownValue)) + }) +} +func TestContinueAsNewInitiator(t *testing.T) { + for _, item := range []apiv1.ContinueAsNewInitiator{ + apiv1.ContinueAsNewInitiator_CONTINUE_AS_NEW_INITIATOR_INVALID, + apiv1.ContinueAsNewInitiator_CONTINUE_AS_NEW_INITIATOR_DECIDER, + apiv1.ContinueAsNewInitiator_CONTINUE_AS_NEW_INITIATOR_RETRY_POLICY, + apiv1.ContinueAsNewInitiator_CONTINUE_AS_NEW_INITIATOR_CRON_SCHEDULE, + } { + assert.Equal(t, item, proto.ContinueAsNewInitiator(thrift.ContinueAsNewInitiator(item))) + } + assert.Panics(t, func() { proto.ContinueAsNewInitiator(shared.ContinueAsNewInitiator(UnknownValue).Ptr()) }) + assert.Panics(t, func() { thrift.ContinueAsNewInitiator(apiv1.ContinueAsNewInitiator(UnknownValue)) }) +} +func TestDecisionTaskFailedCause(t *testing.T) { + for _, item := range []apiv1.DecisionTaskFailedCause{ + apiv1.DecisionTaskFailedCause_DECISION_TASK_FAILED_CAUSE_INVALID, + apiv1.DecisionTaskFailedCause_DECISION_TASK_FAILED_CAUSE_UNHANDLED_DECISION, + apiv1.DecisionTaskFailedCause_DECISION_TASK_FAILED_CAUSE_BAD_SCHEDULE_ACTIVITY_ATTRIBUTES, + apiv1.DecisionTaskFailedCause_DECISION_TASK_FAILED_CAUSE_BAD_REQUEST_CANCEL_ACTIVITY_ATTRIBUTES, + apiv1.DecisionTaskFailedCause_DECISION_TASK_FAILED_CAUSE_BAD_START_TIMER_ATTRIBUTES, + apiv1.DecisionTaskFailedCause_DECISION_TASK_FAILED_CAUSE_BAD_CANCEL_TIMER_ATTRIBUTES, + apiv1.DecisionTaskFailedCause_DECISION_TASK_FAILED_CAUSE_BAD_RECORD_MARKER_ATTRIBUTES, + apiv1.DecisionTaskFailedCause_DECISION_TASK_FAILED_CAUSE_BAD_COMPLETE_WORKFLOW_EXECUTION_ATTRIBUTES, + apiv1.DecisionTaskFailedCause_DECISION_TASK_FAILED_CAUSE_BAD_FAIL_WORKFLOW_EXECUTION_ATTRIBUTES, + apiv1.DecisionTaskFailedCause_DECISION_TASK_FAILED_CAUSE_BAD_CANCEL_WORKFLOW_EXECUTION_ATTRIBUTES, + apiv1.DecisionTaskFailedCause_DECISION_TASK_FAILED_CAUSE_BAD_REQUEST_CANCEL_EXTERNAL_WORKFLOW_EXECUTION_ATTRIBUTES, + apiv1.DecisionTaskFailedCause_DECISION_TASK_FAILED_CAUSE_BAD_CONTINUE_AS_NEW_ATTRIBUTES, + apiv1.DecisionTaskFailedCause_DECISION_TASK_FAILED_CAUSE_START_TIMER_DUPLICATE_ID, + apiv1.DecisionTaskFailedCause_DECISION_TASK_FAILED_CAUSE_RESET_STICKY_TASK_LIST, + apiv1.DecisionTaskFailedCause_DECISION_TASK_FAILED_CAUSE_WORKFLOW_WORKER_UNHANDLED_FAILURE, + apiv1.DecisionTaskFailedCause_DECISION_TASK_FAILED_CAUSE_BAD_SIGNAL_WORKFLOW_EXECUTION_ATTRIBUTES, + apiv1.DecisionTaskFailedCause_DECISION_TASK_FAILED_CAUSE_BAD_START_CHILD_EXECUTION_ATTRIBUTES, + apiv1.DecisionTaskFailedCause_DECISION_TASK_FAILED_CAUSE_FORCE_CLOSE_DECISION, + apiv1.DecisionTaskFailedCause_DECISION_TASK_FAILED_CAUSE_FAILOVER_CLOSE_DECISION, + apiv1.DecisionTaskFailedCause_DECISION_TASK_FAILED_CAUSE_BAD_SIGNAL_INPUT_SIZE, + apiv1.DecisionTaskFailedCause_DECISION_TASK_FAILED_CAUSE_RESET_WORKFLOW, + apiv1.DecisionTaskFailedCause_DECISION_TASK_FAILED_CAUSE_BAD_BINARY, + apiv1.DecisionTaskFailedCause_DECISION_TASK_FAILED_CAUSE_SCHEDULE_ACTIVITY_DUPLICATE_ID, + apiv1.DecisionTaskFailedCause_DECISION_TASK_FAILED_CAUSE_BAD_SEARCH_ATTRIBUTES, + } { + assert.Equal(t, item, proto.DecisionTaskFailedCause(thrift.DecisionTaskFailedCause(item))) + } + assert.Panics(t, func() { proto.DecisionTaskFailedCause(shared.DecisionTaskFailedCause(UnknownValue).Ptr()) }) + assert.Panics(t, func() { thrift.DecisionTaskFailedCause(apiv1.DecisionTaskFailedCause(UnknownValue)) }) +} +func TestDomainStatus(t *testing.T) { + for _, item := range []apiv1.DomainStatus{ + apiv1.DomainStatus_DOMAIN_STATUS_INVALID, + apiv1.DomainStatus_DOMAIN_STATUS_REGISTERED, + apiv1.DomainStatus_DOMAIN_STATUS_DEPRECATED, + apiv1.DomainStatus_DOMAIN_STATUS_DELETED, + } { + assert.Equal(t, item, proto.DomainStatus(thrift.DomainStatus(item))) + } + assert.Panics(t, func() { proto.DomainStatus(shared.DomainStatus(UnknownValue).Ptr()) }) + assert.Panics(t, func() { thrift.DomainStatus(apiv1.DomainStatus(UnknownValue)) }) +} +func TestEncodingType(t *testing.T) { + for _, item := range []apiv1.EncodingType{ + apiv1.EncodingType_ENCODING_TYPE_INVALID, + apiv1.EncodingType_ENCODING_TYPE_THRIFTRW, + apiv1.EncodingType_ENCODING_TYPE_JSON, + } { + assert.Equal(t, item, proto.EncodingType(thrift.EncodingType(item))) + } + assert.Panics(t, func() { proto.EncodingType(shared.EncodingType(UnknownValue).Ptr()) }) + assert.Panics(t, func() { thrift.EncodingType(apiv1.EncodingType(UnknownValue)) }) + assert.Panics(t, func() { thrift.EncodingType(apiv1.EncodingType_ENCODING_TYPE_PROTO3) }) +} +func TestEventFilterType(t *testing.T) { + for _, item := range []apiv1.EventFilterType{ + apiv1.EventFilterType_EVENT_FILTER_TYPE_INVALID, + apiv1.EventFilterType_EVENT_FILTER_TYPE_ALL_EVENT, + apiv1.EventFilterType_EVENT_FILTER_TYPE_CLOSE_EVENT, + } { + assert.Equal(t, item, proto.EventFilterType(thrift.EventFilterType(item))) + } + assert.Panics(t, func() { proto.EventFilterType(shared.HistoryEventFilterType(UnknownValue).Ptr()) }) + assert.Panics(t, func() { thrift.EventFilterType(apiv1.EventFilterType(UnknownValue)) }) +} +func TestIndexedValueType(t *testing.T) { + for _, item := range []apiv1.IndexedValueType{ + apiv1.IndexedValueType_INDEXED_VALUE_TYPE_STRING, + apiv1.IndexedValueType_INDEXED_VALUE_TYPE_KEYWORD, + apiv1.IndexedValueType_INDEXED_VALUE_TYPE_INT, + apiv1.IndexedValueType_INDEXED_VALUE_TYPE_DOUBLE, + apiv1.IndexedValueType_INDEXED_VALUE_TYPE_BOOL, + apiv1.IndexedValueType_INDEXED_VALUE_TYPE_DATETIME, + } { + assert.Equal(t, item, proto.IndexedValueType(thrift.IndexedValueType(item))) + } + assert.Panics(t, func() { thrift.IndexedValueType(apiv1.IndexedValueType_INDEXED_VALUE_TYPE_INVALID) }) + assert.Panics(t, func() { proto.IndexedValueType(shared.IndexedValueType(UnknownValue)) }) + assert.Panics(t, func() { thrift.IndexedValueType(apiv1.IndexedValueType(UnknownValue)) }) +} +func TestParentClosePolicy(t *testing.T) { + for _, item := range []apiv1.ParentClosePolicy{ + apiv1.ParentClosePolicy_PARENT_CLOSE_POLICY_INVALID, + apiv1.ParentClosePolicy_PARENT_CLOSE_POLICY_ABANDON, + apiv1.ParentClosePolicy_PARENT_CLOSE_POLICY_REQUEST_CANCEL, + apiv1.ParentClosePolicy_PARENT_CLOSE_POLICY_TERMINATE, + } { + assert.Equal(t, item, proto.ParentClosePolicy(thrift.ParentClosePolicy(item))) + } + assert.Panics(t, func() { proto.ParentClosePolicy(shared.ParentClosePolicy(UnknownValue).Ptr()) }) + assert.Panics(t, func() { thrift.ParentClosePolicy(apiv1.ParentClosePolicy(UnknownValue)) }) +} +func TestPendingActivityState(t *testing.T) { + for _, item := range []apiv1.PendingActivityState{ + apiv1.PendingActivityState_PENDING_ACTIVITY_STATE_INVALID, + apiv1.PendingActivityState_PENDING_ACTIVITY_STATE_SCHEDULED, + apiv1.PendingActivityState_PENDING_ACTIVITY_STATE_STARTED, + apiv1.PendingActivityState_PENDING_ACTIVITY_STATE_CANCEL_REQUESTED, + } { + assert.Equal(t, item, proto.PendingActivityState(thrift.PendingActivityState(item))) + } + assert.Panics(t, func() { proto.PendingActivityState(shared.PendingActivityState(UnknownValue).Ptr()) }) + assert.Panics(t, func() { thrift.PendingActivityState(apiv1.PendingActivityState(UnknownValue)) }) +} +func TestPendingDecisionState(t *testing.T) { + for _, item := range []apiv1.PendingDecisionState{ + apiv1.PendingDecisionState_PENDING_DECISION_STATE_INVALID, + apiv1.PendingDecisionState_PENDING_DECISION_STATE_SCHEDULED, + apiv1.PendingDecisionState_PENDING_DECISION_STATE_STARTED, + } { + assert.Equal(t, item, proto.PendingDecisionState(thrift.PendingDecisionState(item))) + } + assert.Panics(t, func() { proto.PendingDecisionState(shared.PendingDecisionState(UnknownValue).Ptr()) }) + assert.Panics(t, func() { thrift.PendingDecisionState(apiv1.PendingDecisionState(UnknownValue)) }) +} +func TestQueryConsistencyLevel(t *testing.T) { + for _, item := range []apiv1.QueryConsistencyLevel{ + apiv1.QueryConsistencyLevel_QUERY_CONSISTENCY_LEVEL_INVALID, + apiv1.QueryConsistencyLevel_QUERY_CONSISTENCY_LEVEL_EVENTUAL, + apiv1.QueryConsistencyLevel_QUERY_CONSISTENCY_LEVEL_STRONG, + } { + assert.Equal(t, item, proto.QueryConsistencyLevel(thrift.QueryConsistencyLevel(item))) + } + assert.Panics(t, func() { proto.QueryConsistencyLevel(shared.QueryConsistencyLevel(UnknownValue).Ptr()) }) + assert.Panics(t, func() { thrift.QueryConsistencyLevel(apiv1.QueryConsistencyLevel(UnknownValue)) }) +} +func TestQueryRejectCondition(t *testing.T) { + for _, item := range []apiv1.QueryRejectCondition{ + apiv1.QueryRejectCondition_QUERY_REJECT_CONDITION_INVALID, + apiv1.QueryRejectCondition_QUERY_REJECT_CONDITION_NOT_OPEN, + apiv1.QueryRejectCondition_QUERY_REJECT_CONDITION_NOT_COMPLETED_CLEANLY, + } { + assert.Equal(t, item, proto.QueryRejectCondition(thrift.QueryRejectCondition(item))) + } + assert.Panics(t, func() { proto.QueryRejectCondition(shared.QueryRejectCondition(UnknownValue).Ptr()) }) + assert.Panics(t, func() { thrift.QueryRejectCondition(apiv1.QueryRejectCondition(UnknownValue)) }) +} +func TestQueryResultType(t *testing.T) { + for _, item := range []apiv1.QueryResultType{ + apiv1.QueryResultType_QUERY_RESULT_TYPE_INVALID, + apiv1.QueryResultType_QUERY_RESULT_TYPE_ANSWERED, + apiv1.QueryResultType_QUERY_RESULT_TYPE_FAILED, + } { + assert.Equal(t, item, proto.QueryResultType(thrift.QueryResultType(item))) + } + assert.Panics(t, func() { proto.QueryResultType(shared.QueryResultType(UnknownValue).Ptr()) }) + assert.Panics(t, func() { thrift.QueryResultType(apiv1.QueryResultType(UnknownValue)) }) +} +func TestQueryTaskCompletedType(t *testing.T) { + for _, item := range []apiv1.QueryResultType{ + apiv1.QueryResultType_QUERY_RESULT_TYPE_INVALID, + apiv1.QueryResultType_QUERY_RESULT_TYPE_ANSWERED, + apiv1.QueryResultType_QUERY_RESULT_TYPE_FAILED, + } { + assert.Equal(t, item, proto.QueryTaskCompletedType(thrift.QueryTaskCompletedType(item))) + } + assert.Panics(t, func() { thrift.QueryTaskCompletedType(apiv1.QueryResultType(UnknownValue)) }) + assert.Panics(t, func() { proto.QueryTaskCompletedType(shared.QueryTaskCompletedType(UnknownValue).Ptr()) }) +} +func TestSignalExternalWorkflowExecutionFailedCause(t *testing.T) { + for _, item := range []apiv1.SignalExternalWorkflowExecutionFailedCause{ + apiv1.SignalExternalWorkflowExecutionFailedCause_SIGNAL_EXTERNAL_WORKFLOW_EXECUTION_FAILED_CAUSE_INVALID, + apiv1.SignalExternalWorkflowExecutionFailedCause_SIGNAL_EXTERNAL_WORKFLOW_EXECUTION_FAILED_CAUSE_UNKNOWN_EXTERNAL_WORKFLOW_EXECUTION, + } { + assert.Equal(t, item, proto.SignalExternalWorkflowExecutionFailedCause(thrift.SignalExternalWorkflowExecutionFailedCause(item))) + } + assert.Panics(t, func() { + proto.SignalExternalWorkflowExecutionFailedCause(shared.SignalExternalWorkflowExecutionFailedCause(UnknownValue).Ptr()) + }) + assert.Panics(t, func() { + thrift.SignalExternalWorkflowExecutionFailedCause(apiv1.SignalExternalWorkflowExecutionFailedCause(UnknownValue)) + }) +} +func TestTaskListKind(t *testing.T) { + for _, item := range []apiv1.TaskListKind{ + apiv1.TaskListKind_TASK_LIST_KIND_INVALID, + apiv1.TaskListKind_TASK_LIST_KIND_NORMAL, + apiv1.TaskListKind_TASK_LIST_KIND_STICKY, + } { + assert.Equal(t, item, proto.TaskListKind(thrift.TaskListKind(item))) + } + assert.Panics(t, func() { proto.TaskListKind(shared.TaskListKind(UnknownValue).Ptr()) }) + assert.Panics(t, func() { thrift.TaskListKind(apiv1.TaskListKind(UnknownValue)) }) +} +func TestTaskListType(t *testing.T) { + for _, item := range []apiv1.TaskListType{ + apiv1.TaskListType_TASK_LIST_TYPE_INVALID, + apiv1.TaskListType_TASK_LIST_TYPE_DECISION, + apiv1.TaskListType_TASK_LIST_TYPE_ACTIVITY, + } { + assert.Equal(t, item, proto.TaskListType(thrift.TaskListType(item))) + } + assert.Panics(t, func() { proto.TaskListType(shared.TaskListType(UnknownValue).Ptr()) }) + assert.Panics(t, func() { thrift.TaskListType(apiv1.TaskListType(UnknownValue)) }) +} +func TestTimeoutType(t *testing.T) { + for _, item := range []apiv1.TimeoutType{ + apiv1.TimeoutType_TIMEOUT_TYPE_INVALID, + apiv1.TimeoutType_TIMEOUT_TYPE_START_TO_CLOSE, + apiv1.TimeoutType_TIMEOUT_TYPE_SCHEDULE_TO_START, + apiv1.TimeoutType_TIMEOUT_TYPE_SCHEDULE_TO_CLOSE, + apiv1.TimeoutType_TIMEOUT_TYPE_HEARTBEAT, + } { + assert.Equal(t, item, proto.TimeoutType(thrift.TimeoutType(item))) + } + assert.Panics(t, func() { proto.TimeoutType(shared.TimeoutType(UnknownValue).Ptr()) }) + assert.Panics(t, func() { thrift.TimeoutType(apiv1.TimeoutType(UnknownValue)) }) +} +func TestDecisionTaskTimedOutCause(t *testing.T) { + for _, item := range []apiv1.DecisionTaskTimedOutCause{ + apiv1.DecisionTaskTimedOutCause_DECISION_TASK_TIMED_OUT_CAUSE_INVALID, + apiv1.DecisionTaskTimedOutCause_DECISION_TASK_TIMED_OUT_CAUSE_TIMEOUT, + apiv1.DecisionTaskTimedOutCause_DECISION_TASK_TIMED_OUT_CAUSE_RESET, + } { + assert.Equal(t, item, proto.DecisionTaskTimedOutCause(thrift.DecisionTaskTimedOutCause(item))) + } + assert.Panics(t, func() { proto.DecisionTaskTimedOutCause(shared.DecisionTaskTimedOutCause(UnknownValue).Ptr()) }) + assert.Panics(t, func() { thrift.DecisionTaskTimedOutCause(apiv1.DecisionTaskTimedOutCause(UnknownValue)) }) +} +func TestWorkflowExecutionCloseStatus(t *testing.T) { + for _, item := range []apiv1.WorkflowExecutionCloseStatus{ + apiv1.WorkflowExecutionCloseStatus_WORKFLOW_EXECUTION_CLOSE_STATUS_INVALID, + apiv1.WorkflowExecutionCloseStatus_WORKFLOW_EXECUTION_CLOSE_STATUS_COMPLETED, + apiv1.WorkflowExecutionCloseStatus_WORKFLOW_EXECUTION_CLOSE_STATUS_FAILED, + apiv1.WorkflowExecutionCloseStatus_WORKFLOW_EXECUTION_CLOSE_STATUS_CANCELED, + apiv1.WorkflowExecutionCloseStatus_WORKFLOW_EXECUTION_CLOSE_STATUS_TERMINATED, + apiv1.WorkflowExecutionCloseStatus_WORKFLOW_EXECUTION_CLOSE_STATUS_CONTINUED_AS_NEW, + apiv1.WorkflowExecutionCloseStatus_WORKFLOW_EXECUTION_CLOSE_STATUS_TIMED_OUT, + } { + assert.Equal(t, item, proto.WorkflowExecutionCloseStatus(thrift.WorkflowExecutionCloseStatus(item))) + } + assert.Panics(t, func() { proto.WorkflowExecutionCloseStatus(shared.WorkflowExecutionCloseStatus(UnknownValue).Ptr()) }) + assert.Panics(t, func() { thrift.WorkflowExecutionCloseStatus(apiv1.WorkflowExecutionCloseStatus(UnknownValue)) }) +} +func TestWorkflowIDReusePolicy(t *testing.T) { + for _, item := range []apiv1.WorkflowIdReusePolicy{ + apiv1.WorkflowIdReusePolicy_WORKFLOW_ID_REUSE_POLICY_INVALID, + apiv1.WorkflowIdReusePolicy_WORKFLOW_ID_REUSE_POLICY_ALLOW_DUPLICATE_FAILED_ONLY, + apiv1.WorkflowIdReusePolicy_WORKFLOW_ID_REUSE_POLICY_ALLOW_DUPLICATE, + apiv1.WorkflowIdReusePolicy_WORKFLOW_ID_REUSE_POLICY_REJECT_DUPLICATE, + apiv1.WorkflowIdReusePolicy_WORKFLOW_ID_REUSE_POLICY_TERMINATE_IF_RUNNING, + } { + assert.Equal(t, item, proto.WorkflowIdReusePolicy(thrift.WorkflowIdReusePolicy(item))) + } + assert.Panics(t, func() { proto.WorkflowIdReusePolicy(shared.WorkflowIdReusePolicy(UnknownValue).Ptr()) }) + assert.Panics(t, func() { thrift.WorkflowIdReusePolicy(apiv1.WorkflowIdReusePolicy(UnknownValue)) }) +} diff --git a/internal/compatibility/error_test.go b/internal/compatibility/error_test.go new file mode 100644 index 000000000..7f9843e8c --- /dev/null +++ b/internal/compatibility/error_test.go @@ -0,0 +1,64 @@ +// Copyright (c) 2021 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +package compatibility + +import ( + "reflect" + "testing" + + "github.com/stretchr/testify/assert" + "go.uber.org/cadence/internal/compatibility/proto" + "go.uber.org/cadence/internal/compatibility/testdata" + "go.uber.org/cadence/internal/compatibility/thrift" + "go.uber.org/yarpc/yarpcerrors" +) + +func TestErrors(t *testing.T) { + for _, err := range []error{ + nil, // OK - no error + testdata.AccessDeniedError, + testdata.BadRequestError, + testdata.CancellationAlreadyRequestedError, + testdata.ClientVersionNotSupportedError, + testdata.DomainAlreadyExistsError, + testdata.DomainNotActiveError, + testdata.EntityNotExistsError, + testdata.FeatureNotEnabledError, + testdata.WorkflowExecutionAlreadyCompletedError, + testdata.InternalServiceError, + testdata.LimitExceededError, + testdata.QueryFailedError, + testdata.ServiceBusyError, + testdata.WorkflowExecutionAlreadyStartedError, + testdata.UnknownError, + } { + name := "OK" + if err != nil { + name = reflect.TypeOf(err).Elem().Name() + } + t.Run(name, func(t *testing.T) { + assert.Equal(t, err, proto.Error(thrift.Error(err))) + }) + } + + timeout := yarpcerrors.DeadlineExceededErrorf("timeout") + assert.Equal(t, timeout, thrift.Error(timeout)) +} diff --git a/internal/compatibility/proto/decision.go b/internal/compatibility/proto/decision.go new file mode 100644 index 000000000..2a56bc44e --- /dev/null +++ b/internal/compatibility/proto/decision.go @@ -0,0 +1,189 @@ +// Copyright (c) 2021 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +package proto + +import ( + "go.uber.org/cadence/.gen/go/shared" + apiv1 "go.uber.org/cadence/.gen/proto/api/v1" +) + +func DecisionArray(t []*shared.Decision) []*apiv1.Decision { + if t == nil { + return nil + } + v := make([]*apiv1.Decision, len(t)) + for i := range t { + v[i] = Decision(t[i]) + } + return v +} + +func Decision(d *shared.Decision) *apiv1.Decision { + if d == nil { + return nil + } + decision := apiv1.Decision{} + switch *d.DecisionType { + case shared.DecisionTypeScheduleActivityTask: + attr := d.ScheduleActivityTaskDecisionAttributes + decision.Attributes = &apiv1.Decision_ScheduleActivityTaskDecisionAttributes{ + ScheduleActivityTaskDecisionAttributes: &apiv1.ScheduleActivityTaskDecisionAttributes{ + ActivityId: attr.GetActivityId(), + ActivityType: ActivityType(attr.ActivityType), + Domain: attr.GetDomain(), + TaskList: TaskList(attr.TaskList), + Input: Payload(attr.Input), + ScheduleToCloseTimeout: secondsToDuration(attr.ScheduleToCloseTimeoutSeconds), + ScheduleToStartTimeout: secondsToDuration(attr.ScheduleToStartTimeoutSeconds), + StartToCloseTimeout: secondsToDuration(attr.StartToCloseTimeoutSeconds), + HeartbeatTimeout: secondsToDuration(attr.HeartbeatTimeoutSeconds), + RetryPolicy: RetryPolicy(attr.RetryPolicy), + Header: Header(attr.Header), + RequestLocalDispatch: attr.GetRequestLocalDispatch(), + }, + } + case shared.DecisionTypeRequestCancelActivityTask: + attr := d.RequestCancelActivityTaskDecisionAttributes + decision.Attributes = &apiv1.Decision_RequestCancelActivityTaskDecisionAttributes{ + RequestCancelActivityTaskDecisionAttributes: &apiv1.RequestCancelActivityTaskDecisionAttributes{ + ActivityId: attr.GetActivityId(), + }, + } + case shared.DecisionTypeStartTimer: + attr := d.StartTimerDecisionAttributes + decision.Attributes = &apiv1.Decision_StartTimerDecisionAttributes{ + StartTimerDecisionAttributes: &apiv1.StartTimerDecisionAttributes{ + TimerId: attr.GetTimerId(), + StartToFireTimeout: secondsToDuration(int64To32(attr.StartToFireTimeoutSeconds)), + }, + } + case shared.DecisionTypeCompleteWorkflowExecution: + attr := d.CompleteWorkflowExecutionDecisionAttributes + decision.Attributes = &apiv1.Decision_CompleteWorkflowExecutionDecisionAttributes{ + CompleteWorkflowExecutionDecisionAttributes: &apiv1.CompleteWorkflowExecutionDecisionAttributes{ + Result: Payload(attr.Result), + }, + } + case shared.DecisionTypeFailWorkflowExecution: + attr := d.FailWorkflowExecutionDecisionAttributes + decision.Attributes = &apiv1.Decision_FailWorkflowExecutionDecisionAttributes{ + FailWorkflowExecutionDecisionAttributes: &apiv1.FailWorkflowExecutionDecisionAttributes{ + Failure: Failure(attr.Reason, attr.Details), + }, + } + case shared.DecisionTypeCancelTimer: + attr := d.CancelTimerDecisionAttributes + decision.Attributes = &apiv1.Decision_CancelTimerDecisionAttributes{ + CancelTimerDecisionAttributes: &apiv1.CancelTimerDecisionAttributes{ + TimerId: attr.GetTimerId(), + }, + } + case shared.DecisionTypeCancelWorkflowExecution: + attr := d.CancelWorkflowExecutionDecisionAttributes + decision.Attributes = &apiv1.Decision_CancelWorkflowExecutionDecisionAttributes{ + CancelWorkflowExecutionDecisionAttributes: &apiv1.CancelWorkflowExecutionDecisionAttributes{ + Details: Payload(attr.Details), + }, + } + case shared.DecisionTypeRequestCancelExternalWorkflowExecution: + attr := d.RequestCancelExternalWorkflowExecutionDecisionAttributes + decision.Attributes = &apiv1.Decision_RequestCancelExternalWorkflowExecutionDecisionAttributes{ + RequestCancelExternalWorkflowExecutionDecisionAttributes: &apiv1.RequestCancelExternalWorkflowExecutionDecisionAttributes{ + Domain: attr.GetDomain(), + WorkflowExecution: WorkflowRunPair(attr.WorkflowId, attr.RunId), + Control: attr.Control, + ChildWorkflowOnly: attr.GetChildWorkflowOnly(), + }, + } + case shared.DecisionTypeRecordMarker: + attr := d.RecordMarkerDecisionAttributes + decision.Attributes = &apiv1.Decision_RecordMarkerDecisionAttributes{ + RecordMarkerDecisionAttributes: &apiv1.RecordMarkerDecisionAttributes{ + MarkerName: attr.GetMarkerName(), + Details: Payload(attr.Details), + Header: Header(attr.Header), + }, + } + case shared.DecisionTypeContinueAsNewWorkflowExecution: + attr := d.ContinueAsNewWorkflowExecutionDecisionAttributes + decision.Attributes = &apiv1.Decision_ContinueAsNewWorkflowExecutionDecisionAttributes{ + ContinueAsNewWorkflowExecutionDecisionAttributes: &apiv1.ContinueAsNewWorkflowExecutionDecisionAttributes{ + WorkflowType: WorkflowType(attr.WorkflowType), + TaskList: TaskList(attr.TaskList), + Input: Payload(attr.Input), + ExecutionStartToCloseTimeout: secondsToDuration(attr.ExecutionStartToCloseTimeoutSeconds), + TaskStartToCloseTimeout: secondsToDuration(attr.TaskStartToCloseTimeoutSeconds), + BackoffStartInterval: secondsToDuration(attr.BackoffStartIntervalInSeconds), + RetryPolicy: RetryPolicy(attr.RetryPolicy), + Initiator: ContinueAsNewInitiator(attr.Initiator), + Failure: Failure(attr.FailureReason, attr.FailureDetails), + LastCompletionResult: Payload(attr.LastCompletionResult), + CronSchedule: attr.GetCronSchedule(), + Header: Header(attr.Header), + Memo: Memo(attr.Memo), + SearchAttributes: SearchAttributes(attr.SearchAttributes), + }, + } + case shared.DecisionTypeStartChildWorkflowExecution: + attr := d.StartChildWorkflowExecutionDecisionAttributes + decision.Attributes = &apiv1.Decision_StartChildWorkflowExecutionDecisionAttributes{ + StartChildWorkflowExecutionDecisionAttributes: &apiv1.StartChildWorkflowExecutionDecisionAttributes{ + Domain: attr.GetDomain(), + WorkflowId: attr.GetWorkflowId(), + WorkflowType: WorkflowType(attr.WorkflowType), + TaskList: TaskList(attr.TaskList), + Input: Payload(attr.Input), + ExecutionStartToCloseTimeout: secondsToDuration(attr.ExecutionStartToCloseTimeoutSeconds), + TaskStartToCloseTimeout: secondsToDuration(attr.TaskStartToCloseTimeoutSeconds), + ParentClosePolicy: ParentClosePolicy(attr.ParentClosePolicy), + Control: attr.Control, + WorkflowIdReusePolicy: WorkflowIdReusePolicy(attr.WorkflowIdReusePolicy), + RetryPolicy: RetryPolicy(attr.RetryPolicy), + CronSchedule: attr.GetCronSchedule(), + Header: Header(attr.Header), + Memo: Memo(attr.Memo), + SearchAttributes: SearchAttributes(attr.SearchAttributes), + }, + } + case shared.DecisionTypeSignalExternalWorkflowExecution: + attr := d.SignalExternalWorkflowExecutionDecisionAttributes + decision.Attributes = &apiv1.Decision_SignalExternalWorkflowExecutionDecisionAttributes{ + SignalExternalWorkflowExecutionDecisionAttributes: &apiv1.SignalExternalWorkflowExecutionDecisionAttributes{ + Domain: attr.GetDomain(), + WorkflowExecution: WorkflowExecution(attr.Execution), + SignalName: attr.GetSignalName(), + Input: Payload(attr.Input), + Control: attr.Control, + ChildWorkflowOnly: attr.GetChildWorkflowOnly(), + }, + } + case shared.DecisionTypeUpsertWorkflowSearchAttributes: + attr := d.UpsertWorkflowSearchAttributesDecisionAttributes + decision.Attributes = &apiv1.Decision_UpsertWorkflowSearchAttributesDecisionAttributes{ + UpsertWorkflowSearchAttributesDecisionAttributes: &apiv1.UpsertWorkflowSearchAttributesDecisionAttributes{ + SearchAttributes: SearchAttributes(attr.SearchAttributes), + }, + } + default: + panic("unknown decision type") + } + return &decision +} diff --git a/internal/compatibility/proto/enum.go b/internal/compatibility/proto/enum.go new file mode 100644 index 000000000..2d342caf7 --- /dev/null +++ b/internal/compatibility/proto/enum.go @@ -0,0 +1,390 @@ +// Copyright (c) 2021 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +package proto + +import ( + "go.uber.org/cadence/.gen/go/shared" + apiv1 "go.uber.org/cadence/.gen/proto/api/v1" +) + +func TaskListKind(t *shared.TaskListKind) apiv1.TaskListKind { + if t == nil { + return apiv1.TaskListKind_TASK_LIST_KIND_INVALID + } + switch *t { + case shared.TaskListKindNormal: + return apiv1.TaskListKind_TASK_LIST_KIND_NORMAL + case shared.TaskListKindSticky: + return apiv1.TaskListKind_TASK_LIST_KIND_STICKY + } + panic("unexpected enum value") +} + +func TaskListType(t *shared.TaskListType) apiv1.TaskListType { + if t == nil { + return apiv1.TaskListType_TASK_LIST_TYPE_INVALID + } + switch *t { + case shared.TaskListTypeDecision: + return apiv1.TaskListType_TASK_LIST_TYPE_DECISION + case shared.TaskListTypeActivity: + return apiv1.TaskListType_TASK_LIST_TYPE_ACTIVITY + } + panic("unexpected enum value") +} + +func EventFilterType(t *shared.HistoryEventFilterType) apiv1.EventFilterType { + if t == nil { + return apiv1.EventFilterType_EVENT_FILTER_TYPE_INVALID + } + switch *t { + case shared.HistoryEventFilterTypeAllEvent: + return apiv1.EventFilterType_EVENT_FILTER_TYPE_ALL_EVENT + case shared.HistoryEventFilterTypeCloseEvent: + return apiv1.EventFilterType_EVENT_FILTER_TYPE_CLOSE_EVENT + } + panic("unexpected enum value") +} + +func QueryRejectCondition(t *shared.QueryRejectCondition) apiv1.QueryRejectCondition { + if t == nil { + return apiv1.QueryRejectCondition_QUERY_REJECT_CONDITION_INVALID + } + switch *t { + case shared.QueryRejectConditionNotOpen: + return apiv1.QueryRejectCondition_QUERY_REJECT_CONDITION_NOT_OPEN + case shared.QueryRejectConditionNotCompletedCleanly: + return apiv1.QueryRejectCondition_QUERY_REJECT_CONDITION_NOT_COMPLETED_CLEANLY + } + panic("unexpected enum value") +} + +func QueryConsistencyLevel(t *shared.QueryConsistencyLevel) apiv1.QueryConsistencyLevel { + if t == nil { + return apiv1.QueryConsistencyLevel_QUERY_CONSISTENCY_LEVEL_INVALID + } + switch *t { + case shared.QueryConsistencyLevelEventual: + return apiv1.QueryConsistencyLevel_QUERY_CONSISTENCY_LEVEL_EVENTUAL + case shared.QueryConsistencyLevelStrong: + return apiv1.QueryConsistencyLevel_QUERY_CONSISTENCY_LEVEL_STRONG + } + panic("unexpected enum value") +} + +func ContinueAsNewInitiator(t *shared.ContinueAsNewInitiator) apiv1.ContinueAsNewInitiator { + if t == nil { + return apiv1.ContinueAsNewInitiator_CONTINUE_AS_NEW_INITIATOR_INVALID + } + switch *t { + case shared.ContinueAsNewInitiatorDecider: + return apiv1.ContinueAsNewInitiator_CONTINUE_AS_NEW_INITIATOR_DECIDER + case shared.ContinueAsNewInitiatorRetryPolicy: + return apiv1.ContinueAsNewInitiator_CONTINUE_AS_NEW_INITIATOR_RETRY_POLICY + case shared.ContinueAsNewInitiatorCronSchedule: + return apiv1.ContinueAsNewInitiator_CONTINUE_AS_NEW_INITIATOR_CRON_SCHEDULE + } + panic("unexpected enum value") +} + +func WorkflowIdReusePolicy(t *shared.WorkflowIdReusePolicy) apiv1.WorkflowIdReusePolicy { + if t == nil { + return apiv1.WorkflowIdReusePolicy_WORKFLOW_ID_REUSE_POLICY_INVALID + } + switch *t { + case shared.WorkflowIdReusePolicyAllowDuplicateFailedOnly: + return apiv1.WorkflowIdReusePolicy_WORKFLOW_ID_REUSE_POLICY_ALLOW_DUPLICATE_FAILED_ONLY + case shared.WorkflowIdReusePolicyAllowDuplicate: + return apiv1.WorkflowIdReusePolicy_WORKFLOW_ID_REUSE_POLICY_ALLOW_DUPLICATE + case shared.WorkflowIdReusePolicyRejectDuplicate: + return apiv1.WorkflowIdReusePolicy_WORKFLOW_ID_REUSE_POLICY_REJECT_DUPLICATE + case shared.WorkflowIdReusePolicyTerminateIfRunning: + return apiv1.WorkflowIdReusePolicy_WORKFLOW_ID_REUSE_POLICY_TERMINATE_IF_RUNNING + } + panic("unexpected enum value") +} + +func QueryResultType(t *shared.QueryResultType) apiv1.QueryResultType { + if t == nil { + return apiv1.QueryResultType_QUERY_RESULT_TYPE_INVALID + } + switch *t { + case shared.QueryResultTypeAnswered: + return apiv1.QueryResultType_QUERY_RESULT_TYPE_ANSWERED + case shared.QueryResultTypeFailed: + return apiv1.QueryResultType_QUERY_RESULT_TYPE_FAILED + } + panic("unexpected enum value") +} + +func ArchivalStatus(t *shared.ArchivalStatus) apiv1.ArchivalStatus { + if t == nil { + return apiv1.ArchivalStatus_ARCHIVAL_STATUS_INVALID + } + switch *t { + case shared.ArchivalStatusDisabled: + return apiv1.ArchivalStatus_ARCHIVAL_STATUS_DISABLED + case shared.ArchivalStatusEnabled: + return apiv1.ArchivalStatus_ARCHIVAL_STATUS_ENABLED + } + panic("unexpected enum value") +} + +func ParentClosePolicy(t *shared.ParentClosePolicy) apiv1.ParentClosePolicy { + if t == nil { + return apiv1.ParentClosePolicy_PARENT_CLOSE_POLICY_INVALID + } + switch *t { + case shared.ParentClosePolicyAbandon: + return apiv1.ParentClosePolicy_PARENT_CLOSE_POLICY_ABANDON + case shared.ParentClosePolicyRequestCancel: + return apiv1.ParentClosePolicy_PARENT_CLOSE_POLICY_REQUEST_CANCEL + case shared.ParentClosePolicyTerminate: + return apiv1.ParentClosePolicy_PARENT_CLOSE_POLICY_TERMINATE + } + panic("unexpected enum value") +} + +func DecisionTaskFailedCause(t *shared.DecisionTaskFailedCause) apiv1.DecisionTaskFailedCause { + if t == nil { + return apiv1.DecisionTaskFailedCause_DECISION_TASK_FAILED_CAUSE_INVALID + } + switch *t { + case shared.DecisionTaskFailedCauseUnhandledDecision: + return apiv1.DecisionTaskFailedCause_DECISION_TASK_FAILED_CAUSE_UNHANDLED_DECISION + case shared.DecisionTaskFailedCauseBadScheduleActivityAttributes: + return apiv1.DecisionTaskFailedCause_DECISION_TASK_FAILED_CAUSE_BAD_SCHEDULE_ACTIVITY_ATTRIBUTES + case shared.DecisionTaskFailedCauseBadRequestCancelActivityAttributes: + return apiv1.DecisionTaskFailedCause_DECISION_TASK_FAILED_CAUSE_BAD_REQUEST_CANCEL_ACTIVITY_ATTRIBUTES + case shared.DecisionTaskFailedCauseBadStartTimerAttributes: + return apiv1.DecisionTaskFailedCause_DECISION_TASK_FAILED_CAUSE_BAD_START_TIMER_ATTRIBUTES + case shared.DecisionTaskFailedCauseBadCancelTimerAttributes: + return apiv1.DecisionTaskFailedCause_DECISION_TASK_FAILED_CAUSE_BAD_CANCEL_TIMER_ATTRIBUTES + case shared.DecisionTaskFailedCauseBadRecordMarkerAttributes: + return apiv1.DecisionTaskFailedCause_DECISION_TASK_FAILED_CAUSE_BAD_RECORD_MARKER_ATTRIBUTES + case shared.DecisionTaskFailedCauseBadCompleteWorkflowExecutionAttributes: + return apiv1.DecisionTaskFailedCause_DECISION_TASK_FAILED_CAUSE_BAD_COMPLETE_WORKFLOW_EXECUTION_ATTRIBUTES + case shared.DecisionTaskFailedCauseBadFailWorkflowExecutionAttributes: + return apiv1.DecisionTaskFailedCause_DECISION_TASK_FAILED_CAUSE_BAD_FAIL_WORKFLOW_EXECUTION_ATTRIBUTES + case shared.DecisionTaskFailedCauseBadCancelWorkflowExecutionAttributes: + return apiv1.DecisionTaskFailedCause_DECISION_TASK_FAILED_CAUSE_BAD_CANCEL_WORKFLOW_EXECUTION_ATTRIBUTES + case shared.DecisionTaskFailedCauseBadRequestCancelExternalWorkflowExecutionAttributes: + return apiv1.DecisionTaskFailedCause_DECISION_TASK_FAILED_CAUSE_BAD_REQUEST_CANCEL_EXTERNAL_WORKFLOW_EXECUTION_ATTRIBUTES + case shared.DecisionTaskFailedCauseBadContinueAsNewAttributes: + return apiv1.DecisionTaskFailedCause_DECISION_TASK_FAILED_CAUSE_BAD_CONTINUE_AS_NEW_ATTRIBUTES + case shared.DecisionTaskFailedCauseStartTimerDuplicateID: + return apiv1.DecisionTaskFailedCause_DECISION_TASK_FAILED_CAUSE_START_TIMER_DUPLICATE_ID + case shared.DecisionTaskFailedCauseResetStickyTasklist: + return apiv1.DecisionTaskFailedCause_DECISION_TASK_FAILED_CAUSE_RESET_STICKY_TASK_LIST + case shared.DecisionTaskFailedCauseWorkflowWorkerUnhandledFailure: + return apiv1.DecisionTaskFailedCause_DECISION_TASK_FAILED_CAUSE_WORKFLOW_WORKER_UNHANDLED_FAILURE + case shared.DecisionTaskFailedCauseBadSignalWorkflowExecutionAttributes: + return apiv1.DecisionTaskFailedCause_DECISION_TASK_FAILED_CAUSE_BAD_SIGNAL_WORKFLOW_EXECUTION_ATTRIBUTES + case shared.DecisionTaskFailedCauseBadStartChildExecutionAttributes: + return apiv1.DecisionTaskFailedCause_DECISION_TASK_FAILED_CAUSE_BAD_START_CHILD_EXECUTION_ATTRIBUTES + case shared.DecisionTaskFailedCauseForceCloseDecision: + return apiv1.DecisionTaskFailedCause_DECISION_TASK_FAILED_CAUSE_FORCE_CLOSE_DECISION + case shared.DecisionTaskFailedCauseFailoverCloseDecision: + return apiv1.DecisionTaskFailedCause_DECISION_TASK_FAILED_CAUSE_FAILOVER_CLOSE_DECISION + case shared.DecisionTaskFailedCauseBadSignalInputSize: + return apiv1.DecisionTaskFailedCause_DECISION_TASK_FAILED_CAUSE_BAD_SIGNAL_INPUT_SIZE + case shared.DecisionTaskFailedCauseResetWorkflow: + return apiv1.DecisionTaskFailedCause_DECISION_TASK_FAILED_CAUSE_RESET_WORKFLOW + case shared.DecisionTaskFailedCauseBadBinary: + return apiv1.DecisionTaskFailedCause_DECISION_TASK_FAILED_CAUSE_BAD_BINARY + case shared.DecisionTaskFailedCauseScheduleActivityDuplicateID: + return apiv1.DecisionTaskFailedCause_DECISION_TASK_FAILED_CAUSE_SCHEDULE_ACTIVITY_DUPLICATE_ID + case shared.DecisionTaskFailedCauseBadSearchAttributes: + return apiv1.DecisionTaskFailedCause_DECISION_TASK_FAILED_CAUSE_BAD_SEARCH_ATTRIBUTES + } + panic("unexpected enum value") +} + +func WorkflowExecutionCloseStatus(t *shared.WorkflowExecutionCloseStatus) apiv1.WorkflowExecutionCloseStatus { + if t == nil { + return apiv1.WorkflowExecutionCloseStatus_WORKFLOW_EXECUTION_CLOSE_STATUS_INVALID + } + switch *t { + case shared.WorkflowExecutionCloseStatusCompleted: + return apiv1.WorkflowExecutionCloseStatus_WORKFLOW_EXECUTION_CLOSE_STATUS_COMPLETED + case shared.WorkflowExecutionCloseStatusFailed: + return apiv1.WorkflowExecutionCloseStatus_WORKFLOW_EXECUTION_CLOSE_STATUS_FAILED + case shared.WorkflowExecutionCloseStatusCanceled: + return apiv1.WorkflowExecutionCloseStatus_WORKFLOW_EXECUTION_CLOSE_STATUS_CANCELED + case shared.WorkflowExecutionCloseStatusTerminated: + return apiv1.WorkflowExecutionCloseStatus_WORKFLOW_EXECUTION_CLOSE_STATUS_TERMINATED + case shared.WorkflowExecutionCloseStatusContinuedAsNew: + return apiv1.WorkflowExecutionCloseStatus_WORKFLOW_EXECUTION_CLOSE_STATUS_CONTINUED_AS_NEW + case shared.WorkflowExecutionCloseStatusTimedOut: + return apiv1.WorkflowExecutionCloseStatus_WORKFLOW_EXECUTION_CLOSE_STATUS_TIMED_OUT + } + panic("unexpected enum value") +} + +func QueryTaskCompletedType(t *shared.QueryTaskCompletedType) apiv1.QueryResultType { + if t == nil { + return apiv1.QueryResultType_QUERY_RESULT_TYPE_INVALID + } + switch *t { + case shared.QueryTaskCompletedTypeCompleted: + return apiv1.QueryResultType_QUERY_RESULT_TYPE_ANSWERED + case shared.QueryTaskCompletedTypeFailed: + return apiv1.QueryResultType_QUERY_RESULT_TYPE_FAILED + } + panic("unexpected enum value") +} + +func DomainStatus(t *shared.DomainStatus) apiv1.DomainStatus { + if t == nil { + return apiv1.DomainStatus_DOMAIN_STATUS_INVALID + } + switch *t { + case shared.DomainStatusRegistered: + return apiv1.DomainStatus_DOMAIN_STATUS_REGISTERED + case shared.DomainStatusDeprecated: + return apiv1.DomainStatus_DOMAIN_STATUS_DEPRECATED + case shared.DomainStatusDeleted: + return apiv1.DomainStatus_DOMAIN_STATUS_DELETED + } + panic("unexpected enum value") +} + +func PendingActivityState(t *shared.PendingActivityState) apiv1.PendingActivityState { + if t == nil { + return apiv1.PendingActivityState_PENDING_ACTIVITY_STATE_INVALID + } + switch *t { + case shared.PendingActivityStateScheduled: + return apiv1.PendingActivityState_PENDING_ACTIVITY_STATE_SCHEDULED + case shared.PendingActivityStateStarted: + return apiv1.PendingActivityState_PENDING_ACTIVITY_STATE_STARTED + case shared.PendingActivityStateCancelRequested: + return apiv1.PendingActivityState_PENDING_ACTIVITY_STATE_CANCEL_REQUESTED + } + panic("unexpected enum value") +} + +func PendingDecisionState(t *shared.PendingDecisionState) apiv1.PendingDecisionState { + if t == nil { + return apiv1.PendingDecisionState_PENDING_DECISION_STATE_INVALID + } + switch *t { + case shared.PendingDecisionStateScheduled: + return apiv1.PendingDecisionState_PENDING_DECISION_STATE_SCHEDULED + case shared.PendingDecisionStateStarted: + return apiv1.PendingDecisionState_PENDING_DECISION_STATE_STARTED + } + panic("unexpected enum value") +} + +func IndexedValueType(t shared.IndexedValueType) apiv1.IndexedValueType { + switch t { + case shared.IndexedValueTypeString: + return apiv1.IndexedValueType_INDEXED_VALUE_TYPE_STRING + case shared.IndexedValueTypeKeyword: + return apiv1.IndexedValueType_INDEXED_VALUE_TYPE_KEYWORD + case shared.IndexedValueTypeInt: + return apiv1.IndexedValueType_INDEXED_VALUE_TYPE_INT + case shared.IndexedValueTypeDouble: + return apiv1.IndexedValueType_INDEXED_VALUE_TYPE_DOUBLE + case shared.IndexedValueTypeBool: + return apiv1.IndexedValueType_INDEXED_VALUE_TYPE_BOOL + case shared.IndexedValueTypeDatetime: + return apiv1.IndexedValueType_INDEXED_VALUE_TYPE_DATETIME + } + panic("unexpected enum value") +} + +func EncodingType(t *shared.EncodingType) apiv1.EncodingType { + if t == nil { + return apiv1.EncodingType_ENCODING_TYPE_INVALID + } + switch *t { + case shared.EncodingTypeThriftRW: + return apiv1.EncodingType_ENCODING_TYPE_THRIFTRW + case shared.EncodingTypeJSON: + return apiv1.EncodingType_ENCODING_TYPE_JSON + } + panic("unexpected enum value") +} + +func TimeoutType(t *shared.TimeoutType) apiv1.TimeoutType { + if t == nil { + return apiv1.TimeoutType_TIMEOUT_TYPE_INVALID + } + switch *t { + case shared.TimeoutTypeStartToClose: + return apiv1.TimeoutType_TIMEOUT_TYPE_START_TO_CLOSE + case shared.TimeoutTypeScheduleToStart: + return apiv1.TimeoutType_TIMEOUT_TYPE_SCHEDULE_TO_START + case shared.TimeoutTypeScheduleToClose: + return apiv1.TimeoutType_TIMEOUT_TYPE_SCHEDULE_TO_CLOSE + case shared.TimeoutTypeHeartbeat: + return apiv1.TimeoutType_TIMEOUT_TYPE_HEARTBEAT + } + panic("unexpected enum value") +} + +func DecisionTaskTimedOutCause(t *shared.DecisionTaskTimedOutCause) apiv1.DecisionTaskTimedOutCause { + if t == nil { + return apiv1.DecisionTaskTimedOutCause_DECISION_TASK_TIMED_OUT_CAUSE_INVALID + } + switch *t { + case shared.DecisionTaskTimedOutCauseTimeout: + return apiv1.DecisionTaskTimedOutCause_DECISION_TASK_TIMED_OUT_CAUSE_TIMEOUT + case shared.DecisionTaskTimedOutCauseReset: + return apiv1.DecisionTaskTimedOutCause_DECISION_TASK_TIMED_OUT_CAUSE_RESET + } + panic("unexpected enum value") +} + +func CancelExternalWorkflowExecutionFailedCause(t *shared.CancelExternalWorkflowExecutionFailedCause) apiv1.CancelExternalWorkflowExecutionFailedCause { + if t == nil { + return apiv1.CancelExternalWorkflowExecutionFailedCause_CANCEL_EXTERNAL_WORKFLOW_EXECUTION_FAILED_CAUSE_INVALID + } + switch *t { + case shared.CancelExternalWorkflowExecutionFailedCauseUnknownExternalWorkflowExecution: + return apiv1.CancelExternalWorkflowExecutionFailedCause_CANCEL_EXTERNAL_WORKFLOW_EXECUTION_FAILED_CAUSE_UNKNOWN_EXTERNAL_WORKFLOW_EXECUTION + } + panic("unexpected enum value") +} + +func SignalExternalWorkflowExecutionFailedCause(t *shared.SignalExternalWorkflowExecutionFailedCause) apiv1.SignalExternalWorkflowExecutionFailedCause { + if t == nil { + return apiv1.SignalExternalWorkflowExecutionFailedCause_SIGNAL_EXTERNAL_WORKFLOW_EXECUTION_FAILED_CAUSE_INVALID + } + switch *t { + case shared.SignalExternalWorkflowExecutionFailedCauseUnknownExternalWorkflowExecution: + return apiv1.SignalExternalWorkflowExecutionFailedCause_SIGNAL_EXTERNAL_WORKFLOW_EXECUTION_FAILED_CAUSE_UNKNOWN_EXTERNAL_WORKFLOW_EXECUTION + } + panic("unexpected enum value") +} + +func ChildWorkflowExecutionFailedCause(t *shared.ChildWorkflowExecutionFailedCause) apiv1.ChildWorkflowExecutionFailedCause { + if t == nil { + return apiv1.ChildWorkflowExecutionFailedCause_CHILD_WORKFLOW_EXECUTION_FAILED_CAUSE_INVALID + } + switch *t { + case shared.ChildWorkflowExecutionFailedCauseWorkflowAlreadyRunning: + return apiv1.ChildWorkflowExecutionFailedCause_CHILD_WORKFLOW_EXECUTION_FAILED_CAUSE_WORKFLOW_ALREADY_RUNNING + } + panic("unexpected enum value") +} diff --git a/internal/compatibility/proto/error.go b/internal/compatibility/proto/error.go new file mode 100644 index 000000000..0a7d31afc --- /dev/null +++ b/internal/compatibility/proto/error.go @@ -0,0 +1,84 @@ +// Copyright (c) 2021 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +package proto + +import ( + "go.uber.org/cadence/.gen/go/shared" + apiv1 "go.uber.org/cadence/.gen/proto/api/v1" + "go.uber.org/yarpc/encoding/protobuf" + "go.uber.org/yarpc/yarpcerrors" +) + +func Error(err error) error { + if err == nil { + return protobuf.NewError(yarpcerrors.CodeOK, "") + } + + switch e := err.(type) { + case *shared.AccessDeniedError: + return protobuf.NewError(yarpcerrors.CodePermissionDenied, e.Message) + case *shared.InternalServiceError: + return protobuf.NewError(yarpcerrors.CodeInternal, e.Message) + case *shared.EntityNotExistsError: + return protobuf.NewError(yarpcerrors.CodeNotFound, e.Message, protobuf.WithErrorDetails(&apiv1.EntityNotExistsError{ + CurrentCluster: e.GetCurrentCluster(), + ActiveCluster: e.GetActiveCluster(), + })) + case *shared.WorkflowExecutionAlreadyCompletedError: + return protobuf.NewError(yarpcerrors.CodeNotFound, e.Message, protobuf.WithErrorDetails(&apiv1.WorkflowExecutionAlreadyCompletedError{})) + case *shared.BadRequestError: + return protobuf.NewError(yarpcerrors.CodeInvalidArgument, e.Message) + case *shared.QueryFailedError: + return protobuf.NewError(yarpcerrors.CodeInvalidArgument, e.Message, protobuf.WithErrorDetails(&apiv1.QueryFailedError{})) + + case *shared.CancellationAlreadyRequestedError: + return protobuf.NewError(yarpcerrors.CodeAlreadyExists, e.Message, protobuf.WithErrorDetails(&apiv1.CancellationAlreadyRequestedError{})) + case *shared.DomainAlreadyExistsError: + return protobuf.NewError(yarpcerrors.CodeAlreadyExists, e.Message, protobuf.WithErrorDetails(&apiv1.DomainAlreadyExistsError{})) + case *shared.WorkflowExecutionAlreadyStartedError: + return protobuf.NewError(yarpcerrors.CodeAlreadyExists, e.GetMessage(), protobuf.WithErrorDetails(&apiv1.WorkflowExecutionAlreadyStartedError{ + StartRequestId: e.GetStartRequestId(), + RunId: e.GetRunId(), + })) + case *shared.ClientVersionNotSupportedError: + return protobuf.NewError(yarpcerrors.CodeFailedPrecondition, "Client version not supported", protobuf.WithErrorDetails(&apiv1.ClientVersionNotSupportedError{ + FeatureVersion: e.FeatureVersion, + ClientImpl: e.ClientImpl, + SupportedVersions: e.SupportedVersions, + })) + case *shared.FeatureNotEnabledError: + return protobuf.NewError(yarpcerrors.CodeFailedPrecondition, "Feature flag not enabled", protobuf.WithErrorDetails(&apiv1.FeatureNotEnabledError{ + FeatureFlag: e.FeatureFlag, + })) + case *shared.DomainNotActiveError: + return protobuf.NewError(yarpcerrors.CodeFailedPrecondition, e.Message, protobuf.WithErrorDetails(&apiv1.DomainNotActiveError{ + Domain: e.DomainName, + CurrentCluster: e.CurrentCluster, + ActiveCluster: e.ActiveCluster, + })) + case *shared.LimitExceededError: + return protobuf.NewError(yarpcerrors.CodeResourceExhausted, e.Message, protobuf.WithErrorDetails(&apiv1.LimitExceededError{})) + case *shared.ServiceBusyError: + return protobuf.NewError(yarpcerrors.CodeResourceExhausted, e.Message, protobuf.WithErrorDetails(&apiv1.ServiceBusyError{})) + } + + return protobuf.NewError(yarpcerrors.CodeUnknown, err.Error()) +} diff --git a/internal/compatibility/proto/helpers.go b/internal/compatibility/proto/helpers.go new file mode 100644 index 000000000..f7bf99b9e --- /dev/null +++ b/internal/compatibility/proto/helpers.go @@ -0,0 +1,78 @@ +// Copyright (c) 2021 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +package proto + +import ( + "time" + + gogo "github.com/gogo/protobuf/types" + "go.uber.org/cadence/internal/common" +) + +func fromDoubleValue(v *float64) *gogo.DoubleValue { + if v == nil { + return nil + } + return &gogo.DoubleValue{Value: *v} +} + +func fromInt64Value(v *int64) *gogo.Int64Value { + if v == nil { + return nil + } + return &gogo.Int64Value{Value: *v} +} + +func unixNanoToTime(t *int64) *gogo.Timestamp { + if t == nil { + return nil + } + time, err := gogo.TimestampProto(time.Unix(0, *t)) + if err != nil { + panic(err) + } + return time +} + +func daysToDuration(d *int32) *gogo.Duration { + if d == nil { + return nil + } + return gogo.DurationProto(time.Duration(*d) * (24 * time.Hour)) +} + +func secondsToDuration(d *int32) *gogo.Duration { + if d == nil { + return nil + } + return gogo.DurationProto(time.Duration(*d) * time.Second) +} + +func int64To32(v *int64) *int32 { + if v == nil { + return nil + } + return common.Int32Ptr(int32(*v)) +} + +func newFieldMask(fields []string) *gogo.FieldMask { + return &gogo.FieldMask{Paths: fields} +} diff --git a/internal/compatibility/proto/history.go b/internal/compatibility/proto/history.go new file mode 100644 index 000000000..11af384c8 --- /dev/null +++ b/internal/compatibility/proto/history.go @@ -0,0 +1,711 @@ +// Copyright (c) 2021 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +package proto + +import ( + "go.uber.org/cadence/.gen/go/shared" + apiv1 "go.uber.org/cadence/.gen/proto/api/v1" +) + +func History(t *shared.History) *apiv1.History { + if t == nil { + return nil + } + return &apiv1.History{ + Events: HistoryEventArray(t.Events), + } +} + +func HistoryEventArray(t []*shared.HistoryEvent) []*apiv1.HistoryEvent { + if t == nil { + return nil + } + v := make([]*apiv1.HistoryEvent, len(t)) + for i := range t { + v[i] = HistoryEvent(t[i]) + } + return v +} + +func HistoryEvent(e *shared.HistoryEvent) *apiv1.HistoryEvent { + if e == nil { + return nil + } + event := apiv1.HistoryEvent{ + EventId: e.GetEventId(), + EventTime: unixNanoToTime(e.Timestamp), + Version: e.GetVersion(), + TaskId: e.GetTaskId(), + } + switch *e.EventType { + case shared.EventTypeWorkflowExecutionStarted: + event.Attributes = &apiv1.HistoryEvent_WorkflowExecutionStartedEventAttributes{WorkflowExecutionStartedEventAttributes: WorkflowExecutionStartedEventAttributes(e.WorkflowExecutionStartedEventAttributes)} + case shared.EventTypeWorkflowExecutionCompleted: + event.Attributes = &apiv1.HistoryEvent_WorkflowExecutionCompletedEventAttributes{WorkflowExecutionCompletedEventAttributes: WorkflowExecutionCompletedEventAttributes(e.WorkflowExecutionCompletedEventAttributes)} + case shared.EventTypeWorkflowExecutionFailed: + event.Attributes = &apiv1.HistoryEvent_WorkflowExecutionFailedEventAttributes{WorkflowExecutionFailedEventAttributes: WorkflowExecutionFailedEventAttributes(e.WorkflowExecutionFailedEventAttributes)} + case shared.EventTypeWorkflowExecutionTimedOut: + event.Attributes = &apiv1.HistoryEvent_WorkflowExecutionTimedOutEventAttributes{WorkflowExecutionTimedOutEventAttributes: WorkflowExecutionTimedOutEventAttributes(e.WorkflowExecutionTimedOutEventAttributes)} + case shared.EventTypeDecisionTaskScheduled: + event.Attributes = &apiv1.HistoryEvent_DecisionTaskScheduledEventAttributes{DecisionTaskScheduledEventAttributes: DecisionTaskScheduledEventAttributes(e.DecisionTaskScheduledEventAttributes)} + case shared.EventTypeDecisionTaskStarted: + event.Attributes = &apiv1.HistoryEvent_DecisionTaskStartedEventAttributes{DecisionTaskStartedEventAttributes: DecisionTaskStartedEventAttributes(e.DecisionTaskStartedEventAttributes)} + case shared.EventTypeDecisionTaskCompleted: + event.Attributes = &apiv1.HistoryEvent_DecisionTaskCompletedEventAttributes{DecisionTaskCompletedEventAttributes: DecisionTaskCompletedEventAttributes(e.DecisionTaskCompletedEventAttributes)} + case shared.EventTypeDecisionTaskTimedOut: + event.Attributes = &apiv1.HistoryEvent_DecisionTaskTimedOutEventAttributes{DecisionTaskTimedOutEventAttributes: DecisionTaskTimedOutEventAttributes(e.DecisionTaskTimedOutEventAttributes)} + case shared.EventTypeDecisionTaskFailed: + event.Attributes = &apiv1.HistoryEvent_DecisionTaskFailedEventAttributes{DecisionTaskFailedEventAttributes: DecisionTaskFailedEventAttributes(e.DecisionTaskFailedEventAttributes)} + case shared.EventTypeActivityTaskScheduled: + event.Attributes = &apiv1.HistoryEvent_ActivityTaskScheduledEventAttributes{ActivityTaskScheduledEventAttributes: ActivityTaskScheduledEventAttributes(e.ActivityTaskScheduledEventAttributes)} + case shared.EventTypeActivityTaskStarted: + event.Attributes = &apiv1.HistoryEvent_ActivityTaskStartedEventAttributes{ActivityTaskStartedEventAttributes: ActivityTaskStartedEventAttributes(e.ActivityTaskStartedEventAttributes)} + case shared.EventTypeActivityTaskCompleted: + event.Attributes = &apiv1.HistoryEvent_ActivityTaskCompletedEventAttributes{ActivityTaskCompletedEventAttributes: ActivityTaskCompletedEventAttributes(e.ActivityTaskCompletedEventAttributes)} + case shared.EventTypeActivityTaskFailed: + event.Attributes = &apiv1.HistoryEvent_ActivityTaskFailedEventAttributes{ActivityTaskFailedEventAttributes: ActivityTaskFailedEventAttributes(e.ActivityTaskFailedEventAttributes)} + case shared.EventTypeActivityTaskTimedOut: + event.Attributes = &apiv1.HistoryEvent_ActivityTaskTimedOutEventAttributes{ActivityTaskTimedOutEventAttributes: ActivityTaskTimedOutEventAttributes(e.ActivityTaskTimedOutEventAttributes)} + case shared.EventTypeTimerStarted: + event.Attributes = &apiv1.HistoryEvent_TimerStartedEventAttributes{TimerStartedEventAttributes: TimerStartedEventAttributes(e.TimerStartedEventAttributes)} + case shared.EventTypeTimerFired: + event.Attributes = &apiv1.HistoryEvent_TimerFiredEventAttributes{TimerFiredEventAttributes: TimerFiredEventAttributes(e.TimerFiredEventAttributes)} + case shared.EventTypeActivityTaskCancelRequested: + event.Attributes = &apiv1.HistoryEvent_ActivityTaskCancelRequestedEventAttributes{ActivityTaskCancelRequestedEventAttributes: ActivityTaskCancelRequestedEventAttributes(e.ActivityTaskCancelRequestedEventAttributes)} + case shared.EventTypeRequestCancelActivityTaskFailed: + event.Attributes = &apiv1.HistoryEvent_RequestCancelActivityTaskFailedEventAttributes{RequestCancelActivityTaskFailedEventAttributes: RequestCancelActivityTaskFailedEventAttributes(e.RequestCancelActivityTaskFailedEventAttributes)} + case shared.EventTypeActivityTaskCanceled: + event.Attributes = &apiv1.HistoryEvent_ActivityTaskCanceledEventAttributes{ActivityTaskCanceledEventAttributes: ActivityTaskCanceledEventAttributes(e.ActivityTaskCanceledEventAttributes)} + case shared.EventTypeTimerCanceled: + event.Attributes = &apiv1.HistoryEvent_TimerCanceledEventAttributes{TimerCanceledEventAttributes: TimerCanceledEventAttributes(e.TimerCanceledEventAttributes)} + case shared.EventTypeCancelTimerFailed: + event.Attributes = &apiv1.HistoryEvent_CancelTimerFailedEventAttributes{CancelTimerFailedEventAttributes: CancelTimerFailedEventAttributes(e.CancelTimerFailedEventAttributes)} + case shared.EventTypeMarkerRecorded: + event.Attributes = &apiv1.HistoryEvent_MarkerRecordedEventAttributes{MarkerRecordedEventAttributes: MarkerRecordedEventAttributes(e.MarkerRecordedEventAttributes)} + case shared.EventTypeWorkflowExecutionSignaled: + event.Attributes = &apiv1.HistoryEvent_WorkflowExecutionSignaledEventAttributes{WorkflowExecutionSignaledEventAttributes: WorkflowExecutionSignaledEventAttributes(e.WorkflowExecutionSignaledEventAttributes)} + case shared.EventTypeWorkflowExecutionTerminated: + event.Attributes = &apiv1.HistoryEvent_WorkflowExecutionTerminatedEventAttributes{WorkflowExecutionTerminatedEventAttributes: WorkflowExecutionTerminatedEventAttributes(e.WorkflowExecutionTerminatedEventAttributes)} + case shared.EventTypeWorkflowExecutionCancelRequested: + event.Attributes = &apiv1.HistoryEvent_WorkflowExecutionCancelRequestedEventAttributes{WorkflowExecutionCancelRequestedEventAttributes: WorkflowExecutionCancelRequestedEventAttributes(e.WorkflowExecutionCancelRequestedEventAttributes)} + case shared.EventTypeWorkflowExecutionCanceled: + event.Attributes = &apiv1.HistoryEvent_WorkflowExecutionCanceledEventAttributes{WorkflowExecutionCanceledEventAttributes: WorkflowExecutionCanceledEventAttributes(e.WorkflowExecutionCanceledEventAttributes)} + case shared.EventTypeRequestCancelExternalWorkflowExecutionInitiated: + event.Attributes = &apiv1.HistoryEvent_RequestCancelExternalWorkflowExecutionInitiatedEventAttributes{RequestCancelExternalWorkflowExecutionInitiatedEventAttributes: RequestCancelExternalWorkflowExecutionInitiatedEventAttributes(e.RequestCancelExternalWorkflowExecutionInitiatedEventAttributes)} + case shared.EventTypeRequestCancelExternalWorkflowExecutionFailed: + event.Attributes = &apiv1.HistoryEvent_RequestCancelExternalWorkflowExecutionFailedEventAttributes{RequestCancelExternalWorkflowExecutionFailedEventAttributes: RequestCancelExternalWorkflowExecutionFailedEventAttributes(e.RequestCancelExternalWorkflowExecutionFailedEventAttributes)} + case shared.EventTypeExternalWorkflowExecutionCancelRequested: + event.Attributes = &apiv1.HistoryEvent_ExternalWorkflowExecutionCancelRequestedEventAttributes{ExternalWorkflowExecutionCancelRequestedEventAttributes: ExternalWorkflowExecutionCancelRequestedEventAttributes(e.ExternalWorkflowExecutionCancelRequestedEventAttributes)} + case shared.EventTypeWorkflowExecutionContinuedAsNew: + event.Attributes = &apiv1.HistoryEvent_WorkflowExecutionContinuedAsNewEventAttributes{WorkflowExecutionContinuedAsNewEventAttributes: WorkflowExecutionContinuedAsNewEventAttributes(e.WorkflowExecutionContinuedAsNewEventAttributes)} + case shared.EventTypeStartChildWorkflowExecutionInitiated: + event.Attributes = &apiv1.HistoryEvent_StartChildWorkflowExecutionInitiatedEventAttributes{StartChildWorkflowExecutionInitiatedEventAttributes: StartChildWorkflowExecutionInitiatedEventAttributes(e.StartChildWorkflowExecutionInitiatedEventAttributes)} + case shared.EventTypeStartChildWorkflowExecutionFailed: + event.Attributes = &apiv1.HistoryEvent_StartChildWorkflowExecutionFailedEventAttributes{StartChildWorkflowExecutionFailedEventAttributes: StartChildWorkflowExecutionFailedEventAttributes(e.StartChildWorkflowExecutionFailedEventAttributes)} + case shared.EventTypeChildWorkflowExecutionStarted: + event.Attributes = &apiv1.HistoryEvent_ChildWorkflowExecutionStartedEventAttributes{ChildWorkflowExecutionStartedEventAttributes: ChildWorkflowExecutionStartedEventAttributes(e.ChildWorkflowExecutionStartedEventAttributes)} + case shared.EventTypeChildWorkflowExecutionCompleted: + event.Attributes = &apiv1.HistoryEvent_ChildWorkflowExecutionCompletedEventAttributes{ChildWorkflowExecutionCompletedEventAttributes: ChildWorkflowExecutionCompletedEventAttributes(e.ChildWorkflowExecutionCompletedEventAttributes)} + case shared.EventTypeChildWorkflowExecutionFailed: + event.Attributes = &apiv1.HistoryEvent_ChildWorkflowExecutionFailedEventAttributes{ChildWorkflowExecutionFailedEventAttributes: ChildWorkflowExecutionFailedEventAttributes(e.ChildWorkflowExecutionFailedEventAttributes)} + case shared.EventTypeChildWorkflowExecutionCanceled: + event.Attributes = &apiv1.HistoryEvent_ChildWorkflowExecutionCanceledEventAttributes{ChildWorkflowExecutionCanceledEventAttributes: ChildWorkflowExecutionCanceledEventAttributes(e.ChildWorkflowExecutionCanceledEventAttributes)} + case shared.EventTypeChildWorkflowExecutionTimedOut: + event.Attributes = &apiv1.HistoryEvent_ChildWorkflowExecutionTimedOutEventAttributes{ChildWorkflowExecutionTimedOutEventAttributes: ChildWorkflowExecutionTimedOutEventAttributes(e.ChildWorkflowExecutionTimedOutEventAttributes)} + case shared.EventTypeChildWorkflowExecutionTerminated: + event.Attributes = &apiv1.HistoryEvent_ChildWorkflowExecutionTerminatedEventAttributes{ChildWorkflowExecutionTerminatedEventAttributes: ChildWorkflowExecutionTerminatedEventAttributes(e.ChildWorkflowExecutionTerminatedEventAttributes)} + case shared.EventTypeSignalExternalWorkflowExecutionInitiated: + event.Attributes = &apiv1.HistoryEvent_SignalExternalWorkflowExecutionInitiatedEventAttributes{SignalExternalWorkflowExecutionInitiatedEventAttributes: SignalExternalWorkflowExecutionInitiatedEventAttributes(e.SignalExternalWorkflowExecutionInitiatedEventAttributes)} + case shared.EventTypeSignalExternalWorkflowExecutionFailed: + event.Attributes = &apiv1.HistoryEvent_SignalExternalWorkflowExecutionFailedEventAttributes{SignalExternalWorkflowExecutionFailedEventAttributes: SignalExternalWorkflowExecutionFailedEventAttributes(e.SignalExternalWorkflowExecutionFailedEventAttributes)} + case shared.EventTypeExternalWorkflowExecutionSignaled: + event.Attributes = &apiv1.HistoryEvent_ExternalWorkflowExecutionSignaledEventAttributes{ExternalWorkflowExecutionSignaledEventAttributes: ExternalWorkflowExecutionSignaledEventAttributes(e.ExternalWorkflowExecutionSignaledEventAttributes)} + case shared.EventTypeUpsertWorkflowSearchAttributes: + event.Attributes = &apiv1.HistoryEvent_UpsertWorkflowSearchAttributesEventAttributes{UpsertWorkflowSearchAttributesEventAttributes: UpsertWorkflowSearchAttributesEventAttributes(e.UpsertWorkflowSearchAttributesEventAttributes)} + default: + panic("unknown event type") + } + return &event +} + +func ActivityTaskCancelRequestedEventAttributes(t *shared.ActivityTaskCancelRequestedEventAttributes) *apiv1.ActivityTaskCancelRequestedEventAttributes { + if t == nil { + return nil + } + return &apiv1.ActivityTaskCancelRequestedEventAttributes{ + ActivityId: t.GetActivityId(), + DecisionTaskCompletedEventId: t.GetDecisionTaskCompletedEventId(), + } +} + +func ActivityTaskCanceledEventAttributes(t *shared.ActivityTaskCanceledEventAttributes) *apiv1.ActivityTaskCanceledEventAttributes { + if t == nil { + return nil + } + return &apiv1.ActivityTaskCanceledEventAttributes{ + Details: Payload(t.Details), + LatestCancelRequestedEventId: t.GetLatestCancelRequestedEventId(), + ScheduledEventId: t.GetScheduledEventId(), + StartedEventId: t.GetStartedEventId(), + Identity: t.GetIdentity(), + } +} + +func ActivityTaskCompletedEventAttributes(t *shared.ActivityTaskCompletedEventAttributes) *apiv1.ActivityTaskCompletedEventAttributes { + if t == nil { + return nil + } + return &apiv1.ActivityTaskCompletedEventAttributes{ + Result: Payload(t.Result), + ScheduledEventId: t.GetScheduledEventId(), + StartedEventId: t.GetStartedEventId(), + Identity: t.GetIdentity(), + } +} + +func ActivityTaskFailedEventAttributes(t *shared.ActivityTaskFailedEventAttributes) *apiv1.ActivityTaskFailedEventAttributes { + if t == nil { + return nil + } + return &apiv1.ActivityTaskFailedEventAttributes{ + Failure: Failure(t.Reason, t.Details), + ScheduledEventId: t.GetScheduledEventId(), + StartedEventId: t.GetStartedEventId(), + Identity: t.GetIdentity(), + } +} + +func ActivityTaskScheduledEventAttributes(t *shared.ActivityTaskScheduledEventAttributes) *apiv1.ActivityTaskScheduledEventAttributes { + if t == nil { + return nil + } + return &apiv1.ActivityTaskScheduledEventAttributes{ + ActivityId: t.GetActivityId(), + ActivityType: ActivityType(t.ActivityType), + Domain: t.GetDomain(), + TaskList: TaskList(t.TaskList), + Input: Payload(t.Input), + ScheduleToCloseTimeout: secondsToDuration(t.ScheduleToCloseTimeoutSeconds), + ScheduleToStartTimeout: secondsToDuration(t.ScheduleToStartTimeoutSeconds), + StartToCloseTimeout: secondsToDuration(t.StartToCloseTimeoutSeconds), + HeartbeatTimeout: secondsToDuration(t.HeartbeatTimeoutSeconds), + DecisionTaskCompletedEventId: t.GetDecisionTaskCompletedEventId(), + RetryPolicy: RetryPolicy(t.RetryPolicy), + Header: Header(t.Header), + } +} + +func ActivityTaskStartedEventAttributes(t *shared.ActivityTaskStartedEventAttributes) *apiv1.ActivityTaskStartedEventAttributes { + if t == nil { + return nil + } + return &apiv1.ActivityTaskStartedEventAttributes{ + ScheduledEventId: t.GetScheduledEventId(), + Identity: t.GetIdentity(), + RequestId: t.GetRequestId(), + Attempt: t.GetAttempt(), + LastFailure: Failure(t.LastFailureReason, t.LastFailureDetails), + } +} + +func ActivityTaskTimedOutEventAttributes(t *shared.ActivityTaskTimedOutEventAttributes) *apiv1.ActivityTaskTimedOutEventAttributes { + if t == nil { + return nil + } + return &apiv1.ActivityTaskTimedOutEventAttributes{ + Details: Payload(t.Details), + ScheduledEventId: t.GetScheduledEventId(), + StartedEventId: t.GetStartedEventId(), + TimeoutType: TimeoutType(t.TimeoutType), + LastFailure: Failure(t.LastFailureReason, t.LastFailureDetails), + } +} + +func CancelTimerFailedEventAttributes(t *shared.CancelTimerFailedEventAttributes) *apiv1.CancelTimerFailedEventAttributes { + if t == nil { + return nil + } + return &apiv1.CancelTimerFailedEventAttributes{ + TimerId: t.GetTimerId(), + Cause: t.GetCause(), + DecisionTaskCompletedEventId: t.GetDecisionTaskCompletedEventId(), + Identity: t.GetIdentity(), + } +} + +func ChildWorkflowExecutionCanceledEventAttributes(t *shared.ChildWorkflowExecutionCanceledEventAttributes) *apiv1.ChildWorkflowExecutionCanceledEventAttributes { + if t == nil { + return nil + } + return &apiv1.ChildWorkflowExecutionCanceledEventAttributes{ + Domain: t.GetDomain(), + WorkflowExecution: WorkflowExecution(t.WorkflowExecution), + WorkflowType: WorkflowType(t.WorkflowType), + InitiatedEventId: t.GetInitiatedEventId(), + StartedEventId: t.GetStartedEventId(), + Details: Payload(t.Details), + } +} + +func ChildWorkflowExecutionCompletedEventAttributes(t *shared.ChildWorkflowExecutionCompletedEventAttributes) *apiv1.ChildWorkflowExecutionCompletedEventAttributes { + if t == nil { + return nil + } + return &apiv1.ChildWorkflowExecutionCompletedEventAttributes{ + Domain: t.GetDomain(), + WorkflowExecution: WorkflowExecution(t.WorkflowExecution), + WorkflowType: WorkflowType(t.WorkflowType), + InitiatedEventId: t.GetInitiatedEventId(), + StartedEventId: t.GetStartedEventId(), + Result: Payload(t.Result), + } +} + +func ChildWorkflowExecutionFailedEventAttributes(t *shared.ChildWorkflowExecutionFailedEventAttributes) *apiv1.ChildWorkflowExecutionFailedEventAttributes { + if t == nil { + return nil + } + return &apiv1.ChildWorkflowExecutionFailedEventAttributes{ + Domain: t.GetDomain(), + WorkflowExecution: WorkflowExecution(t.WorkflowExecution), + WorkflowType: WorkflowType(t.WorkflowType), + InitiatedEventId: t.GetInitiatedEventId(), + StartedEventId: t.GetStartedEventId(), + Failure: Failure(t.Reason, t.Details), + } +} + +func ChildWorkflowExecutionStartedEventAttributes(t *shared.ChildWorkflowExecutionStartedEventAttributes) *apiv1.ChildWorkflowExecutionStartedEventAttributes { + if t == nil { + return nil + } + return &apiv1.ChildWorkflowExecutionStartedEventAttributes{ + Domain: t.GetDomain(), + WorkflowExecution: WorkflowExecution(t.WorkflowExecution), + WorkflowType: WorkflowType(t.WorkflowType), + InitiatedEventId: t.GetInitiatedEventId(), + Header: Header(t.Header), + } +} + +func ChildWorkflowExecutionTerminatedEventAttributes(t *shared.ChildWorkflowExecutionTerminatedEventAttributes) *apiv1.ChildWorkflowExecutionTerminatedEventAttributes { + if t == nil { + return nil + } + return &apiv1.ChildWorkflowExecutionTerminatedEventAttributes{ + Domain: t.GetDomain(), + WorkflowExecution: WorkflowExecution(t.WorkflowExecution), + WorkflowType: WorkflowType(t.WorkflowType), + InitiatedEventId: t.GetInitiatedEventId(), + StartedEventId: t.GetStartedEventId(), + } +} + +func ChildWorkflowExecutionTimedOutEventAttributes(t *shared.ChildWorkflowExecutionTimedOutEventAttributes) *apiv1.ChildWorkflowExecutionTimedOutEventAttributes { + if t == nil { + return nil + } + return &apiv1.ChildWorkflowExecutionTimedOutEventAttributes{ + Domain: t.GetDomain(), + WorkflowExecution: WorkflowExecution(t.WorkflowExecution), + WorkflowType: WorkflowType(t.WorkflowType), + InitiatedEventId: t.GetInitiatedEventId(), + StartedEventId: t.GetStartedEventId(), + TimeoutType: TimeoutType(t.TimeoutType), + } +} + +func DecisionTaskFailedEventAttributes(t *shared.DecisionTaskFailedEventAttributes) *apiv1.DecisionTaskFailedEventAttributes { + if t == nil { + return nil + } + return &apiv1.DecisionTaskFailedEventAttributes{ + ScheduledEventId: t.GetScheduledEventId(), + StartedEventId: t.GetStartedEventId(), + Cause: DecisionTaskFailedCause(t.Cause), + Failure: Failure(t.Reason, t.Details), + Identity: t.GetIdentity(), + BaseRunId: t.GetBaseRunId(), + NewRunId: t.GetNewRunId(), + ForkEventVersion: t.GetForkEventVersion(), + BinaryChecksum: t.GetBinaryChecksum(), + } +} + +func DecisionTaskScheduledEventAttributes(t *shared.DecisionTaskScheduledEventAttributes) *apiv1.DecisionTaskScheduledEventAttributes { + if t == nil { + return nil + } + return &apiv1.DecisionTaskScheduledEventAttributes{ + TaskList: TaskList(t.TaskList), + StartToCloseTimeout: secondsToDuration(t.StartToCloseTimeoutSeconds), + Attempt: int32(t.GetAttempt()), + } +} + +func DecisionTaskStartedEventAttributes(t *shared.DecisionTaskStartedEventAttributes) *apiv1.DecisionTaskStartedEventAttributes { + if t == nil { + return nil + } + return &apiv1.DecisionTaskStartedEventAttributes{ + ScheduledEventId: t.GetScheduledEventId(), + Identity: t.GetIdentity(), + RequestId: t.GetRequestId(), + } +} + +func DecisionTaskCompletedEventAttributes(t *shared.DecisionTaskCompletedEventAttributes) *apiv1.DecisionTaskCompletedEventAttributes { + if t == nil { + return nil + } + return &apiv1.DecisionTaskCompletedEventAttributes{ + ScheduledEventId: t.GetScheduledEventId(), + StartedEventId: t.GetStartedEventId(), + Identity: t.GetIdentity(), + BinaryChecksum: t.GetBinaryChecksum(), + ExecutionContext: t.ExecutionContext, + } +} + +func DecisionTaskTimedOutEventAttributes(t *shared.DecisionTaskTimedOutEventAttributes) *apiv1.DecisionTaskTimedOutEventAttributes { + if t == nil { + return nil + } + return &apiv1.DecisionTaskTimedOutEventAttributes{ + ScheduledEventId: t.GetScheduledEventId(), + StartedEventId: t.GetStartedEventId(), + TimeoutType: TimeoutType(t.TimeoutType), + BaseRunId: t.GetBaseRunId(), + NewRunId: t.GetNewRunId(), + ForkEventVersion: t.GetForkEventVersion(), + Reason: t.GetReason(), + Cause: DecisionTaskTimedOutCause(t.Cause), + } +} + +func ExternalWorkflowExecutionCancelRequestedEventAttributes(t *shared.ExternalWorkflowExecutionCancelRequestedEventAttributes) *apiv1.ExternalWorkflowExecutionCancelRequestedEventAttributes { + if t == nil { + return nil + } + return &apiv1.ExternalWorkflowExecutionCancelRequestedEventAttributes{ + InitiatedEventId: t.GetInitiatedEventId(), + Domain: t.GetDomain(), + WorkflowExecution: WorkflowExecution(t.WorkflowExecution), + } +} + +func ExternalWorkflowExecutionSignaledEventAttributes(t *shared.ExternalWorkflowExecutionSignaledEventAttributes) *apiv1.ExternalWorkflowExecutionSignaledEventAttributes { + if t == nil { + return nil + } + return &apiv1.ExternalWorkflowExecutionSignaledEventAttributes{ + InitiatedEventId: t.GetInitiatedEventId(), + Domain: t.GetDomain(), + WorkflowExecution: WorkflowExecution(t.WorkflowExecution), + Control: t.Control, + } +} + +func MarkerRecordedEventAttributes(t *shared.MarkerRecordedEventAttributes) *apiv1.MarkerRecordedEventAttributes { + if t == nil { + return nil + } + return &apiv1.MarkerRecordedEventAttributes{ + MarkerName: t.GetMarkerName(), + Details: Payload(t.Details), + DecisionTaskCompletedEventId: t.GetDecisionTaskCompletedEventId(), + Header: Header(t.Header), + } +} + +func RequestCancelActivityTaskFailedEventAttributes(t *shared.RequestCancelActivityTaskFailedEventAttributes) *apiv1.RequestCancelActivityTaskFailedEventAttributes { + if t == nil { + return nil + } + return &apiv1.RequestCancelActivityTaskFailedEventAttributes{ + ActivityId: t.GetActivityId(), + Cause: t.GetCause(), + DecisionTaskCompletedEventId: t.GetDecisionTaskCompletedEventId(), + } +} + +func RequestCancelExternalWorkflowExecutionFailedEventAttributes(t *shared.RequestCancelExternalWorkflowExecutionFailedEventAttributes) *apiv1.RequestCancelExternalWorkflowExecutionFailedEventAttributes { + if t == nil { + return nil + } + return &apiv1.RequestCancelExternalWorkflowExecutionFailedEventAttributes{ + Cause: CancelExternalWorkflowExecutionFailedCause(t.Cause), + DecisionTaskCompletedEventId: t.GetDecisionTaskCompletedEventId(), + Domain: t.GetDomain(), + WorkflowExecution: WorkflowExecution(t.WorkflowExecution), + InitiatedEventId: t.GetInitiatedEventId(), + Control: t.Control, + } +} + +func RequestCancelExternalWorkflowExecutionInitiatedEventAttributes(t *shared.RequestCancelExternalWorkflowExecutionInitiatedEventAttributes) *apiv1.RequestCancelExternalWorkflowExecutionInitiatedEventAttributes { + if t == nil { + return nil + } + return &apiv1.RequestCancelExternalWorkflowExecutionInitiatedEventAttributes{ + DecisionTaskCompletedEventId: t.GetDecisionTaskCompletedEventId(), + Domain: t.GetDomain(), + WorkflowExecution: WorkflowExecution(t.WorkflowExecution), + Control: t.Control, + ChildWorkflowOnly: t.GetChildWorkflowOnly(), + } +} + +func SignalExternalWorkflowExecutionFailedEventAttributes(t *shared.SignalExternalWorkflowExecutionFailedEventAttributes) *apiv1.SignalExternalWorkflowExecutionFailedEventAttributes { + if t == nil { + return nil + } + return &apiv1.SignalExternalWorkflowExecutionFailedEventAttributes{ + Cause: SignalExternalWorkflowExecutionFailedCause(t.Cause), + DecisionTaskCompletedEventId: t.GetDecisionTaskCompletedEventId(), + Domain: t.GetDomain(), + WorkflowExecution: WorkflowExecution(t.WorkflowExecution), + InitiatedEventId: t.GetInitiatedEventId(), + Control: t.Control, + } +} + +func SignalExternalWorkflowExecutionInitiatedEventAttributes(t *shared.SignalExternalWorkflowExecutionInitiatedEventAttributes) *apiv1.SignalExternalWorkflowExecutionInitiatedEventAttributes { + if t == nil { + return nil + } + return &apiv1.SignalExternalWorkflowExecutionInitiatedEventAttributes{ + DecisionTaskCompletedEventId: t.GetDecisionTaskCompletedEventId(), + Domain: t.GetDomain(), + WorkflowExecution: WorkflowExecution(t.WorkflowExecution), + SignalName: t.GetSignalName(), + Input: Payload(t.Input), + Control: t.Control, + ChildWorkflowOnly: t.GetChildWorkflowOnly(), + } +} + +func StartChildWorkflowExecutionFailedEventAttributes(t *shared.StartChildWorkflowExecutionFailedEventAttributes) *apiv1.StartChildWorkflowExecutionFailedEventAttributes { + if t == nil { + return nil + } + return &apiv1.StartChildWorkflowExecutionFailedEventAttributes{ + Domain: t.GetDomain(), + WorkflowId: t.GetWorkflowId(), + WorkflowType: WorkflowType(t.WorkflowType), + Cause: ChildWorkflowExecutionFailedCause(t.Cause), + Control: t.Control, + InitiatedEventId: t.GetInitiatedEventId(), + DecisionTaskCompletedEventId: t.GetDecisionTaskCompletedEventId(), + } +} + +func StartChildWorkflowExecutionInitiatedEventAttributes(t *shared.StartChildWorkflowExecutionInitiatedEventAttributes) *apiv1.StartChildWorkflowExecutionInitiatedEventAttributes { + if t == nil { + return nil + } + return &apiv1.StartChildWorkflowExecutionInitiatedEventAttributes{ + Domain: t.GetDomain(), + WorkflowId: t.GetWorkflowId(), + WorkflowType: WorkflowType(t.WorkflowType), + TaskList: TaskList(t.TaskList), + Input: Payload(t.Input), + ExecutionStartToCloseTimeout: secondsToDuration(t.ExecutionStartToCloseTimeoutSeconds), + TaskStartToCloseTimeout: secondsToDuration(t.TaskStartToCloseTimeoutSeconds), + ParentClosePolicy: ParentClosePolicy(t.ParentClosePolicy), + Control: t.Control, + DecisionTaskCompletedEventId: t.GetDecisionTaskCompletedEventId(), + WorkflowIdReusePolicy: WorkflowIdReusePolicy(t.WorkflowIdReusePolicy), + RetryPolicy: RetryPolicy(t.RetryPolicy), + CronSchedule: t.GetCronSchedule(), + Header: Header(t.Header), + Memo: Memo(t.Memo), + SearchAttributes: SearchAttributes(t.SearchAttributes), + DelayStart: secondsToDuration(t.DelayStartSeconds), + } +} + +func TimerCanceledEventAttributes(t *shared.TimerCanceledEventAttributes) *apiv1.TimerCanceledEventAttributes { + if t == nil { + return nil + } + return &apiv1.TimerCanceledEventAttributes{ + TimerId: t.GetTimerId(), + StartedEventId: t.GetStartedEventId(), + DecisionTaskCompletedEventId: t.GetDecisionTaskCompletedEventId(), + Identity: t.GetIdentity(), + } +} + +func TimerFiredEventAttributes(t *shared.TimerFiredEventAttributes) *apiv1.TimerFiredEventAttributes { + if t == nil { + return nil + } + return &apiv1.TimerFiredEventAttributes{ + TimerId: t.GetTimerId(), + StartedEventId: t.GetStartedEventId(), + } +} + +func TimerStartedEventAttributes(t *shared.TimerStartedEventAttributes) *apiv1.TimerStartedEventAttributes { + if t == nil { + return nil + } + return &apiv1.TimerStartedEventAttributes{ + TimerId: t.GetTimerId(), + StartToFireTimeout: secondsToDuration(int64To32(t.StartToFireTimeoutSeconds)), + DecisionTaskCompletedEventId: t.GetDecisionTaskCompletedEventId(), + } +} + +func UpsertWorkflowSearchAttributesEventAttributes(t *shared.UpsertWorkflowSearchAttributesEventAttributes) *apiv1.UpsertWorkflowSearchAttributesEventAttributes { + if t == nil { + return nil + } + return &apiv1.UpsertWorkflowSearchAttributesEventAttributes{ + DecisionTaskCompletedEventId: t.GetDecisionTaskCompletedEventId(), + SearchAttributes: SearchAttributes(t.SearchAttributes), + } +} + +func WorkflowExecutionCancelRequestedEventAttributes(t *shared.WorkflowExecutionCancelRequestedEventAttributes) *apiv1.WorkflowExecutionCancelRequestedEventAttributes { + if t == nil { + return nil + } + return &apiv1.WorkflowExecutionCancelRequestedEventAttributes{ + Cause: t.GetCause(), + ExternalExecutionInfo: ExternalExecutionInfo(t.ExternalWorkflowExecution, t.ExternalInitiatedEventId), + Identity: t.GetIdentity(), + } +} + +func WorkflowExecutionCanceledEventAttributes(t *shared.WorkflowExecutionCanceledEventAttributes) *apiv1.WorkflowExecutionCanceledEventAttributes { + if t == nil { + return nil + } + return &apiv1.WorkflowExecutionCanceledEventAttributes{ + DecisionTaskCompletedEventId: t.GetDecisionTaskCompletedEventId(), + Details: Payload(t.Details), + } +} + +func WorkflowExecutionCompletedEventAttributes(t *shared.WorkflowExecutionCompletedEventAttributes) *apiv1.WorkflowExecutionCompletedEventAttributes { + if t == nil { + return nil + } + return &apiv1.WorkflowExecutionCompletedEventAttributes{ + Result: Payload(t.Result), + DecisionTaskCompletedEventId: t.GetDecisionTaskCompletedEventId(), + } +} + +func WorkflowExecutionContinuedAsNewEventAttributes(t *shared.WorkflowExecutionContinuedAsNewEventAttributes) *apiv1.WorkflowExecutionContinuedAsNewEventAttributes { + if t == nil { + return nil + } + return &apiv1.WorkflowExecutionContinuedAsNewEventAttributes{ + NewExecutionRunId: t.GetNewExecutionRunId(), + WorkflowType: WorkflowType(t.WorkflowType), + TaskList: TaskList(t.TaskList), + Input: Payload(t.Input), + ExecutionStartToCloseTimeout: secondsToDuration(t.ExecutionStartToCloseTimeoutSeconds), + TaskStartToCloseTimeout: secondsToDuration(t.TaskStartToCloseTimeoutSeconds), + DecisionTaskCompletedEventId: t.GetDecisionTaskCompletedEventId(), + BackoffStartInterval: secondsToDuration(t.BackoffStartIntervalInSeconds), + Initiator: ContinueAsNewInitiator(t.Initiator), + Failure: Failure(t.FailureReason, t.FailureDetails), + LastCompletionResult: Payload(t.LastCompletionResult), + Header: Header(t.Header), + Memo: Memo(t.Memo), + SearchAttributes: SearchAttributes(t.SearchAttributes), + } +} + +func WorkflowExecutionFailedEventAttributes(t *shared.WorkflowExecutionFailedEventAttributes) *apiv1.WorkflowExecutionFailedEventAttributes { + if t == nil { + return nil + } + return &apiv1.WorkflowExecutionFailedEventAttributes{ + Failure: Failure(t.Reason, t.Details), + DecisionTaskCompletedEventId: t.GetDecisionTaskCompletedEventId(), + } +} + +func WorkflowExecutionSignaledEventAttributes(t *shared.WorkflowExecutionSignaledEventAttributes) *apiv1.WorkflowExecutionSignaledEventAttributes { + if t == nil { + return nil + } + return &apiv1.WorkflowExecutionSignaledEventAttributes{ + SignalName: t.GetSignalName(), + Input: Payload(t.Input), + Identity: t.GetIdentity(), + } +} + +func WorkflowExecutionStartedEventAttributes(t *shared.WorkflowExecutionStartedEventAttributes) *apiv1.WorkflowExecutionStartedEventAttributes { + if t == nil { + return nil + } + return &apiv1.WorkflowExecutionStartedEventAttributes{ + WorkflowType: WorkflowType(t.WorkflowType), + ParentExecutionInfo: ParentExecutionInfo(nil, t.ParentWorkflowDomain, t.ParentWorkflowExecution, t.ParentInitiatedEventId), + TaskList: TaskList(t.TaskList), + Input: Payload(t.Input), + ExecutionStartToCloseTimeout: secondsToDuration(t.ExecutionStartToCloseTimeoutSeconds), + TaskStartToCloseTimeout: secondsToDuration(t.TaskStartToCloseTimeoutSeconds), + ContinuedExecutionRunId: t.GetContinuedExecutionRunId(), + Initiator: ContinueAsNewInitiator(t.Initiator), + ContinuedFailure: Failure(t.ContinuedFailureReason, t.ContinuedFailureDetails), + LastCompletionResult: Payload(t.LastCompletionResult), + OriginalExecutionRunId: t.GetOriginalExecutionRunId(), + Identity: t.GetIdentity(), + FirstExecutionRunId: t.GetFirstExecutionRunId(), + RetryPolicy: RetryPolicy(t.RetryPolicy), + Attempt: t.GetAttempt(), + ExpirationTime: unixNanoToTime(t.ExpirationTimestamp), + CronSchedule: t.GetCronSchedule(), + FirstDecisionTaskBackoff: secondsToDuration(t.FirstDecisionTaskBackoffSeconds), + Memo: Memo(t.Memo), + SearchAttributes: SearchAttributes(t.SearchAttributes), + PrevAutoResetPoints: ResetPoints(t.PrevAutoResetPoints), + Header: Header(t.Header), + } +} + +func WorkflowExecutionTerminatedEventAttributes(t *shared.WorkflowExecutionTerminatedEventAttributes) *apiv1.WorkflowExecutionTerminatedEventAttributes { + if t == nil { + return nil + } + return &apiv1.WorkflowExecutionTerminatedEventAttributes{ + Reason: t.GetReason(), + Details: Payload(t.Details), + Identity: t.GetIdentity(), + } +} + +func WorkflowExecutionTimedOutEventAttributes(t *shared.WorkflowExecutionTimedOutEventAttributes) *apiv1.WorkflowExecutionTimedOutEventAttributes { + if t == nil { + return nil + } + return &apiv1.WorkflowExecutionTimedOutEventAttributes{ + TimeoutType: TimeoutType(t.TimeoutType), + } +} diff --git a/internal/compatibility/proto/request.go b/internal/compatibility/proto/request.go new file mode 100644 index 000000000..300476df7 --- /dev/null +++ b/internal/compatibility/proto/request.go @@ -0,0 +1,612 @@ +// Copyright (c) 2021 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +package proto + +import ( + "go.uber.org/cadence/.gen/go/shared" + apiv1 "go.uber.org/cadence/.gen/proto/api/v1" +) + +func CountWorkflowExecutionsRequest(t *shared.CountWorkflowExecutionsRequest) *apiv1.CountWorkflowExecutionsRequest { + if t == nil { + return nil + } + return &apiv1.CountWorkflowExecutionsRequest{ + Domain: t.GetDomain(), + Query: t.GetQuery(), + } +} + +func DeprecateDomainRequest(t *shared.DeprecateDomainRequest) *apiv1.DeprecateDomainRequest { + if t == nil { + return nil + } + return &apiv1.DeprecateDomainRequest{ + Name: t.GetName(), + SecurityToken: t.GetSecurityToken(), + } +} + +func DescribeDomainRequest(t *shared.DescribeDomainRequest) *apiv1.DescribeDomainRequest { + if t == nil { + return nil + } + if t.UUID != nil { + return &apiv1.DescribeDomainRequest{DescribeBy: &apiv1.DescribeDomainRequest_Id{Id: *t.UUID}} + } + if t.Name != nil { + return &apiv1.DescribeDomainRequest{DescribeBy: &apiv1.DescribeDomainRequest_Name{Name: *t.Name}} + } + panic("neither oneof field is set for DescribeDomainRequest") +} + +func DescribeTaskListRequest(t *shared.DescribeTaskListRequest) *apiv1.DescribeTaskListRequest { + if t == nil { + return nil + } + return &apiv1.DescribeTaskListRequest{ + Domain: t.GetDomain(), + TaskList: TaskList(t.TaskList), + TaskListType: TaskListType(t.TaskListType), + IncludeTaskListStatus: t.GetIncludeTaskListStatus(), + } +} + +func DescribeWorkflowExecutionRequest(t *shared.DescribeWorkflowExecutionRequest) *apiv1.DescribeWorkflowExecutionRequest { + if t == nil { + return nil + } + return &apiv1.DescribeWorkflowExecutionRequest{ + Domain: t.GetDomain(), + WorkflowExecution: WorkflowExecution(t.Execution), + } +} + +func GetWorkflowExecutionHistoryRequest(t *shared.GetWorkflowExecutionHistoryRequest) *apiv1.GetWorkflowExecutionHistoryRequest { + if t == nil { + return nil + } + return &apiv1.GetWorkflowExecutionHistoryRequest{ + Domain: t.GetDomain(), + WorkflowExecution: WorkflowExecution(t.Execution), + PageSize: t.GetMaximumPageSize(), + NextPageToken: t.GetNextPageToken(), + WaitForNewEvent: t.GetWaitForNewEvent(), + HistoryEventFilterType: EventFilterType(t.HistoryEventFilterType), + SkipArchival: t.GetSkipArchival(), + } +} + +func ListArchivedWorkflowExecutionsRequest(t *shared.ListArchivedWorkflowExecutionsRequest) *apiv1.ListArchivedWorkflowExecutionsRequest { + if t == nil { + return nil + } + return &apiv1.ListArchivedWorkflowExecutionsRequest{ + Domain: t.GetDomain(), + PageSize: t.GetPageSize(), + NextPageToken: t.GetNextPageToken(), + Query: t.GetQuery(), + } +} + +func ListDomainsRequest(t *shared.ListDomainsRequest) *apiv1.ListDomainsRequest { + if t == nil { + return nil + } + return &apiv1.ListDomainsRequest{ + PageSize: t.GetPageSize(), + NextPageToken: t.NextPageToken, + } +} + +func ListTaskListPartitionsRequest(t *shared.ListTaskListPartitionsRequest) *apiv1.ListTaskListPartitionsRequest { + if t == nil { + return nil + } + return &apiv1.ListTaskListPartitionsRequest{ + Domain: t.GetDomain(), + TaskList: TaskList(t.TaskList), + } +} + +func ListWorkflowExecutionsRequest(t *shared.ListWorkflowExecutionsRequest) *apiv1.ListWorkflowExecutionsRequest { + if t == nil { + return nil + } + return &apiv1.ListWorkflowExecutionsRequest{ + Domain: t.GetDomain(), + PageSize: t.GetPageSize(), + NextPageToken: t.NextPageToken, + Query: t.GetQuery(), + } +} + +func PollForActivityTaskRequest(t *shared.PollForActivityTaskRequest) *apiv1.PollForActivityTaskRequest { + if t == nil { + return nil + } + return &apiv1.PollForActivityTaskRequest{ + Domain: t.GetDomain(), + TaskList: TaskList(t.TaskList), + Identity: t.GetIdentity(), + TaskListMetadata: TaskListMetadata(t.TaskListMetadata), + } +} + +func PollForDecisionTaskRequest(t *shared.PollForDecisionTaskRequest) *apiv1.PollForDecisionTaskRequest { + if t == nil { + return nil + } + return &apiv1.PollForDecisionTaskRequest{ + Domain: t.GetDomain(), + TaskList: TaskList(t.TaskList), + Identity: t.GetIdentity(), + BinaryChecksum: t.GetBinaryChecksum(), + } +} + +func QueryWorkflowRequest(t *shared.QueryWorkflowRequest) *apiv1.QueryWorkflowRequest { + if t == nil { + return nil + } + return &apiv1.QueryWorkflowRequest{ + Domain: t.GetDomain(), + WorkflowExecution: WorkflowExecution(t.Execution), + Query: WorkflowQuery(t.Query), + QueryRejectCondition: QueryRejectCondition(t.QueryRejectCondition), + QueryConsistencyLevel: QueryConsistencyLevel(t.QueryConsistencyLevel), + } +} + +func RecordActivityTaskHeartbeatByIdRequest(t *shared.RecordActivityTaskHeartbeatByIDRequest) *apiv1.RecordActivityTaskHeartbeatByIDRequest { + if t == nil { + return nil + } + return &apiv1.RecordActivityTaskHeartbeatByIDRequest{ + Domain: t.GetDomain(), + WorkflowExecution: WorkflowRunPair(t.WorkflowID, t.RunID), + ActivityId: t.GetActivityID(), + Details: Payload(t.Details), + Identity: t.GetIdentity(), + } +} + +func RecordActivityTaskHeartbeatRequest(t *shared.RecordActivityTaskHeartbeatRequest) *apiv1.RecordActivityTaskHeartbeatRequest { + if t == nil { + return nil + } + return &apiv1.RecordActivityTaskHeartbeatRequest{ + TaskToken: t.TaskToken, + Details: Payload(t.Details), + Identity: t.GetIdentity(), + } +} + +func RegisterDomainRequest(t *shared.RegisterDomainRequest) *apiv1.RegisterDomainRequest { + if t == nil { + return nil + } + return &apiv1.RegisterDomainRequest{ + Name: t.GetName(), + Description: t.GetDescription(), + OwnerEmail: t.GetOwnerEmail(), + WorkflowExecutionRetentionPeriod: daysToDuration(t.WorkflowExecutionRetentionPeriodInDays), + Clusters: ClusterReplicationConfigurationArray(t.Clusters), + ActiveClusterName: t.GetActiveClusterName(), + Data: t.Data, + SecurityToken: t.GetSecurityToken(), + IsGlobalDomain: t.GetIsGlobalDomain(), + HistoryArchivalStatus: ArchivalStatus(t.HistoryArchivalStatus), + HistoryArchivalUri: t.GetHistoryArchivalURI(), + VisibilityArchivalStatus: ArchivalStatus(t.VisibilityArchivalStatus), + VisibilityArchivalUri: t.GetVisibilityArchivalURI(), + } +} + +func RequestCancelWorkflowExecutionRequest(t *shared.RequestCancelWorkflowExecutionRequest) *apiv1.RequestCancelWorkflowExecutionRequest { + if t == nil { + return nil + } + return &apiv1.RequestCancelWorkflowExecutionRequest{ + Domain: t.GetDomain(), + WorkflowExecution: WorkflowExecution(t.WorkflowExecution), + Identity: t.GetIdentity(), + RequestId: t.GetRequestId(), + } +} + +func ResetStickyTaskListRequest(t *shared.ResetStickyTaskListRequest) *apiv1.ResetStickyTaskListRequest { + if t == nil { + return nil + } + return &apiv1.ResetStickyTaskListRequest{ + Domain: t.GetDomain(), + WorkflowExecution: WorkflowExecution(t.Execution), + } +} + +func ResetWorkflowExecutionRequest(t *shared.ResetWorkflowExecutionRequest) *apiv1.ResetWorkflowExecutionRequest { + if t == nil { + return nil + } + return &apiv1.ResetWorkflowExecutionRequest{ + Domain: t.GetDomain(), + WorkflowExecution: WorkflowExecution(t.WorkflowExecution), + Reason: t.GetReason(), + DecisionFinishEventId: t.GetDecisionFinishEventId(), + RequestId: t.GetRequestId(), + SkipSignalReapply: t.GetSkipSignalReapply(), + } +} + +func RespondActivityTaskCanceledByIdRequest(t *shared.RespondActivityTaskCanceledByIDRequest) *apiv1.RespondActivityTaskCanceledByIDRequest { + if t == nil { + return nil + } + return &apiv1.RespondActivityTaskCanceledByIDRequest{ + Domain: t.GetDomain(), + WorkflowExecution: WorkflowRunPair(t.WorkflowID, t.RunID), + ActivityId: t.GetActivityID(), + Details: Payload(t.Details), + Identity: t.GetIdentity(), + } +} + +func RespondActivityTaskCanceledRequest(t *shared.RespondActivityTaskCanceledRequest) *apiv1.RespondActivityTaskCanceledRequest { + if t == nil { + return nil + } + return &apiv1.RespondActivityTaskCanceledRequest{ + TaskToken: t.TaskToken, + Details: Payload(t.Details), + Identity: t.GetIdentity(), + } +} + +func RespondActivityTaskCompletedByIdRequest(t *shared.RespondActivityTaskCompletedByIDRequest) *apiv1.RespondActivityTaskCompletedByIDRequest { + if t == nil { + return nil + } + return &apiv1.RespondActivityTaskCompletedByIDRequest{ + Domain: t.GetDomain(), + WorkflowExecution: WorkflowRunPair(t.WorkflowID, t.RunID), + ActivityId: t.GetActivityID(), + Result: Payload(t.Result), + Identity: t.GetIdentity(), + } +} + +func RespondActivityTaskCompletedRequest(t *shared.RespondActivityTaskCompletedRequest) *apiv1.RespondActivityTaskCompletedRequest { + if t == nil { + return nil + } + return &apiv1.RespondActivityTaskCompletedRequest{ + TaskToken: t.TaskToken, + Result: Payload(t.Result), + Identity: t.GetIdentity(), + } +} + +func RespondActivityTaskFailedByIdRequest(t *shared.RespondActivityTaskFailedByIDRequest) *apiv1.RespondActivityTaskFailedByIDRequest { + if t == nil { + return nil + } + return &apiv1.RespondActivityTaskFailedByIDRequest{ + Domain: t.GetDomain(), + WorkflowExecution: WorkflowRunPair(t.WorkflowID, t.RunID), + ActivityId: t.GetActivityID(), + Failure: Failure(t.Reason, t.Details), + Identity: t.GetIdentity(), + } +} + +func RespondActivityTaskFailedRequest(t *shared.RespondActivityTaskFailedRequest) *apiv1.RespondActivityTaskFailedRequest { + if t == nil { + return nil + } + return &apiv1.RespondActivityTaskFailedRequest{ + TaskToken: t.TaskToken, + Failure: Failure(t.Reason, t.Details), + Identity: t.GetIdentity(), + } +} + +func RespondDecisionTaskCompletedRequest(t *shared.RespondDecisionTaskCompletedRequest) *apiv1.RespondDecisionTaskCompletedRequest { + if t == nil { + return nil + } + return &apiv1.RespondDecisionTaskCompletedRequest{ + TaskToken: t.TaskToken, + Decisions: DecisionArray(t.Decisions), + ExecutionContext: t.ExecutionContext, + Identity: t.GetIdentity(), + StickyAttributes: StickyExecutionAttributes(t.StickyAttributes), + ReturnNewDecisionTask: t.GetReturnNewDecisionTask(), + ForceCreateNewDecisionTask: t.GetForceCreateNewDecisionTask(), + BinaryChecksum: t.GetBinaryChecksum(), + QueryResults: WorkflowQueryResultMap(t.QueryResults), + } +} + +func RespondDecisionTaskFailedRequest(t *shared.RespondDecisionTaskFailedRequest) *apiv1.RespondDecisionTaskFailedRequest { + if t == nil { + return nil + } + return &apiv1.RespondDecisionTaskFailedRequest{ + TaskToken: t.TaskToken, + Cause: DecisionTaskFailedCause(t.Cause), + Details: Payload(t.Details), + Identity: t.GetIdentity(), + BinaryChecksum: t.GetBinaryChecksum(), + } +} + +func RespondQueryTaskCompletedRequest(t *shared.RespondQueryTaskCompletedRequest) *apiv1.RespondQueryTaskCompletedRequest { + if t == nil { + return nil + } + return &apiv1.RespondQueryTaskCompletedRequest{ + TaskToken: t.TaskToken, + Result: &apiv1.WorkflowQueryResult{ + ResultType: QueryTaskCompletedType(t.CompletedType), + Answer: Payload(t.QueryResult), + ErrorMessage: t.GetErrorMessage(), + }, + WorkerVersionInfo: WorkerVersionInfo(t.WorkerVersionInfo), + } +} + +func ScanWorkflowExecutionsRequest(t *shared.ListWorkflowExecutionsRequest) *apiv1.ScanWorkflowExecutionsRequest { + if t == nil { + return nil + } + return &apiv1.ScanWorkflowExecutionsRequest{ + Domain: t.GetDomain(), + PageSize: t.GetPageSize(), + NextPageToken: t.NextPageToken, + Query: t.GetQuery(), + } +} + +func SignalWithStartWorkflowExecutionRequest(t *shared.SignalWithStartWorkflowExecutionRequest) *apiv1.SignalWithStartWorkflowExecutionRequest { + if t == nil { + return nil + } + return &apiv1.SignalWithStartWorkflowExecutionRequest{ + StartRequest: &apiv1.StartWorkflowExecutionRequest{ + Domain: t.GetDomain(), + WorkflowId: t.GetWorkflowId(), + WorkflowType: WorkflowType(t.WorkflowType), + TaskList: TaskList(t.TaskList), + Input: Payload(t.Input), + ExecutionStartToCloseTimeout: secondsToDuration(t.ExecutionStartToCloseTimeoutSeconds), + TaskStartToCloseTimeout: secondsToDuration(t.TaskStartToCloseTimeoutSeconds), + Identity: t.GetIdentity(), + RequestId: t.GetRequestId(), + WorkflowIdReusePolicy: WorkflowIdReusePolicy(t.WorkflowIdReusePolicy), + RetryPolicy: RetryPolicy(t.RetryPolicy), + CronSchedule: t.GetCronSchedule(), + Memo: Memo(t.Memo), + SearchAttributes: SearchAttributes(t.SearchAttributes), + Header: Header(t.Header), + DelayStart: secondsToDuration(t.DelayStartSeconds), + }, + SignalName: t.GetSignalName(), + SignalInput: Payload(t.SignalInput), + Control: t.Control, + } +} + +func SignalWorkflowExecutionRequest(t *shared.SignalWorkflowExecutionRequest) *apiv1.SignalWorkflowExecutionRequest { + if t == nil { + return nil + } + return &apiv1.SignalWorkflowExecutionRequest{ + Domain: t.GetDomain(), + WorkflowExecution: WorkflowExecution(t.WorkflowExecution), + SignalName: t.GetSignalName(), + SignalInput: Payload(t.Input), + Identity: t.GetIdentity(), + RequestId: t.GetRequestId(), + Control: t.Control, + } +} + +func StartWorkflowExecutionRequest(t *shared.StartWorkflowExecutionRequest) *apiv1.StartWorkflowExecutionRequest { + if t == nil { + return nil + } + return &apiv1.StartWorkflowExecutionRequest{ + Domain: t.GetDomain(), + WorkflowId: t.GetWorkflowId(), + WorkflowType: WorkflowType(t.WorkflowType), + TaskList: TaskList(t.TaskList), + Input: Payload(t.Input), + ExecutionStartToCloseTimeout: secondsToDuration(t.ExecutionStartToCloseTimeoutSeconds), + TaskStartToCloseTimeout: secondsToDuration(t.TaskStartToCloseTimeoutSeconds), + Identity: t.GetIdentity(), + RequestId: t.GetRequestId(), + WorkflowIdReusePolicy: WorkflowIdReusePolicy(t.WorkflowIdReusePolicy), + RetryPolicy: RetryPolicy(t.RetryPolicy), + CronSchedule: t.GetCronSchedule(), + Memo: Memo(t.Memo), + SearchAttributes: SearchAttributes(t.SearchAttributes), + Header: Header(t.Header), + DelayStart: secondsToDuration(t.DelayStartSeconds), + } +} + +func TerminateWorkflowExecutionRequest(t *shared.TerminateWorkflowExecutionRequest) *apiv1.TerminateWorkflowExecutionRequest { + if t == nil { + return nil + } + return &apiv1.TerminateWorkflowExecutionRequest{ + Domain: t.GetDomain(), + WorkflowExecution: WorkflowExecution(t.WorkflowExecution), + Reason: t.GetReason(), + Details: Payload(t.Details), + Identity: t.GetIdentity(), + } +} + +const ( + DomainUpdateDescriptionField = "description" + DomainUpdateOwnerEmailField = "owner_email" + DomainUpdateDataField = "data" + DomainUpdateRetentionPeriodField = "workflow_execution_retention_period" + DomainUpdateBadBinariesField = "bad_binaries" + DomainUpdateHistoryArchivalStatusField = "history_archival_status" + DomainUpdateHistoryArchivalURIField = "history_archival_uri" + DomainUpdateVisibilityArchivalStatusField = "visibility_archival_status" + DomainUpdateVisibilityArchivalURIField = "visibility_archival_uri" + DomainUpdateActiveClusterNameField = "active_cluster_name" + DomainUpdateClustersField = "clusters" + DomainUpdateDeleteBadBinaryField = "delete_bad_binary" + DomainUpdateFailoverTimeoutField = "failover_timeout" +) + +func UpdateDomainRequest(t *shared.UpdateDomainRequest) *apiv1.UpdateDomainRequest { + if t == nil { + return nil + } + request := apiv1.UpdateDomainRequest{ + Name: t.GetName(), + SecurityToken: t.GetSecurityToken(), + } + var fields []string + + if updatedInfo := t.GetUpdatedInfo(); updatedInfo != nil { + if updatedInfo.Description != nil { + request.Description = *updatedInfo.Description + fields = append(fields, DomainUpdateDescriptionField) + } + if updatedInfo.OwnerEmail != nil { + request.OwnerEmail = *updatedInfo.OwnerEmail + fields = append(fields, DomainUpdateOwnerEmailField) + } + if updatedInfo.Data != nil { + request.Data = updatedInfo.Data + fields = append(fields, DomainUpdateDataField) + } + } + if configuration := t.GetConfiguration(); configuration != nil { + if configuration.WorkflowExecutionRetentionPeriodInDays != nil { + request.WorkflowExecutionRetentionPeriod = daysToDuration(configuration.WorkflowExecutionRetentionPeriodInDays) + fields = append(fields, DomainUpdateRetentionPeriodField) + } + //if t.EmitMetric != nil {} - DEPRECATED + if configuration.BadBinaries != nil { + request.BadBinaries = BadBinaries(configuration.BadBinaries) + fields = append(fields, DomainUpdateBadBinariesField) + } + if configuration.HistoryArchivalStatus != nil { + request.HistoryArchivalStatus = ArchivalStatus(configuration.HistoryArchivalStatus) + fields = append(fields, DomainUpdateHistoryArchivalStatusField) + } + if configuration.HistoryArchivalURI != nil { + request.HistoryArchivalUri = *configuration.HistoryArchivalURI + fields = append(fields, DomainUpdateHistoryArchivalURIField) + } + if configuration.VisibilityArchivalStatus != nil { + request.VisibilityArchivalStatus = ArchivalStatus(configuration.VisibilityArchivalStatus) + fields = append(fields, DomainUpdateVisibilityArchivalStatusField) + } + if configuration.VisibilityArchivalURI != nil { + request.VisibilityArchivalUri = *configuration.VisibilityArchivalURI + fields = append(fields, DomainUpdateVisibilityArchivalURIField) + } + } + if replicationConfiguration := t.GetReplicationConfiguration(); replicationConfiguration != nil { + if replicationConfiguration.ActiveClusterName != nil { + request.ActiveClusterName = *replicationConfiguration.ActiveClusterName + fields = append(fields, DomainUpdateActiveClusterNameField) + } + if replicationConfiguration.Clusters != nil { + request.Clusters = ClusterReplicationConfigurationArray(replicationConfiguration.Clusters) + fields = append(fields, DomainUpdateClustersField) + } + } + if t.DeleteBadBinary != nil { + request.DeleteBadBinary = *t.DeleteBadBinary + fields = append(fields, DomainUpdateDeleteBadBinaryField) + } + if t.FailoverTimeoutInSeconds != nil { + request.FailoverTimeout = secondsToDuration(t.FailoverTimeoutInSeconds) + fields = append(fields, DomainUpdateFailoverTimeoutField) + } + + request.UpdateMask = newFieldMask(fields) + + return &request +} + +func ListClosedWorkflowExecutionsRequest(r *shared.ListClosedWorkflowExecutionsRequest) *apiv1.ListClosedWorkflowExecutionsRequest { + if r == nil { + return nil + } + request := apiv1.ListClosedWorkflowExecutionsRequest{ + Domain: r.GetDomain(), + PageSize: r.GetMaximumPageSize(), + NextPageToken: r.NextPageToken, + StartTimeFilter: StartTimeFilter(r.StartTimeFilter), + } + if r.ExecutionFilter != nil { + request.Filters = &apiv1.ListClosedWorkflowExecutionsRequest_ExecutionFilter{ + ExecutionFilter: WorkflowExecutionFilter(r.ExecutionFilter), + } + } + if r.TypeFilter != nil { + request.Filters = &apiv1.ListClosedWorkflowExecutionsRequest_TypeFilter{ + TypeFilter: WorkflowTypeFilter(r.TypeFilter), + } + } + if r.StatusFilter != nil { + request.Filters = &apiv1.ListClosedWorkflowExecutionsRequest_StatusFilter{ + StatusFilter: StatusFilter(r.StatusFilter), + } + } + + return &request +} + +func ListOpenWorkflowExecutionsRequest(r *shared.ListOpenWorkflowExecutionsRequest) *apiv1.ListOpenWorkflowExecutionsRequest { + if r == nil { + return nil + } + request := apiv1.ListOpenWorkflowExecutionsRequest{ + Domain: r.GetDomain(), + PageSize: r.GetMaximumPageSize(), + NextPageToken: r.NextPageToken, + StartTimeFilter: StartTimeFilter(r.StartTimeFilter), + } + if r.ExecutionFilter != nil { + request.Filters = &apiv1.ListOpenWorkflowExecutionsRequest_ExecutionFilter{ + ExecutionFilter: WorkflowExecutionFilter(r.ExecutionFilter), + } + } + if r.TypeFilter != nil { + request.Filters = &apiv1.ListOpenWorkflowExecutionsRequest_TypeFilter{ + TypeFilter: WorkflowTypeFilter(r.TypeFilter), + } + } + + return &request +} diff --git a/internal/compatibility/proto/response.go b/internal/compatibility/proto/response.go new file mode 100644 index 000000000..59acc4c16 --- /dev/null +++ b/internal/compatibility/proto/response.go @@ -0,0 +1,334 @@ +// Copyright (c) 2021 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +package proto + +import ( + "go.uber.org/cadence/.gen/go/shared" + apiv1 "go.uber.org/cadence/.gen/proto/api/v1" +) + +func CountWorkflowExecutionsResponse(t *shared.CountWorkflowExecutionsResponse) *apiv1.CountWorkflowExecutionsResponse { + if t == nil { + return nil + } + return &apiv1.CountWorkflowExecutionsResponse{ + Count: t.GetCount(), + } +} + +func DescribeDomainResponse(t *shared.DescribeDomainResponse) *apiv1.DescribeDomainResponse { + if t == nil { + return nil + } + domain := apiv1.Domain{ + FailoverVersion: t.GetFailoverVersion(), + IsGlobalDomain: t.GetIsGlobalDomain(), + } + if info := t.DomainInfo; info != nil { + domain.Id = info.GetUUID() + domain.Name = info.GetName() + domain.Status = DomainStatus(info.Status) + domain.Description = info.GetDescription() + domain.OwnerEmail = info.GetOwnerEmail() + domain.Data = info.Data + } + if config := t.Configuration; config != nil { + domain.WorkflowExecutionRetentionPeriod = daysToDuration(config.WorkflowExecutionRetentionPeriodInDays) + domain.BadBinaries = BadBinaries(config.BadBinaries) + domain.HistoryArchivalStatus = ArchivalStatus(config.HistoryArchivalStatus) + domain.HistoryArchivalUri = config.GetHistoryArchivalURI() + domain.VisibilityArchivalStatus = ArchivalStatus(config.VisibilityArchivalStatus) + domain.VisibilityArchivalUri = config.GetVisibilityArchivalURI() + } + if repl := t.ReplicationConfiguration; repl != nil { + domain.ActiveClusterName = repl.GetActiveClusterName() + domain.Clusters = ClusterReplicationConfigurationArray(repl.Clusters) + } + return &apiv1.DescribeDomainResponse{Domain: &domain} +} + +func DescribeTaskListResponse(t *shared.DescribeTaskListResponse) *apiv1.DescribeTaskListResponse { + if t == nil { + return nil + } + return &apiv1.DescribeTaskListResponse{ + Pollers: PollerInfoArray(t.Pollers), + TaskListStatus: TaskListStatus(t.TaskListStatus), + } +} + +func DescribeWorkflowExecutionResponse(t *shared.DescribeWorkflowExecutionResponse) *apiv1.DescribeWorkflowExecutionResponse { + if t == nil { + return nil + } + return &apiv1.DescribeWorkflowExecutionResponse{ + ExecutionConfiguration: WorkflowExecutionConfiguration(t.ExecutionConfiguration), + WorkflowExecutionInfo: WorkflowExecutionInfo(t.WorkflowExecutionInfo), + PendingActivities: PendingActivityInfoArray(t.PendingActivities), + PendingChildren: PendingChildExecutionInfoArray(t.PendingChildren), + PendingDecision: PendingDecisionInfo(t.PendingDecision), + } +} + +func GetClusterInfoResponse(t *shared.ClusterInfo) *apiv1.GetClusterInfoResponse { + if t == nil { + return nil + } + return &apiv1.GetClusterInfoResponse{ + SupportedClientVersions: SupportedClientVersions(t.SupportedClientVersions), + } +} + +func GetSearchAttributesResponse(t *shared.GetSearchAttributesResponse) *apiv1.GetSearchAttributesResponse { + if t == nil { + return nil + } + return &apiv1.GetSearchAttributesResponse{ + Keys: IndexedValueTypeMap(t.Keys), + } +} + +func GetWorkflowExecutionHistoryResponse(t *shared.GetWorkflowExecutionHistoryResponse) *apiv1.GetWorkflowExecutionHistoryResponse { + if t == nil { + return nil + } + return &apiv1.GetWorkflowExecutionHistoryResponse{ + History: History(t.History), + RawHistory: DataBlobArray(t.RawHistory), + NextPageToken: t.NextPageToken, + Archived: t.GetArchived(), + } +} + +func ListArchivedWorkflowExecutionsResponse(t *shared.ListArchivedWorkflowExecutionsResponse) *apiv1.ListArchivedWorkflowExecutionsResponse { + if t == nil { + return nil + } + return &apiv1.ListArchivedWorkflowExecutionsResponse{ + Executions: WorkflowExecutionInfoArray(t.Executions), + NextPageToken: t.NextPageToken, + } +} + +func ListClosedWorkflowExecutionsResponse(t *shared.ListClosedWorkflowExecutionsResponse) *apiv1.ListClosedWorkflowExecutionsResponse { + if t == nil { + return nil + } + return &apiv1.ListClosedWorkflowExecutionsResponse{ + Executions: WorkflowExecutionInfoArray(t.Executions), + NextPageToken: t.NextPageToken, + } +} + +func ListDomainsResponse(t *shared.ListDomainsResponse) *apiv1.ListDomainsResponse { + if t == nil { + return nil + } + return &apiv1.ListDomainsResponse{ + Domains: DescribeDomainResponseArray(t.Domains), + NextPageToken: t.NextPageToken, + } +} + +func ListOpenWorkflowExecutionsResponse(t *shared.ListOpenWorkflowExecutionsResponse) *apiv1.ListOpenWorkflowExecutionsResponse { + if t == nil { + return nil + } + return &apiv1.ListOpenWorkflowExecutionsResponse{ + Executions: WorkflowExecutionInfoArray(t.Executions), + NextPageToken: t.NextPageToken, + } +} + +func ListTaskListPartitionsResponse(t *shared.ListTaskListPartitionsResponse) *apiv1.ListTaskListPartitionsResponse { + if t == nil { + return nil + } + return &apiv1.ListTaskListPartitionsResponse{ + ActivityTaskListPartitions: TaskListPartitionMetadataArray(t.ActivityTaskListPartitions), + DecisionTaskListPartitions: TaskListPartitionMetadataArray(t.DecisionTaskListPartitions), + } +} + +func ListWorkflowExecutionsResponse(t *shared.ListWorkflowExecutionsResponse) *apiv1.ListWorkflowExecutionsResponse { + if t == nil { + return nil + } + return &apiv1.ListWorkflowExecutionsResponse{ + Executions: WorkflowExecutionInfoArray(t.Executions), + NextPageToken: t.NextPageToken, + } +} + +func PollForActivityTaskResponse(t *shared.PollForActivityTaskResponse) *apiv1.PollForActivityTaskResponse { + if t == nil { + return nil + } + return &apiv1.PollForActivityTaskResponse{ + TaskToken: t.TaskToken, + WorkflowExecution: WorkflowExecution(t.WorkflowExecution), + ActivityId: t.GetActivityId(), + ActivityType: ActivityType(t.ActivityType), + Input: Payload(t.Input), + ScheduledTime: unixNanoToTime(t.ScheduledTimestamp), + StartedTime: unixNanoToTime(t.StartedTimestamp), + ScheduleToCloseTimeout: secondsToDuration(t.ScheduleToCloseTimeoutSeconds), + StartToCloseTimeout: secondsToDuration(t.StartToCloseTimeoutSeconds), + HeartbeatTimeout: secondsToDuration(t.HeartbeatTimeoutSeconds), + Attempt: t.GetAttempt(), + ScheduledTimeOfThisAttempt: unixNanoToTime(t.ScheduledTimestampOfThisAttempt), + HeartbeatDetails: Payload(t.HeartbeatDetails), + WorkflowType: WorkflowType(t.WorkflowType), + WorkflowDomain: t.GetWorkflowDomain(), + Header: Header(t.Header), + } +} + +func PollForDecisionTaskResponse(t *shared.PollForDecisionTaskResponse) *apiv1.PollForDecisionTaskResponse { + if t == nil { + return nil + } + return &apiv1.PollForDecisionTaskResponse{ + TaskToken: t.TaskToken, + WorkflowExecution: WorkflowExecution(t.WorkflowExecution), + WorkflowType: WorkflowType(t.WorkflowType), + PreviousStartedEventId: fromInt64Value(t.PreviousStartedEventId), + StartedEventId: t.GetStartedEventId(), + Attempt: t.GetAttempt(), + BacklogCountHint: t.GetBacklogCountHint(), + History: History(t.History), + NextPageToken: t.NextPageToken, + Query: WorkflowQuery(t.Query), + WorkflowExecutionTaskList: TaskList(t.WorkflowExecutionTaskList), + ScheduledTime: unixNanoToTime(t.ScheduledTimestamp), + StartedTime: unixNanoToTime(t.StartedTimestamp), + Queries: WorkflowQueryMap(t.Queries), + NextEventId: t.GetNextEventId(), + } +} + +func QueryWorkflowResponse(t *shared.QueryWorkflowResponse) *apiv1.QueryWorkflowResponse { + if t == nil { + return nil + } + return &apiv1.QueryWorkflowResponse{ + QueryResult: Payload(t.QueryResult), + QueryRejected: QueryRejected(t.QueryRejected), + } +} + +func RecordActivityTaskHeartbeatByIdResponse(t *shared.RecordActivityTaskHeartbeatResponse) *apiv1.RecordActivityTaskHeartbeatByIDResponse { + if t == nil { + return nil + } + return &apiv1.RecordActivityTaskHeartbeatByIDResponse{ + CancelRequested: t.GetCancelRequested(), + } +} + +func RecordActivityTaskHeartbeatResponse(t *shared.RecordActivityTaskHeartbeatResponse) *apiv1.RecordActivityTaskHeartbeatResponse { + if t == nil { + return nil + } + return &apiv1.RecordActivityTaskHeartbeatResponse{ + CancelRequested: t.GetCancelRequested(), + } +} + +func ResetWorkflowExecutionResponse(t *shared.ResetWorkflowExecutionResponse) *apiv1.ResetWorkflowExecutionResponse { + if t == nil { + return nil + } + return &apiv1.ResetWorkflowExecutionResponse{ + RunId: t.GetRunId(), + } +} + +func RespondDecisionTaskCompletedResponse(t *shared.RespondDecisionTaskCompletedResponse) *apiv1.RespondDecisionTaskCompletedResponse { + if t == nil { + return nil + } + return &apiv1.RespondDecisionTaskCompletedResponse{ + DecisionTask: PollForDecisionTaskResponse(t.DecisionTask), + ActivitiesToDispatchLocally: ActivityLocalDispatchInfoMap(t.ActivitiesToDispatchLocally), + } +} + +func ScanWorkflowExecutionsResponse(t *shared.ListWorkflowExecutionsResponse) *apiv1.ScanWorkflowExecutionsResponse { + if t == nil { + return nil + } + return &apiv1.ScanWorkflowExecutionsResponse{ + Executions: WorkflowExecutionInfoArray(t.Executions), + NextPageToken: t.NextPageToken, + } +} + +func SignalWithStartWorkflowExecutionResponse(t *shared.StartWorkflowExecutionResponse) *apiv1.SignalWithStartWorkflowExecutionResponse { + if t == nil { + return nil + } + return &apiv1.SignalWithStartWorkflowExecutionResponse{ + RunId: t.GetRunId(), + } +} + +func StartWorkflowExecutionResponse(t *shared.StartWorkflowExecutionResponse) *apiv1.StartWorkflowExecutionResponse { + if t == nil { + return nil + } + return &apiv1.StartWorkflowExecutionResponse{ + RunId: t.GetRunId(), + } +} + +func UpdateDomainResponse(t *shared.UpdateDomainResponse) *apiv1.UpdateDomainResponse { + if t == nil { + return nil + } + domain := &apiv1.Domain{ + FailoverVersion: t.GetFailoverVersion(), + IsGlobalDomain: t.GetIsGlobalDomain(), + } + if info := t.DomainInfo; info != nil { + domain.Id = info.GetUUID() + domain.Name = info.GetName() + domain.Status = DomainStatus(info.Status) + domain.Description = info.GetDescription() + domain.OwnerEmail = info.GetOwnerEmail() + domain.Data = info.Data + } + if config := t.Configuration; config != nil { + domain.WorkflowExecutionRetentionPeriod = daysToDuration(config.WorkflowExecutionRetentionPeriodInDays) + domain.BadBinaries = BadBinaries(config.BadBinaries) + domain.HistoryArchivalStatus = ArchivalStatus(config.HistoryArchivalStatus) + domain.HistoryArchivalUri = config.GetHistoryArchivalURI() + domain.VisibilityArchivalStatus = ArchivalStatus(config.VisibilityArchivalStatus) + domain.VisibilityArchivalUri = config.GetVisibilityArchivalURI() + } + if repl := t.ReplicationConfiguration; repl != nil { + domain.ActiveClusterName = repl.GetActiveClusterName() + domain.Clusters = ClusterReplicationConfigurationArray(repl.Clusters) + } + return &apiv1.UpdateDomainResponse{ + Domain: domain, + } +} diff --git a/internal/compatibility/proto/types.go b/internal/compatibility/proto/types.go new file mode 100644 index 000000000..3d14ad783 --- /dev/null +++ b/internal/compatibility/proto/types.go @@ -0,0 +1,686 @@ +// Copyright (c) 2021 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +package proto + +import ( + "go.uber.org/cadence/.gen/go/shared" + apiv1 "go.uber.org/cadence/.gen/proto/api/v1" +) + +func Payload(data []byte) *apiv1.Payload { + if data == nil { + return nil + } + return &apiv1.Payload{ + Data: data, + } +} + +func Failure(reason *string, details []byte) *apiv1.Failure { + if reason == nil { + return nil + } + return &apiv1.Failure{ + Reason: *reason, + Details: details, + } +} + +func WorkflowExecution(t *shared.WorkflowExecution) *apiv1.WorkflowExecution { + if t == nil { + return nil + } + if t.WorkflowId == nil && t.RunId == nil { + return nil + } + return &apiv1.WorkflowExecution{ + WorkflowId: t.GetWorkflowId(), + RunId: t.GetRunId(), + } +} + +func WorkflowRunPair(workflowId, runId *string) *apiv1.WorkflowExecution { + if workflowId == nil && runId == nil { + return nil + } + return &apiv1.WorkflowExecution{ + WorkflowId: *workflowId, + RunId: *runId, + } +} + +func ActivityType(t *shared.ActivityType) *apiv1.ActivityType { + if t == nil { + return nil + } + return &apiv1.ActivityType{ + Name: t.GetName(), + } +} + +func WorkflowType(t *shared.WorkflowType) *apiv1.WorkflowType { + if t == nil { + return nil + } + return &apiv1.WorkflowType{ + Name: t.GetName(), + } +} + +func TaskList(t *shared.TaskList) *apiv1.TaskList { + if t == nil { + return nil + } + return &apiv1.TaskList{ + Name: t.GetName(), + Kind: TaskListKind(t.Kind), + } +} + +func TaskListMetadata(t *shared.TaskListMetadata) *apiv1.TaskListMetadata { + if t == nil { + return nil + } + return &apiv1.TaskListMetadata{ + MaxTasksPerSecond: fromDoubleValue(t.MaxTasksPerSecond), + } +} + +func RetryPolicy(t *shared.RetryPolicy) *apiv1.RetryPolicy { + if t == nil { + return nil + } + return &apiv1.RetryPolicy{ + InitialInterval: secondsToDuration(t.InitialIntervalInSeconds), + BackoffCoefficient: t.GetBackoffCoefficient(), + MaximumInterval: secondsToDuration(t.MaximumIntervalInSeconds), + MaximumAttempts: t.GetMaximumAttempts(), + NonRetryableErrorReasons: t.NonRetriableErrorReasons, + ExpirationInterval: secondsToDuration(t.ExpirationIntervalInSeconds), + } +} + +func Header(t *shared.Header) *apiv1.Header { + if t == nil { + return nil + } + return &apiv1.Header{ + Fields: PayloadMap(t.Fields), + } +} + +func Memo(t *shared.Memo) *apiv1.Memo { + if t == nil { + return nil + } + return &apiv1.Memo{ + Fields: PayloadMap(t.Fields), + } +} + +func SearchAttributes(t *shared.SearchAttributes) *apiv1.SearchAttributes { + if t == nil { + return nil + } + return &apiv1.SearchAttributes{ + IndexedFields: PayloadMap(t.IndexedFields), + } +} + +func BadBinaries(t *shared.BadBinaries) *apiv1.BadBinaries { + if t == nil { + return nil + } + return &apiv1.BadBinaries{ + Binaries: BadBinaryInfoMap(t.Binaries), + } +} + +func BadBinaryInfo(t *shared.BadBinaryInfo) *apiv1.BadBinaryInfo { + if t == nil { + return nil + } + return &apiv1.BadBinaryInfo{ + Reason: t.GetReason(), + Operator: t.GetOperator(), + CreatedTime: unixNanoToTime(t.CreatedTimeNano), + } +} + +func ClusterReplicationConfiguration(t *shared.ClusterReplicationConfiguration) *apiv1.ClusterReplicationConfiguration { + if t == nil { + return nil + } + return &apiv1.ClusterReplicationConfiguration{ + ClusterName: t.GetClusterName(), + } +} + +func WorkflowQuery(t *shared.WorkflowQuery) *apiv1.WorkflowQuery { + if t == nil { + return nil + } + return &apiv1.WorkflowQuery{ + QueryType: t.GetQueryType(), + QueryArgs: Payload(t.QueryArgs), + } +} + +func WorkflowQueryResult(t *shared.WorkflowQueryResult) *apiv1.WorkflowQueryResult { + if t == nil { + return nil + } + return &apiv1.WorkflowQueryResult{ + ResultType: QueryResultType(t.ResultType), + Answer: Payload(t.Answer), + ErrorMessage: t.GetErrorMessage(), + } +} + +func StickyExecutionAttributes(t *shared.StickyExecutionAttributes) *apiv1.StickyExecutionAttributes { + if t == nil { + return nil + } + return &apiv1.StickyExecutionAttributes{ + WorkerTaskList: TaskList(t.WorkerTaskList), + ScheduleToStartTimeout: secondsToDuration(t.ScheduleToStartTimeoutSeconds), + } +} + +func WorkerVersionInfo(t *shared.WorkerVersionInfo) *apiv1.WorkerVersionInfo { + if t == nil { + return nil + } + return &apiv1.WorkerVersionInfo{ + Impl: t.GetImpl(), + FeatureVersion: t.GetFeatureVersion(), + } +} + +func StartTimeFilter(t *shared.StartTimeFilter) *apiv1.StartTimeFilter { + if t == nil { + return nil + } + return &apiv1.StartTimeFilter{ + EarliestTime: unixNanoToTime(t.EarliestTime), + LatestTime: unixNanoToTime(t.LatestTime), + } +} + +func WorkflowExecutionFilter(t *shared.WorkflowExecutionFilter) *apiv1.WorkflowExecutionFilter { + if t == nil { + return nil + } + return &apiv1.WorkflowExecutionFilter{ + WorkflowId: t.GetWorkflowId(), + RunId: t.GetRunId(), + } +} + +func WorkflowTypeFilter(t *shared.WorkflowTypeFilter) *apiv1.WorkflowTypeFilter { + if t == nil { + return nil + } + return &apiv1.WorkflowTypeFilter{ + Name: t.GetName(), + } +} + +func StatusFilter(t *shared.WorkflowExecutionCloseStatus) *apiv1.StatusFilter { + if t == nil { + return nil + } + return &apiv1.StatusFilter{ + Status: WorkflowExecutionCloseStatus(t), + } +} + +func PayloadMap(t map[string][]byte) map[string]*apiv1.Payload { + if t == nil { + return nil + } + v := make(map[string]*apiv1.Payload, len(t)) + for key := range t { + v[key] = Payload(t[key]) + } + return v +} + +func BadBinaryInfoMap(t map[string]*shared.BadBinaryInfo) map[string]*apiv1.BadBinaryInfo { + if t == nil { + return nil + } + v := make(map[string]*apiv1.BadBinaryInfo, len(t)) + for key := range t { + v[key] = BadBinaryInfo(t[key]) + } + return v +} + +func ClusterReplicationConfigurationArray(t []*shared.ClusterReplicationConfiguration) []*apiv1.ClusterReplicationConfiguration { + if t == nil { + return nil + } + v := make([]*apiv1.ClusterReplicationConfiguration, len(t)) + for i := range t { + v[i] = ClusterReplicationConfiguration(t[i]) + } + return v +} + +func WorkflowQueryResultMap(t map[string]*shared.WorkflowQueryResult) map[string]*apiv1.WorkflowQueryResult { + if t == nil { + return nil + } + v := make(map[string]*apiv1.WorkflowQueryResult, len(t)) + for key := range t { + v[key] = WorkflowQueryResult(t[key]) + } + return v +} + +func DataBlob(t *shared.DataBlob) *apiv1.DataBlob { + if t == nil { + return nil + } + return &apiv1.DataBlob{ + EncodingType: EncodingType(t.EncodingType), + Data: t.Data, + } +} + +func ExternalExecutionInfo(we *shared.WorkflowExecution, initiatedID *int64) *apiv1.ExternalExecutionInfo { + if we == nil && initiatedID == nil { + return nil + } + if we == nil || initiatedID == nil { + panic("either all or none external execution info fields must be set") + } + return &apiv1.ExternalExecutionInfo{ + WorkflowExecution: WorkflowExecution(we), + InitiatedId: *initiatedID, + } +} + +func ResetPoints(t *shared.ResetPoints) *apiv1.ResetPoints { + if t == nil { + return nil + } + return &apiv1.ResetPoints{ + Points: ResetPointInfoArray(t.Points), + } +} + +func ResetPointInfo(t *shared.ResetPointInfo) *apiv1.ResetPointInfo { + if t == nil { + return nil + } + return &apiv1.ResetPointInfo{ + BinaryChecksum: t.GetBinaryChecksum(), + RunId: t.GetRunId(), + FirstDecisionCompletedId: t.GetFirstDecisionCompletedId(), + CreatedTime: unixNanoToTime(t.CreatedTimeNano), + ExpiringTime: unixNanoToTime(t.ExpiringTimeNano), + Resettable: t.GetResettable(), + } +} + +func PollerInfo(t *shared.PollerInfo) *apiv1.PollerInfo { + if t == nil { + return nil + } + return &apiv1.PollerInfo{ + LastAccessTime: unixNanoToTime(t.LastAccessTime), + Identity: t.GetIdentity(), + RatePerSecond: t.GetRatePerSecond(), + } +} + +func TaskListStatus(t *shared.TaskListStatus) *apiv1.TaskListStatus { + if t == nil { + return nil + } + return &apiv1.TaskListStatus{ + BacklogCountHint: t.GetBacklogCountHint(), + ReadLevel: t.GetReadLevel(), + AckLevel: t.GetAckLevel(), + RatePerSecond: t.GetRatePerSecond(), + TaskIdBlock: TaskIdBlock(t.TaskIDBlock), + } +} + +func TaskIdBlock(t *shared.TaskIDBlock) *apiv1.TaskIDBlock { + if t == nil { + return nil + } + return &apiv1.TaskIDBlock{ + StartId: t.GetStartID(), + EndId: t.GetEndID(), + } +} + +func WorkflowExecutionConfiguration(t *shared.WorkflowExecutionConfiguration) *apiv1.WorkflowExecutionConfiguration { + if t == nil { + return nil + } + return &apiv1.WorkflowExecutionConfiguration{ + TaskList: TaskList(t.TaskList), + ExecutionStartToCloseTimeout: secondsToDuration(t.ExecutionStartToCloseTimeoutSeconds), + TaskStartToCloseTimeout: secondsToDuration(t.TaskStartToCloseTimeoutSeconds), + } +} + +func WorkflowExecutionInfo(t *shared.WorkflowExecutionInfo) *apiv1.WorkflowExecutionInfo { + if t == nil { + return nil + } + return &apiv1.WorkflowExecutionInfo{ + WorkflowExecution: WorkflowExecution(t.Execution), + Type: WorkflowType(t.Type), + StartTime: unixNanoToTime(t.StartTime), + CloseTime: unixNanoToTime(t.CloseTime), + CloseStatus: WorkflowExecutionCloseStatus(t.CloseStatus), + HistoryLength: t.GetHistoryLength(), + ParentExecutionInfo: ParentExecutionInfo2(t.ParentDomainId, t.ParentExecution), + ExecutionTime: unixNanoToTime(t.ExecutionTime), + Memo: Memo(t.Memo), + SearchAttributes: SearchAttributes(t.SearchAttributes), + AutoResetPoints: ResetPoints(t.AutoResetPoints), + TaskList: t.GetTaskList(), + IsCron: t.GetIsCron(), + } +} + +func ParentExecutionInfo(domainID, domainName *string, we *shared.WorkflowExecution, initiatedID *int64) *apiv1.ParentExecutionInfo { + if domainID == nil && domainName == nil && we == nil && initiatedID == nil { + return nil + } + if domainName == nil || we == nil || initiatedID == nil { + panic("either all or none parent execution info must be set") + } + + // Domain ID was added to unify parent execution info in several places. + // However it may not be present: + // - on older histories + // - if conversion involves thrift data types + // Fallback to empty string in those cases + parentDomainID := "" + if domainID != nil { + parentDomainID = *domainID + } + + return &apiv1.ParentExecutionInfo{ + DomainId: parentDomainID, + DomainName: *domainName, + WorkflowExecution: WorkflowExecution(we), + InitiatedId: *initiatedID, + } +} + +func ParentExecutionInfo2(domainID *string, we *shared.WorkflowExecution) *apiv1.ParentExecutionInfo { + if domainID == nil && we == nil { + return nil + } + + return &apiv1.ParentExecutionInfo{ + DomainId: *domainID, + WorkflowExecution: WorkflowExecution(we), + } +} + +func PendingActivityInfo(t *shared.PendingActivityInfo) *apiv1.PendingActivityInfo { + if t == nil { + return nil + } + return &apiv1.PendingActivityInfo{ + ActivityId: t.GetActivityID(), + ActivityType: ActivityType(t.ActivityType), + State: PendingActivityState(t.State), + HeartbeatDetails: Payload(t.HeartbeatDetails), + LastHeartbeatTime: unixNanoToTime(t.LastHeartbeatTimestamp), + LastStartedTime: unixNanoToTime(t.LastStartedTimestamp), + Attempt: t.GetAttempt(), + MaximumAttempts: t.GetMaximumAttempts(), + ScheduledTime: unixNanoToTime(t.ScheduledTimestamp), + ExpirationTime: unixNanoToTime(t.ExpirationTimestamp), + LastFailure: Failure(t.LastFailureReason, t.LastFailureDetails), + LastWorkerIdentity: t.GetLastWorkerIdentity(), + } +} + +func PendingChildExecutionInfo(t *shared.PendingChildExecutionInfo) *apiv1.PendingChildExecutionInfo { + if t == nil { + return nil + } + return &apiv1.PendingChildExecutionInfo{ + WorkflowExecution: WorkflowRunPair(t.WorkflowID, t.RunID), + WorkflowTypeName: t.GetWorkflowTypName(), + InitiatedId: t.GetInitiatedID(), + ParentClosePolicy: ParentClosePolicy(t.ParentClosePolicy), + } +} + +func PendingDecisionInfo(t *shared.PendingDecisionInfo) *apiv1.PendingDecisionInfo { + if t == nil { + return nil + } + return &apiv1.PendingDecisionInfo{ + State: PendingDecisionState(t.State), + ScheduledTime: unixNanoToTime(t.ScheduledTimestamp), + StartedTime: unixNanoToTime(t.StartedTimestamp), + Attempt: int32(t.GetAttempt()), + OriginalScheduledTime: unixNanoToTime(t.OriginalScheduledTimestamp), + } +} + +func ActivityLocalDispatchInfo(t *shared.ActivityLocalDispatchInfo) *apiv1.ActivityLocalDispatchInfo { + if t == nil { + return nil + } + return &apiv1.ActivityLocalDispatchInfo{ + ActivityId: t.GetActivityId(), + ScheduledTime: unixNanoToTime(t.ScheduledTimestamp), + StartedTime: unixNanoToTime(t.StartedTimestamp), + ScheduledTimeOfThisAttempt: unixNanoToTime(t.ScheduledTimestampOfThisAttempt), + TaskToken: t.TaskToken, + } +} + +func SupportedClientVersions(t *shared.SupportedClientVersions) *apiv1.SupportedClientVersions { + if t == nil { + return nil + } + return &apiv1.SupportedClientVersions{ + GoSdk: t.GetGoSdk(), + JavaSdk: t.GetJavaSdk(), + } +} + +func DescribeDomainResponseDomain(t *shared.DescribeDomainResponse) *apiv1.Domain { + if t == nil { + return nil + } + domain := apiv1.Domain{ + FailoverVersion: t.GetFailoverVersion(), + IsGlobalDomain: t.GetIsGlobalDomain(), + } + if info := t.DomainInfo; info != nil { + domain.Id = info.GetUUID() + domain.Name = info.GetName() + domain.Status = DomainStatus(info.Status) + domain.Description = info.GetDescription() + domain.OwnerEmail = info.GetOwnerEmail() + domain.Data = info.Data + } + if config := t.Configuration; config != nil { + domain.WorkflowExecutionRetentionPeriod = daysToDuration(config.WorkflowExecutionRetentionPeriodInDays) + domain.BadBinaries = BadBinaries(config.BadBinaries) + domain.HistoryArchivalStatus = ArchivalStatus(config.HistoryArchivalStatus) + domain.HistoryArchivalUri = config.GetHistoryArchivalURI() + domain.VisibilityArchivalStatus = ArchivalStatus(config.VisibilityArchivalStatus) + domain.VisibilityArchivalUri = config.GetVisibilityArchivalURI() + } + if repl := t.ReplicationConfiguration; repl != nil { + domain.ActiveClusterName = repl.GetActiveClusterName() + domain.Clusters = ClusterReplicationConfigurationArray(repl.Clusters) + } + return &domain +} + +func TaskListPartitionMetadata(t *shared.TaskListPartitionMetadata) *apiv1.TaskListPartitionMetadata { + if t == nil { + return nil + } + return &apiv1.TaskListPartitionMetadata{ + Key: t.GetKey(), + OwnerHostName: t.GetOwnerHostName(), + } +} + +func QueryRejected(t *shared.QueryRejected) *apiv1.QueryRejected { + if t == nil { + return nil + } + return &apiv1.QueryRejected{ + CloseStatus: WorkflowExecutionCloseStatus(t.CloseStatus), + } +} + +func PollerInfoArray(t []*shared.PollerInfo) []*apiv1.PollerInfo { + if t == nil { + return nil + } + v := make([]*apiv1.PollerInfo, len(t)) + for i := range t { + v[i] = PollerInfo(t[i]) + } + return v +} + +func ResetPointInfoArray(t []*shared.ResetPointInfo) []*apiv1.ResetPointInfo { + if t == nil { + return nil + } + v := make([]*apiv1.ResetPointInfo, len(t)) + for i := range t { + v[i] = ResetPointInfo(t[i]) + } + return v +} + +func PendingActivityInfoArray(t []*shared.PendingActivityInfo) []*apiv1.PendingActivityInfo { + if t == nil { + return nil + } + v := make([]*apiv1.PendingActivityInfo, len(t)) + for i := range t { + v[i] = PendingActivityInfo(t[i]) + } + return v +} + +func PendingChildExecutionInfoArray(t []*shared.PendingChildExecutionInfo) []*apiv1.PendingChildExecutionInfo { + if t == nil { + return nil + } + v := make([]*apiv1.PendingChildExecutionInfo, len(t)) + for i := range t { + v[i] = PendingChildExecutionInfo(t[i]) + } + return v +} + +func IndexedValueTypeMap(t map[string]shared.IndexedValueType) map[string]apiv1.IndexedValueType { + if t == nil { + return nil + } + v := make(map[string]apiv1.IndexedValueType, len(t)) + for key := range t { + v[key] = IndexedValueType(t[key]) + } + return v +} + +func DataBlobArray(t []*shared.DataBlob) []*apiv1.DataBlob { + if t == nil { + return nil + } + v := make([]*apiv1.DataBlob, len(t)) + for i := range t { + v[i] = DataBlob(t[i]) + } + return v +} + +func WorkflowExecutionInfoArray(t []*shared.WorkflowExecutionInfo) []*apiv1.WorkflowExecutionInfo { + if t == nil { + return nil + } + v := make([]*apiv1.WorkflowExecutionInfo, len(t)) + for i := range t { + v[i] = WorkflowExecutionInfo(t[i]) + } + return v +} + +func DescribeDomainResponseArray(t []*shared.DescribeDomainResponse) []*apiv1.Domain { + if t == nil { + return nil + } + v := make([]*apiv1.Domain, len(t)) + for i := range t { + v[i] = DescribeDomainResponseDomain(t[i]) + } + return v +} + +func TaskListPartitionMetadataArray(t []*shared.TaskListPartitionMetadata) []*apiv1.TaskListPartitionMetadata { + if t == nil { + return nil + } + v := make([]*apiv1.TaskListPartitionMetadata, len(t)) + for i := range t { + v[i] = TaskListPartitionMetadata(t[i]) + } + return v +} + +func WorkflowQueryMap(t map[string]*shared.WorkflowQuery) map[string]*apiv1.WorkflowQuery { + if t == nil { + return nil + } + v := make(map[string]*apiv1.WorkflowQuery, len(t)) + for key := range t { + v[key] = WorkflowQuery(t[key]) + } + return v +} + +func ActivityLocalDispatchInfoMap(t map[string]*shared.ActivityLocalDispatchInfo) map[string]*apiv1.ActivityLocalDispatchInfo { + if t == nil { + return nil + } + v := make(map[string]*apiv1.ActivityLocalDispatchInfo, len(t)) + for key := range t { + v[key] = ActivityLocalDispatchInfo(t[key]) + } + return v +} diff --git a/internal/compatibility/request.go b/internal/compatibility/request.go deleted file mode 100644 index 45b6df5d7..000000000 --- a/internal/compatibility/request.go +++ /dev/null @@ -1,1270 +0,0 @@ -// Copyright (c) 2021 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -package compatibility - -import ( - "go.uber.org/cadence/.gen/go/shared" - apiv1 "go.uber.org/cadence/.gen/proto/api/v1" -) - -func protoCountWorkflowExecutionsRequest(t *shared.CountWorkflowExecutionsRequest) *apiv1.CountWorkflowExecutionsRequest { - if t == nil { - return nil - } - return &apiv1.CountWorkflowExecutionsRequest{ - Domain: t.GetDomain(), - Query: t.GetQuery(), - } -} - -func protoDeprecateDomainRequest(t *shared.DeprecateDomainRequest) *apiv1.DeprecateDomainRequest { - if t == nil { - return nil - } - return &apiv1.DeprecateDomainRequest{ - Name: t.GetName(), - SecurityToken: t.GetSecurityToken(), - } -} - -func protoDescribeDomainRequest(t *shared.DescribeDomainRequest) *apiv1.DescribeDomainRequest { - if t == nil { - return nil - } - if t.UUID != nil { - return &apiv1.DescribeDomainRequest{DescribeBy: &apiv1.DescribeDomainRequest_Id{Id: *t.UUID}} - } - if t.Name != nil { - return &apiv1.DescribeDomainRequest{DescribeBy: &apiv1.DescribeDomainRequest_Name{Name: *t.Name}} - } - panic("neither oneof field is set for DescribeDomainRequest") -} - -func protoDescribeTaskListRequest(t *shared.DescribeTaskListRequest) *apiv1.DescribeTaskListRequest { - if t == nil { - return nil - } - return &apiv1.DescribeTaskListRequest{ - Domain: t.GetDomain(), - TaskList: protoTaskList(t.TaskList), - TaskListType: protoTaskListType(t.TaskListType), - IncludeTaskListStatus: t.GetIncludeTaskListStatus(), - } -} - -func protoDescribeWorkflowExecutionRequest(t *shared.DescribeWorkflowExecutionRequest) *apiv1.DescribeWorkflowExecutionRequest { - if t == nil { - return nil - } - return &apiv1.DescribeWorkflowExecutionRequest{ - Domain: t.GetDomain(), - WorkflowExecution: protoWorkflowExecution(t.Execution), - } -} - -func protoGetWorkflowExecutionHistoryRequest(t *shared.GetWorkflowExecutionHistoryRequest) *apiv1.GetWorkflowExecutionHistoryRequest { - if t == nil { - return nil - } - return &apiv1.GetWorkflowExecutionHistoryRequest{ - Domain: t.GetDomain(), - WorkflowExecution: protoWorkflowExecution(t.Execution), - PageSize: t.GetMaximumPageSize(), - NextPageToken: t.GetNextPageToken(), - WaitForNewEvent: t.GetWaitForNewEvent(), - HistoryEventFilterType: protoEventFilterType(t.HistoryEventFilterType), - SkipArchival: t.GetSkipArchival(), - } -} - -func protoListArchivedWorkflowExecutionsRequest(t *shared.ListArchivedWorkflowExecutionsRequest) *apiv1.ListArchivedWorkflowExecutionsRequest { - if t == nil { - return nil - } - return &apiv1.ListArchivedWorkflowExecutionsRequest{ - Domain: t.GetDomain(), - PageSize: t.GetPageSize(), - NextPageToken: t.GetNextPageToken(), - Query: t.GetQuery(), - } -} - -func protoListDomainsRequest(t *shared.ListDomainsRequest) *apiv1.ListDomainsRequest { - if t == nil { - return nil - } - return &apiv1.ListDomainsRequest{ - PageSize: t.GetPageSize(), - NextPageToken: t.NextPageToken, - } -} - -func protoListTaskListPartitionsRequest(t *shared.ListTaskListPartitionsRequest) *apiv1.ListTaskListPartitionsRequest { - if t == nil { - return nil - } - return &apiv1.ListTaskListPartitionsRequest{ - Domain: t.GetDomain(), - TaskList: protoTaskList(t.TaskList), - } -} - -func protoListWorkflowExecutionsRequest(t *shared.ListWorkflowExecutionsRequest) *apiv1.ListWorkflowExecutionsRequest { - if t == nil { - return nil - } - return &apiv1.ListWorkflowExecutionsRequest{ - Domain: t.GetDomain(), - PageSize: t.GetPageSize(), - NextPageToken: t.NextPageToken, - Query: t.GetQuery(), - } -} - -func protoPollForActivityTaskRequest(t *shared.PollForActivityTaskRequest) *apiv1.PollForActivityTaskRequest { - if t == nil { - return nil - } - return &apiv1.PollForActivityTaskRequest{ - Domain: t.GetDomain(), - TaskList: protoTaskList(t.TaskList), - Identity: t.GetIdentity(), - TaskListMetadata: protoTaskListMetadata(t.TaskListMetadata), - } -} - -func protoPollForDecisionTaskRequest(t *shared.PollForDecisionTaskRequest) *apiv1.PollForDecisionTaskRequest { - if t == nil { - return nil - } - return &apiv1.PollForDecisionTaskRequest{ - Domain: t.GetDomain(), - TaskList: protoTaskList(t.TaskList), - Identity: t.GetIdentity(), - BinaryChecksum: t.GetBinaryChecksum(), - } -} - - -func protoQueryWorkflowRequest(t *shared.QueryWorkflowRequest) *apiv1.QueryWorkflowRequest { - if t == nil { - return nil - } - return &apiv1.QueryWorkflowRequest{ - Domain: t.GetDomain(), - WorkflowExecution: protoWorkflowExecution(t.Execution), - Query: protoWorkflowQuery(t.Query), - QueryRejectCondition: protoQueryRejectCondition(t.QueryRejectCondition), - QueryConsistencyLevel: protoQueryConsistencyLevel(t.QueryConsistencyLevel), - } -} - -func protoRecordActivityTaskHeartbeatByIdRequest(t *shared.RecordActivityTaskHeartbeatByIDRequest) *apiv1.RecordActivityTaskHeartbeatByIDRequest { - if t == nil { - return nil - } - return &apiv1.RecordActivityTaskHeartbeatByIDRequest{ - Domain: t.GetDomain(), - WorkflowExecution: protoWorkflowRunPair(t.GetWorkflowID(), t.GetRunID()), - ActivityId: t.GetActivityID(), - Details: protoPayload(t.Details), - Identity: t.GetIdentity(), - } -} - -func protoRecordActivityTaskHeartbeatRequest(t *shared.RecordActivityTaskHeartbeatRequest) *apiv1.RecordActivityTaskHeartbeatRequest { - if t == nil { - return nil - } - return &apiv1.RecordActivityTaskHeartbeatRequest{ - TaskToken: t.TaskToken, - Details: protoPayload(t.Details), - Identity: t.GetIdentity(), - } -} - -func protoRegisterDomainRequest(t *shared.RegisterDomainRequest) *apiv1.RegisterDomainRequest { - if t == nil { - return nil - } - return &apiv1.RegisterDomainRequest{ - Name: t.GetName(), - Description: t.GetDescription(), - OwnerEmail: t.GetOwnerEmail(), - WorkflowExecutionRetentionPeriod: daysToDuration(t.WorkflowExecutionRetentionPeriodInDays), - Clusters: protoClusterReplicationConfigurationArray(t.Clusters), - ActiveClusterName: t.GetActiveClusterName(), - Data: t.Data, - SecurityToken: t.GetSecurityToken(), - IsGlobalDomain: t.GetIsGlobalDomain(), - HistoryArchivalStatus: protoArchivalStatus(t.HistoryArchivalStatus), - HistoryArchivalUri: t.GetHistoryArchivalURI(), - VisibilityArchivalStatus: protoArchivalStatus(t.VisibilityArchivalStatus), - VisibilityArchivalUri: t.GetVisibilityArchivalURI(), - } -} - -func protoRequestCancelWorkflowExecutionRequest(t *shared.RequestCancelWorkflowExecutionRequest) *apiv1.RequestCancelWorkflowExecutionRequest { - if t == nil { - return nil - } - return &apiv1.RequestCancelWorkflowExecutionRequest{ - Domain: t.GetDomain(), - WorkflowExecution: protoWorkflowExecution(t.WorkflowExecution), - Identity: t.GetIdentity(), - RequestId: t.GetRequestId(), - } -} - -func protoResetStickyTaskListRequest(t *shared.ResetStickyTaskListRequest) *apiv1.ResetStickyTaskListRequest { - if t == nil { - return nil - } - return &apiv1.ResetStickyTaskListRequest{ - Domain: t.GetDomain(), - WorkflowExecution: protoWorkflowExecution(t.Execution), - } -} - -func protoResetWorkflowExecutionRequest(t *shared.ResetWorkflowExecutionRequest) *apiv1.ResetWorkflowExecutionRequest { - if t == nil { - return nil - } - return &apiv1.ResetWorkflowExecutionRequest{ - Domain: t.GetDomain(), - WorkflowExecution: protoWorkflowExecution(t.WorkflowExecution), - Reason: t.GetReason(), - DecisionFinishEventId: t.GetDecisionFinishEventId(), - RequestId: t.GetRequestId(), - SkipSignalReapply: t.GetSkipSignalReapply(), - } -} - -func protoRespondActivityTaskCanceledByIdRequest(t *shared.RespondActivityTaskCanceledByIDRequest) *apiv1.RespondActivityTaskCanceledByIDRequest { - if t == nil { - return nil - } - return &apiv1.RespondActivityTaskCanceledByIDRequest{ - Domain: t.GetDomain(), - WorkflowExecution: protoWorkflowRunPair(t.GetWorkflowID(), t.GetRunID()), - ActivityId: t.GetActivityID(), - Details: protoPayload(t.Details), - Identity: t.GetIdentity(), - } -} - -func protoRespondActivityTaskCanceledRequest(t *shared.RespondActivityTaskCanceledRequest) *apiv1.RespondActivityTaskCanceledRequest { - if t == nil { - return nil - } - return &apiv1.RespondActivityTaskCanceledRequest{ - TaskToken: t.TaskToken, - Details: protoPayload(t.Details), - Identity: t.GetIdentity(), - } -} - -func protoRespondActivityTaskCompletedByIdRequest(t *shared.RespondActivityTaskCompletedByIDRequest) *apiv1.RespondActivityTaskCompletedByIDRequest { - if t == nil { - return nil - } - return &apiv1.RespondActivityTaskCompletedByIDRequest{ - Domain: t.GetDomain(), - WorkflowExecution: protoWorkflowRunPair(t.GetWorkflowID(), t.GetRunID()), - ActivityId: t.GetActivityID(), - Result: protoPayload(t.Result), - Identity: t.GetIdentity(), - } -} - -func protoRespondActivityTaskCompletedRequest(t *shared.RespondActivityTaskCompletedRequest) *apiv1.RespondActivityTaskCompletedRequest { - if t == nil { - return nil - } - return &apiv1.RespondActivityTaskCompletedRequest{ - TaskToken: t.TaskToken, - Result: protoPayload(t.Result), - Identity: t.GetIdentity(), - } -} - -func protoRespondActivityTaskFailedByIdRequest(t *shared.RespondActivityTaskFailedByIDRequest) *apiv1.RespondActivityTaskFailedByIDRequest { - if t == nil { - return nil - } - return &apiv1.RespondActivityTaskFailedByIDRequest{ - Domain: t.GetDomain(), - WorkflowExecution: protoWorkflowRunPair(t.GetWorkflowID(), t.GetRunID()), - ActivityId: t.GetActivityID(), - Failure: protoFailure(t.Reason, t.Details), - Identity: t.GetIdentity(), - } -} - -func protoRespondActivityTaskFailedRequest(t *shared.RespondActivityTaskFailedRequest) *apiv1.RespondActivityTaskFailedRequest { - if t == nil { - return nil - } - return &apiv1.RespondActivityTaskFailedRequest{ - TaskToken: t.TaskToken, - Failure: protoFailure(t.Reason, t.Details), - Identity: t.GetIdentity(), - } -} - -func protoRespondDecisionTaskCompletedRequest(t *shared.RespondDecisionTaskCompletedRequest) *apiv1.RespondDecisionTaskCompletedRequest { - if t == nil { - return nil - } - return &apiv1.RespondDecisionTaskCompletedRequest{ - TaskToken: t.TaskToken, - Decisions: protoDecisionArray(t.Decisions), - ExecutionContext: t.ExecutionContext, - Identity: t.GetIdentity(), - StickyAttributes: protoStickyExecutionAttributes(t.StickyAttributes), - ReturnNewDecisionTask: t.GetReturnNewDecisionTask(), - ForceCreateNewDecisionTask: t.GetForceCreateNewDecisionTask(), - BinaryChecksum: t.GetBinaryChecksum(), - QueryResults: protoWorkflowQueryResultMap(t.QueryResults), - } -} - -func protoRespondDecisionTaskFailedRequest(t *shared.RespondDecisionTaskFailedRequest) *apiv1.RespondDecisionTaskFailedRequest { - if t == nil { - return nil - } - return &apiv1.RespondDecisionTaskFailedRequest{ - TaskToken: t.TaskToken, - Cause: protoDecisionTaskFailedCause(t.Cause), - Details: protoPayload(t.Details), - Identity: t.GetIdentity(), - BinaryChecksum: t.GetBinaryChecksum(), - } -} - -func protoRespondQueryTaskCompletedRequest(t *shared.RespondQueryTaskCompletedRequest) *apiv1.RespondQueryTaskCompletedRequest { - if t == nil { - return nil - } - return &apiv1.RespondQueryTaskCompletedRequest{ - TaskToken: t.TaskToken, - Result: &apiv1.WorkflowQueryResult{ - ResultType: protoQueryTaskCompletedType(t.CompletedType), - Answer: protoPayload(t.QueryResult), - ErrorMessage: t.GetErrorMessage(), - }, - WorkerVersionInfo: protoWorkerVersionInfo(t.WorkerVersionInfo), - } -} - -func protoScanWorkflowExecutionsRequest(t *shared.ListWorkflowExecutionsRequest) *apiv1.ScanWorkflowExecutionsRequest { - if t == nil { - return nil - } - return &apiv1.ScanWorkflowExecutionsRequest{ - Domain: t.GetDomain(), - PageSize: t.GetPageSize(), - NextPageToken: t.NextPageToken, - Query: t.GetQuery(), - } -} - -func protoSignalWithStartWorkflowExecutionRequest(t *shared.SignalWithStartWorkflowExecutionRequest) *apiv1.SignalWithStartWorkflowExecutionRequest { - if t == nil { - return nil - } - return &apiv1.SignalWithStartWorkflowExecutionRequest{ - StartRequest: &apiv1.StartWorkflowExecutionRequest{ - Domain: t.GetDomain(), - WorkflowId: t.GetWorkflowId(), - WorkflowType: protoWorkflowType(t.WorkflowType), - TaskList: protoTaskList(t.TaskList), - Input: protoPayload(t.Input), - ExecutionStartToCloseTimeout: secondsToDuration(t.ExecutionStartToCloseTimeoutSeconds), - TaskStartToCloseTimeout: secondsToDuration(t.TaskStartToCloseTimeoutSeconds), - Identity: t.GetIdentity(), - RequestId: t.GetRequestId(), - WorkflowIdReusePolicy: protoWorkflowIdReusePolicy(t.WorkflowIdReusePolicy), - RetryPolicy: protoRetryPolicy(t.RetryPolicy), - CronSchedule: t.GetCronSchedule(), - Memo: protoMemo(t.Memo), - SearchAttributes: protoSearchAttributes(t.SearchAttributes), - Header: protoHeader(t.Header), - DelayStart: secondsToDuration(t.DelayStartSeconds), - }, - SignalName: t.GetSignalName(), - SignalInput: protoPayload(t.SignalInput), - Control: t.Control, - } -} - -func protoSignalWorkflowExecutionRequest(t *shared.SignalWorkflowExecutionRequest) *apiv1.SignalWorkflowExecutionRequest { - if t == nil { - return nil - } - return &apiv1.SignalWorkflowExecutionRequest{ - Domain: t.GetDomain(), - WorkflowExecution: protoWorkflowExecution(t.WorkflowExecution), - SignalName: t.GetSignalName(), - SignalInput: protoPayload(t.Input), - Identity: t.GetIdentity(), - RequestId: t.GetRequestId(), - Control: t.Control, - } -} - -func protoStartWorkflowExecutionRequest(t *shared.StartWorkflowExecutionRequest) *apiv1.StartWorkflowExecutionRequest { - if t == nil { - return nil - } - return &apiv1.StartWorkflowExecutionRequest{ - Domain: t.GetDomain(), - WorkflowId: t.GetWorkflowId(), - WorkflowType: protoWorkflowType(t.WorkflowType), - TaskList: protoTaskList(t.TaskList), - Input: protoPayload(t.Input), - ExecutionStartToCloseTimeout: secondsToDuration(t.ExecutionStartToCloseTimeoutSeconds), - TaskStartToCloseTimeout: secondsToDuration(t.TaskStartToCloseTimeoutSeconds), - Identity: t.GetIdentity(), - RequestId: t.GetRequestId(), - WorkflowIdReusePolicy: protoWorkflowIdReusePolicy(t.WorkflowIdReusePolicy), - RetryPolicy: protoRetryPolicy(t.RetryPolicy), - CronSchedule: t.GetCronSchedule(), - Memo: protoMemo(t.Memo), - SearchAttributes: protoSearchAttributes(t.SearchAttributes), - Header: protoHeader(t.Header), - DelayStart: secondsToDuration(t.DelayStartSeconds), - } -} - -func protoTerminateWorkflowExecutionRequest(t *shared.TerminateWorkflowExecutionRequest) *apiv1.TerminateWorkflowExecutionRequest { - if t == nil { - return nil - } - return &apiv1.TerminateWorkflowExecutionRequest{ - Domain: t.GetDomain(), - WorkflowExecution: protoWorkflowExecution(t.WorkflowExecution), - Reason: t.GetReason(), - Details: protoPayload(t.Details), - Identity: t.GetIdentity(), - } -} - -const ( - DomainUpdateDescriptionField = "description" - DomainUpdateOwnerEmailField = "owner_email" - DomainUpdateDataField = "data" - DomainUpdateRetentionPeriodField = "workflow_execution_retention_period" - DomainUpdateBadBinariesField = "bad_binaries" - DomainUpdateHistoryArchivalStatusField = "history_archival_status" - DomainUpdateHistoryArchivalURIField = "history_archival_uri" - DomainUpdateVisibilityArchivalStatusField = "visibility_archival_status" - DomainUpdateVisibilityArchivalURIField = "visibility_archival_uri" - DomainUpdateActiveClusterNameField = "active_cluster_name" - DomainUpdateClustersField = "clusters" - DomainUpdateDeleteBadBinaryField = "delete_bad_binary" - DomainUpdateFailoverTimeoutField = "failover_timeout" -) - -func protoUpdateDomainRequest(t *shared.UpdateDomainRequest) *apiv1.UpdateDomainRequest { - if t == nil { - return nil - } - request := apiv1.UpdateDomainRequest{ - Name: t.GetName(), - SecurityToken: t.GetSecurityToken(), - } - fields := []string{} - - if updatedInfo := t.GetUpdatedInfo(); updatedInfo != nil { - if updatedInfo.Description != nil { - request.Description = *updatedInfo.Description - fields = append(fields, DomainUpdateDescriptionField) - } - if updatedInfo.OwnerEmail != nil { - request.OwnerEmail = *updatedInfo.OwnerEmail - fields = append(fields, DomainUpdateOwnerEmailField) - } - if updatedInfo.Data != nil { - request.Data = updatedInfo.Data - fields = append(fields, DomainUpdateDataField) - } - } - if configuration := t.GetConfiguration(); configuration != nil { - if configuration.WorkflowExecutionRetentionPeriodInDays != nil { - request.WorkflowExecutionRetentionPeriod = daysToDuration(configuration.WorkflowExecutionRetentionPeriodInDays) - fields = append(fields, DomainUpdateRetentionPeriodField) - } - //if t.EmitMetric != nil {} - DEPRECATED - if configuration.BadBinaries != nil { - request.BadBinaries = protoBadBinaries(configuration.BadBinaries) - fields = append(fields, DomainUpdateBadBinariesField) - } - if configuration.HistoryArchivalStatus != nil { - request.HistoryArchivalStatus = protoArchivalStatus(configuration.HistoryArchivalStatus) - fields = append(fields, DomainUpdateHistoryArchivalStatusField) - } - if configuration.HistoryArchivalURI != nil { - request.HistoryArchivalUri = *configuration.HistoryArchivalURI - fields = append(fields, DomainUpdateHistoryArchivalURIField) - } - if configuration.VisibilityArchivalStatus != nil { - request.VisibilityArchivalStatus = protoArchivalStatus(configuration.VisibilityArchivalStatus) - fields = append(fields, DomainUpdateVisibilityArchivalStatusField) - } - if configuration.VisibilityArchivalURI != nil { - request.VisibilityArchivalUri = *configuration.VisibilityArchivalURI - fields = append(fields, DomainUpdateVisibilityArchivalURIField) - } - } - if replicationConfiguration := t.GetReplicationConfiguration(); replicationConfiguration != nil { - if replicationConfiguration.ActiveClusterName != nil { - request.ActiveClusterName = *replicationConfiguration.ActiveClusterName - fields = append(fields, DomainUpdateActiveClusterNameField) - } - if replicationConfiguration.Clusters != nil { - request.Clusters = protoClusterReplicationConfigurationArray(replicationConfiguration.Clusters) - fields = append(fields, DomainUpdateClustersField) - } - } - if t.DeleteBadBinary != nil { - request.DeleteBadBinary = *t.DeleteBadBinary - fields = append(fields, DomainUpdateDeleteBadBinaryField) - } - if t.FailoverTimeoutInSeconds != nil { - request.FailoverTimeout = secondsToDuration(t.FailoverTimeoutInSeconds) - fields = append(fields, DomainUpdateFailoverTimeoutField) - } - - request.UpdateMask = newFieldMask(fields) - - return &request -} - -func protoListClosedWorkflowExecutionsRequest(r *shared.ListClosedWorkflowExecutionsRequest) *apiv1.ListClosedWorkflowExecutionsRequest { - if r == nil { - return nil - } - request := apiv1.ListClosedWorkflowExecutionsRequest{ - Domain: r.GetDomain(), - PageSize: r.GetMaximumPageSize(), - NextPageToken: r.NextPageToken, - StartTimeFilter: protoStartTimeFilter(r.StartTimeFilter), - } - if r.ExecutionFilter != nil { - request.Filters = &apiv1.ListClosedWorkflowExecutionsRequest_ExecutionFilter{ - ExecutionFilter: protoWorkflowExecutionFilter(r.ExecutionFilter), - } - } - if r.TypeFilter != nil { - request.Filters = &apiv1.ListClosedWorkflowExecutionsRequest_TypeFilter{ - TypeFilter: protoWorkflowTypeFilter(r.TypeFilter), - } - } - if r.StatusFilter != nil { - request.Filters = &apiv1.ListClosedWorkflowExecutionsRequest_StatusFilter{ - StatusFilter: protoStatusFilter(r.StatusFilter), - } - } - - return &request -} - -func protoListOpenWorkflowExecutionsRequest(r *shared.ListOpenWorkflowExecutionsRequest) *apiv1.ListOpenWorkflowExecutionsRequest { - if r == nil { - return nil - } - request := apiv1.ListOpenWorkflowExecutionsRequest{ - Domain: r.GetDomain(), - PageSize: r.GetMaximumPageSize(), - NextPageToken: r.NextPageToken, - StartTimeFilter: protoStartTimeFilter(r.StartTimeFilter), - } - if r.ExecutionFilter != nil { - request.Filters = &apiv1.ListOpenWorkflowExecutionsRequest_ExecutionFilter{ - ExecutionFilter: protoWorkflowExecutionFilter(r.ExecutionFilter), - } - } - if r.TypeFilter != nil { - request.Filters = &apiv1.ListOpenWorkflowExecutionsRequest_TypeFilter{ - TypeFilter: protoWorkflowTypeFilter(r.TypeFilter), - } - } - - return &request -} - - -func protoPayload(data []byte) *apiv1.Payload { - if data == nil { - return nil - } - return &apiv1.Payload{ - Data: data, - } -} - -func protoFailure(reason *string, details []byte) *apiv1.Failure { - if reason == nil { - return nil - } - return &apiv1.Failure{ - Reason: *reason, - Details: details, - } -} - -func protoWorkflowExecution(t *shared.WorkflowExecution) *apiv1.WorkflowExecution { - if t == nil { - return nil - } - return &apiv1.WorkflowExecution{ - WorkflowId: t.GetWorkflowId(), - RunId: t.GetRunId(), - } -} - -func protoWorkflowRunPair(workflowId, runId string) *apiv1.WorkflowExecution { - return &apiv1.WorkflowExecution{ - WorkflowId: workflowId, - RunId: runId, - } -} - -func protoActivityType(t *shared.ActivityType) *apiv1.ActivityType { - if t == nil { - return nil - } - return &apiv1.ActivityType{ - Name: t.GetName(), - } -} - -func protoWorkflowType(t *shared.WorkflowType) *apiv1.WorkflowType { - if t == nil { - return nil - } - return &apiv1.WorkflowType{ - Name: t.GetName(), - } -} - -func protoTaskList(t *shared.TaskList) *apiv1.TaskList { - if t == nil { - return nil - } - return &apiv1.TaskList{ - Name: t.GetName(), - Kind: protoTaskListKind(t.Kind), - } -} - -func protoTaskListMetadata(t *shared.TaskListMetadata) *apiv1.TaskListMetadata { - if t == nil { - return nil - } - return &apiv1.TaskListMetadata{ - MaxTasksPerSecond: fromDoubleValue(t.MaxTasksPerSecond), - } -} - -func protoRetryPolicy(t *shared.RetryPolicy) *apiv1.RetryPolicy { - if t == nil { - return nil - } - return &apiv1.RetryPolicy{ - InitialInterval: secondsToDuration(t.InitialIntervalInSeconds), - BackoffCoefficient: t.GetBackoffCoefficient(), - MaximumInterval: secondsToDuration(t.MaximumIntervalInSeconds), - MaximumAttempts: t.GetMaximumAttempts(), - NonRetryableErrorReasons: t.NonRetriableErrorReasons, - ExpirationInterval: secondsToDuration(t.ExpirationIntervalInSeconds), - } -} - -func protoHeader(t *shared.Header) *apiv1.Header { - if t == nil { - return nil - } - return &apiv1.Header{ - Fields: protoPayloadMap(t.Fields), - } -} - -func protoMemo(t *shared.Memo) *apiv1.Memo { - if t == nil { - return nil - } - return &apiv1.Memo{ - Fields: protoPayloadMap(t.Fields), - } -} - -func protoSearchAttributes(t *shared.SearchAttributes) *apiv1.SearchAttributes { - if t == nil { - return nil - } - return &apiv1.SearchAttributes{ - IndexedFields: protoPayloadMap(t.IndexedFields), - } -} - - -func protoBadBinaries(t *shared.BadBinaries) *apiv1.BadBinaries { - if t == nil { - return nil - } - return &apiv1.BadBinaries{ - Binaries: protoBadBinaryInfoMap(t.Binaries), - } -} - -func protoBadBinaryInfo(t *shared.BadBinaryInfo) *apiv1.BadBinaryInfo { - if t == nil { - return nil - } - return &apiv1.BadBinaryInfo{ - Reason: t.GetReason(), - Operator: t.GetOperator(), - CreatedTime: unixNanoToTime(t.CreatedTimeNano), - } -} - -func protoClusterReplicationConfiguration(t *shared.ClusterReplicationConfiguration) *apiv1.ClusterReplicationConfiguration { - if t == nil { - return nil - } - return &apiv1.ClusterReplicationConfiguration{ - ClusterName: t.GetClusterName(), - } -} - -func protoWorkflowQuery(t *shared.WorkflowQuery) *apiv1.WorkflowQuery { - if t == nil { - return nil - } - return &apiv1.WorkflowQuery{ - QueryType: t.GetQueryType(), - QueryArgs: protoPayload(t.QueryArgs), - } -} - -func protoWorkflowQueryResult(t *shared.WorkflowQueryResult) *apiv1.WorkflowQueryResult { - if t == nil { - return nil - } - return &apiv1.WorkflowQueryResult{ - ResultType: protoQueryResultType(t.ResultType), - Answer: protoPayload(t.Answer), - ErrorMessage: t.GetErrorMessage(), - } -} - - -func protoStickyExecutionAttributes(t *shared.StickyExecutionAttributes) *apiv1.StickyExecutionAttributes { - if t == nil { - return nil - } - return &apiv1.StickyExecutionAttributes{ - WorkerTaskList: protoTaskList(t.WorkerTaskList), - ScheduleToStartTimeout: secondsToDuration(t.ScheduleToStartTimeoutSeconds), - } -} - -func protoWorkerVersionInfo(t *shared.WorkerVersionInfo) *apiv1.WorkerVersionInfo { - if t == nil { - return nil - } - return &apiv1.WorkerVersionInfo{ - Impl: t.GetImpl(), - FeatureVersion: t.GetFeatureVersion(), - } -} - -func protoStartTimeFilter(t *shared.StartTimeFilter) *apiv1.StartTimeFilter { - if t == nil { - return nil - } - return &apiv1.StartTimeFilter{ - EarliestTime: unixNanoToTime(t.EarliestTime), - LatestTime: unixNanoToTime(t.LatestTime), - } -} - -func protoWorkflowExecutionFilter(t *shared.WorkflowExecutionFilter) *apiv1.WorkflowExecutionFilter { - if t == nil { - return nil - } - return &apiv1.WorkflowExecutionFilter{ - WorkflowId: t.GetWorkflowId(), - RunId: t.GetRunId(), - } -} - -func protoWorkflowTypeFilter(t *shared.WorkflowTypeFilter) *apiv1.WorkflowTypeFilter { - if t == nil { - return nil - } - return &apiv1.WorkflowTypeFilter{ - Name: t.GetName(), - } -} - -func protoStatusFilter(t *shared.WorkflowExecutionCloseStatus) *apiv1.StatusFilter { - if t == nil { - return nil - } - return &apiv1.StatusFilter{ - Status: protoWorkflowExecutionCloseStatus(t), - } -} - -func protoDecision(d *shared.Decision) *apiv1.Decision { - if d == nil { - return nil - } - decision := apiv1.Decision{} - switch *d.DecisionType { - case shared.DecisionTypeScheduleActivityTask: - attr := d.ScheduleActivityTaskDecisionAttributes - decision.Attributes = &apiv1.Decision_ScheduleActivityTaskDecisionAttributes{ - ScheduleActivityTaskDecisionAttributes: &apiv1.ScheduleActivityTaskDecisionAttributes{ - ActivityId: attr.GetActivityId(), - ActivityType: protoActivityType(attr.ActivityType), - Domain: attr.GetDomain(), - TaskList: protoTaskList(attr.TaskList), - Input: protoPayload(attr.Input), - ScheduleToCloseTimeout: secondsToDuration(attr.ScheduleToCloseTimeoutSeconds), - ScheduleToStartTimeout: secondsToDuration(attr.ScheduleToStartTimeoutSeconds), - StartToCloseTimeout: secondsToDuration(attr.StartToCloseTimeoutSeconds), - HeartbeatTimeout: secondsToDuration(attr.HeartbeatTimeoutSeconds), - RetryPolicy: protoRetryPolicy(attr.RetryPolicy), - Header: protoHeader(attr.Header), - RequestLocalDispatch: attr.GetRequestLocalDispatch(), - }, - } - case shared.DecisionTypeRequestCancelActivityTask: - attr := d.RequestCancelActivityTaskDecisionAttributes - decision.Attributes = &apiv1.Decision_RequestCancelActivityTaskDecisionAttributes{ - RequestCancelActivityTaskDecisionAttributes: &apiv1.RequestCancelActivityTaskDecisionAttributes{ - ActivityId: attr.GetActivityId(), - }, - } - case shared.DecisionTypeStartTimer: - attr := d.StartTimerDecisionAttributes - decision.Attributes = &apiv1.Decision_StartTimerDecisionAttributes{ - StartTimerDecisionAttributes: &apiv1.StartTimerDecisionAttributes{ - TimerId: attr.GetTimerId(), - StartToFireTimeout: secondsToDuration(int64To32(attr.StartToFireTimeoutSeconds)), - }, - } - case shared.DecisionTypeCompleteWorkflowExecution: - attr := d.CompleteWorkflowExecutionDecisionAttributes - decision.Attributes = &apiv1.Decision_CompleteWorkflowExecutionDecisionAttributes{ - CompleteWorkflowExecutionDecisionAttributes: &apiv1.CompleteWorkflowExecutionDecisionAttributes{ - Result: protoPayload(attr.Result), - }, - } - case shared.DecisionTypeFailWorkflowExecution: - attr := d.FailWorkflowExecutionDecisionAttributes - decision.Attributes = &apiv1.Decision_FailWorkflowExecutionDecisionAttributes{ - FailWorkflowExecutionDecisionAttributes: &apiv1.FailWorkflowExecutionDecisionAttributes{ - Failure: protoFailure(attr.Reason, attr.Details), - }, - } - case shared.DecisionTypeCancelTimer: - attr := d.CancelTimerDecisionAttributes - decision.Attributes = &apiv1.Decision_CancelTimerDecisionAttributes{ - CancelTimerDecisionAttributes: &apiv1.CancelTimerDecisionAttributes{ - TimerId: attr.GetTimerId(), - }, - } - case shared.DecisionTypeCancelWorkflowExecution: - attr := d.CancelWorkflowExecutionDecisionAttributes - decision.Attributes = &apiv1.Decision_CancelWorkflowExecutionDecisionAttributes{ - CancelWorkflowExecutionDecisionAttributes: &apiv1.CancelWorkflowExecutionDecisionAttributes{ - Details: protoPayload(attr.Details), - }, - } - case shared.DecisionTypeRequestCancelExternalWorkflowExecution: - attr := d.RequestCancelExternalWorkflowExecutionDecisionAttributes - decision.Attributes = &apiv1.Decision_RequestCancelExternalWorkflowExecutionDecisionAttributes{ - RequestCancelExternalWorkflowExecutionDecisionAttributes: &apiv1.RequestCancelExternalWorkflowExecutionDecisionAttributes{ - Domain: attr.GetDomain(), - WorkflowExecution: protoWorkflowRunPair(attr.GetWorkflowId(), attr.GetRunId()), - Control: attr.Control, - ChildWorkflowOnly: attr.GetChildWorkflowOnly(), - }, - } - case shared.DecisionTypeRecordMarker: - attr := d.RecordMarkerDecisionAttributes - decision.Attributes = &apiv1.Decision_RecordMarkerDecisionAttributes{ - RecordMarkerDecisionAttributes: &apiv1.RecordMarkerDecisionAttributes{ - MarkerName: attr.GetMarkerName(), - Details: protoPayload(attr.Details), - Header: protoHeader(attr.Header), - }, - } - case shared.DecisionTypeContinueAsNewWorkflowExecution: - attr := d.ContinueAsNewWorkflowExecutionDecisionAttributes - decision.Attributes = &apiv1.Decision_ContinueAsNewWorkflowExecutionDecisionAttributes{ - ContinueAsNewWorkflowExecutionDecisionAttributes: &apiv1.ContinueAsNewWorkflowExecutionDecisionAttributes{ - WorkflowType: protoWorkflowType(attr.WorkflowType), - TaskList: protoTaskList(attr.TaskList), - Input: protoPayload(attr.Input), - ExecutionStartToCloseTimeout: secondsToDuration(attr.ExecutionStartToCloseTimeoutSeconds), - TaskStartToCloseTimeout: secondsToDuration(attr.TaskStartToCloseTimeoutSeconds), - BackoffStartInterval: secondsToDuration(attr.BackoffStartIntervalInSeconds), - RetryPolicy: protoRetryPolicy(attr.RetryPolicy), - Initiator: protoContinueAsNewInitiator(attr.Initiator), - Failure: protoFailure(attr.FailureReason, attr.FailureDetails), - LastCompletionResult: protoPayload(attr.LastCompletionResult), - CronSchedule: attr.GetCronSchedule(), - Header: protoHeader(attr.Header), - Memo: protoMemo(attr.Memo), - SearchAttributes: protoSearchAttributes(attr.SearchAttributes), - }, - } - case shared.DecisionTypeStartChildWorkflowExecution: - attr := d.StartChildWorkflowExecutionDecisionAttributes - decision.Attributes = &apiv1.Decision_StartChildWorkflowExecutionDecisionAttributes{ - StartChildWorkflowExecutionDecisionAttributes: &apiv1.StartChildWorkflowExecutionDecisionAttributes{ - Domain: attr.GetDomain(), - WorkflowId: attr.GetWorkflowId(), - WorkflowType: protoWorkflowType(attr.WorkflowType), - TaskList: protoTaskList(attr.TaskList), - Input: protoPayload(attr.Input), - ExecutionStartToCloseTimeout: secondsToDuration(attr.ExecutionStartToCloseTimeoutSeconds), - TaskStartToCloseTimeout: secondsToDuration(attr.TaskStartToCloseTimeoutSeconds), - ParentClosePolicy: protoParentClosePolicy(attr.ParentClosePolicy), - Control: attr.Control, - WorkflowIdReusePolicy: protoWorkflowIdReusePolicy(attr.WorkflowIdReusePolicy), - RetryPolicy: protoRetryPolicy(attr.RetryPolicy), - CronSchedule: attr.GetCronSchedule(), - Header: protoHeader(attr.Header), - Memo: protoMemo(attr.Memo), - SearchAttributes: protoSearchAttributes(attr.SearchAttributes), - }, - } - case shared.DecisionTypeSignalExternalWorkflowExecution: - attr := d.SignalExternalWorkflowExecutionDecisionAttributes - decision.Attributes = &apiv1.Decision_SignalExternalWorkflowExecutionDecisionAttributes{ - SignalExternalWorkflowExecutionDecisionAttributes: &apiv1.SignalExternalWorkflowExecutionDecisionAttributes{ - Domain: attr.GetDomain(), - WorkflowExecution: protoWorkflowExecution(attr.Execution), - SignalName: attr.GetSignalName(), - Input: protoPayload(attr.Input), - Control: attr.Control, - ChildWorkflowOnly: attr.GetChildWorkflowOnly(), - }, - } - case shared.DecisionTypeUpsertWorkflowSearchAttributes: - attr := d.UpsertWorkflowSearchAttributesDecisionAttributes - decision.Attributes = &apiv1.Decision_UpsertWorkflowSearchAttributesDecisionAttributes{ - UpsertWorkflowSearchAttributesDecisionAttributes: &apiv1.UpsertWorkflowSearchAttributesDecisionAttributes{ - SearchAttributes: protoSearchAttributes(attr.SearchAttributes), - }, - } - } - return &decision -} - -func protoPayloadMap(t map[string][]byte) map[string]*apiv1.Payload { - if t == nil { - return nil - } - v := make(map[string]*apiv1.Payload, len(t)) - for key := range t { - v[key] = protoPayload(t[key]) - } - return v -} - -func protoBadBinaryInfoMap(t map[string]*shared.BadBinaryInfo) map[string]*apiv1.BadBinaryInfo { - if t == nil { - return nil - } - v := make(map[string]*apiv1.BadBinaryInfo, len(t)) - for key := range t { - v[key] = protoBadBinaryInfo(t[key]) - } - return v -} - -func protoClusterReplicationConfigurationArray(t []*shared.ClusterReplicationConfiguration) []*apiv1.ClusterReplicationConfiguration { - if t == nil { - return nil - } - v := make([]*apiv1.ClusterReplicationConfiguration, len(t)) - for i := range t { - v[i] = protoClusterReplicationConfiguration(t[i]) - } - return v -} - -func protoWorkflowQueryResultMap(t map[string]*shared.WorkflowQueryResult) map[string]*apiv1.WorkflowQueryResult { - if t == nil { - return nil - } - v := make(map[string]*apiv1.WorkflowQueryResult, len(t)) - for key := range t { - v[key] = protoWorkflowQueryResult(t[key]) - } - return v -} - -func protoDecisionArray(t []*shared.Decision) []*apiv1.Decision { - if t == nil { - return nil - } - v := make([]*apiv1.Decision, len(t)) - for i := range t { - v[i] = protoDecision(t[i]) - } - return v -} - -func protoTaskListKind(t *shared.TaskListKind) apiv1.TaskListKind { - if t == nil { - return apiv1.TaskListKind_TASK_LIST_KIND_INVALID - } - switch *t { - case shared.TaskListKindNormal: - return apiv1.TaskListKind_TASK_LIST_KIND_NORMAL - case shared.TaskListKindSticky: - return apiv1.TaskListKind_TASK_LIST_KIND_STICKY - } - panic("unexpected enum value") -} - -func protoTaskListType(t *shared.TaskListType) apiv1.TaskListType { - if t == nil { - return apiv1.TaskListType_TASK_LIST_TYPE_INVALID - } - switch *t { - case shared.TaskListTypeDecision: - return apiv1.TaskListType_TASK_LIST_TYPE_DECISION - case shared.TaskListTypeActivity: - return apiv1.TaskListType_TASK_LIST_TYPE_ACTIVITY - } - panic("unexpected enum value") -} - -func protoEventFilterType(t *shared.HistoryEventFilterType) apiv1.EventFilterType { - if t == nil { - return apiv1.EventFilterType_EVENT_FILTER_TYPE_INVALID - } - switch *t { - case shared.HistoryEventFilterTypeAllEvent: - return apiv1.EventFilterType_EVENT_FILTER_TYPE_ALL_EVENT - case shared.HistoryEventFilterTypeCloseEvent: - return apiv1.EventFilterType_EVENT_FILTER_TYPE_CLOSE_EVENT - } - panic("unexpected enum value") -} - -func protoQueryRejectCondition(t *shared.QueryRejectCondition) apiv1.QueryRejectCondition { - if t == nil { - return apiv1.QueryRejectCondition_QUERY_REJECT_CONDITION_INVALID - } - switch *t { - case shared.QueryRejectConditionNotOpen: - return apiv1.QueryRejectCondition_QUERY_REJECT_CONDITION_NOT_OPEN - case shared.QueryRejectConditionNotCompletedCleanly: - return apiv1.QueryRejectCondition_QUERY_REJECT_CONDITION_NOT_COMPLETED_CLEANLY - } - panic("unexpected enum value") -} - -func protoQueryConsistencyLevel(t *shared.QueryConsistencyLevel) apiv1.QueryConsistencyLevel { - if t == nil { - return apiv1.QueryConsistencyLevel_QUERY_CONSISTENCY_LEVEL_INVALID - } - switch *t { - case shared.QueryConsistencyLevelEventual: - return apiv1.QueryConsistencyLevel_QUERY_CONSISTENCY_LEVEL_EVENTUAL - case shared.QueryConsistencyLevelStrong: - return apiv1.QueryConsistencyLevel_QUERY_CONSISTENCY_LEVEL_STRONG - } - panic("unexpected enum value") -} - -func protoContinueAsNewInitiator(t *shared.ContinueAsNewInitiator) apiv1.ContinueAsNewInitiator { - if t == nil { - return apiv1.ContinueAsNewInitiator_CONTINUE_AS_NEW_INITIATOR_INVALID - } - switch *t { - case shared.ContinueAsNewInitiatorDecider: - return apiv1.ContinueAsNewInitiator_CONTINUE_AS_NEW_INITIATOR_DECIDER - case shared.ContinueAsNewInitiatorRetryPolicy: - return apiv1.ContinueAsNewInitiator_CONTINUE_AS_NEW_INITIATOR_RETRY_POLICY - case shared.ContinueAsNewInitiatorCronSchedule: - return apiv1.ContinueAsNewInitiator_CONTINUE_AS_NEW_INITIATOR_CRON_SCHEDULE - } - panic("unexpected enum value") -} - -func protoWorkflowIdReusePolicy(t *shared.WorkflowIdReusePolicy) apiv1.WorkflowIdReusePolicy { - if t == nil { - return apiv1.WorkflowIdReusePolicy_WORKFLOW_ID_REUSE_POLICY_INVALID - } - switch *t { - case shared.WorkflowIdReusePolicyAllowDuplicateFailedOnly: - return apiv1.WorkflowIdReusePolicy_WORKFLOW_ID_REUSE_POLICY_ALLOW_DUPLICATE_FAILED_ONLY - case shared.WorkflowIdReusePolicyAllowDuplicate: - return apiv1.WorkflowIdReusePolicy_WORKFLOW_ID_REUSE_POLICY_ALLOW_DUPLICATE - case shared.WorkflowIdReusePolicyRejectDuplicate: - return apiv1.WorkflowIdReusePolicy_WORKFLOW_ID_REUSE_POLICY_REJECT_DUPLICATE - case shared.WorkflowIdReusePolicyTerminateIfRunning: - return apiv1.WorkflowIdReusePolicy_WORKFLOW_ID_REUSE_POLICY_TERMINATE_IF_RUNNING - } - panic("unexpected enum value") -} - -func protoQueryResultType(t *shared.QueryResultType) apiv1.QueryResultType { - if t == nil { - return apiv1.QueryResultType_QUERY_RESULT_TYPE_INVALID - } - switch *t { - case shared.QueryResultTypeAnswered: - return apiv1.QueryResultType_QUERY_RESULT_TYPE_ANSWERED - case shared.QueryResultTypeFailed: - return apiv1.QueryResultType_QUERY_RESULT_TYPE_FAILED - } - panic("unexpected enum value") -} - -func protoArchivalStatus(t *shared.ArchivalStatus) apiv1.ArchivalStatus { - if t == nil { - return apiv1.ArchivalStatus_ARCHIVAL_STATUS_INVALID - } - switch *t { - case shared.ArchivalStatusDisabled: - return apiv1.ArchivalStatus_ARCHIVAL_STATUS_DISABLED - case shared.ArchivalStatusEnabled: - return apiv1.ArchivalStatus_ARCHIVAL_STATUS_ENABLED - } - panic("unexpected enum value") -} - -func protoParentClosePolicy(t *shared.ParentClosePolicy) apiv1.ParentClosePolicy { - if t == nil { - return apiv1.ParentClosePolicy_PARENT_CLOSE_POLICY_INVALID - } - switch *t { - case shared.ParentClosePolicyAbandon: - return apiv1.ParentClosePolicy_PARENT_CLOSE_POLICY_ABANDON - case shared.ParentClosePolicyRequestCancel: - return apiv1.ParentClosePolicy_PARENT_CLOSE_POLICY_REQUEST_CANCEL - case shared.ParentClosePolicyTerminate: - return apiv1.ParentClosePolicy_PARENT_CLOSE_POLICY_TERMINATE - } - panic("unexpected enum value") -} - -func protoDecisionTaskFailedCause(t *shared.DecisionTaskFailedCause) apiv1.DecisionTaskFailedCause { - if t == nil { - return apiv1.DecisionTaskFailedCause_DECISION_TASK_FAILED_CAUSE_INVALID - } - switch *t { - case shared.DecisionTaskFailedCauseUnhandledDecision: - return apiv1.DecisionTaskFailedCause_DECISION_TASK_FAILED_CAUSE_UNHANDLED_DECISION - case shared.DecisionTaskFailedCauseBadScheduleActivityAttributes: - return apiv1.DecisionTaskFailedCause_DECISION_TASK_FAILED_CAUSE_BAD_SCHEDULE_ACTIVITY_ATTRIBUTES - case shared.DecisionTaskFailedCauseBadRequestCancelActivityAttributes: - return apiv1.DecisionTaskFailedCause_DECISION_TASK_FAILED_CAUSE_BAD_REQUEST_CANCEL_ACTIVITY_ATTRIBUTES - case shared.DecisionTaskFailedCauseBadStartTimerAttributes: - return apiv1.DecisionTaskFailedCause_DECISION_TASK_FAILED_CAUSE_BAD_START_TIMER_ATTRIBUTES - case shared.DecisionTaskFailedCauseBadCancelTimerAttributes: - return apiv1.DecisionTaskFailedCause_DECISION_TASK_FAILED_CAUSE_BAD_CANCEL_TIMER_ATTRIBUTES - case shared.DecisionTaskFailedCauseBadRecordMarkerAttributes: - return apiv1.DecisionTaskFailedCause_DECISION_TASK_FAILED_CAUSE_BAD_RECORD_MARKER_ATTRIBUTES - case shared.DecisionTaskFailedCauseBadCompleteWorkflowExecutionAttributes: - return apiv1.DecisionTaskFailedCause_DECISION_TASK_FAILED_CAUSE_BAD_COMPLETE_WORKFLOW_EXECUTION_ATTRIBUTES - case shared.DecisionTaskFailedCauseBadFailWorkflowExecutionAttributes: - return apiv1.DecisionTaskFailedCause_DECISION_TASK_FAILED_CAUSE_BAD_FAIL_WORKFLOW_EXECUTION_ATTRIBUTES - case shared.DecisionTaskFailedCauseBadCancelWorkflowExecutionAttributes: - return apiv1.DecisionTaskFailedCause_DECISION_TASK_FAILED_CAUSE_BAD_CANCEL_WORKFLOW_EXECUTION_ATTRIBUTES - case shared.DecisionTaskFailedCauseBadRequestCancelExternalWorkflowExecutionAttributes: - return apiv1.DecisionTaskFailedCause_DECISION_TASK_FAILED_CAUSE_BAD_REQUEST_CANCEL_EXTERNAL_WORKFLOW_EXECUTION_ATTRIBUTES - case shared.DecisionTaskFailedCauseBadContinueAsNewAttributes: - return apiv1.DecisionTaskFailedCause_DECISION_TASK_FAILED_CAUSE_BAD_CONTINUE_AS_NEW_ATTRIBUTES - case shared.DecisionTaskFailedCauseStartTimerDuplicateID: - return apiv1.DecisionTaskFailedCause_DECISION_TASK_FAILED_CAUSE_START_TIMER_DUPLICATE_ID - case shared.DecisionTaskFailedCauseResetStickyTasklist: - return apiv1.DecisionTaskFailedCause_DECISION_TASK_FAILED_CAUSE_RESET_STICKY_TASK_LIST - case shared.DecisionTaskFailedCauseWorkflowWorkerUnhandledFailure: - return apiv1.DecisionTaskFailedCause_DECISION_TASK_FAILED_CAUSE_WORKFLOW_WORKER_UNHANDLED_FAILURE - case shared.DecisionTaskFailedCauseBadSignalWorkflowExecutionAttributes: - return apiv1.DecisionTaskFailedCause_DECISION_TASK_FAILED_CAUSE_BAD_SIGNAL_WORKFLOW_EXECUTION_ATTRIBUTES - case shared.DecisionTaskFailedCauseBadStartChildExecutionAttributes: - return apiv1.DecisionTaskFailedCause_DECISION_TASK_FAILED_CAUSE_BAD_START_CHILD_EXECUTION_ATTRIBUTES - case shared.DecisionTaskFailedCauseForceCloseDecision: - return apiv1.DecisionTaskFailedCause_DECISION_TASK_FAILED_CAUSE_FORCE_CLOSE_DECISION - case shared.DecisionTaskFailedCauseFailoverCloseDecision: - return apiv1.DecisionTaskFailedCause_DECISION_TASK_FAILED_CAUSE_FAILOVER_CLOSE_DECISION - case shared.DecisionTaskFailedCauseBadSignalInputSize: - return apiv1.DecisionTaskFailedCause_DECISION_TASK_FAILED_CAUSE_BAD_SIGNAL_INPUT_SIZE - case shared.DecisionTaskFailedCauseResetWorkflow: - return apiv1.DecisionTaskFailedCause_DECISION_TASK_FAILED_CAUSE_RESET_WORKFLOW - case shared.DecisionTaskFailedCauseBadBinary: - return apiv1.DecisionTaskFailedCause_DECISION_TASK_FAILED_CAUSE_BAD_BINARY - case shared.DecisionTaskFailedCauseScheduleActivityDuplicateID: - return apiv1.DecisionTaskFailedCause_DECISION_TASK_FAILED_CAUSE_SCHEDULE_ACTIVITY_DUPLICATE_ID - case shared.DecisionTaskFailedCauseBadSearchAttributes: - return apiv1.DecisionTaskFailedCause_DECISION_TASK_FAILED_CAUSE_BAD_SEARCH_ATTRIBUTES - } - panic("unexpected enum value") -} - -func protoWorkflowExecutionCloseStatus(t *shared.WorkflowExecutionCloseStatus) apiv1.WorkflowExecutionCloseStatus { - if t == nil { - return apiv1.WorkflowExecutionCloseStatus_WORKFLOW_EXECUTION_CLOSE_STATUS_INVALID - } - switch *t { - case shared.WorkflowExecutionCloseStatusCompleted: - return apiv1.WorkflowExecutionCloseStatus_WORKFLOW_EXECUTION_CLOSE_STATUS_COMPLETED - case shared.WorkflowExecutionCloseStatusFailed: - return apiv1.WorkflowExecutionCloseStatus_WORKFLOW_EXECUTION_CLOSE_STATUS_FAILED - case shared.WorkflowExecutionCloseStatusCanceled: - return apiv1.WorkflowExecutionCloseStatus_WORKFLOW_EXECUTION_CLOSE_STATUS_CANCELED - case shared.WorkflowExecutionCloseStatusTerminated: - return apiv1.WorkflowExecutionCloseStatus_WORKFLOW_EXECUTION_CLOSE_STATUS_TERMINATED - case shared.WorkflowExecutionCloseStatusContinuedAsNew: - return apiv1.WorkflowExecutionCloseStatus_WORKFLOW_EXECUTION_CLOSE_STATUS_CONTINUED_AS_NEW - case shared.WorkflowExecutionCloseStatusTimedOut: - return apiv1.WorkflowExecutionCloseStatus_WORKFLOW_EXECUTION_CLOSE_STATUS_TIMED_OUT - } - panic("unexpected enum value") -} - -func protoQueryTaskCompletedType(t *shared.QueryTaskCompletedType) apiv1.QueryResultType { - if t == nil { - return apiv1.QueryResultType_QUERY_RESULT_TYPE_INVALID - } - switch *t { - case shared.QueryTaskCompletedTypeCompleted: - return apiv1.QueryResultType_QUERY_RESULT_TYPE_ANSWERED - case shared.QueryTaskCompletedTypeFailed: - return apiv1.QueryResultType_QUERY_RESULT_TYPE_FAILED - } - panic("unexpected enum value") -} \ No newline at end of file diff --git a/internal/compatibility/response.go b/internal/compatibility/response.go deleted file mode 100644 index ae3ead998..000000000 --- a/internal/compatibility/response.go +++ /dev/null @@ -1,1923 +0,0 @@ -// Copyright (c) 2021 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -package compatibility - -import ( - "go.uber.org/cadence/.gen/go/shared" - apiv1 "go.uber.org/cadence/.gen/proto/api/v1" - "go.uber.org/cadence/internal/common" -) - -func thriftCountWorkflowExecutionsResponse(t *apiv1.CountWorkflowExecutionsResponse) *shared.CountWorkflowExecutionsResponse { - if t == nil { - return nil - } - return &shared.CountWorkflowExecutionsResponse{ - Count: &t.Count, - } -} - -func thriftDescribeDomainResponse(t *apiv1.DescribeDomainResponse) *shared.DescribeDomainResponse { - if t == nil || t.Domain == nil { - return nil - } - return &shared.DescribeDomainResponse{ - DomainInfo: &shared.DomainInfo{ - Name: &t.Domain.Name, - Status: thriftDomainStatus(t.Domain.Status), - Description: &t.Domain.Description, - OwnerEmail: &t.Domain.OwnerEmail, - Data: t.Domain.Data, - UUID: &t.Domain.Id, - }, - Configuration: &shared.DomainConfiguration{ - WorkflowExecutionRetentionPeriodInDays: durationToDays(t.Domain.WorkflowExecutionRetentionPeriod), - EmitMetric: boolPtr(true), - BadBinaries: thriftBadBinaries(t.Domain.BadBinaries), - HistoryArchivalStatus: thriftArchivalStatus(t.Domain.HistoryArchivalStatus), - HistoryArchivalURI: &t.Domain.HistoryArchivalUri, - VisibilityArchivalStatus: thriftArchivalStatus(t.Domain.VisibilityArchivalStatus), - VisibilityArchivalURI: &t.Domain.VisibilityArchivalUri, - }, - ReplicationConfiguration: &shared.DomainReplicationConfiguration{ - ActiveClusterName: &t.Domain.ActiveClusterName, - Clusters: thriftClusterReplicationConfigurationArray(t.Domain.Clusters), - }, - FailoverVersion: &t.Domain.FailoverVersion, - IsGlobalDomain: &t.Domain.IsGlobalDomain, - } -} - -func thriftDescribeTaskListResponse(t *apiv1.DescribeTaskListResponse) *shared.DescribeTaskListResponse { - if t == nil { - return nil - } - return &shared.DescribeTaskListResponse{ - Pollers: thriftPollerInfoArray(t.Pollers), - TaskListStatus: thriftTaskListStatus(t.TaskListStatus), - } -} - -func thriftDescribeWorkflowExecutionResponse(t *apiv1.DescribeWorkflowExecutionResponse) *shared.DescribeWorkflowExecutionResponse { - if t == nil { - return nil - } - return &shared.DescribeWorkflowExecutionResponse{ - ExecutionConfiguration: thriftWorkflowExecutionConfiguration(t.ExecutionConfiguration), - WorkflowExecutionInfo: thriftWorkflowExecutionInfo(t.WorkflowExecutionInfo), - PendingActivities: thriftPendingActivityInfoArray(t.PendingActivities), - PendingChildren: thriftPendingChildExecutionInfoArray(t.PendingChildren), - PendingDecision: thriftPendingDecisionInfo(t.PendingDecision), - } -} - -func thriftGetClusterInfoResponse(t *apiv1.GetClusterInfoResponse) *shared.ClusterInfo { - if t == nil { - return nil - } - return &shared.ClusterInfo{ - SupportedClientVersions: thriftSupportedClientVersions(t.SupportedClientVersions), - } -} - -func thriftGetSearchAttributesResponse(t *apiv1.GetSearchAttributesResponse) *shared.GetSearchAttributesResponse { - if t == nil { - return nil - } - return &shared.GetSearchAttributesResponse{ - Keys: thriftIndexedValueTypeMap(t.Keys), - } -} - -func thriftGetWorkflowExecutionHistoryResponse(t *apiv1.GetWorkflowExecutionHistoryResponse) *shared.GetWorkflowExecutionHistoryResponse { - if t == nil { - return nil - } - return &shared.GetWorkflowExecutionHistoryResponse{ - History: thriftHistory(t.History), - RawHistory: thriftDataBlobArray(t.RawHistory), - NextPageToken: t.NextPageToken, - Archived: &t.Archived, - } -} - -func thriftListArchivedWorkflowExecutionsResponse(t *apiv1.ListArchivedWorkflowExecutionsResponse) *shared.ListArchivedWorkflowExecutionsResponse { - if t == nil { - return nil - } - return &shared.ListArchivedWorkflowExecutionsResponse{ - Executions: thriftWorkflowExecutionInfoArray(t.Executions), - NextPageToken: t.NextPageToken, - } -} - -func thriftListClosedWorkflowExecutionsResponse(t *apiv1.ListClosedWorkflowExecutionsResponse) *shared.ListClosedWorkflowExecutionsResponse { - if t == nil { - return nil - } - return &shared.ListClosedWorkflowExecutionsResponse{ - Executions: thriftWorkflowExecutionInfoArray(t.Executions), - NextPageToken: t.NextPageToken, - } -} - -func thriftListDomainsResponse(t *apiv1.ListDomainsResponse) *shared.ListDomainsResponse { - if t == nil { - return nil - } - return &shared.ListDomainsResponse{ - Domains: thriftDescribeDomainResponseArray(t.Domains), - NextPageToken: t.NextPageToken, - } -} - -func thriftListOpenWorkflowExecutionsResponse(t *apiv1.ListOpenWorkflowExecutionsResponse) *shared.ListOpenWorkflowExecutionsResponse { - if t == nil { - return nil - } - return &shared.ListOpenWorkflowExecutionsResponse{ - Executions: thriftWorkflowExecutionInfoArray(t.Executions), - NextPageToken: t.NextPageToken, - } -} - -func thriftListTaskListPartitionsResponse(t *apiv1.ListTaskListPartitionsResponse) *shared.ListTaskListPartitionsResponse { - if t == nil { - return nil - } - return &shared.ListTaskListPartitionsResponse{ - ActivityTaskListPartitions: thriftTaskListPartitionMetadataArray(t.ActivityTaskListPartitions), - DecisionTaskListPartitions: thriftTaskListPartitionMetadataArray(t.DecisionTaskListPartitions), - } -} - -func thriftListWorkflowExecutionsResponse(t *apiv1.ListWorkflowExecutionsResponse) *shared.ListWorkflowExecutionsResponse { - if t == nil { - return nil - } - return &shared.ListWorkflowExecutionsResponse{ - Executions: thriftWorkflowExecutionInfoArray(t.Executions), - NextPageToken: t.NextPageToken, - } -} - - -func thriftPollForActivityTaskResponse(t *apiv1.PollForActivityTaskResponse) *shared.PollForActivityTaskResponse { - if t == nil { - return nil - } - return &shared.PollForActivityTaskResponse{ - TaskToken: t.TaskToken, - WorkflowExecution: thriftWorkflowExecution(t.WorkflowExecution), - ActivityId: &t.ActivityId, - ActivityType: thriftActivityType(t.ActivityType), - Input: thriftPayload(t.Input), - ScheduledTimestamp: timeToUnixNano(t.ScheduledTime), - StartedTimestamp: timeToUnixNano(t.StartedTime), - ScheduleToCloseTimeoutSeconds: durationToSeconds(t.ScheduleToCloseTimeout), - StartToCloseTimeoutSeconds: durationToSeconds(t.StartToCloseTimeout), - HeartbeatTimeoutSeconds: durationToSeconds(t.HeartbeatTimeout), - Attempt: &t.Attempt, - ScheduledTimestampOfThisAttempt: timeToUnixNano(t.ScheduledTimeOfThisAttempt), - HeartbeatDetails: thriftPayload(t.HeartbeatDetails), - WorkflowType: thriftWorkflowType(t.WorkflowType), - WorkflowDomain: &t.WorkflowDomain, - Header: thriftHeader(t.Header), - } -} - - -func thriftPollForDecisionTaskResponse(t *apiv1.PollForDecisionTaskResponse) *shared.PollForDecisionTaskResponse { - if t == nil { - return nil - } - return &shared.PollForDecisionTaskResponse{ - TaskToken: t.TaskToken, - WorkflowExecution: thriftWorkflowExecution(t.WorkflowExecution), - WorkflowType: thriftWorkflowType(t.WorkflowType), - PreviousStartedEventId: toInt64Value(t.PreviousStartedEventId), - StartedEventId: &t.StartedEventId, - Attempt: &t.Attempt, - BacklogCountHint: &t.BacklogCountHint, - History: thriftHistory(t.History), - NextPageToken: t.NextPageToken, - Query: thriftWorkflowQuery(t.Query), - WorkflowExecutionTaskList: thriftTaskList(t.WorkflowExecutionTaskList), - ScheduledTimestamp: timeToUnixNano(t.ScheduledTime), - StartedTimestamp: timeToUnixNano(t.StartedTime), - Queries: thriftWorkflowQueryMap(t.Queries), - NextEventId: &t.NextEventId, - } -} - -func thriftQueryWorkflowResponse(t *apiv1.QueryWorkflowResponse) *shared.QueryWorkflowResponse { - if t == nil { - return nil - } - return &shared.QueryWorkflowResponse{ - QueryResult: thriftPayload(t.QueryResult), - QueryRejected: thriftQueryRejected(t.QueryRejected), - } -} - -func thriftRecordActivityTaskHeartbeatByIdResponse(t *apiv1.RecordActivityTaskHeartbeatByIDResponse) *shared.RecordActivityTaskHeartbeatResponse { - if t == nil { - return nil - } - return &shared.RecordActivityTaskHeartbeatResponse{ - CancelRequested: &t.CancelRequested, - } -} - -func thriftRecordActivityTaskHeartbeatResponse(t *apiv1.RecordActivityTaskHeartbeatResponse) *shared.RecordActivityTaskHeartbeatResponse { - if t == nil { - return nil - } - return &shared.RecordActivityTaskHeartbeatResponse{ - CancelRequested: &t.CancelRequested, - } -} - -func thriftResetWorkflowExecutionResponse(t *apiv1.ResetWorkflowExecutionResponse) *shared.ResetWorkflowExecutionResponse { - if t == nil { - return nil - } - return &shared.ResetWorkflowExecutionResponse{ - RunId: &t.RunId, - } -} - -func thriftRespondDecisionTaskCompletedResponse(t *apiv1.RespondDecisionTaskCompletedResponse) *shared.RespondDecisionTaskCompletedResponse { - if t == nil { - return nil - } - return &shared.RespondDecisionTaskCompletedResponse{ - DecisionTask: thriftPollForDecisionTaskResponse(t.DecisionTask), - ActivitiesToDispatchLocally: thriftActivityLocalDispatchInfoMap(t.ActivitiesToDispatchLocally), - } -} - -func thriftScanWorkflowExecutionsResponse(t *apiv1.ScanWorkflowExecutionsResponse) *shared.ListWorkflowExecutionsResponse { - if t == nil { - return nil - } - return &shared.ListWorkflowExecutionsResponse{ - Executions: thriftWorkflowExecutionInfoArray(t.Executions), - NextPageToken: t.NextPageToken, - } -} - -func thriftSignalWithStartWorkflowExecutionResponse(t *apiv1.SignalWithStartWorkflowExecutionResponse) *shared.StartWorkflowExecutionResponse { - if t == nil { - return nil - } - return &shared.StartWorkflowExecutionResponse{ - RunId: &t.RunId, - } -} - -func thriftStartWorkflowExecutionResponse(t *apiv1.StartWorkflowExecutionResponse) *shared.StartWorkflowExecutionResponse { - if t == nil { - return nil - } - return &shared.StartWorkflowExecutionResponse{ - RunId: &t.RunId, - } -} - -func thriftUpdateDomainResponse(t *apiv1.UpdateDomainResponse) *shared.UpdateDomainResponse { - if t == nil || t.Domain == nil { - return nil - } - return &shared.UpdateDomainResponse{ - DomainInfo: &shared.DomainInfo{ - Name: &t.Domain.Name, - Status: thriftDomainStatus(t.Domain.Status), - Description: &t.Domain.Description, - OwnerEmail: &t.Domain.OwnerEmail, - Data: t.Domain.Data, - UUID: &t.Domain.Id, - }, - Configuration: &shared.DomainConfiguration{ - WorkflowExecutionRetentionPeriodInDays: durationToDays(t.Domain.WorkflowExecutionRetentionPeriod), - EmitMetric: boolPtr(true), - BadBinaries: thriftBadBinaries(t.Domain.BadBinaries), - HistoryArchivalStatus: thriftArchivalStatus(t.Domain.HistoryArchivalStatus), - HistoryArchivalURI: &t.Domain.HistoryArchivalUri, - VisibilityArchivalStatus: thriftArchivalStatus(t.Domain.VisibilityArchivalStatus), - VisibilityArchivalURI: &t.Domain.VisibilityArchivalUri, - }, - ReplicationConfiguration: &shared.DomainReplicationConfiguration{ - ActiveClusterName: &t.Domain.ActiveClusterName, - Clusters: thriftClusterReplicationConfigurationArray(t.Domain.Clusters), - }, - FailoverVersion: &t.Domain.FailoverVersion, - IsGlobalDomain: &t.Domain.IsGlobalDomain, - } -} - - -func thriftPayload(p *apiv1.Payload) []byte { - if p == nil { - return nil - } - if p.Data == nil { - // FromPayload will not generate this case - // however, Data field will be dropped by the encoding if it's empty - // and receiver side will see nil for the Data field - // since we already know p is not nil, Data field must be an empty byte array - return []byte{} - } - return p.Data -} - -func thriftFailureReason(failure *apiv1.Failure) *string { - if failure == nil { - return nil - } - return &failure.Reason -} - -func thriftFailureDetails(failure *apiv1.Failure) []byte { - if failure == nil { - return nil - } - return failure.Details -} - -func thriftDataBlob(t *apiv1.DataBlob) *shared.DataBlob { - if t == nil { - return nil - } - return &shared.DataBlob{ - EncodingType: thriftEncodingType(t.EncodingType), - Data: t.Data, - } -} - -func thriftWorkflowExecution(t *apiv1.WorkflowExecution) *shared.WorkflowExecution { - if t == nil { - return nil - } - return &shared.WorkflowExecution{ - WorkflowId: &t.WorkflowId, - RunId: &t.RunId, - } -} - -func thriftWorkflowId(t *apiv1.WorkflowExecution) *string { - if t == nil { - return nil - } - return &t.WorkflowId -} - -func thriftRunId(t *apiv1.WorkflowExecution) *string { - if t == nil { - return nil - } - return &t.RunId -} - -func thriftExternalWorkflowExecution(t *apiv1.ExternalExecutionInfo) *shared.WorkflowExecution { - if t == nil { - return nil - } - return thriftWorkflowExecution(t.WorkflowExecution) -} - -func thriftWorkflowType(t *apiv1.WorkflowType) *shared.WorkflowType { - if t == nil { - return nil - } - return &shared.WorkflowType{ - Name: &t.Name, - } -} - -func thriftActivityType(t *apiv1.ActivityType) *shared.ActivityType { - if t == nil { - return nil - } - return &shared.ActivityType{ - Name: &t.Name, - } -} - -func thriftHeader(t *apiv1.Header) *shared.Header { - if t == nil { - return nil - } - return &shared.Header{ - Fields: thriftPayloadMap(t.Fields), - } -} - -func thriftMemo(t *apiv1.Memo) *shared.Memo { - if t == nil { - return nil - } - return &shared.Memo{ - Fields: thriftPayloadMap(t.Fields), - } -} - -func thriftSearchAttributes(t *apiv1.SearchAttributes) *shared.SearchAttributes { - if t == nil { - return nil - } - return &shared.SearchAttributes{ - IndexedFields: thriftPayloadMap(t.IndexedFields), - } -} - -func thriftRetryPolicy(t *apiv1.RetryPolicy) *shared.RetryPolicy { - if t == nil { - return nil - } - return &shared.RetryPolicy{ - InitialIntervalInSeconds: durationToSeconds(t.InitialInterval), - BackoffCoefficient: &t.BackoffCoefficient, - MaximumIntervalInSeconds: durationToSeconds(t.MaximumInterval), - MaximumAttempts: &t.MaximumAttempts, - NonRetriableErrorReasons: t.NonRetryableErrorReasons, - ExpirationIntervalInSeconds: durationToSeconds(t.ExpirationInterval), - } -} - -func thriftTaskList(t *apiv1.TaskList) *shared.TaskList { - if t == nil { - return nil - } - return &shared.TaskList{ - Name: &t.Name, - Kind: thriftTaskListKind(t.Kind), - } -} - -func thriftBadBinaries(t *apiv1.BadBinaries) *shared.BadBinaries { - if t == nil { - return nil - } - return &shared.BadBinaries{ - Binaries: thriftBadBinaryInfoMap(t.Binaries), - } -} - -func thriftBadBinaryInfo(t *apiv1.BadBinaryInfo) *shared.BadBinaryInfo { - if t == nil { - return nil - } - return &shared.BadBinaryInfo{ - Reason: &t.Reason, - Operator: &t.Operator, - CreatedTimeNano: timeToUnixNano(t.CreatedTime), - } -} - -func thriftResetPoints(t *apiv1.ResetPoints) *shared.ResetPoints { - if t == nil { - return nil - } - return &shared.ResetPoints{ - Points: thriftResetPointInfoArray(t.Points), - } -} - -func thriftClusterReplicationConfiguration(t *apiv1.ClusterReplicationConfiguration) *shared.ClusterReplicationConfiguration { - if t == nil { - return nil - } - return &shared.ClusterReplicationConfiguration{ - ClusterName: &t.ClusterName, - } -} - -func thriftPollerInfo(t *apiv1.PollerInfo) *shared.PollerInfo { - if t == nil { - return nil - } - return &shared.PollerInfo{ - LastAccessTime: timeToUnixNano(t.LastAccessTime), - Identity: &t.Identity, - RatePerSecond: &t.RatePerSecond, - } -} - -func thriftResetPointInfo(t *apiv1.ResetPointInfo) *shared.ResetPointInfo { - if t == nil { - return nil - } - return &shared.ResetPointInfo{ - BinaryChecksum: &t.BinaryChecksum, - RunId: &t.RunId, - FirstDecisionCompletedId: &t.FirstDecisionCompletedId, - CreatedTimeNano: timeToUnixNano(t.CreatedTime), - ExpiringTimeNano: timeToUnixNano(t.ExpiringTime), - Resettable: &t.Resettable, - } -} - -func thriftTaskListStatus(t *apiv1.TaskListStatus) *shared.TaskListStatus { - if t == nil { - return nil - } - return &shared.TaskListStatus{ - BacklogCountHint: &t.BacklogCountHint, - ReadLevel: &t.ReadLevel, - AckLevel: &t.AckLevel, - RatePerSecond: &t.RatePerSecond, - TaskIDBlock: thriftTaskIdBlock(t.TaskIdBlock), - } -} - -func thriftTaskIdBlock(t *apiv1.TaskIDBlock) *shared.TaskIDBlock { - if t == nil { - return nil - } - return &shared.TaskIDBlock{ - StartID: &t.StartId, - EndID: &t.EndId, - } -} - -func thriftWorkflowExecutionConfiguration(t *apiv1.WorkflowExecutionConfiguration) *shared.WorkflowExecutionConfiguration { - if t == nil { - return nil - } - return &shared.WorkflowExecutionConfiguration{ - TaskList: thriftTaskList(t.TaskList), - ExecutionStartToCloseTimeoutSeconds: durationToSeconds(t.ExecutionStartToCloseTimeout), - TaskStartToCloseTimeoutSeconds: durationToSeconds(t.TaskStartToCloseTimeout), - } -} - -func thriftWorkflowExecutionInfo(t *apiv1.WorkflowExecutionInfo) *shared.WorkflowExecutionInfo { - if t == nil { - return nil - } - return &shared.WorkflowExecutionInfo{ - Execution: thriftWorkflowExecution(t.WorkflowExecution), - Type: thriftWorkflowType(t.Type), - StartTime: timeToUnixNano(t.StartTime), - CloseTime: timeToUnixNano(t.CloseTime), - CloseStatus: thriftWorkflowExecutionCloseStatus(t.CloseStatus), - HistoryLength: &t.HistoryLength, - ParentDomainId: thriftParentDomainId(t.ParentExecutionInfo), - ParentExecution: thriftParentWorkflowExecution(t.ParentExecutionInfo), - ExecutionTime: timeToUnixNano(t.ExecutionTime), - Memo: thriftMemo(t.Memo), - SearchAttributes: thriftSearchAttributes(t.SearchAttributes), - AutoResetPoints: thriftResetPoints(t.AutoResetPoints), - TaskList: &t.TaskList, - IsCron: &t.IsCron, - } -} - -func thriftParentDomainId(pei *apiv1.ParentExecutionInfo) *string { - if pei == nil { - return nil - } - return &pei.DomainId -} - -func thriftParentDomainName(pei *apiv1.ParentExecutionInfo) *string { - if pei == nil { - return nil - } - return &pei.DomainName -} - -func thriftParentInitiatedId(pei *apiv1.ParentExecutionInfo) *int64 { - if pei == nil { - return nil - } - return &pei.InitiatedId -} - -func thriftParentWorkflowExecution(pei *apiv1.ParentExecutionInfo) *shared.WorkflowExecution { - if pei == nil { - return nil - } - return thriftWorkflowExecution(pei.WorkflowExecution) -} - -func thriftPendingActivityInfo(t *apiv1.PendingActivityInfo) *shared.PendingActivityInfo { - if t == nil { - return nil - } - return &shared.PendingActivityInfo{ - ActivityID: &t.ActivityId, - ActivityType: thriftActivityType(t.ActivityType), - State: thriftPendingActivityState(t.State), - HeartbeatDetails: thriftPayload(t.HeartbeatDetails), - LastHeartbeatTimestamp: timeToUnixNano(t.LastHeartbeatTime), - LastStartedTimestamp: timeToUnixNano(t.LastStartedTime), - Attempt: &t.Attempt, - MaximumAttempts: &t.MaximumAttempts, - ScheduledTimestamp: timeToUnixNano(t.ScheduledTime), - ExpirationTimestamp: timeToUnixNano(t.ExpirationTime), - LastFailureReason: thriftFailureReason(t.LastFailure), - LastFailureDetails: thriftFailureDetails(t.LastFailure), - LastWorkerIdentity: &t.LastWorkerIdentity, - } -} - -func thriftPendingChildExecutionInfo(t *apiv1.PendingChildExecutionInfo) *shared.PendingChildExecutionInfo { - if t == nil { - return nil - } - return &shared.PendingChildExecutionInfo{ - WorkflowID: thriftWorkflowId(t.WorkflowExecution), - RunID: thriftRunId(t.WorkflowExecution), - WorkflowTypName: &t.WorkflowTypeName, - InitiatedID: &t.InitiatedId, - ParentClosePolicy: thriftParentClosePolicy(t.ParentClosePolicy), - } -} - -func thriftPendingDecisionInfo(t *apiv1.PendingDecisionInfo) *shared.PendingDecisionInfo { - if t == nil { - return nil - } - return &shared.PendingDecisionInfo{ - State: thriftPendingDecisionState(t.State), - ScheduledTimestamp: timeToUnixNano(t.ScheduledTime), - StartedTimestamp: timeToUnixNano(t.StartedTime), - Attempt: common.Int64Ptr(int64(t.Attempt)), - OriginalScheduledTimestamp: timeToUnixNano(t.OriginalScheduledTime), - } -} - -func thriftActivityLocalDispatchInfo(t *apiv1.ActivityLocalDispatchInfo) *shared.ActivityLocalDispatchInfo { - if t == nil { - return nil - } - return &shared.ActivityLocalDispatchInfo{ - ActivityId: &t.ActivityId, - ScheduledTimestamp: timeToUnixNano(t.ScheduledTime), - StartedTimestamp: timeToUnixNano(t.StartedTime), - ScheduledTimestampOfThisAttempt: timeToUnixNano(t.ScheduledTimeOfThisAttempt), - TaskToken: t.TaskToken, - } -} - -func thriftSupportedClientVersions(t *apiv1.SupportedClientVersions) *shared.SupportedClientVersions { - if t == nil { - return nil - } - return &shared.SupportedClientVersions{ - GoSdk: &t.GoSdk, - JavaSdk: &t.JavaSdk, - } -} - -func thriftWorkflowQuery(t *apiv1.WorkflowQuery) *shared.WorkflowQuery { - if t == nil { - return nil - } - return &shared.WorkflowQuery{ - QueryType: &t.QueryType, - QueryArgs: thriftPayload(t.QueryArgs), - } -} - -func thriftDescribeDomainResponseDomain(t *apiv1.Domain) *shared.DescribeDomainResponse { - if t == nil { - return nil - } - return &shared.DescribeDomainResponse{ - DomainInfo: &shared.DomainInfo{ - Name: &t.Name, - Status: thriftDomainStatus(t.Status), - Description: &t.Description, - OwnerEmail: &t.OwnerEmail, - Data: t.Data, - UUID: &t.Id, - }, - Configuration: &shared.DomainConfiguration{ - WorkflowExecutionRetentionPeriodInDays: durationToDays(t.WorkflowExecutionRetentionPeriod), - EmitMetric: boolPtr(true), - BadBinaries: thriftBadBinaries(t.BadBinaries), - HistoryArchivalStatus: thriftArchivalStatus(t.HistoryArchivalStatus), - HistoryArchivalURI: &t.HistoryArchivalUri, - VisibilityArchivalStatus: thriftArchivalStatus(t.VisibilityArchivalStatus), - VisibilityArchivalURI: &t.VisibilityArchivalUri, - }, - ReplicationConfiguration: &shared.DomainReplicationConfiguration{ - ActiveClusterName: &t.ActiveClusterName, - Clusters: thriftClusterReplicationConfigurationArray(t.Clusters), - }, - FailoverVersion: &t.FailoverVersion, - IsGlobalDomain: &t.IsGlobalDomain, - } -} - -func thriftTaskListPartitionMetadata(t *apiv1.TaskListPartitionMetadata) *shared.TaskListPartitionMetadata { - if t == nil { - return nil - } - return &shared.TaskListPartitionMetadata{ - Key: &t.Key, - OwnerHostName: &t.OwnerHostName, - } -} - -func thriftQueryRejected(t *apiv1.QueryRejected) *shared.QueryRejected { - if t == nil { - return nil - } - return &shared.QueryRejected{ - CloseStatus: thriftWorkflowExecutionCloseStatus(t.CloseStatus), - } -} - -func thriftExternalInitiatedId(t *apiv1.ExternalExecutionInfo) *int64 { - if t == nil { - return nil - } - return &t.InitiatedId -} - -func thriftHistory(t *apiv1.History) *shared.History { - if t == nil { - return nil - } - return &shared.History{ - Events: thriftHistoryEventArray(t.Events), - } -} - -func thriftHistoryEvent(e *apiv1.HistoryEvent) *shared.HistoryEvent { - if e == nil { - return nil - } - event := shared.HistoryEvent{ - EventId: &e.EventId, - Timestamp: timeToUnixNano(e.EventTime), - Version: &e.Version, - TaskId: &e.TaskId, - } - switch attr := e.Attributes.(type) { - case *apiv1.HistoryEvent_WorkflowExecutionStartedEventAttributes: - event.EventType = shared.EventTypeWorkflowExecutionStarted.Ptr() - event.WorkflowExecutionStartedEventAttributes = thriftWorkflowExecutionStartedEventAttributes(attr.WorkflowExecutionStartedEventAttributes) - case *apiv1.HistoryEvent_WorkflowExecutionCompletedEventAttributes: - event.EventType = shared.EventTypeWorkflowExecutionCompleted.Ptr() - event.WorkflowExecutionCompletedEventAttributes = thriftWorkflowExecutionCompletedEventAttributes(attr.WorkflowExecutionCompletedEventAttributes) - case *apiv1.HistoryEvent_WorkflowExecutionFailedEventAttributes: - event.EventType = shared.EventTypeWorkflowExecutionFailed.Ptr() - event.WorkflowExecutionFailedEventAttributes = thriftWorkflowExecutionFailedEventAttributes(attr.WorkflowExecutionFailedEventAttributes) - case *apiv1.HistoryEvent_WorkflowExecutionTimedOutEventAttributes: - event.EventType = shared.EventTypeWorkflowExecutionTimedOut.Ptr() - event.WorkflowExecutionTimedOutEventAttributes = thriftWorkflowExecutionTimedOutEventAttributes(attr.WorkflowExecutionTimedOutEventAttributes) - case *apiv1.HistoryEvent_DecisionTaskScheduledEventAttributes: - event.EventType = shared.EventTypeDecisionTaskScheduled.Ptr() - event.DecisionTaskScheduledEventAttributes = thriftDecisionTaskScheduledEventAttributes(attr.DecisionTaskScheduledEventAttributes) - case *apiv1.HistoryEvent_DecisionTaskStartedEventAttributes: - event.EventType = shared.EventTypeDecisionTaskStarted.Ptr() - event.DecisionTaskStartedEventAttributes = thriftDecisionTaskStartedEventAttributes(attr.DecisionTaskStartedEventAttributes) - case *apiv1.HistoryEvent_DecisionTaskCompletedEventAttributes: - event.EventType = shared.EventTypeDecisionTaskCompleted.Ptr() - event.DecisionTaskCompletedEventAttributes = thriftDecisionTaskCompletedEventAttributes(attr.DecisionTaskCompletedEventAttributes) - case *apiv1.HistoryEvent_DecisionTaskTimedOutEventAttributes: - event.EventType = shared.EventTypeDecisionTaskTimedOut.Ptr() - event.DecisionTaskTimedOutEventAttributes = thriftDecisionTaskTimedOutEventAttributes(attr.DecisionTaskTimedOutEventAttributes) - case *apiv1.HistoryEvent_DecisionTaskFailedEventAttributes: - event.EventType = shared.EventTypeDecisionTaskFailed.Ptr() - event.DecisionTaskFailedEventAttributes = thriftDecisionTaskFailedEventAttributes(attr.DecisionTaskFailedEventAttributes) - case *apiv1.HistoryEvent_ActivityTaskScheduledEventAttributes: - event.EventType = shared.EventTypeActivityTaskScheduled.Ptr() - event.ActivityTaskScheduledEventAttributes = thriftActivityTaskScheduledEventAttributes(attr.ActivityTaskScheduledEventAttributes) - case *apiv1.HistoryEvent_ActivityTaskStartedEventAttributes: - event.EventType = shared.EventTypeActivityTaskStarted.Ptr() - event.ActivityTaskStartedEventAttributes = thriftActivityTaskStartedEventAttributes(attr.ActivityTaskStartedEventAttributes) - case *apiv1.HistoryEvent_ActivityTaskCompletedEventAttributes: - event.EventType = shared.EventTypeActivityTaskCompleted.Ptr() - event.ActivityTaskCompletedEventAttributes = thriftActivityTaskCompletedEventAttributes(attr.ActivityTaskCompletedEventAttributes) - case *apiv1.HistoryEvent_ActivityTaskFailedEventAttributes: - event.EventType = shared.EventTypeActivityTaskFailed.Ptr() - event.ActivityTaskFailedEventAttributes = thriftActivityTaskFailedEventAttributes(attr.ActivityTaskFailedEventAttributes) - case *apiv1.HistoryEvent_ActivityTaskTimedOutEventAttributes: - event.EventType = shared.EventTypeActivityTaskTimedOut.Ptr() - event.ActivityTaskTimedOutEventAttributes = thriftActivityTaskTimedOutEventAttributes(attr.ActivityTaskTimedOutEventAttributes) - case *apiv1.HistoryEvent_TimerStartedEventAttributes: - event.EventType = shared.EventTypeTimerStarted.Ptr() - event.TimerStartedEventAttributes = thriftTimerStartedEventAttributes(attr.TimerStartedEventAttributes) - case *apiv1.HistoryEvent_TimerFiredEventAttributes: - event.EventType = shared.EventTypeTimerFired.Ptr() - event.TimerFiredEventAttributes = thriftTimerFiredEventAttributes(attr.TimerFiredEventAttributes) - case *apiv1.HistoryEvent_ActivityTaskCancelRequestedEventAttributes: - event.EventType = shared.EventTypeActivityTaskCancelRequested.Ptr() - event.ActivityTaskCancelRequestedEventAttributes = thriftActivityTaskCancelRequestedEventAttributes(attr.ActivityTaskCancelRequestedEventAttributes) - case *apiv1.HistoryEvent_RequestCancelActivityTaskFailedEventAttributes: - event.EventType = shared.EventTypeRequestCancelActivityTaskFailed.Ptr() - event.RequestCancelActivityTaskFailedEventAttributes = thriftRequestCancelActivityTaskFailedEventAttributes(attr.RequestCancelActivityTaskFailedEventAttributes) - case *apiv1.HistoryEvent_ActivityTaskCanceledEventAttributes: - event.EventType = shared.EventTypeActivityTaskCanceled.Ptr() - event.ActivityTaskCanceledEventAttributes = thriftActivityTaskCanceledEventAttributes(attr.ActivityTaskCanceledEventAttributes) - case *apiv1.HistoryEvent_TimerCanceledEventAttributes: - event.EventType = shared.EventTypeTimerCanceled.Ptr() - event.TimerCanceledEventAttributes = thriftTimerCanceledEventAttributes(attr.TimerCanceledEventAttributes) - case *apiv1.HistoryEvent_CancelTimerFailedEventAttributes: - event.EventType = shared.EventTypeCancelTimerFailed.Ptr() - event.CancelTimerFailedEventAttributes = thriftCancelTimerFailedEventAttributes(attr.CancelTimerFailedEventAttributes) - case *apiv1.HistoryEvent_MarkerRecordedEventAttributes: - event.EventType = shared.EventTypeMarkerRecorded.Ptr() - event.MarkerRecordedEventAttributes = thriftMarkerRecordedEventAttributes(attr.MarkerRecordedEventAttributes) - case *apiv1.HistoryEvent_WorkflowExecutionSignaledEventAttributes: - event.EventType = shared.EventTypeWorkflowExecutionSignaled.Ptr() - event.WorkflowExecutionSignaledEventAttributes = thriftWorkflowExecutionSignaledEventAttributes(attr.WorkflowExecutionSignaledEventAttributes) - case *apiv1.HistoryEvent_WorkflowExecutionTerminatedEventAttributes: - event.EventType = shared.EventTypeWorkflowExecutionTerminated.Ptr() - event.WorkflowExecutionTerminatedEventAttributes = thriftWorkflowExecutionTerminatedEventAttributes(attr.WorkflowExecutionTerminatedEventAttributes) - case *apiv1.HistoryEvent_WorkflowExecutionCancelRequestedEventAttributes: - event.EventType = shared.EventTypeWorkflowExecutionCancelRequested.Ptr() - event.WorkflowExecutionCancelRequestedEventAttributes = thriftWorkflowExecutionCancelRequestedEventAttributes(attr.WorkflowExecutionCancelRequestedEventAttributes) - case *apiv1.HistoryEvent_WorkflowExecutionCanceledEventAttributes: - event.EventType = shared.EventTypeWorkflowExecutionCanceled.Ptr() - event.WorkflowExecutionCanceledEventAttributes = thriftWorkflowExecutionCanceledEventAttributes(attr.WorkflowExecutionCanceledEventAttributes) - case *apiv1.HistoryEvent_RequestCancelExternalWorkflowExecutionInitiatedEventAttributes: - event.EventType = shared.EventTypeRequestCancelExternalWorkflowExecutionInitiated.Ptr() - event.RequestCancelExternalWorkflowExecutionInitiatedEventAttributes = thriftRequestCancelExternalWorkflowExecutionInitiatedEventAttributes(attr.RequestCancelExternalWorkflowExecutionInitiatedEventAttributes) - case *apiv1.HistoryEvent_RequestCancelExternalWorkflowExecutionFailedEventAttributes: - event.EventType = shared.EventTypeRequestCancelExternalWorkflowExecutionFailed.Ptr() - event.RequestCancelExternalWorkflowExecutionFailedEventAttributes = thriftRequestCancelExternalWorkflowExecutionFailedEventAttributes(attr.RequestCancelExternalWorkflowExecutionFailedEventAttributes) - case *apiv1.HistoryEvent_ExternalWorkflowExecutionCancelRequestedEventAttributes: - event.EventType = shared.EventTypeExternalWorkflowExecutionCancelRequested.Ptr() - event.ExternalWorkflowExecutionCancelRequestedEventAttributes = thriftExternalWorkflowExecutionCancelRequestedEventAttributes(attr.ExternalWorkflowExecutionCancelRequestedEventAttributes) - case *apiv1.HistoryEvent_WorkflowExecutionContinuedAsNewEventAttributes: - event.EventType = shared.EventTypeWorkflowExecutionContinuedAsNew.Ptr() - event.WorkflowExecutionContinuedAsNewEventAttributes = thriftWorkflowExecutionContinuedAsNewEventAttributes(attr.WorkflowExecutionContinuedAsNewEventAttributes) - case *apiv1.HistoryEvent_StartChildWorkflowExecutionInitiatedEventAttributes: - event.EventType = shared.EventTypeStartChildWorkflowExecutionInitiated.Ptr() - event.StartChildWorkflowExecutionInitiatedEventAttributes = thriftStartChildWorkflowExecutionInitiatedEventAttributes(attr.StartChildWorkflowExecutionInitiatedEventAttributes) - case *apiv1.HistoryEvent_StartChildWorkflowExecutionFailedEventAttributes: - event.EventType = shared.EventTypeStartChildWorkflowExecutionFailed.Ptr() - event.StartChildWorkflowExecutionFailedEventAttributes = thriftStartChildWorkflowExecutionFailedEventAttributes(attr.StartChildWorkflowExecutionFailedEventAttributes) - case *apiv1.HistoryEvent_ChildWorkflowExecutionStartedEventAttributes: - event.EventType = shared.EventTypeChildWorkflowExecutionStarted.Ptr() - event.ChildWorkflowExecutionStartedEventAttributes = thriftChildWorkflowExecutionStartedEventAttributes(attr.ChildWorkflowExecutionStartedEventAttributes) - case *apiv1.HistoryEvent_ChildWorkflowExecutionCompletedEventAttributes: - event.EventType = shared.EventTypeChildWorkflowExecutionCompleted.Ptr() - event.ChildWorkflowExecutionCompletedEventAttributes = thriftChildWorkflowExecutionCompletedEventAttributes(attr.ChildWorkflowExecutionCompletedEventAttributes) - case *apiv1.HistoryEvent_ChildWorkflowExecutionFailedEventAttributes: - event.EventType = shared.EventTypeChildWorkflowExecutionFailed.Ptr() - event.ChildWorkflowExecutionFailedEventAttributes = thriftChildWorkflowExecutionFailedEventAttributes(attr.ChildWorkflowExecutionFailedEventAttributes) - case *apiv1.HistoryEvent_ChildWorkflowExecutionCanceledEventAttributes: - event.EventType = shared.EventTypeChildWorkflowExecutionCanceled.Ptr() - event.ChildWorkflowExecutionCanceledEventAttributes = thriftChildWorkflowExecutionCanceledEventAttributes(attr.ChildWorkflowExecutionCanceledEventAttributes) - case *apiv1.HistoryEvent_ChildWorkflowExecutionTimedOutEventAttributes: - event.EventType = shared.EventTypeChildWorkflowExecutionTimedOut.Ptr() - event.ChildWorkflowExecutionTimedOutEventAttributes = thriftChildWorkflowExecutionTimedOutEventAttributes(attr.ChildWorkflowExecutionTimedOutEventAttributes) - case *apiv1.HistoryEvent_ChildWorkflowExecutionTerminatedEventAttributes: - event.EventType = shared.EventTypeChildWorkflowExecutionTerminated.Ptr() - event.ChildWorkflowExecutionTerminatedEventAttributes = thriftChildWorkflowExecutionTerminatedEventAttributes(attr.ChildWorkflowExecutionTerminatedEventAttributes) - case *apiv1.HistoryEvent_SignalExternalWorkflowExecutionInitiatedEventAttributes: - event.EventType = shared.EventTypeSignalExternalWorkflowExecutionInitiated.Ptr() - event.SignalExternalWorkflowExecutionInitiatedEventAttributes = thriftSignalExternalWorkflowExecutionInitiatedEventAttributes(attr.SignalExternalWorkflowExecutionInitiatedEventAttributes) - case *apiv1.HistoryEvent_SignalExternalWorkflowExecutionFailedEventAttributes: - event.EventType = shared.EventTypeSignalExternalWorkflowExecutionFailed.Ptr() - event.SignalExternalWorkflowExecutionFailedEventAttributes = thriftSignalExternalWorkflowExecutionFailedEventAttributes(attr.SignalExternalWorkflowExecutionFailedEventAttributes) - case *apiv1.HistoryEvent_ExternalWorkflowExecutionSignaledEventAttributes: - event.EventType = shared.EventTypeExternalWorkflowExecutionSignaled.Ptr() - event.ExternalWorkflowExecutionSignaledEventAttributes = thriftExternalWorkflowExecutionSignaledEventAttributes(attr.ExternalWorkflowExecutionSignaledEventAttributes) - case *apiv1.HistoryEvent_UpsertWorkflowSearchAttributesEventAttributes: - event.EventType = shared.EventTypeUpsertWorkflowSearchAttributes.Ptr() - event.UpsertWorkflowSearchAttributesEventAttributes = thriftUpsertWorkflowSearchAttributesEventAttributes(attr.UpsertWorkflowSearchAttributesEventAttributes) - } - return &event -} - -func thriftActivityTaskCancelRequestedEventAttributes(t *apiv1.ActivityTaskCancelRequestedEventAttributes) *shared.ActivityTaskCancelRequestedEventAttributes { - if t == nil { - return nil - } - return &shared.ActivityTaskCancelRequestedEventAttributes{ - ActivityId: &t.ActivityId, - DecisionTaskCompletedEventId: &t.DecisionTaskCompletedEventId, - } -} - -func thriftActivityTaskCanceledEventAttributes(t *apiv1.ActivityTaskCanceledEventAttributes) *shared.ActivityTaskCanceledEventAttributes { - if t == nil { - return nil - } - return &shared.ActivityTaskCanceledEventAttributes{ - Details: thriftPayload(t.Details), - LatestCancelRequestedEventId: &t.LatestCancelRequestedEventId, - ScheduledEventId: &t.ScheduledEventId, - StartedEventId: &t.StartedEventId, - Identity: &t.Identity, - } -} - -func thriftActivityTaskCompletedEventAttributes(t *apiv1.ActivityTaskCompletedEventAttributes) *shared.ActivityTaskCompletedEventAttributes { - if t == nil { - return nil - } - return &shared.ActivityTaskCompletedEventAttributes{ - Result: thriftPayload(t.Result), - ScheduledEventId: &t.ScheduledEventId, - StartedEventId: &t.StartedEventId, - Identity: &t.Identity, - } -} - -func thriftActivityTaskFailedEventAttributes(t *apiv1.ActivityTaskFailedEventAttributes) *shared.ActivityTaskFailedEventAttributes { - if t == nil { - return nil - } - return &shared.ActivityTaskFailedEventAttributes{ - Reason: thriftFailureReason(t.Failure), - Details: thriftFailureDetails(t.Failure), - ScheduledEventId: &t.ScheduledEventId, - StartedEventId: &t.StartedEventId, - Identity: &t.Identity, - } -} - -func thriftActivityTaskScheduledEventAttributes(t *apiv1.ActivityTaskScheduledEventAttributes) *shared.ActivityTaskScheduledEventAttributes { - if t == nil { - return nil - } - return &shared.ActivityTaskScheduledEventAttributes{ - ActivityId: &t.ActivityId, - ActivityType: thriftActivityType(t.ActivityType), - Domain: &t.Domain, - TaskList: thriftTaskList(t.TaskList), - Input: thriftPayload(t.Input), - ScheduleToCloseTimeoutSeconds: durationToSeconds(t.ScheduleToCloseTimeout), - ScheduleToStartTimeoutSeconds: durationToSeconds(t.ScheduleToStartTimeout), - StartToCloseTimeoutSeconds: durationToSeconds(t.StartToCloseTimeout), - HeartbeatTimeoutSeconds: durationToSeconds(t.HeartbeatTimeout), - DecisionTaskCompletedEventId: &t.DecisionTaskCompletedEventId, - RetryPolicy: thriftRetryPolicy(t.RetryPolicy), - Header: thriftHeader(t.Header), - } -} - -func thriftActivityTaskStartedEventAttributes(t *apiv1.ActivityTaskStartedEventAttributes) *shared.ActivityTaskStartedEventAttributes { - if t == nil { - return nil - } - return &shared.ActivityTaskStartedEventAttributes{ - ScheduledEventId: &t.ScheduledEventId, - Identity: &t.Identity, - RequestId: &t.RequestId, - Attempt: &t.Attempt, - LastFailureReason: thriftFailureReason(t.LastFailure), - LastFailureDetails: thriftFailureDetails(t.LastFailure), - } -} - -func thriftActivityTaskTimedOutEventAttributes(t *apiv1.ActivityTaskTimedOutEventAttributes) *shared.ActivityTaskTimedOutEventAttributes { - if t == nil { - return nil - } - return &shared.ActivityTaskTimedOutEventAttributes{ - Details: thriftPayload(t.Details), - ScheduledEventId: &t.ScheduledEventId, - StartedEventId: &t.StartedEventId, - TimeoutType: thriftTimeoutType(t.TimeoutType), - LastFailureReason: thriftFailureReason(t.LastFailure), - LastFailureDetails: thriftFailureDetails(t.LastFailure), - } -} - -func thriftCancelTimerFailedEventAttributes(t *apiv1.CancelTimerFailedEventAttributes) *shared.CancelTimerFailedEventAttributes { - if t == nil { - return nil - } - return &shared.CancelTimerFailedEventAttributes{ - TimerId: &t.TimerId, - Cause: &t.Cause, - DecisionTaskCompletedEventId: &t.DecisionTaskCompletedEventId, - Identity: &t.Identity, - } -} - -func thriftChildWorkflowExecutionCanceledEventAttributes(t *apiv1.ChildWorkflowExecutionCanceledEventAttributes) *shared.ChildWorkflowExecutionCanceledEventAttributes { - if t == nil { - return nil - } - return &shared.ChildWorkflowExecutionCanceledEventAttributes{ - Domain: &t.Domain, - WorkflowExecution: thriftWorkflowExecution(t.WorkflowExecution), - WorkflowType: thriftWorkflowType(t.WorkflowType), - InitiatedEventId: &t.InitiatedEventId, - StartedEventId: &t.StartedEventId, - Details: thriftPayload(t.Details), - } -} - -func thriftChildWorkflowExecutionCompletedEventAttributes(t *apiv1.ChildWorkflowExecutionCompletedEventAttributes) *shared.ChildWorkflowExecutionCompletedEventAttributes { - if t == nil { - return nil - } - return &shared.ChildWorkflowExecutionCompletedEventAttributes{ - Domain: &t.Domain, - WorkflowExecution: thriftWorkflowExecution(t.WorkflowExecution), - WorkflowType: thriftWorkflowType(t.WorkflowType), - InitiatedEventId: &t.InitiatedEventId, - StartedEventId: &t.StartedEventId, - Result: thriftPayload(t.Result), - } -} - -func thriftChildWorkflowExecutionFailedEventAttributes(t *apiv1.ChildWorkflowExecutionFailedEventAttributes) *shared.ChildWorkflowExecutionFailedEventAttributes { - if t == nil { - return nil - } - return &shared.ChildWorkflowExecutionFailedEventAttributes{ - Domain: &t.Domain, - WorkflowExecution: thriftWorkflowExecution(t.WorkflowExecution), - WorkflowType: thriftWorkflowType(t.WorkflowType), - InitiatedEventId: &t.InitiatedEventId, - StartedEventId: &t.StartedEventId, - Reason: thriftFailureReason(t.Failure), - Details: thriftFailureDetails(t.Failure), - } -} - -func thriftChildWorkflowExecutionStartedEventAttributes(t *apiv1.ChildWorkflowExecutionStartedEventAttributes) *shared.ChildWorkflowExecutionStartedEventAttributes { - if t == nil { - return nil - } - return &shared.ChildWorkflowExecutionStartedEventAttributes{ - Domain: &t.Domain, - WorkflowExecution: thriftWorkflowExecution(t.WorkflowExecution), - WorkflowType: thriftWorkflowType(t.WorkflowType), - InitiatedEventId: &t.InitiatedEventId, - Header: thriftHeader(t.Header), - } -} - -func thriftChildWorkflowExecutionTerminatedEventAttributes(t *apiv1.ChildWorkflowExecutionTerminatedEventAttributes) *shared.ChildWorkflowExecutionTerminatedEventAttributes { - if t == nil { - return nil - } - return &shared.ChildWorkflowExecutionTerminatedEventAttributes{ - Domain: &t.Domain, - WorkflowExecution: thriftWorkflowExecution(t.WorkflowExecution), - WorkflowType: thriftWorkflowType(t.WorkflowType), - InitiatedEventId: &t.InitiatedEventId, - StartedEventId: &t.StartedEventId, - } -} - -func thriftChildWorkflowExecutionTimedOutEventAttributes(t *apiv1.ChildWorkflowExecutionTimedOutEventAttributes) *shared.ChildWorkflowExecutionTimedOutEventAttributes { - if t == nil { - return nil - } - return &shared.ChildWorkflowExecutionTimedOutEventAttributes{ - Domain: &t.Domain, - WorkflowExecution: thriftWorkflowExecution(t.WorkflowExecution), - WorkflowType: thriftWorkflowType(t.WorkflowType), - InitiatedEventId: &t.InitiatedEventId, - StartedEventId: &t.StartedEventId, - TimeoutType: thriftTimeoutType(t.TimeoutType), - } -} - -func thriftDecisionTaskFailedEventAttributes(t *apiv1.DecisionTaskFailedEventAttributes) *shared.DecisionTaskFailedEventAttributes { - if t == nil { - return nil - } - return &shared.DecisionTaskFailedEventAttributes{ - ScheduledEventId: &t.ScheduledEventId, - StartedEventId: &t.StartedEventId, - Cause: thriftDecisionTaskFailedCause(t.Cause), - Reason: thriftFailureReason(t.Failure), - Details: thriftFailureDetails(t.Failure), - Identity: &t.Identity, - BaseRunId: &t.BaseRunId, - NewRunId: &t.NewRunId, - ForkEventVersion: &t.ForkEventVersion, - BinaryChecksum: &t.BinaryChecksum, - } -} - -func thriftDecisionTaskScheduledEventAttributes(t *apiv1.DecisionTaskScheduledEventAttributes) *shared.DecisionTaskScheduledEventAttributes { - if t == nil { - return nil - } - return &shared.DecisionTaskScheduledEventAttributes{ - TaskList: thriftTaskList(t.TaskList), - StartToCloseTimeoutSeconds: durationToSeconds(t.StartToCloseTimeout), - Attempt: common.Int64Ptr(int64(t.Attempt)), - } -} - -func thriftDecisionTaskStartedEventAttributes(t *apiv1.DecisionTaskStartedEventAttributes) *shared.DecisionTaskStartedEventAttributes { - if t == nil { - return nil - } - return &shared.DecisionTaskStartedEventAttributes{ - ScheduledEventId: &t.ScheduledEventId, - Identity: &t.Identity, - RequestId: &t.RequestId, - } -} - -func thriftDecisionTaskCompletedEventAttributes(t *apiv1.DecisionTaskCompletedEventAttributes) *shared.DecisionTaskCompletedEventAttributes { - if t == nil { - return nil - } - return &shared.DecisionTaskCompletedEventAttributes{ - ScheduledEventId: &t.ScheduledEventId, - StartedEventId: &t.StartedEventId, - Identity: &t.Identity, - BinaryChecksum: &t.BinaryChecksum, - ExecutionContext: t.ExecutionContext, - } -} - -func thriftDecisionTaskTimedOutEventAttributes(t *apiv1.DecisionTaskTimedOutEventAttributes) *shared.DecisionTaskTimedOutEventAttributes { - if t == nil { - return nil - } - return &shared.DecisionTaskTimedOutEventAttributes{ - ScheduledEventId: &t.ScheduledEventId, - StartedEventId: &t.StartedEventId, - TimeoutType: thriftTimeoutType(t.TimeoutType), - BaseRunId: &t.BaseRunId, - NewRunId: &t.NewRunId, - ForkEventVersion: &t.ForkEventVersion, - Reason: &t.Reason, - Cause: thriftDecisionTaskTimedOutCause(t.Cause), - } -} - -func thriftExternalWorkflowExecutionCancelRequestedEventAttributes(t *apiv1.ExternalWorkflowExecutionCancelRequestedEventAttributes) *shared.ExternalWorkflowExecutionCancelRequestedEventAttributes { - if t == nil { - return nil - } - return &shared.ExternalWorkflowExecutionCancelRequestedEventAttributes{ - InitiatedEventId: &t.InitiatedEventId, - Domain: &t.Domain, - WorkflowExecution: thriftWorkflowExecution(t.WorkflowExecution), - } -} - -func thriftExternalWorkflowExecutionSignaledEventAttributes(t *apiv1.ExternalWorkflowExecutionSignaledEventAttributes) *shared.ExternalWorkflowExecutionSignaledEventAttributes { - if t == nil { - return nil - } - return &shared.ExternalWorkflowExecutionSignaledEventAttributes{ - InitiatedEventId: &t.InitiatedEventId, - Domain: &t.Domain, - WorkflowExecution: thriftWorkflowExecution(t.WorkflowExecution), - Control: t.Control, - } -} - -func thriftMarkerRecordedEventAttributes(t *apiv1.MarkerRecordedEventAttributes) *shared.MarkerRecordedEventAttributes { - if t == nil { - return nil - } - return &shared.MarkerRecordedEventAttributes{ - MarkerName: &t.MarkerName, - Details: thriftPayload(t.Details), - DecisionTaskCompletedEventId: &t.DecisionTaskCompletedEventId, - Header: thriftHeader(t.Header), - } -} - -func thriftRequestCancelActivityTaskFailedEventAttributes(t *apiv1.RequestCancelActivityTaskFailedEventAttributes) *shared.RequestCancelActivityTaskFailedEventAttributes { - if t == nil { - return nil - } - return &shared.RequestCancelActivityTaskFailedEventAttributes{ - ActivityId: &t.ActivityId, - Cause: &t.Cause, - DecisionTaskCompletedEventId: &t.DecisionTaskCompletedEventId, - } -} - -func thriftRequestCancelExternalWorkflowExecutionFailedEventAttributes(t *apiv1.RequestCancelExternalWorkflowExecutionFailedEventAttributes) *shared.RequestCancelExternalWorkflowExecutionFailedEventAttributes { - if t == nil { - return nil - } - return &shared.RequestCancelExternalWorkflowExecutionFailedEventAttributes{ - Cause: thriftCancelExternalWorkflowExecutionFailedCause(t.Cause), - DecisionTaskCompletedEventId: &t.DecisionTaskCompletedEventId, - Domain: &t.Domain, - WorkflowExecution: thriftWorkflowExecution(t.WorkflowExecution), - InitiatedEventId: &t.InitiatedEventId, - Control: t.Control, - } -} - -func thriftRequestCancelExternalWorkflowExecutionInitiatedEventAttributes(t *apiv1.RequestCancelExternalWorkflowExecutionInitiatedEventAttributes) *shared.RequestCancelExternalWorkflowExecutionInitiatedEventAttributes { - if t == nil { - return nil - } - return &shared.RequestCancelExternalWorkflowExecutionInitiatedEventAttributes{ - DecisionTaskCompletedEventId: &t.DecisionTaskCompletedEventId, - Domain: &t.Domain, - WorkflowExecution: thriftWorkflowExecution(t.WorkflowExecution), - Control: t.Control, - ChildWorkflowOnly: &t.ChildWorkflowOnly, - } -} - -func thriftSignalExternalWorkflowExecutionFailedEventAttributes(t *apiv1.SignalExternalWorkflowExecutionFailedEventAttributes) *shared.SignalExternalWorkflowExecutionFailedEventAttributes { - if t == nil { - return nil - } - return &shared.SignalExternalWorkflowExecutionFailedEventAttributes{ - Cause: thriftSignalExternalWorkflowExecutionFailedCause(t.Cause), - DecisionTaskCompletedEventId: &t.DecisionTaskCompletedEventId, - Domain: &t.Domain, - WorkflowExecution: thriftWorkflowExecution(t.WorkflowExecution), - InitiatedEventId: &t.InitiatedEventId, - Control: t.Control, - } -} - -func thriftSignalExternalWorkflowExecutionInitiatedEventAttributes(t *apiv1.SignalExternalWorkflowExecutionInitiatedEventAttributes) *shared.SignalExternalWorkflowExecutionInitiatedEventAttributes { - if t == nil { - return nil - } - return &shared.SignalExternalWorkflowExecutionInitiatedEventAttributes{ - DecisionTaskCompletedEventId: &t.DecisionTaskCompletedEventId, - Domain: &t.Domain, - WorkflowExecution: thriftWorkflowExecution(t.WorkflowExecution), - SignalName: &t.SignalName, - Input: thriftPayload(t.Input), - Control: t.Control, - ChildWorkflowOnly: &t.ChildWorkflowOnly, - } -} - -func thriftStartChildWorkflowExecutionFailedEventAttributes(t *apiv1.StartChildWorkflowExecutionFailedEventAttributes) *shared.StartChildWorkflowExecutionFailedEventAttributes { - if t == nil { - return nil - } - return &shared.StartChildWorkflowExecutionFailedEventAttributes{ - Domain: &t.Domain, - WorkflowId: &t.WorkflowId, - WorkflowType: thriftWorkflowType(t.WorkflowType), - Cause: thriftChildWorkflowExecutionFailedCause(t.Cause), - Control: t.Control, - InitiatedEventId: &t.InitiatedEventId, - DecisionTaskCompletedEventId: &t.DecisionTaskCompletedEventId, - } -} - -func thriftStartChildWorkflowExecutionInitiatedEventAttributes(t *apiv1.StartChildWorkflowExecutionInitiatedEventAttributes) *shared.StartChildWorkflowExecutionInitiatedEventAttributes { - if t == nil { - return nil - } - return &shared.StartChildWorkflowExecutionInitiatedEventAttributes{ - Domain: &t.Domain, - WorkflowId: &t.WorkflowId, - WorkflowType: thriftWorkflowType(t.WorkflowType), - TaskList: thriftTaskList(t.TaskList), - Input: thriftPayload(t.Input), - ExecutionStartToCloseTimeoutSeconds: durationToSeconds(t.ExecutionStartToCloseTimeout), - TaskStartToCloseTimeoutSeconds: durationToSeconds(t.TaskStartToCloseTimeout), - ParentClosePolicy: thriftParentClosePolicy(t.ParentClosePolicy), - Control: t.Control, - DecisionTaskCompletedEventId: &t.DecisionTaskCompletedEventId, - WorkflowIdReusePolicy: thriftWorkflowIdReusePolicy(t.WorkflowIdReusePolicy), - RetryPolicy: thriftRetryPolicy(t.RetryPolicy), - CronSchedule: &t.CronSchedule, - Header: thriftHeader(t.Header), - Memo: thriftMemo(t.Memo), - SearchAttributes: thriftSearchAttributes(t.SearchAttributes), - DelayStartSeconds: durationToSeconds(t.DelayStart), - } -} - -func thriftTimerCanceledEventAttributes(t *apiv1.TimerCanceledEventAttributes) *shared.TimerCanceledEventAttributes { - if t == nil { - return nil - } - return &shared.TimerCanceledEventAttributes{ - TimerId: &t.TimerId, - StartedEventId: &t.StartedEventId, - DecisionTaskCompletedEventId: &t.DecisionTaskCompletedEventId, - Identity: &t.Identity, - } -} - -func thriftTimerFiredEventAttributes(t *apiv1.TimerFiredEventAttributes) *shared.TimerFiredEventAttributes { - if t == nil { - return nil - } - return &shared.TimerFiredEventAttributes{ - TimerId: &t.TimerId, - StartedEventId: &t.StartedEventId, - } -} - -func thriftTimerStartedEventAttributes(t *apiv1.TimerStartedEventAttributes) *shared.TimerStartedEventAttributes { - if t == nil { - return nil - } - return &shared.TimerStartedEventAttributes{ - TimerId: &t.TimerId, - StartToFireTimeoutSeconds: int32To64(durationToSeconds(t.StartToFireTimeout)), - DecisionTaskCompletedEventId: &t.DecisionTaskCompletedEventId, - } -} - -func thriftUpsertWorkflowSearchAttributesEventAttributes(t *apiv1.UpsertWorkflowSearchAttributesEventAttributes) *shared.UpsertWorkflowSearchAttributesEventAttributes { - if t == nil { - return nil - } - return &shared.UpsertWorkflowSearchAttributesEventAttributes{ - DecisionTaskCompletedEventId: &t.DecisionTaskCompletedEventId, - SearchAttributes: thriftSearchAttributes(t.SearchAttributes), - } -} - -func thriftWorkflowExecutionCancelRequestedEventAttributes(t *apiv1.WorkflowExecutionCancelRequestedEventAttributes) *shared.WorkflowExecutionCancelRequestedEventAttributes { - if t == nil { - return nil - } - return &shared.WorkflowExecutionCancelRequestedEventAttributes{ - Cause: &t.Cause, - ExternalInitiatedEventId: thriftExternalInitiatedId(t.ExternalExecutionInfo), - ExternalWorkflowExecution: thriftExternalWorkflowExecution(t.ExternalExecutionInfo), - Identity: &t.Identity, - } -} - -func thriftWorkflowExecutionCanceledEventAttributes(t *apiv1.WorkflowExecutionCanceledEventAttributes) *shared.WorkflowExecutionCanceledEventAttributes { - if t == nil { - return nil - } - return &shared.WorkflowExecutionCanceledEventAttributes{ - DecisionTaskCompletedEventId: &t.DecisionTaskCompletedEventId, - Details: thriftPayload(t.Details), - } -} - -func thriftWorkflowExecutionCompletedEventAttributes(t *apiv1.WorkflowExecutionCompletedEventAttributes) *shared.WorkflowExecutionCompletedEventAttributes { - if t == nil { - return nil - } - return &shared.WorkflowExecutionCompletedEventAttributes{ - Result: thriftPayload(t.Result), - DecisionTaskCompletedEventId: &t.DecisionTaskCompletedEventId, - } -} - -func thriftWorkflowExecutionContinuedAsNewEventAttributes(t *apiv1.WorkflowExecutionContinuedAsNewEventAttributes) *shared.WorkflowExecutionContinuedAsNewEventAttributes { - if t == nil { - return nil - } - return &shared.WorkflowExecutionContinuedAsNewEventAttributes{ - NewExecutionRunId: &t.NewExecutionRunId, - WorkflowType: thriftWorkflowType(t.WorkflowType), - TaskList: thriftTaskList(t.TaskList), - Input: thriftPayload(t.Input), - ExecutionStartToCloseTimeoutSeconds: durationToSeconds(t.ExecutionStartToCloseTimeout), - TaskStartToCloseTimeoutSeconds: durationToSeconds(t.TaskStartToCloseTimeout), - DecisionTaskCompletedEventId: &t.DecisionTaskCompletedEventId, - BackoffStartIntervalInSeconds: durationToSeconds(t.BackoffStartInterval), - Initiator: thriftContinueAsNewInitiator(t.Initiator), - FailureReason: thriftFailureReason(t.Failure), - FailureDetails: thriftFailureDetails(t.Failure), - LastCompletionResult: thriftPayload(t.LastCompletionResult), - Header: thriftHeader(t.Header), - Memo: thriftMemo(t.Memo), - SearchAttributes: thriftSearchAttributes(t.SearchAttributes), - } -} - -func thriftWorkflowExecutionFailedEventAttributes(t *apiv1.WorkflowExecutionFailedEventAttributes) *shared.WorkflowExecutionFailedEventAttributes { - if t == nil { - return nil - } - return &shared.WorkflowExecutionFailedEventAttributes{ - Reason: thriftFailureReason(t.Failure), - Details: thriftFailureDetails(t.Failure), - DecisionTaskCompletedEventId: &t.DecisionTaskCompletedEventId, - } -} - -func thriftWorkflowExecutionSignaledEventAttributes(t *apiv1.WorkflowExecutionSignaledEventAttributes) *shared.WorkflowExecutionSignaledEventAttributes { - if t == nil { - return nil - } - return &shared.WorkflowExecutionSignaledEventAttributes{ - SignalName: &t.SignalName, - Input: thriftPayload(t.Input), - Identity: &t.Identity, - } -} - -func thriftWorkflowExecutionStartedEventAttributes(t *apiv1.WorkflowExecutionStartedEventAttributes) *shared.WorkflowExecutionStartedEventAttributes { - if t == nil { - return nil - } - return &shared.WorkflowExecutionStartedEventAttributes{ - WorkflowType: thriftWorkflowType(t.WorkflowType), - ParentWorkflowDomain: thriftParentDomainName(t.ParentExecutionInfo), - ParentWorkflowExecution: thriftParentWorkflowExecution(t.ParentExecutionInfo), - ParentInitiatedEventId: thriftParentInitiatedId(t.ParentExecutionInfo), - TaskList: thriftTaskList(t.TaskList), - Input: thriftPayload(t.Input), - ExecutionStartToCloseTimeoutSeconds: durationToSeconds(t.ExecutionStartToCloseTimeout), - TaskStartToCloseTimeoutSeconds: durationToSeconds(t.TaskStartToCloseTimeout), - ContinuedExecutionRunId: &t.ContinuedExecutionRunId, - Initiator: thriftContinueAsNewInitiator(t.Initiator), - ContinuedFailureReason: thriftFailureReason(t.ContinuedFailure), - ContinuedFailureDetails: thriftFailureDetails(t.ContinuedFailure), - LastCompletionResult: thriftPayload(t.LastCompletionResult), - OriginalExecutionRunId: &t.OriginalExecutionRunId, - Identity: &t.Identity, - FirstExecutionRunId: &t.FirstExecutionRunId, - RetryPolicy: thriftRetryPolicy(t.RetryPolicy), - Attempt: &t.Attempt, - ExpirationTimestamp: timeToUnixNano(t.ExpirationTime), - CronSchedule: &t.CronSchedule, - FirstDecisionTaskBackoffSeconds: durationToSeconds(t.FirstDecisionTaskBackoff), - Memo: thriftMemo(t.Memo), - SearchAttributes: thriftSearchAttributes(t.SearchAttributes), - PrevAutoResetPoints: thriftResetPoints(t.PrevAutoResetPoints), - Header: thriftHeader(t.Header), - } -} - -func thriftWorkflowExecutionTerminatedEventAttributes(t *apiv1.WorkflowExecutionTerminatedEventAttributes) *shared.WorkflowExecutionTerminatedEventAttributes { - if t == nil { - return nil - } - return &shared.WorkflowExecutionTerminatedEventAttributes{ - Reason: &t.Reason, - Details: thriftPayload(t.Details), - Identity: &t.Identity, - } -} - -func thriftWorkflowExecutionTimedOutEventAttributes(t *apiv1.WorkflowExecutionTimedOutEventAttributes) *shared.WorkflowExecutionTimedOutEventAttributes { - if t == nil { - return nil - } - return &shared.WorkflowExecutionTimedOutEventAttributes{ - TimeoutType: thriftTimeoutType(t.TimeoutType), - } -} - -func thriftHistoryEventArray(t []*apiv1.HistoryEvent) []*shared.HistoryEvent { - if t == nil { - return nil - } - v := make([]*shared.HistoryEvent, len(t)) - for i := range t { - v[i] = thriftHistoryEvent(t[i]) - } - return v -} - -func thriftPayloadMap(t map[string]*apiv1.Payload) map[string][]byte { - if t == nil { - return nil - } - v := make(map[string][]byte, len(t)) - for key := range t { - v[key] = thriftPayload(t[key]) - } - return v -} - -func thriftBadBinaryInfoMap(t map[string]*apiv1.BadBinaryInfo) map[string]*shared.BadBinaryInfo { - if t == nil { - return nil - } - v := make(map[string]*shared.BadBinaryInfo, len(t)) - for key := range t { - v[key] = thriftBadBinaryInfo(t[key]) - } - return v -} - -func thriftClusterReplicationConfigurationArray(t []*apiv1.ClusterReplicationConfiguration) []*shared.ClusterReplicationConfiguration { - if t == nil { - return nil - } - v := make([]*shared.ClusterReplicationConfiguration, len(t)) - for i := range t { - v[i] = thriftClusterReplicationConfiguration(t[i]) - } - return v -} - -func thriftPollerInfoArray(t []*apiv1.PollerInfo) []*shared.PollerInfo { - if t == nil { - return nil - } - v := make([]*shared.PollerInfo, len(t)) - for i := range t { - v[i] = thriftPollerInfo(t[i]) - } - return v -} - -func thriftResetPointInfoArray(t []*apiv1.ResetPointInfo) []*shared.ResetPointInfo { - if t == nil { - return nil - } - v := make([]*shared.ResetPointInfo, len(t)) - for i := range t { - v[i] = thriftResetPointInfo(t[i]) - } - return v -} - -func thriftPendingActivityInfoArray(t []*apiv1.PendingActivityInfo) []*shared.PendingActivityInfo { - if t == nil { - return nil - } - v := make([]*shared.PendingActivityInfo, len(t)) - for i := range t { - v[i] = thriftPendingActivityInfo(t[i]) - } - return v -} - -func thriftPendingChildExecutionInfoArray(t []*apiv1.PendingChildExecutionInfo) []*shared.PendingChildExecutionInfo { - if t == nil { - return nil - } - v := make([]*shared.PendingChildExecutionInfo, len(t)) - for i := range t { - v[i] = thriftPendingChildExecutionInfo(t[i]) - } - return v -} - -func thriftIndexedValueTypeMap(t map[string]apiv1.IndexedValueType) map[string]shared.IndexedValueType { - if t == nil { - return nil - } - v := make(map[string]shared.IndexedValueType, len(t)) - for key := range t { - v[key] = thriftIndexedValueType(t[key]) - } - return v -} - -func thriftDataBlobArray(t []*apiv1.DataBlob) []*shared.DataBlob { - if t == nil { - return nil - } - v := make([]*shared.DataBlob, len(t)) - for i := range t { - v[i] = thriftDataBlob(t[i]) - } - return v -} - -func thriftWorkflowExecutionInfoArray(t []*apiv1.WorkflowExecutionInfo) []*shared.WorkflowExecutionInfo { - if t == nil { - return nil - } - v := make([]*shared.WorkflowExecutionInfo, len(t)) - for i := range t { - v[i] = thriftWorkflowExecutionInfo(t[i]) - } - return v -} - -func thriftDescribeDomainResponseArray(t []*apiv1.Domain) []*shared.DescribeDomainResponse { - if t == nil { - return nil - } - v := make([]*shared.DescribeDomainResponse, len(t)) - for i := range t { - v[i] = thriftDescribeDomainResponseDomain(t[i]) - } - return v -} - -func thriftTaskListPartitionMetadataArray(t []*apiv1.TaskListPartitionMetadata) []*shared.TaskListPartitionMetadata { - if t == nil { - return nil - } - v := make([]*shared.TaskListPartitionMetadata, len(t)) - for i := range t { - v[i] = thriftTaskListPartitionMetadata(t[i]) - } - return v -} - -func thriftWorkflowQueryMap(t map[string]*apiv1.WorkflowQuery) map[string]*shared.WorkflowQuery { - if t == nil { - return nil - } - v := make(map[string]*shared.WorkflowQuery, len(t)) - for key := range t { - v[key] = thriftWorkflowQuery(t[key]) - } - return v -} - -func thriftActivityLocalDispatchInfoMap(t map[string]*apiv1.ActivityLocalDispatchInfo) map[string]*shared.ActivityLocalDispatchInfo { - if t == nil { - return nil - } - v := make(map[string]*shared.ActivityLocalDispatchInfo, len(t)) - for key := range t { - v[key] = thriftActivityLocalDispatchInfo(t[key]) - } - return v -} - -func thriftDomainStatus(t apiv1.DomainStatus) *shared.DomainStatus { - switch t { - case apiv1.DomainStatus_DOMAIN_STATUS_INVALID: - return nil - case apiv1.DomainStatus_DOMAIN_STATUS_REGISTERED: - return shared.DomainStatusRegistered.Ptr() - case apiv1.DomainStatus_DOMAIN_STATUS_DEPRECATED: - return shared.DomainStatusDeprecated.Ptr() - case apiv1.DomainStatus_DOMAIN_STATUS_DELETED: - return shared.DomainStatusDeleted.Ptr() - } - panic("unexpected enum value") -} - -func thriftArchivalStatus(t apiv1.ArchivalStatus) *shared.ArchivalStatus { - switch t { - case apiv1.ArchivalStatus_ARCHIVAL_STATUS_INVALID: - return nil - case apiv1.ArchivalStatus_ARCHIVAL_STATUS_DISABLED: - return shared.ArchivalStatusDisabled.Ptr() - case apiv1.ArchivalStatus_ARCHIVAL_STATUS_ENABLED: - return shared.ArchivalStatusEnabled.Ptr() - } - panic("unexpected enum value") -} - -func thriftTaskListKind(t apiv1.TaskListKind) *shared.TaskListKind { - switch t { - case apiv1.TaskListKind_TASK_LIST_KIND_INVALID: - return nil - case apiv1.TaskListKind_TASK_LIST_KIND_NORMAL: - return shared.TaskListKindNormal.Ptr() - case apiv1.TaskListKind_TASK_LIST_KIND_STICKY: - return shared.TaskListKindSticky.Ptr() - } - panic("unexpected enum value") -} - -func thriftWorkflowExecutionCloseStatus(t apiv1.WorkflowExecutionCloseStatus) *shared.WorkflowExecutionCloseStatus { - switch t { - case apiv1.WorkflowExecutionCloseStatus_WORKFLOW_EXECUTION_CLOSE_STATUS_INVALID: - return nil - case apiv1.WorkflowExecutionCloseStatus_WORKFLOW_EXECUTION_CLOSE_STATUS_COMPLETED: - return shared.WorkflowExecutionCloseStatusCompleted.Ptr() - case apiv1.WorkflowExecutionCloseStatus_WORKFLOW_EXECUTION_CLOSE_STATUS_FAILED: - return shared.WorkflowExecutionCloseStatusFailed.Ptr() - case apiv1.WorkflowExecutionCloseStatus_WORKFLOW_EXECUTION_CLOSE_STATUS_CANCELED: - return shared.WorkflowExecutionCloseStatusCanceled.Ptr() - case apiv1.WorkflowExecutionCloseStatus_WORKFLOW_EXECUTION_CLOSE_STATUS_TERMINATED: - return shared.WorkflowExecutionCloseStatusTerminated.Ptr() - case apiv1.WorkflowExecutionCloseStatus_WORKFLOW_EXECUTION_CLOSE_STATUS_CONTINUED_AS_NEW: - return shared.WorkflowExecutionCloseStatusContinuedAsNew.Ptr() - case apiv1.WorkflowExecutionCloseStatus_WORKFLOW_EXECUTION_CLOSE_STATUS_TIMED_OUT: - return shared.WorkflowExecutionCloseStatusTimedOut.Ptr() - } - panic("unexpected enum value") -} - -func thriftPendingActivityState(t apiv1.PendingActivityState) *shared.PendingActivityState { - switch t { - case apiv1.PendingActivityState_PENDING_ACTIVITY_STATE_INVALID: - return nil - case apiv1.PendingActivityState_PENDING_ACTIVITY_STATE_SCHEDULED: - return shared.PendingActivityStateScheduled.Ptr() - case apiv1.PendingActivityState_PENDING_ACTIVITY_STATE_STARTED: - return shared.PendingActivityStateStarted.Ptr() - case apiv1.PendingActivityState_PENDING_ACTIVITY_STATE_CANCEL_REQUESTED: - return shared.PendingActivityStateCancelRequested.Ptr() - } - panic("unexpected enum value") -} - -func thriftParentClosePolicy(t apiv1.ParentClosePolicy) *shared.ParentClosePolicy { - switch t { - case apiv1.ParentClosePolicy_PARENT_CLOSE_POLICY_INVALID: - return nil - case apiv1.ParentClosePolicy_PARENT_CLOSE_POLICY_ABANDON: - return shared.ParentClosePolicyAbandon.Ptr() - case apiv1.ParentClosePolicy_PARENT_CLOSE_POLICY_REQUEST_CANCEL: - return shared.ParentClosePolicyRequestCancel.Ptr() - case apiv1.ParentClosePolicy_PARENT_CLOSE_POLICY_TERMINATE: - return shared.ParentClosePolicyTerminate.Ptr() - } - panic("unexpected enum value") -} - -func thriftPendingDecisionState(t apiv1.PendingDecisionState) *shared.PendingDecisionState { - switch t { - case apiv1.PendingDecisionState_PENDING_DECISION_STATE_INVALID: - return nil - case apiv1.PendingDecisionState_PENDING_DECISION_STATE_SCHEDULED: - return shared.PendingDecisionStateScheduled.Ptr() - case apiv1.PendingDecisionState_PENDING_DECISION_STATE_STARTED: - return shared.PendingDecisionStateStarted.Ptr() - } - panic("unexpected enum value") -} - -func thriftIndexedValueType(t apiv1.IndexedValueType) shared.IndexedValueType { - switch t { - case apiv1.IndexedValueType_INDEXED_VALUE_TYPE_INVALID: - panic("received IndexedValueType_INDEXED_VALUE_TYPE_INVALID") - case apiv1.IndexedValueType_INDEXED_VALUE_TYPE_STRING: - return shared.IndexedValueTypeString - case apiv1.IndexedValueType_INDEXED_VALUE_TYPE_KEYWORD: - return shared.IndexedValueTypeKeyword - case apiv1.IndexedValueType_INDEXED_VALUE_TYPE_INT: - return shared.IndexedValueTypeInt - case apiv1.IndexedValueType_INDEXED_VALUE_TYPE_DOUBLE: - return shared.IndexedValueTypeDouble - case apiv1.IndexedValueType_INDEXED_VALUE_TYPE_BOOL: - return shared.IndexedValueTypeBool - case apiv1.IndexedValueType_INDEXED_VALUE_TYPE_DATETIME: - return shared.IndexedValueTypeDatetime - } - panic("unexpected enum value") -} - -func thriftEncodingType(t apiv1.EncodingType) *shared.EncodingType { - switch t { - case apiv1.EncodingType_ENCODING_TYPE_INVALID: - return nil - case apiv1.EncodingType_ENCODING_TYPE_THRIFTRW: - return shared.EncodingTypeThriftRW.Ptr() - case apiv1.EncodingType_ENCODING_TYPE_JSON: - return shared.EncodingTypeJSON.Ptr() - case apiv1.EncodingType_ENCODING_TYPE_PROTO3: - panic("not supported yet") - } - panic("unexpected enum value") -} - -func thriftTimeoutType(t apiv1.TimeoutType) *shared.TimeoutType { - switch t { - case apiv1.TimeoutType_TIMEOUT_TYPE_INVALID: - return nil - case apiv1.TimeoutType_TIMEOUT_TYPE_START_TO_CLOSE: - return shared.TimeoutTypeStartToClose.Ptr() - case apiv1.TimeoutType_TIMEOUT_TYPE_SCHEDULE_TO_START: - return shared.TimeoutTypeScheduleToStart.Ptr() - case apiv1.TimeoutType_TIMEOUT_TYPE_SCHEDULE_TO_CLOSE: - return shared.TimeoutTypeScheduleToClose.Ptr() - case apiv1.TimeoutType_TIMEOUT_TYPE_HEARTBEAT: - return shared.TimeoutTypeHeartbeat.Ptr() - } - panic("unexpected enum value") -} - - -func thriftDecisionTaskFailedCause(t apiv1.DecisionTaskFailedCause) *shared.DecisionTaskFailedCause { - switch t { - case apiv1.DecisionTaskFailedCause_DECISION_TASK_FAILED_CAUSE_INVALID: - return nil - case apiv1.DecisionTaskFailedCause_DECISION_TASK_FAILED_CAUSE_UNHANDLED_DECISION: - return shared.DecisionTaskFailedCauseUnhandledDecision.Ptr() - case apiv1.DecisionTaskFailedCause_DECISION_TASK_FAILED_CAUSE_BAD_SCHEDULE_ACTIVITY_ATTRIBUTES: - return shared.DecisionTaskFailedCauseBadScheduleActivityAttributes.Ptr() - case apiv1.DecisionTaskFailedCause_DECISION_TASK_FAILED_CAUSE_BAD_REQUEST_CANCEL_ACTIVITY_ATTRIBUTES: - return shared.DecisionTaskFailedCauseBadRequestCancelActivityAttributes.Ptr() - case apiv1.DecisionTaskFailedCause_DECISION_TASK_FAILED_CAUSE_BAD_START_TIMER_ATTRIBUTES: - return shared.DecisionTaskFailedCauseBadStartTimerAttributes.Ptr() - case apiv1.DecisionTaskFailedCause_DECISION_TASK_FAILED_CAUSE_BAD_CANCEL_TIMER_ATTRIBUTES: - return shared.DecisionTaskFailedCauseBadCancelTimerAttributes.Ptr() - case apiv1.DecisionTaskFailedCause_DECISION_TASK_FAILED_CAUSE_BAD_RECORD_MARKER_ATTRIBUTES: - return shared.DecisionTaskFailedCauseBadRecordMarkerAttributes.Ptr() - case apiv1.DecisionTaskFailedCause_DECISION_TASK_FAILED_CAUSE_BAD_COMPLETE_WORKFLOW_EXECUTION_ATTRIBUTES: - return shared.DecisionTaskFailedCauseBadCompleteWorkflowExecutionAttributes.Ptr() - case apiv1.DecisionTaskFailedCause_DECISION_TASK_FAILED_CAUSE_BAD_FAIL_WORKFLOW_EXECUTION_ATTRIBUTES: - return shared.DecisionTaskFailedCauseBadFailWorkflowExecutionAttributes.Ptr() - case apiv1.DecisionTaskFailedCause_DECISION_TASK_FAILED_CAUSE_BAD_CANCEL_WORKFLOW_EXECUTION_ATTRIBUTES: - return shared.DecisionTaskFailedCauseBadCancelWorkflowExecutionAttributes.Ptr() - case apiv1.DecisionTaskFailedCause_DECISION_TASK_FAILED_CAUSE_BAD_REQUEST_CANCEL_EXTERNAL_WORKFLOW_EXECUTION_ATTRIBUTES: - return shared.DecisionTaskFailedCauseBadRequestCancelExternalWorkflowExecutionAttributes.Ptr() - case apiv1.DecisionTaskFailedCause_DECISION_TASK_FAILED_CAUSE_BAD_CONTINUE_AS_NEW_ATTRIBUTES: - return shared.DecisionTaskFailedCauseBadContinueAsNewAttributes.Ptr() - case apiv1.DecisionTaskFailedCause_DECISION_TASK_FAILED_CAUSE_START_TIMER_DUPLICATE_ID: - return shared.DecisionTaskFailedCauseStartTimerDuplicateID.Ptr() - case apiv1.DecisionTaskFailedCause_DECISION_TASK_FAILED_CAUSE_RESET_STICKY_TASK_LIST: - return shared.DecisionTaskFailedCauseResetStickyTasklist.Ptr() - case apiv1.DecisionTaskFailedCause_DECISION_TASK_FAILED_CAUSE_WORKFLOW_WORKER_UNHANDLED_FAILURE: - return shared.DecisionTaskFailedCauseWorkflowWorkerUnhandledFailure.Ptr() - case apiv1.DecisionTaskFailedCause_DECISION_TASK_FAILED_CAUSE_BAD_SIGNAL_WORKFLOW_EXECUTION_ATTRIBUTES: - return shared.DecisionTaskFailedCauseBadSignalWorkflowExecutionAttributes.Ptr() - case apiv1.DecisionTaskFailedCause_DECISION_TASK_FAILED_CAUSE_BAD_START_CHILD_EXECUTION_ATTRIBUTES: - return shared.DecisionTaskFailedCauseBadStartChildExecutionAttributes.Ptr() - case apiv1.DecisionTaskFailedCause_DECISION_TASK_FAILED_CAUSE_FORCE_CLOSE_DECISION: - return shared.DecisionTaskFailedCauseForceCloseDecision.Ptr() - case apiv1.DecisionTaskFailedCause_DECISION_TASK_FAILED_CAUSE_FAILOVER_CLOSE_DECISION: - return shared.DecisionTaskFailedCauseFailoverCloseDecision.Ptr() - case apiv1.DecisionTaskFailedCause_DECISION_TASK_FAILED_CAUSE_BAD_SIGNAL_INPUT_SIZE: - return shared.DecisionTaskFailedCauseBadSignalInputSize.Ptr() - case apiv1.DecisionTaskFailedCause_DECISION_TASK_FAILED_CAUSE_RESET_WORKFLOW: - return shared.DecisionTaskFailedCauseResetWorkflow.Ptr() - case apiv1.DecisionTaskFailedCause_DECISION_TASK_FAILED_CAUSE_BAD_BINARY: - return shared.DecisionTaskFailedCauseBadBinary.Ptr() - case apiv1.DecisionTaskFailedCause_DECISION_TASK_FAILED_CAUSE_SCHEDULE_ACTIVITY_DUPLICATE_ID: - return shared.DecisionTaskFailedCauseScheduleActivityDuplicateID.Ptr() - case apiv1.DecisionTaskFailedCause_DECISION_TASK_FAILED_CAUSE_BAD_SEARCH_ATTRIBUTES: - return shared.DecisionTaskFailedCauseBadSearchAttributes.Ptr() - } - panic("unexpected enum value") -} - -func thriftDecisionTaskTimedOutCause(t apiv1.DecisionTaskTimedOutCause) *shared.DecisionTaskTimedOutCause { - switch t { - case apiv1.DecisionTaskTimedOutCause_DECISION_TASK_TIMED_OUT_CAUSE_INVALID: - return nil - case apiv1.DecisionTaskTimedOutCause_DECISION_TASK_TIMED_OUT_CAUSE_TIMEOUT: - return shared.DecisionTaskTimedOutCauseTimeout.Ptr() - case apiv1.DecisionTaskTimedOutCause_DECISION_TASK_TIMED_OUT_CAUSE_RESET: - return shared.DecisionTaskTimedOutCauseReset.Ptr() - } - panic("unexpected enum value") -} - -func thriftCancelExternalWorkflowExecutionFailedCause(t apiv1.CancelExternalWorkflowExecutionFailedCause) *shared.CancelExternalWorkflowExecutionFailedCause { - switch t { - case apiv1.CancelExternalWorkflowExecutionFailedCause_CANCEL_EXTERNAL_WORKFLOW_EXECUTION_FAILED_CAUSE_INVALID: - return nil - case apiv1.CancelExternalWorkflowExecutionFailedCause_CANCEL_EXTERNAL_WORKFLOW_EXECUTION_FAILED_CAUSE_UNKNOWN_EXTERNAL_WORKFLOW_EXECUTION: - return shared.CancelExternalWorkflowExecutionFailedCauseUnknownExternalWorkflowExecution.Ptr() - } - panic("unexpected enum value") -} - -func thriftSignalExternalWorkflowExecutionFailedCause(t apiv1.SignalExternalWorkflowExecutionFailedCause) *shared.SignalExternalWorkflowExecutionFailedCause { - switch t { - case apiv1.SignalExternalWorkflowExecutionFailedCause_SIGNAL_EXTERNAL_WORKFLOW_EXECUTION_FAILED_CAUSE_INVALID: - return nil - case apiv1.SignalExternalWorkflowExecutionFailedCause_SIGNAL_EXTERNAL_WORKFLOW_EXECUTION_FAILED_CAUSE_UNKNOWN_EXTERNAL_WORKFLOW_EXECUTION: - return shared.SignalExternalWorkflowExecutionFailedCauseUnknownExternalWorkflowExecution.Ptr() - } - panic("unexpected enum value") -} - -func thriftChildWorkflowExecutionFailedCause(t apiv1.ChildWorkflowExecutionFailedCause) *shared.ChildWorkflowExecutionFailedCause { - switch t { - case apiv1.ChildWorkflowExecutionFailedCause_CHILD_WORKFLOW_EXECUTION_FAILED_CAUSE_INVALID: - return nil - case apiv1.ChildWorkflowExecutionFailedCause_CHILD_WORKFLOW_EXECUTION_FAILED_CAUSE_WORKFLOW_ALREADY_RUNNING: - return shared.ChildWorkflowExecutionFailedCauseWorkflowAlreadyRunning.Ptr() - } - panic("unexpected enum value") -} - -func thriftWorkflowIdReusePolicy(t apiv1.WorkflowIdReusePolicy) *shared.WorkflowIdReusePolicy { - switch t { - case apiv1.WorkflowIdReusePolicy_WORKFLOW_ID_REUSE_POLICY_INVALID: - return nil - case apiv1.WorkflowIdReusePolicy_WORKFLOW_ID_REUSE_POLICY_ALLOW_DUPLICATE_FAILED_ONLY: - return shared.WorkflowIdReusePolicyAllowDuplicateFailedOnly.Ptr() - case apiv1.WorkflowIdReusePolicy_WORKFLOW_ID_REUSE_POLICY_ALLOW_DUPLICATE: - return shared.WorkflowIdReusePolicyAllowDuplicate.Ptr() - case apiv1.WorkflowIdReusePolicy_WORKFLOW_ID_REUSE_POLICY_REJECT_DUPLICATE: - return shared.WorkflowIdReusePolicyRejectDuplicate.Ptr() - case apiv1.WorkflowIdReusePolicy_WORKFLOW_ID_REUSE_POLICY_TERMINATE_IF_RUNNING: - return shared.WorkflowIdReusePolicyTerminateIfRunning.Ptr() - } - panic("unexpected enum value") -} - -func thriftContinueAsNewInitiator(t apiv1.ContinueAsNewInitiator) *shared.ContinueAsNewInitiator { - switch t { - case apiv1.ContinueAsNewInitiator_CONTINUE_AS_NEW_INITIATOR_INVALID: - return nil - case apiv1.ContinueAsNewInitiator_CONTINUE_AS_NEW_INITIATOR_DECIDER: - return shared.ContinueAsNewInitiatorDecider.Ptr() - case apiv1.ContinueAsNewInitiator_CONTINUE_AS_NEW_INITIATOR_RETRY_POLICY: - return shared.ContinueAsNewInitiatorRetryPolicy.Ptr() - case apiv1.ContinueAsNewInitiator_CONTINUE_AS_NEW_INITIATOR_CRON_SCHEDULE: - return shared.ContinueAsNewInitiatorCronSchedule.Ptr() - } - panic("unexpected enum value") -} \ No newline at end of file diff --git a/internal/compatibility/testdata/common.go b/internal/compatibility/testdata/common.go new file mode 100644 index 000000000..1e99c6e2f --- /dev/null +++ b/internal/compatibility/testdata/common.go @@ -0,0 +1,345 @@ +// Copyright (c) 2021 Uber Technologies Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +package testdata + +import ( + "time" + + gogo "github.com/gogo/protobuf/types" + apiv1 "go.uber.org/cadence/.gen/proto/api/v1" +) + +const ( + WorkflowID = "WorkflowID" + RunID = "RunID" + RunID1 = "RunID1" + RunID2 = "RunID2" + RunID3 = "RunID3" + + ActivityID = "ActivityID" + RequestID = "RequestID" + TimerID = "TimerID" + + WorkflowTypeName = "WorkflowTypeName" + ActivityTypeName = "ActivityTypeName" + TaskListName = "TaskListName" + MarkerName = "MarkerName" + SignalName = "SignalName" + QueryType = "QueryType" + HostName = "HostName" + Identity = "Identity" + CronSchedule = "CronSchedule" + Checksum = "Checksum" + Reason = "Reason" + Cause = "Cause" + SecurityToken = "SecurityToken" + VisibilityQuery = "VisibilityQuery" + FeatureVersion = "FeatureVersion" + ClientImpl = "ClientImpl" + ClientLibraryVersion = "ClientLibraryVersion" + SupportedVersions = "SupportedVersions" + + Attempt = 2 + PageSize = 10 + HistoryLength = 20 + BacklogCountHint = 30 + AckLevel = 1001 + ReadLevel = 1002 + RatePerSecond = 3.14 + TaskID = 444 + ShardID = 12345 + MessageID1 = 50001 + MessageID2 = 50002 + EventStoreVersion = 333 + + EventID1 = int64(1) + EventID2 = int64(2) + EventID3 = int64(3) + EventID4 = int64(4) + + Version1 = int64(11) + Version2 = int64(22) + Version3 = int64(33) +) + +var ( + ts = time.Now() + Timestamp, _ = gogo.TimestampProto(ts) + Timestamp1, _ = gogo.TimestampProto(ts.Add(1 * time.Second)) + Timestamp2, _ = gogo.TimestampProto(ts.Add(2 * time.Second)) + Timestamp3, _ = gogo.TimestampProto(ts.Add(3 * time.Second)) + Timestamp4, _ = gogo.TimestampProto(ts.Add(4 * time.Second)) + Timestamp5, _ = gogo.TimestampProto(ts.Add(5 * time.Second)) +) + +var ( + Duration1 = gogo.DurationProto(11 * time.Second) + Duration2 = gogo.DurationProto(12 * time.Second) + Duration3 = gogo.DurationProto(13 * time.Second) + Duration4 = gogo.DurationProto(14 * time.Second) +) + +var ( + Token1 = []byte{1, 0} + Token2 = []byte{2, 0} + Token3 = []byte{3, 0} +) + +var ( + Payload1 = apiv1.Payload{Data: []byte{10, 0}} + Payload2 = apiv1.Payload{Data: []byte{20, 0}} + Payload3 = apiv1.Payload{Data: []byte{30, 0}} +) + +var ( + ExecutionContext = []byte{110, 0} + Control = []byte{120, 0} + NextPageToken = []byte{130, 0} + TaskToken = []byte{140, 0} + BranchToken = []byte{150, 0} + QueryArgs = &apiv1.Payload{Data: []byte{9, 9, 9}} +) + +var ( + FailureReason = "FailureReason" + FailureDetails = []byte{190, 0} +) + +var ( + Failure = apiv1.Failure{ + Reason: FailureReason, + Details: FailureDetails, + } + WorkflowExecution = apiv1.WorkflowExecution{ + WorkflowId: WorkflowID, + RunId: RunID, + } + WorkflowType = apiv1.WorkflowType{ + Name: WorkflowTypeName, + } + ActivityType = apiv1.ActivityType{ + Name: ActivityTypeName, + } + TaskList = apiv1.TaskList{ + Name: TaskListName, + Kind: apiv1.TaskListKind_TASK_LIST_KIND_NORMAL, + } + RetryPolicy = apiv1.RetryPolicy{ + InitialInterval: Duration1, + BackoffCoefficient: 1.1, + MaximumInterval: Duration2, + MaximumAttempts: 3, + NonRetryableErrorReasons: []string{"a", "b"}, + ExpirationInterval: Duration3, + } + Header = apiv1.Header{ + Fields: map[string]*apiv1.Payload{ + "HeaderField1": &apiv1.Payload{Data: []byte{211, 0}}, + "HeaderField2": &apiv1.Payload{Data: []byte{212, 0}}, + }, + } + Memo = apiv1.Memo{ + Fields: map[string]*apiv1.Payload{ + "MemoField1": &apiv1.Payload{Data: []byte{221, 0}}, + "MemoField2": &apiv1.Payload{Data: []byte{222, 0}}, + }, + } + SearchAttributes = apiv1.SearchAttributes{ + IndexedFields: map[string]*apiv1.Payload{ + "IndexedField1": &apiv1.Payload{Data: []byte{231, 0}}, + "IndexedField2": &apiv1.Payload{Data: []byte{232, 0}}, + }, + } + PayloadMap = map[string]*apiv1.Payload{ + "Payload1": &Payload1, + "Payload2": &Payload2, + } + ResetPointInfo = apiv1.ResetPointInfo{ + BinaryChecksum: Checksum, + RunId: RunID1, + FirstDecisionCompletedId: EventID1, + CreatedTime: Timestamp1, + ExpiringTime: Timestamp2, + Resettable: true, + } + ResetPointInfoArray = []*apiv1.ResetPointInfo{ + &ResetPointInfo, + } + ResetPoints = apiv1.ResetPoints{ + Points: ResetPointInfoArray, + } + DataBlob = apiv1.DataBlob{ + EncodingType: EncodingType, + Data: []byte{7, 7, 7}, + } + DataBlobArray = []*apiv1.DataBlob{ + &DataBlob, + } + StickyExecutionAttributes = apiv1.StickyExecutionAttributes{ + WorkerTaskList: &TaskList, + ScheduleToStartTimeout: Duration1, + } + ActivityLocalDispatchInfo = apiv1.ActivityLocalDispatchInfo{ + ActivityId: ActivityID, + ScheduledTime: Timestamp1, + StartedTime: Timestamp2, + ScheduledTimeOfThisAttempt: Timestamp3, + TaskToken: TaskToken, + } + ActivityLocalDispatchInfoMap = map[string]*apiv1.ActivityLocalDispatchInfo{ + ActivityID: &ActivityLocalDispatchInfo, + } + TaskListMetadata = apiv1.TaskListMetadata{ + MaxTasksPerSecond: &gogo.DoubleValue{Value: RatePerSecond}, + } + WorkerVersionInfo = apiv1.WorkerVersionInfo{ + Impl: ClientImpl, + FeatureVersion: FeatureVersion, + } + PollerInfo = apiv1.PollerInfo{ + LastAccessTime: Timestamp1, + Identity: Identity, + RatePerSecond: RatePerSecond, + } + PollerInfoArray = []*apiv1.PollerInfo{ + &PollerInfo, + } + TaskListStatus = apiv1.TaskListStatus{ + BacklogCountHint: BacklogCountHint, + ReadLevel: ReadLevel, + AckLevel: AckLevel, + RatePerSecond: RatePerSecond, + TaskIdBlock: &TaskIDBlock, + } + TaskIDBlock = apiv1.TaskIDBlock{ + StartId: 551, + EndId: 559, + } + TaskListPartitionMetadata = apiv1.TaskListPartitionMetadata{ + Key: "Key", + OwnerHostName: "HostName", + } + TaskListPartitionMetadataArray = []*apiv1.TaskListPartitionMetadata{ + &TaskListPartitionMetadata, + } + SupportedClientVersions = apiv1.SupportedClientVersions{ + GoSdk: "GoSDK", + JavaSdk: "JavaSDK", + } + IndexedValueTypeMap = map[string]apiv1.IndexedValueType{ + "IndexedValueType1": IndexedValueType, + } + ParentExecutionInfo = apiv1.ParentExecutionInfo{ + DomainId: DomainID, + DomainName: DomainName, + WorkflowExecution: &WorkflowExecution, + InitiatedId: EventID1, + } + WorkflowExecutionFilter = apiv1.WorkflowExecutionFilter{ + WorkflowId: WorkflowID, + RunId: RunID, + } + WorkflowTypeFilter = apiv1.WorkflowTypeFilter{ + Name: WorkflowTypeName, + } + StartTimeFilter = apiv1.StartTimeFilter{ + EarliestTime: Timestamp1, + LatestTime: Timestamp2, + } + StatusFilter = apiv1.StatusFilter{ + Status: WorkflowExecutionCloseStatus, + } + WorkflowExecutionInfo = apiv1.WorkflowExecutionInfo{ + WorkflowExecution: &WorkflowExecution, + Type: &WorkflowType, + StartTime: Timestamp1, + CloseTime: Timestamp2, + CloseStatus: WorkflowExecutionCloseStatus, + HistoryLength: HistoryLength, + ParentExecutionInfo: &apiv1.ParentExecutionInfo{ + DomainId: DomainID, + WorkflowExecution: &WorkflowExecution, + }, + ExecutionTime: Timestamp3, + Memo: &Memo, + SearchAttributes: &SearchAttributes, + AutoResetPoints: &ResetPoints, + TaskList: TaskListName, + } + WorkflowExecutionInfoArray = []*apiv1.WorkflowExecutionInfo{&WorkflowExecutionInfo} + + WorkflowQuery = apiv1.WorkflowQuery{ + QueryType: QueryType, + QueryArgs: QueryArgs, + } + WorkflowQueryMap = map[string]*apiv1.WorkflowQuery{ + "WorkflowQuery1": &WorkflowQuery, + } + WorkflowQueryResult = apiv1.WorkflowQueryResult{ + ResultType: QueryResultType, + Answer: &Payload1, + ErrorMessage: ErrorMessage, + } + WorkflowQueryResultMap = map[string]*apiv1.WorkflowQueryResult{ + "WorkflowQuery1": &WorkflowQueryResult, + } + QueryRejected = apiv1.QueryRejected{ + CloseStatus: WorkflowExecutionCloseStatus, + } + WorkflowExecutionConfiguration = apiv1.WorkflowExecutionConfiguration{ + TaskList: &TaskList, + ExecutionStartToCloseTimeout: Duration1, + TaskStartToCloseTimeout: Duration2, + } + PendingActivityInfo = apiv1.PendingActivityInfo{ + ActivityId: ActivityID, + ActivityType: &ActivityType, + State: PendingActivityState, + HeartbeatDetails: &Payload1, + LastHeartbeatTime: Timestamp1, + LastStartedTime: Timestamp2, + Attempt: Attempt, + MaximumAttempts: 3, + ScheduledTime: Timestamp3, + ExpirationTime: Timestamp4, + LastFailure: &Failure, + LastWorkerIdentity: Identity, + } + PendingActivityInfoArray = []*apiv1.PendingActivityInfo{ + &PendingActivityInfo, + } + PendingChildExecutionInfo = apiv1.PendingChildExecutionInfo{ + WorkflowExecution: &WorkflowExecution, + WorkflowTypeName: WorkflowTypeName, + InitiatedId: EventID1, + ParentClosePolicy: ParentClosePolicy, + } + PendingChildExecutionInfoArray = []*apiv1.PendingChildExecutionInfo{ + &PendingChildExecutionInfo, + } + PendingDecisionInfo = apiv1.PendingDecisionInfo{ + State: PendingDecisionState, + ScheduledTime: Timestamp1, + StartedTime: Timestamp2, + Attempt: Attempt, + OriginalScheduledTime: Timestamp3, + } +) diff --git a/internal/compatibility/testdata/decision.go b/internal/compatibility/testdata/decision.go new file mode 100644 index 000000000..d2c251e46 --- /dev/null +++ b/internal/compatibility/testdata/decision.go @@ -0,0 +1,172 @@ +// Copyright (c) 2021 Uber Technologies Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +package testdata + +import ( + apiv1 "go.uber.org/cadence/.gen/proto/api/v1" +) + +var ( + DecisionArray = []*apiv1.Decision{ + &Decision_CancelTimer, + &Decision_CancelWorkflowExecution, + &Decision_CompleteWorkflowExecution, + &Decision_ContinueAsNewWorkflowExecution, + &Decision_FailWorkflowExecution, + &Decision_RecordMarker, + &Decision_RequestCancelActivityTask, + &Decision_RequestCancelExternalWorkflowExecution, + &Decision_ScheduleActivityTask, + &Decision_SignalExternalWorkflowExecution, + &Decision_StartChildWorkflowExecution, + &Decision_StartTimer, + &Decision_UpsertWorkflowSearchAttributes, + } + + Decision_CancelTimer = apiv1.Decision{Attributes: &apiv1.Decision_CancelTimerDecisionAttributes{ + CancelTimerDecisionAttributes: &CancelTimerDecisionAttributes, + }} + Decision_CancelWorkflowExecution = apiv1.Decision{Attributes: &apiv1.Decision_CancelWorkflowExecutionDecisionAttributes{ + CancelWorkflowExecutionDecisionAttributes: &CancelWorkflowExecutionDecisionAttributes, + }} + Decision_CompleteWorkflowExecution = apiv1.Decision{Attributes: &apiv1.Decision_CompleteWorkflowExecutionDecisionAttributes{ + CompleteWorkflowExecutionDecisionAttributes: &CompleteWorkflowExecutionDecisionAttributes, + }} + Decision_ContinueAsNewWorkflowExecution = apiv1.Decision{Attributes: &apiv1.Decision_ContinueAsNewWorkflowExecutionDecisionAttributes{ + ContinueAsNewWorkflowExecutionDecisionAttributes: &ContinueAsNewWorkflowExecutionDecisionAttributes, + }} + Decision_FailWorkflowExecution = apiv1.Decision{Attributes: &apiv1.Decision_FailWorkflowExecutionDecisionAttributes{ + FailWorkflowExecutionDecisionAttributes: &FailWorkflowExecutionDecisionAttributes, + }} + Decision_RecordMarker = apiv1.Decision{Attributes: &apiv1.Decision_RecordMarkerDecisionAttributes{ + RecordMarkerDecisionAttributes: &RecordMarkerDecisionAttributes, + }} + Decision_RequestCancelActivityTask = apiv1.Decision{Attributes: &apiv1.Decision_RequestCancelActivityTaskDecisionAttributes{ + RequestCancelActivityTaskDecisionAttributes: &RequestCancelActivityTaskDecisionAttributes, + }} + Decision_RequestCancelExternalWorkflowExecution = apiv1.Decision{Attributes: &apiv1.Decision_RequestCancelExternalWorkflowExecutionDecisionAttributes{ + RequestCancelExternalWorkflowExecutionDecisionAttributes: &RequestCancelExternalWorkflowExecutionDecisionAttributes, + }} + Decision_ScheduleActivityTask = apiv1.Decision{Attributes: &apiv1.Decision_ScheduleActivityTaskDecisionAttributes{ + ScheduleActivityTaskDecisionAttributes: &ScheduleActivityTaskDecisionAttributes, + }} + Decision_SignalExternalWorkflowExecution = apiv1.Decision{Attributes: &apiv1.Decision_SignalExternalWorkflowExecutionDecisionAttributes{ + SignalExternalWorkflowExecutionDecisionAttributes: &SignalExternalWorkflowExecutionDecisionAttributes, + }} + Decision_StartChildWorkflowExecution = apiv1.Decision{Attributes: &apiv1.Decision_StartChildWorkflowExecutionDecisionAttributes{ + StartChildWorkflowExecutionDecisionAttributes: &StartChildWorkflowExecutionDecisionAttributes, + }} + Decision_StartTimer = apiv1.Decision{Attributes: &apiv1.Decision_StartTimerDecisionAttributes{ + StartTimerDecisionAttributes: &StartTimerDecisionAttributes, + }} + Decision_UpsertWorkflowSearchAttributes = apiv1.Decision{Attributes: &apiv1.Decision_UpsertWorkflowSearchAttributesDecisionAttributes{ + UpsertWorkflowSearchAttributesDecisionAttributes: &UpsertWorkflowSearchAttributesDecisionAttributes, + }} + + CancelTimerDecisionAttributes = apiv1.CancelTimerDecisionAttributes{ + TimerId: TimerID, + } + CancelWorkflowExecutionDecisionAttributes = apiv1.CancelWorkflowExecutionDecisionAttributes{ + Details: &Payload1, + } + CompleteWorkflowExecutionDecisionAttributes = apiv1.CompleteWorkflowExecutionDecisionAttributes{ + Result: &Payload1, + } + ContinueAsNewWorkflowExecutionDecisionAttributes = apiv1.ContinueAsNewWorkflowExecutionDecisionAttributes{ + WorkflowType: &WorkflowType, + TaskList: &TaskList, + Input: &Payload1, + ExecutionStartToCloseTimeout: Duration1, + TaskStartToCloseTimeout: Duration2, + BackoffStartInterval: Duration3, + RetryPolicy: &RetryPolicy, + Initiator: ContinueAsNewInitiator, + Failure: &Failure, + LastCompletionResult: &Payload2, + CronSchedule: CronSchedule, + Header: &Header, + Memo: &Memo, + SearchAttributes: &SearchAttributes, + } + FailWorkflowExecutionDecisionAttributes = apiv1.FailWorkflowExecutionDecisionAttributes{ + Failure: &Failure, + } + RecordMarkerDecisionAttributes = apiv1.RecordMarkerDecisionAttributes{ + MarkerName: MarkerName, + Details: &Payload1, + Header: &Header, + } + RequestCancelActivityTaskDecisionAttributes = apiv1.RequestCancelActivityTaskDecisionAttributes{ + ActivityId: ActivityID, + } + RequestCancelExternalWorkflowExecutionDecisionAttributes = apiv1.RequestCancelExternalWorkflowExecutionDecisionAttributes{ + Domain: DomainName, + WorkflowExecution: &WorkflowExecution, + Control: Control, + ChildWorkflowOnly: true, + } + ScheduleActivityTaskDecisionAttributes = apiv1.ScheduleActivityTaskDecisionAttributes{ + ActivityId: ActivityID, + ActivityType: &ActivityType, + Domain: DomainName, + TaskList: &TaskList, + Input: &Payload1, + ScheduleToCloseTimeout: Duration1, + ScheduleToStartTimeout: Duration2, + StartToCloseTimeout: Duration3, + HeartbeatTimeout: Duration4, + RetryPolicy: &RetryPolicy, + Header: &Header, + RequestLocalDispatch: true, + } + SignalExternalWorkflowExecutionDecisionAttributes = apiv1.SignalExternalWorkflowExecutionDecisionAttributes{ + Domain: DomainName, + WorkflowExecution: &WorkflowExecution, + SignalName: SignalName, + Input: &Payload1, + Control: Control, + ChildWorkflowOnly: true, + } + StartChildWorkflowExecutionDecisionAttributes = apiv1.StartChildWorkflowExecutionDecisionAttributes{ + Domain: DomainName, + WorkflowId: WorkflowID, + WorkflowType: &WorkflowType, + TaskList: &TaskList, + Input: &Payload1, + ExecutionStartToCloseTimeout: Duration1, + TaskStartToCloseTimeout: Duration2, + ParentClosePolicy: ParentClosePolicy, + Control: Control, + WorkflowIdReusePolicy: WorkflowIDReusePolicy, + RetryPolicy: &RetryPolicy, + CronSchedule: CronSchedule, + Header: &Header, + Memo: &Memo, + SearchAttributes: &SearchAttributes, + } + StartTimerDecisionAttributes = apiv1.StartTimerDecisionAttributes{ + TimerId: TimerID, + StartToFireTimeout: Duration1, + } + UpsertWorkflowSearchAttributesDecisionAttributes = apiv1.UpsertWorkflowSearchAttributesDecisionAttributes{ + SearchAttributes: &SearchAttributes, + } +) diff --git a/internal/compatibility/testdata/domain.go b/internal/compatibility/testdata/domain.go new file mode 100644 index 000000000..883f037d2 --- /dev/null +++ b/internal/compatibility/testdata/domain.go @@ -0,0 +1,90 @@ +// Copyright (c) 2021 Uber Technologies Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +package testdata + +import ( + "time" + + gogo "github.com/gogo/protobuf/types" + apiv1 "go.uber.org/cadence/.gen/proto/api/v1" +) + +const ( + DomainID = "DomainID" + DomainName = "DomainName" + DomainDescription = "DomainDescription" + DomainOwnerEmail = "DomainOwnerEmail" + DomainDataKey = "DomainDataKey" + DomainDataValue = "DomainDataValue" + + ClusterName1 = "ClusterName1" + ClusterName2 = "ClusterName2" + + BadBinaryReason = "BadBinaryReason" + BadBinaryOperator = "BadBinaryOperator" + + HistoryArchivalURI = "HistoryArchivalURI" + VisibilityArchivalURI = "VisibilityArchivalURI" + + DeleteBadBinary = "DeleteBadBinary" + + FailoverVersion1 = 301 + FailoverVersion2 = 302 +) + +var ( + DomainRetention = gogo.DurationProto(3 * time.Hour * 24) + + BadBinaryInfo = apiv1.BadBinaryInfo{ + Reason: BadBinaryReason, + Operator: BadBinaryOperator, + CreatedTime: Timestamp1, + } + BadBinaryInfoMap = map[string]*apiv1.BadBinaryInfo{ + "BadBinary1": &BadBinaryInfo, + } + BadBinaries = apiv1.BadBinaries{ + Binaries: BadBinaryInfoMap, + } + DomainData = map[string]string{DomainDataKey: DomainDataValue} + Domain = apiv1.Domain{ + Id: DomainID, + Name: DomainName, + Status: DomainStatus, + Description: DomainDescription, + OwnerEmail: DomainOwnerEmail, + Data: DomainData, + WorkflowExecutionRetentionPeriod: DomainRetention, + BadBinaries: &BadBinaries, + HistoryArchivalStatus: ArchivalStatus, + HistoryArchivalUri: HistoryArchivalURI, + VisibilityArchivalStatus: ArchivalStatus, + VisibilityArchivalUri: VisibilityArchivalURI, + ActiveClusterName: ClusterName1, + Clusters: ClusterReplicationConfigurationArray, + } + ClusterReplicationConfiguration = apiv1.ClusterReplicationConfiguration{ + ClusterName: ClusterName1, + } + ClusterReplicationConfigurationArray = []*apiv1.ClusterReplicationConfiguration{ + &ClusterReplicationConfiguration, + } +) diff --git a/internal/compatibility/testdata/enum.go b/internal/compatibility/testdata/enum.go new file mode 100644 index 000000000..dca858630 --- /dev/null +++ b/internal/compatibility/testdata/enum.go @@ -0,0 +1,48 @@ +// Copyright (c) 2021 Uber Technologies Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +package testdata + +import apiv1 "go.uber.org/cadence/.gen/proto/api/v1" + +var ( + ArchivalStatus = apiv1.ArchivalStatus_ARCHIVAL_STATUS_ENABLED + CancelExternalWorkflowExecutionFailedCause = apiv1.CancelExternalWorkflowExecutionFailedCause_CANCEL_EXTERNAL_WORKFLOW_EXECUTION_FAILED_CAUSE_UNKNOWN_EXTERNAL_WORKFLOW_EXECUTION + ChildWorkflowExecutionFailedCause = apiv1.ChildWorkflowExecutionFailedCause_CHILD_WORKFLOW_EXECUTION_FAILED_CAUSE_WORKFLOW_ALREADY_RUNNING + ContinueAsNewInitiator = apiv1.ContinueAsNewInitiator_CONTINUE_AS_NEW_INITIATOR_RETRY_POLICY + DecisionTaskFailedCause = apiv1.DecisionTaskFailedCause_DECISION_TASK_FAILED_CAUSE_BAD_CANCEL_WORKFLOW_EXECUTION_ATTRIBUTES + DecisionTaskTimedOutCause = apiv1.DecisionTaskTimedOutCause_DECISION_TASK_TIMED_OUT_CAUSE_RESET + DomainStatus = apiv1.DomainStatus_DOMAIN_STATUS_REGISTERED + EncodingType = apiv1.EncodingType_ENCODING_TYPE_JSON + HistoryEventFilterType = apiv1.EventFilterType_EVENT_FILTER_TYPE_CLOSE_EVENT + IndexedValueType = apiv1.IndexedValueType_INDEXED_VALUE_TYPE_INT + ParentClosePolicy = apiv1.ParentClosePolicy_PARENT_CLOSE_POLICY_TERMINATE + PendingActivityState = apiv1.PendingActivityState_PENDING_ACTIVITY_STATE_CANCEL_REQUESTED + PendingDecisionState = apiv1.PendingDecisionState_PENDING_DECISION_STATE_STARTED + QueryConsistencyLevel = apiv1.QueryConsistencyLevel_QUERY_CONSISTENCY_LEVEL_STRONG + QueryRejectCondition = apiv1.QueryRejectCondition_QUERY_REJECT_CONDITION_NOT_COMPLETED_CLEANLY + QueryResultType = apiv1.QueryResultType_QUERY_RESULT_TYPE_FAILED + SignalExternalWorkflowExecutionFailedCause = apiv1.SignalExternalWorkflowExecutionFailedCause_SIGNAL_EXTERNAL_WORKFLOW_EXECUTION_FAILED_CAUSE_UNKNOWN_EXTERNAL_WORKFLOW_EXECUTION + TaskListKind = apiv1.TaskListKind_TASK_LIST_KIND_STICKY + TaskListType = apiv1.TaskListType_TASK_LIST_TYPE_ACTIVITY + TimeoutType = apiv1.TimeoutType_TIMEOUT_TYPE_SCHEDULE_TO_START + WorkflowExecutionCloseStatus = apiv1.WorkflowExecutionCloseStatus_WORKFLOW_EXECUTION_CLOSE_STATUS_CONTINUED_AS_NEW + WorkflowIDReusePolicy = apiv1.WorkflowIdReusePolicy_WORKFLOW_ID_REUSE_POLICY_TERMINATE_IF_RUNNING +) diff --git a/internal/compatibility/testdata/error.go b/internal/compatibility/testdata/error.go new file mode 100644 index 000000000..e9a63f33f --- /dev/null +++ b/internal/compatibility/testdata/error.go @@ -0,0 +1,66 @@ +// Copyright (c) 2021 Uber Technologies Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +package testdata + +import ( + apiv1 "go.uber.org/cadence/.gen/proto/api/v1" + "go.uber.org/yarpc/encoding/protobuf" + "go.uber.org/yarpc/yarpcerrors" +) + +const ( + ErrorMessage = "ErrorMessage" + FeatureFlag = "FeatureFlag" +) + +var ( + AccessDeniedError = protobuf.NewError(yarpcerrors.CodePermissionDenied, ErrorMessage) + BadRequestError = protobuf.NewError(yarpcerrors.CodeInvalidArgument, ErrorMessage) + CancellationAlreadyRequestedError = protobuf.NewError(yarpcerrors.CodeAlreadyExists, ErrorMessage, protobuf.WithErrorDetails(&apiv1.CancellationAlreadyRequestedError{})) + ClientVersionNotSupportedError = protobuf.NewError(yarpcerrors.CodeFailedPrecondition, "Client version not supported", protobuf.WithErrorDetails(&apiv1.ClientVersionNotSupportedError{ + FeatureVersion: FeatureVersion, + ClientImpl: ClientImpl, + SupportedVersions: SupportedVersions, + })) + DomainAlreadyExistsError = protobuf.NewError(yarpcerrors.CodeAlreadyExists, ErrorMessage, protobuf.WithErrorDetails(&apiv1.DomainAlreadyExistsError{})) + DomainNotActiveError = protobuf.NewError(yarpcerrors.CodeFailedPrecondition, ErrorMessage, protobuf.WithErrorDetails(&apiv1.DomainNotActiveError{ + Domain: DomainName, + CurrentCluster: ClusterName1, + ActiveCluster: ClusterName2, + })) + EntityNotExistsError = protobuf.NewError(yarpcerrors.CodeNotFound, ErrorMessage, protobuf.WithErrorDetails(&apiv1.EntityNotExistsError{ + CurrentCluster: ClusterName1, + ActiveCluster: ClusterName2, + })) + FeatureNotEnabledError = protobuf.NewError(yarpcerrors.CodeFailedPrecondition, "Feature flag not enabled", protobuf.WithErrorDetails(&apiv1.FeatureNotEnabledError{ + FeatureFlag: FeatureFlag, + })) + WorkflowExecutionAlreadyCompletedError = protobuf.NewError(yarpcerrors.CodeNotFound, ErrorMessage, protobuf.WithErrorDetails(&apiv1.WorkflowExecutionAlreadyCompletedError{})) + InternalServiceError = protobuf.NewError(yarpcerrors.CodeInternal, ErrorMessage) + LimitExceededError = protobuf.NewError(yarpcerrors.CodeResourceExhausted, ErrorMessage, protobuf.WithErrorDetails(&apiv1.LimitExceededError{})) + QueryFailedError = protobuf.NewError(yarpcerrors.CodeInvalidArgument, ErrorMessage, protobuf.WithErrorDetails(&apiv1.QueryFailedError{})) + ServiceBusyError = protobuf.NewError(yarpcerrors.CodeResourceExhausted, ErrorMessage, protobuf.WithErrorDetails(&apiv1.ServiceBusyError{})) + WorkflowExecutionAlreadyStartedError = protobuf.NewError(yarpcerrors.CodeAlreadyExists, ErrorMessage, protobuf.WithErrorDetails(&apiv1.WorkflowExecutionAlreadyStartedError{ + StartRequestId: RequestID, + RunId: RunID, + })) + UnknownError = protobuf.NewError(yarpcerrors.CodeUnknown, ErrorMessage) +) diff --git a/internal/compatibility/testdata/history.go b/internal/compatibility/testdata/history.go new file mode 100644 index 000000000..f08f9daea --- /dev/null +++ b/internal/compatibility/testdata/history.go @@ -0,0 +1,533 @@ +// Copyright (c) 2021 Uber Technologies Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +package testdata + +import ( + apiv1 "go.uber.org/cadence/.gen/proto/api/v1" +) + +var ( + History = apiv1.History{ + Events: HistoryEventArray, + } + HistoryEventArray = []*apiv1.HistoryEvent{ + &HistoryEvent_WorkflowExecutionStarted, + &HistoryEvent_WorkflowExecutionStarted, + &HistoryEvent_WorkflowExecutionCompleted, + &HistoryEvent_WorkflowExecutionFailed, + &HistoryEvent_WorkflowExecutionTimedOut, + &HistoryEvent_DecisionTaskScheduled, + &HistoryEvent_DecisionTaskStarted, + &HistoryEvent_DecisionTaskCompleted, + &HistoryEvent_DecisionTaskTimedOut, + &HistoryEvent_DecisionTaskFailed, + &HistoryEvent_ActivityTaskScheduled, + &HistoryEvent_ActivityTaskStarted, + &HistoryEvent_ActivityTaskCompleted, + &HistoryEvent_ActivityTaskFailed, + &HistoryEvent_ActivityTaskTimedOut, + &HistoryEvent_ActivityTaskCancelRequested, + &HistoryEvent_RequestCancelActivityTaskFailed, + &HistoryEvent_ActivityTaskCanceled, + &HistoryEvent_TimerStarted, + &HistoryEvent_TimerFired, + &HistoryEvent_CancelTimerFailed, + &HistoryEvent_TimerCanceled, + &HistoryEvent_WorkflowExecutionCancelRequested, + &HistoryEvent_WorkflowExecutionCanceled, + &HistoryEvent_RequestCancelExternalWorkflowExecutionInitiated, + &HistoryEvent_RequestCancelExternalWorkflowExecutionFailed, + &HistoryEvent_ExternalWorkflowExecutionCancelRequested, + &HistoryEvent_MarkerRecorded, + &HistoryEvent_WorkflowExecutionSignaled, + &HistoryEvent_WorkflowExecutionTerminated, + &HistoryEvent_WorkflowExecutionContinuedAsNew, + &HistoryEvent_StartChildWorkflowExecutionInitiated, + &HistoryEvent_StartChildWorkflowExecutionFailed, + &HistoryEvent_ChildWorkflowExecutionStarted, + &HistoryEvent_ChildWorkflowExecutionCompleted, + &HistoryEvent_ChildWorkflowExecutionFailed, + &HistoryEvent_ChildWorkflowExecutionCanceled, + &HistoryEvent_ChildWorkflowExecutionTimedOut, + &HistoryEvent_ChildWorkflowExecutionTerminated, + &HistoryEvent_SignalExternalWorkflowExecutionInitiated, + &HistoryEvent_SignalExternalWorkflowExecutionFailed, + &HistoryEvent_ExternalWorkflowExecutionSignaled, + &HistoryEvent_UpsertWorkflowSearchAttributes, + } + + HistoryEvent_WorkflowExecutionStarted = generateEvent(func(e *apiv1.HistoryEvent) { + e.Attributes = &apiv1.HistoryEvent_WorkflowExecutionStartedEventAttributes{WorkflowExecutionStartedEventAttributes: &WorkflowExecutionStartedEventAttributes} + }) + HistoryEvent_WorkflowExecutionCompleted = generateEvent(func(e *apiv1.HistoryEvent) { + e.Attributes = &apiv1.HistoryEvent_WorkflowExecutionCompletedEventAttributes{WorkflowExecutionCompletedEventAttributes: &WorkflowExecutionCompletedEventAttributes} + }) + HistoryEvent_WorkflowExecutionFailed = generateEvent(func(e *apiv1.HistoryEvent) { + e.Attributes = &apiv1.HistoryEvent_WorkflowExecutionFailedEventAttributes{WorkflowExecutionFailedEventAttributes: &WorkflowExecutionFailedEventAttributes} + }) + HistoryEvent_WorkflowExecutionTimedOut = generateEvent(func(e *apiv1.HistoryEvent) { + e.Attributes = &apiv1.HistoryEvent_WorkflowExecutionTimedOutEventAttributes{WorkflowExecutionTimedOutEventAttributes: &WorkflowExecutionTimedOutEventAttributes} + }) + HistoryEvent_DecisionTaskScheduled = generateEvent(func(e *apiv1.HistoryEvent) { + e.Attributes = &apiv1.HistoryEvent_DecisionTaskScheduledEventAttributes{DecisionTaskScheduledEventAttributes: &DecisionTaskScheduledEventAttributes} + }) + HistoryEvent_DecisionTaskStarted = generateEvent(func(e *apiv1.HistoryEvent) { + e.Attributes = &apiv1.HistoryEvent_DecisionTaskStartedEventAttributes{DecisionTaskStartedEventAttributes: &DecisionTaskStartedEventAttributes} + }) + HistoryEvent_DecisionTaskCompleted = generateEvent(func(e *apiv1.HistoryEvent) { + e.Attributes = &apiv1.HistoryEvent_DecisionTaskCompletedEventAttributes{DecisionTaskCompletedEventAttributes: &DecisionTaskCompletedEventAttributes} + }) + HistoryEvent_DecisionTaskTimedOut = generateEvent(func(e *apiv1.HistoryEvent) { + e.Attributes = &apiv1.HistoryEvent_DecisionTaskTimedOutEventAttributes{DecisionTaskTimedOutEventAttributes: &DecisionTaskTimedOutEventAttributes} + }) + HistoryEvent_DecisionTaskFailed = generateEvent(func(e *apiv1.HistoryEvent) { + e.Attributes = &apiv1.HistoryEvent_DecisionTaskFailedEventAttributes{DecisionTaskFailedEventAttributes: &DecisionTaskFailedEventAttributes} + }) + HistoryEvent_ActivityTaskScheduled = generateEvent(func(e *apiv1.HistoryEvent) { + e.Attributes = &apiv1.HistoryEvent_ActivityTaskScheduledEventAttributes{ActivityTaskScheduledEventAttributes: &ActivityTaskScheduledEventAttributes} + }) + HistoryEvent_ActivityTaskStarted = generateEvent(func(e *apiv1.HistoryEvent) { + e.Attributes = &apiv1.HistoryEvent_ActivityTaskStartedEventAttributes{ActivityTaskStartedEventAttributes: &ActivityTaskStartedEventAttributes} + }) + HistoryEvent_ActivityTaskCompleted = generateEvent(func(e *apiv1.HistoryEvent) { + e.Attributes = &apiv1.HistoryEvent_ActivityTaskCompletedEventAttributes{ActivityTaskCompletedEventAttributes: &ActivityTaskCompletedEventAttributes} + }) + HistoryEvent_ActivityTaskFailed = generateEvent(func(e *apiv1.HistoryEvent) { + e.Attributes = &apiv1.HistoryEvent_ActivityTaskFailedEventAttributes{ActivityTaskFailedEventAttributes: &ActivityTaskFailedEventAttributes} + }) + HistoryEvent_ActivityTaskTimedOut = generateEvent(func(e *apiv1.HistoryEvent) { + e.Attributes = &apiv1.HistoryEvent_ActivityTaskTimedOutEventAttributes{ActivityTaskTimedOutEventAttributes: &ActivityTaskTimedOutEventAttributes} + }) + HistoryEvent_ActivityTaskCancelRequested = generateEvent(func(e *apiv1.HistoryEvent) { + e.Attributes = &apiv1.HistoryEvent_ActivityTaskCancelRequestedEventAttributes{ActivityTaskCancelRequestedEventAttributes: &ActivityTaskCancelRequestedEventAttributes} + }) + HistoryEvent_RequestCancelActivityTaskFailed = generateEvent(func(e *apiv1.HistoryEvent) { + e.Attributes = &apiv1.HistoryEvent_RequestCancelActivityTaskFailedEventAttributes{RequestCancelActivityTaskFailedEventAttributes: &RequestCancelActivityTaskFailedEventAttributes} + }) + HistoryEvent_ActivityTaskCanceled = generateEvent(func(e *apiv1.HistoryEvent) { + e.Attributes = &apiv1.HistoryEvent_ActivityTaskCanceledEventAttributes{ActivityTaskCanceledEventAttributes: &ActivityTaskCanceledEventAttributes} + }) + HistoryEvent_TimerStarted = generateEvent(func(e *apiv1.HistoryEvent) { + e.Attributes = &apiv1.HistoryEvent_TimerStartedEventAttributes{TimerStartedEventAttributes: &TimerStartedEventAttributes} + }) + HistoryEvent_TimerFired = generateEvent(func(e *apiv1.HistoryEvent) { + e.Attributes = &apiv1.HistoryEvent_TimerFiredEventAttributes{TimerFiredEventAttributes: &TimerFiredEventAttributes} + }) + HistoryEvent_CancelTimerFailed = generateEvent(func(e *apiv1.HistoryEvent) { + e.Attributes = &apiv1.HistoryEvent_CancelTimerFailedEventAttributes{CancelTimerFailedEventAttributes: &CancelTimerFailedEventAttributes} + }) + HistoryEvent_TimerCanceled = generateEvent(func(e *apiv1.HistoryEvent) { + e.Attributes = &apiv1.HistoryEvent_TimerCanceledEventAttributes{TimerCanceledEventAttributes: &TimerCanceledEventAttributes} + }) + HistoryEvent_WorkflowExecutionCancelRequested = generateEvent(func(e *apiv1.HistoryEvent) { + e.Attributes = &apiv1.HistoryEvent_WorkflowExecutionCancelRequestedEventAttributes{WorkflowExecutionCancelRequestedEventAttributes: &WorkflowExecutionCancelRequestedEventAttributes} + }) + HistoryEvent_WorkflowExecutionCanceled = generateEvent(func(e *apiv1.HistoryEvent) { + e.Attributes = &apiv1.HistoryEvent_WorkflowExecutionCanceledEventAttributes{WorkflowExecutionCanceledEventAttributes: &WorkflowExecutionCanceledEventAttributes} + }) + HistoryEvent_RequestCancelExternalWorkflowExecutionInitiated = generateEvent(func(e *apiv1.HistoryEvent) { + e.Attributes = &apiv1.HistoryEvent_RequestCancelExternalWorkflowExecutionInitiatedEventAttributes{RequestCancelExternalWorkflowExecutionInitiatedEventAttributes: &RequestCancelExternalWorkflowExecutionInitiatedEventAttributes} + }) + HistoryEvent_RequestCancelExternalWorkflowExecutionFailed = generateEvent(func(e *apiv1.HistoryEvent) { + e.Attributes = &apiv1.HistoryEvent_RequestCancelExternalWorkflowExecutionFailedEventAttributes{RequestCancelExternalWorkflowExecutionFailedEventAttributes: &RequestCancelExternalWorkflowExecutionFailedEventAttributes} + }) + HistoryEvent_ExternalWorkflowExecutionCancelRequested = generateEvent(func(e *apiv1.HistoryEvent) { + e.Attributes = &apiv1.HistoryEvent_ExternalWorkflowExecutionCancelRequestedEventAttributes{ExternalWorkflowExecutionCancelRequestedEventAttributes: &ExternalWorkflowExecutionCancelRequestedEventAttributes} + }) + HistoryEvent_MarkerRecorded = generateEvent(func(e *apiv1.HistoryEvent) { + e.Attributes = &apiv1.HistoryEvent_MarkerRecordedEventAttributes{MarkerRecordedEventAttributes: &MarkerRecordedEventAttributes} + }) + HistoryEvent_WorkflowExecutionSignaled = generateEvent(func(e *apiv1.HistoryEvent) { + e.Attributes = &apiv1.HistoryEvent_WorkflowExecutionSignaledEventAttributes{WorkflowExecutionSignaledEventAttributes: &WorkflowExecutionSignaledEventAttributes} + }) + HistoryEvent_WorkflowExecutionTerminated = generateEvent(func(e *apiv1.HistoryEvent) { + e.Attributes = &apiv1.HistoryEvent_WorkflowExecutionTerminatedEventAttributes{WorkflowExecutionTerminatedEventAttributes: &WorkflowExecutionTerminatedEventAttributes} + }) + HistoryEvent_WorkflowExecutionContinuedAsNew = generateEvent(func(e *apiv1.HistoryEvent) { + e.Attributes = &apiv1.HistoryEvent_WorkflowExecutionContinuedAsNewEventAttributes{WorkflowExecutionContinuedAsNewEventAttributes: &WorkflowExecutionContinuedAsNewEventAttributes} + }) + HistoryEvent_StartChildWorkflowExecutionInitiated = generateEvent(func(e *apiv1.HistoryEvent) { + e.Attributes = &apiv1.HistoryEvent_StartChildWorkflowExecutionInitiatedEventAttributes{StartChildWorkflowExecutionInitiatedEventAttributes: &StartChildWorkflowExecutionInitiatedEventAttributes} + }) + HistoryEvent_StartChildWorkflowExecutionFailed = generateEvent(func(e *apiv1.HistoryEvent) { + e.Attributes = &apiv1.HistoryEvent_StartChildWorkflowExecutionFailedEventAttributes{StartChildWorkflowExecutionFailedEventAttributes: &StartChildWorkflowExecutionFailedEventAttributes} + }) + HistoryEvent_ChildWorkflowExecutionStarted = generateEvent(func(e *apiv1.HistoryEvent) { + e.Attributes = &apiv1.HistoryEvent_ChildWorkflowExecutionStartedEventAttributes{ChildWorkflowExecutionStartedEventAttributes: &ChildWorkflowExecutionStartedEventAttributes} + }) + HistoryEvent_ChildWorkflowExecutionCompleted = generateEvent(func(e *apiv1.HistoryEvent) { + e.Attributes = &apiv1.HistoryEvent_ChildWorkflowExecutionCompletedEventAttributes{ChildWorkflowExecutionCompletedEventAttributes: &ChildWorkflowExecutionCompletedEventAttributes} + }) + HistoryEvent_ChildWorkflowExecutionFailed = generateEvent(func(e *apiv1.HistoryEvent) { + e.Attributes = &apiv1.HistoryEvent_ChildWorkflowExecutionFailedEventAttributes{ChildWorkflowExecutionFailedEventAttributes: &ChildWorkflowExecutionFailedEventAttributes} + }) + HistoryEvent_ChildWorkflowExecutionCanceled = generateEvent(func(e *apiv1.HistoryEvent) { + e.Attributes = &apiv1.HistoryEvent_ChildWorkflowExecutionCanceledEventAttributes{ChildWorkflowExecutionCanceledEventAttributes: &ChildWorkflowExecutionCanceledEventAttributes} + }) + HistoryEvent_ChildWorkflowExecutionTimedOut = generateEvent(func(e *apiv1.HistoryEvent) { + e.Attributes = &apiv1.HistoryEvent_ChildWorkflowExecutionTimedOutEventAttributes{ChildWorkflowExecutionTimedOutEventAttributes: &ChildWorkflowExecutionTimedOutEventAttributes} + }) + HistoryEvent_ChildWorkflowExecutionTerminated = generateEvent(func(e *apiv1.HistoryEvent) { + e.Attributes = &apiv1.HistoryEvent_ChildWorkflowExecutionTerminatedEventAttributes{ChildWorkflowExecutionTerminatedEventAttributes: &ChildWorkflowExecutionTerminatedEventAttributes} + }) + HistoryEvent_SignalExternalWorkflowExecutionInitiated = generateEvent(func(e *apiv1.HistoryEvent) { + e.Attributes = &apiv1.HistoryEvent_SignalExternalWorkflowExecutionInitiatedEventAttributes{SignalExternalWorkflowExecutionInitiatedEventAttributes: &SignalExternalWorkflowExecutionInitiatedEventAttributes} + }) + HistoryEvent_SignalExternalWorkflowExecutionFailed = generateEvent(func(e *apiv1.HistoryEvent) { + e.Attributes = &apiv1.HistoryEvent_SignalExternalWorkflowExecutionFailedEventAttributes{SignalExternalWorkflowExecutionFailedEventAttributes: &SignalExternalWorkflowExecutionFailedEventAttributes} + }) + HistoryEvent_ExternalWorkflowExecutionSignaled = generateEvent(func(e *apiv1.HistoryEvent) { + e.Attributes = &apiv1.HistoryEvent_ExternalWorkflowExecutionSignaledEventAttributes{ExternalWorkflowExecutionSignaledEventAttributes: &ExternalWorkflowExecutionSignaledEventAttributes} + }) + HistoryEvent_UpsertWorkflowSearchAttributes = generateEvent(func(e *apiv1.HistoryEvent) { + e.Attributes = &apiv1.HistoryEvent_UpsertWorkflowSearchAttributesEventAttributes{UpsertWorkflowSearchAttributesEventAttributes: &UpsertWorkflowSearchAttributesEventAttributes} + }) + + WorkflowExecutionStartedEventAttributes = apiv1.WorkflowExecutionStartedEventAttributes{ + WorkflowType: &WorkflowType, + ParentExecutionInfo: &apiv1.ParentExecutionInfo{ + DomainName: DomainName, + WorkflowExecution: &WorkflowExecution, + InitiatedId: EventID1, + }, + TaskList: &TaskList, + Input: &Payload1, + ExecutionStartToCloseTimeout: Duration1, + TaskStartToCloseTimeout: Duration2, + ContinuedExecutionRunId: RunID1, + Initiator: ContinueAsNewInitiator, + ContinuedFailure: &Failure, + LastCompletionResult: &Payload2, + OriginalExecutionRunId: RunID2, + Identity: Identity, + FirstExecutionRunId: RunID3, + RetryPolicy: &RetryPolicy, + Attempt: Attempt, + ExpirationTime: Timestamp1, + CronSchedule: CronSchedule, + FirstDecisionTaskBackoff: Duration3, + Memo: &Memo, + SearchAttributes: &SearchAttributes, + PrevAutoResetPoints: &ResetPoints, + Header: &Header, + } + WorkflowExecutionCompletedEventAttributes = apiv1.WorkflowExecutionCompletedEventAttributes{ + Result: &Payload1, + DecisionTaskCompletedEventId: EventID1, + } + WorkflowExecutionFailedEventAttributes = apiv1.WorkflowExecutionFailedEventAttributes{ + Failure: &Failure, + DecisionTaskCompletedEventId: EventID1, + } + WorkflowExecutionTimedOutEventAttributes = apiv1.WorkflowExecutionTimedOutEventAttributes{ + TimeoutType: TimeoutType, + } + DecisionTaskScheduledEventAttributes = apiv1.DecisionTaskScheduledEventAttributes{ + TaskList: &TaskList, + StartToCloseTimeout: Duration1, + Attempt: Attempt, + } + DecisionTaskStartedEventAttributes = apiv1.DecisionTaskStartedEventAttributes{ + ScheduledEventId: EventID1, + Identity: Identity, + RequestId: RequestID, + } + DecisionTaskCompletedEventAttributes = apiv1.DecisionTaskCompletedEventAttributes{ + ExecutionContext: ExecutionContext, + ScheduledEventId: EventID1, + StartedEventId: EventID2, + Identity: Identity, + BinaryChecksum: Checksum, + } + DecisionTaskTimedOutEventAttributes = apiv1.DecisionTaskTimedOutEventAttributes{ + ScheduledEventId: EventID1, + StartedEventId: EventID2, + TimeoutType: TimeoutType, + BaseRunId: RunID1, + NewRunId: RunID2, + ForkEventVersion: Version1, + Reason: Reason, + Cause: DecisionTaskTimedOutCause, + } + DecisionTaskFailedEventAttributes = apiv1.DecisionTaskFailedEventAttributes{ + ScheduledEventId: EventID1, + StartedEventId: EventID2, + Cause: DecisionTaskFailedCause, + Failure: &Failure, + Identity: Identity, + BaseRunId: RunID1, + NewRunId: RunID2, + ForkEventVersion: Version1, + BinaryChecksum: Checksum, + } + ActivityTaskScheduledEventAttributes = apiv1.ActivityTaskScheduledEventAttributes{ + ActivityId: ActivityID, + ActivityType: &ActivityType, + Domain: DomainName, + TaskList: &TaskList, + Input: &Payload1, + ScheduleToCloseTimeout: Duration1, + ScheduleToStartTimeout: Duration2, + StartToCloseTimeout: Duration3, + HeartbeatTimeout: Duration4, + DecisionTaskCompletedEventId: EventID1, + RetryPolicy: &RetryPolicy, + Header: &Header, + } + ActivityTaskStartedEventAttributes = apiv1.ActivityTaskStartedEventAttributes{ + ScheduledEventId: EventID1, + Identity: Identity, + RequestId: RequestID, + Attempt: Attempt, + LastFailure: &Failure, + } + ActivityTaskCompletedEventAttributes = apiv1.ActivityTaskCompletedEventAttributes{ + Result: &Payload1, + ScheduledEventId: EventID1, + StartedEventId: EventID2, + Identity: Identity, + } + ActivityTaskFailedEventAttributes = apiv1.ActivityTaskFailedEventAttributes{ + Failure: &Failure, + ScheduledEventId: EventID1, + StartedEventId: EventID2, + Identity: Identity, + } + ActivityTaskTimedOutEventAttributes = apiv1.ActivityTaskTimedOutEventAttributes{ + Details: &Payload1, + ScheduledEventId: EventID1, + StartedEventId: EventID2, + TimeoutType: TimeoutType, + LastFailure: &Failure, + } + TimerStartedEventAttributes = apiv1.TimerStartedEventAttributes{ + TimerId: TimerID, + StartToFireTimeout: Duration1, + DecisionTaskCompletedEventId: EventID1, + } + TimerFiredEventAttributes = apiv1.TimerFiredEventAttributes{ + TimerId: TimerID, + StartedEventId: EventID1, + } + ActivityTaskCancelRequestedEventAttributes = apiv1.ActivityTaskCancelRequestedEventAttributes{ + ActivityId: ActivityID, + DecisionTaskCompletedEventId: EventID1, + } + RequestCancelActivityTaskFailedEventAttributes = apiv1.RequestCancelActivityTaskFailedEventAttributes{ + ActivityId: ActivityID, + Cause: Cause, + DecisionTaskCompletedEventId: EventID1, + } + ActivityTaskCanceledEventAttributes = apiv1.ActivityTaskCanceledEventAttributes{ + Details: &Payload1, + LatestCancelRequestedEventId: EventID1, + ScheduledEventId: EventID2, + StartedEventId: EventID3, + Identity: Identity, + } + TimerCanceledEventAttributes = apiv1.TimerCanceledEventAttributes{ + TimerId: TimerID, + StartedEventId: EventID1, + DecisionTaskCompletedEventId: EventID2, + Identity: Identity, + } + CancelTimerFailedEventAttributes = apiv1.CancelTimerFailedEventAttributes{ + TimerId: TimerID, + Cause: Cause, + DecisionTaskCompletedEventId: EventID1, + Identity: Identity, + } + MarkerRecordedEventAttributes = apiv1.MarkerRecordedEventAttributes{ + MarkerName: MarkerName, + Details: &Payload1, + DecisionTaskCompletedEventId: EventID1, + Header: &Header, + } + WorkflowExecutionSignaledEventAttributes = apiv1.WorkflowExecutionSignaledEventAttributes{ + SignalName: SignalName, + Input: &Payload1, + Identity: Identity, + } + WorkflowExecutionTerminatedEventAttributes = apiv1.WorkflowExecutionTerminatedEventAttributes{ + Reason: Reason, + Details: &Payload1, + Identity: Identity, + } + WorkflowExecutionCancelRequestedEventAttributes = apiv1.WorkflowExecutionCancelRequestedEventAttributes{ + Cause: Cause, + ExternalExecutionInfo: &apiv1.ExternalExecutionInfo{ + WorkflowExecution: &WorkflowExecution, + InitiatedId: EventID1, + }, + Identity: Identity, + } + WorkflowExecutionCanceledEventAttributes = apiv1.WorkflowExecutionCanceledEventAttributes{ + DecisionTaskCompletedEventId: EventID1, + Details: &Payload1, + } + RequestCancelExternalWorkflowExecutionInitiatedEventAttributes = apiv1.RequestCancelExternalWorkflowExecutionInitiatedEventAttributes{ + DecisionTaskCompletedEventId: EventID1, + Domain: DomainName, + WorkflowExecution: &WorkflowExecution, + Control: Control, + ChildWorkflowOnly: true, + } + RequestCancelExternalWorkflowExecutionFailedEventAttributes = apiv1.RequestCancelExternalWorkflowExecutionFailedEventAttributes{ + Cause: CancelExternalWorkflowExecutionFailedCause, + DecisionTaskCompletedEventId: EventID1, + Domain: DomainName, + WorkflowExecution: &WorkflowExecution, + InitiatedEventId: EventID2, + Control: Control, + } + ExternalWorkflowExecutionCancelRequestedEventAttributes = apiv1.ExternalWorkflowExecutionCancelRequestedEventAttributes{ + InitiatedEventId: EventID1, + Domain: DomainName, + WorkflowExecution: &WorkflowExecution, + } + WorkflowExecutionContinuedAsNewEventAttributes = apiv1.WorkflowExecutionContinuedAsNewEventAttributes{ + NewExecutionRunId: RunID1, + WorkflowType: &WorkflowType, + TaskList: &TaskList, + Input: &Payload1, + ExecutionStartToCloseTimeout: Duration1, + TaskStartToCloseTimeout: Duration2, + DecisionTaskCompletedEventId: EventID1, + BackoffStartInterval: Duration3, + Initiator: ContinueAsNewInitiator, + Failure: &Failure, + LastCompletionResult: &Payload2, + Header: &Header, + Memo: &Memo, + SearchAttributes: &SearchAttributes, + } + StartChildWorkflowExecutionInitiatedEventAttributes = apiv1.StartChildWorkflowExecutionInitiatedEventAttributes{ + Domain: DomainName, + WorkflowId: WorkflowID, + WorkflowType: &WorkflowType, + TaskList: &TaskList, + Input: &Payload1, + ExecutionStartToCloseTimeout: Duration1, + TaskStartToCloseTimeout: Duration2, + ParentClosePolicy: ParentClosePolicy, + Control: Control, + DecisionTaskCompletedEventId: EventID1, + WorkflowIdReusePolicy: WorkflowIDReusePolicy, + RetryPolicy: &RetryPolicy, + CronSchedule: CronSchedule, + Header: &Header, + Memo: &Memo, + SearchAttributes: &SearchAttributes, + } + StartChildWorkflowExecutionFailedEventAttributes = apiv1.StartChildWorkflowExecutionFailedEventAttributes{ + Domain: DomainName, + WorkflowId: WorkflowID, + WorkflowType: &WorkflowType, + Cause: ChildWorkflowExecutionFailedCause, + Control: Control, + InitiatedEventId: EventID1, + DecisionTaskCompletedEventId: EventID2, + } + ChildWorkflowExecutionStartedEventAttributes = apiv1.ChildWorkflowExecutionStartedEventAttributes{ + Domain: DomainName, + InitiatedEventId: EventID1, + WorkflowExecution: &WorkflowExecution, + WorkflowType: &WorkflowType, + Header: &Header, + } + ChildWorkflowExecutionCompletedEventAttributes = apiv1.ChildWorkflowExecutionCompletedEventAttributes{ + Result: &Payload1, + Domain: DomainName, + WorkflowExecution: &WorkflowExecution, + WorkflowType: &WorkflowType, + InitiatedEventId: EventID1, + StartedEventId: EventID2, + } + ChildWorkflowExecutionFailedEventAttributes = apiv1.ChildWorkflowExecutionFailedEventAttributes{ + Failure: &Failure, + Domain: DomainName, + WorkflowExecution: &WorkflowExecution, + WorkflowType: &WorkflowType, + InitiatedEventId: EventID1, + StartedEventId: EventID2, + } + ChildWorkflowExecutionCanceledEventAttributes = apiv1.ChildWorkflowExecutionCanceledEventAttributes{ + Details: &Payload1, + Domain: DomainName, + WorkflowExecution: &WorkflowExecution, + WorkflowType: &WorkflowType, + InitiatedEventId: EventID1, + StartedEventId: EventID2, + } + ChildWorkflowExecutionTimedOutEventAttributes = apiv1.ChildWorkflowExecutionTimedOutEventAttributes{ + TimeoutType: TimeoutType, + Domain: DomainName, + WorkflowExecution: &WorkflowExecution, + WorkflowType: &WorkflowType, + InitiatedEventId: EventID1, + StartedEventId: EventID2, + } + ChildWorkflowExecutionTerminatedEventAttributes = apiv1.ChildWorkflowExecutionTerminatedEventAttributes{ + Domain: DomainName, + WorkflowExecution: &WorkflowExecution, + WorkflowType: &WorkflowType, + InitiatedEventId: EventID1, + StartedEventId: EventID2, + } + SignalExternalWorkflowExecutionInitiatedEventAttributes = apiv1.SignalExternalWorkflowExecutionInitiatedEventAttributes{ + DecisionTaskCompletedEventId: EventID1, + Domain: DomainName, + WorkflowExecution: &WorkflowExecution, + SignalName: SignalName, + Input: &Payload1, + Control: Control, + ChildWorkflowOnly: true, + } + SignalExternalWorkflowExecutionFailedEventAttributes = apiv1.SignalExternalWorkflowExecutionFailedEventAttributes{ + Cause: SignalExternalWorkflowExecutionFailedCause, + DecisionTaskCompletedEventId: EventID1, + Domain: DomainName, + WorkflowExecution: &WorkflowExecution, + InitiatedEventId: EventID2, + Control: Control, + } + ExternalWorkflowExecutionSignaledEventAttributes = apiv1.ExternalWorkflowExecutionSignaledEventAttributes{ + InitiatedEventId: EventID1, + Domain: DomainName, + WorkflowExecution: &WorkflowExecution, + Control: Control, + } + UpsertWorkflowSearchAttributesEventAttributes = apiv1.UpsertWorkflowSearchAttributesEventAttributes{ + DecisionTaskCompletedEventId: EventID1, + SearchAttributes: &SearchAttributes, + } +) + +func generateEvent(modifier func(e *apiv1.HistoryEvent)) apiv1.HistoryEvent { + e := apiv1.HistoryEvent{ + EventId: EventID1, + EventTime: Timestamp1, + Version: Version1, + TaskId: TaskID, + } + modifier(&e) + return e +} diff --git a/internal/compatibility/testdata/service.go b/internal/compatibility/testdata/service.go new file mode 100644 index 000000000..f13c449b2 --- /dev/null +++ b/internal/compatibility/testdata/service.go @@ -0,0 +1,440 @@ +// Copyright (c) 2021 Uber Technologies Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +package testdata + +import ( + gogo "github.com/gogo/protobuf/types" + apiv1 "go.uber.org/cadence/.gen/proto/api/v1" +) + +var ( + RegisterDomainRequest = apiv1.RegisterDomainRequest{ + Name: DomainName, + Description: DomainDescription, + OwnerEmail: DomainOwnerEmail, + WorkflowExecutionRetentionPeriod: DomainRetention, + Clusters: ClusterReplicationConfigurationArray, + ActiveClusterName: ClusterName1, + Data: DomainData, + SecurityToken: SecurityToken, + IsGlobalDomain: true, + HistoryArchivalStatus: ArchivalStatus, + HistoryArchivalUri: HistoryArchivalURI, + VisibilityArchivalStatus: ArchivalStatus, + VisibilityArchivalUri: VisibilityArchivalURI, + } + DescribeDomainRequest_ID = apiv1.DescribeDomainRequest{ + DescribeBy: &apiv1.DescribeDomainRequest_Id{Id: DomainID}, + } + DescribeDomainRequest_Name = apiv1.DescribeDomainRequest{ + DescribeBy: &apiv1.DescribeDomainRequest_Name{Name: DomainName}, + } + DescribeDomainResponse = apiv1.DescribeDomainResponse{ + Domain: &Domain, + } + ListDomainsRequest = apiv1.ListDomainsRequest{ + PageSize: PageSize, + NextPageToken: NextPageToken, + } + ListDomainsResponse = apiv1.ListDomainsResponse{ + Domains: []*apiv1.Domain{&Domain}, + NextPageToken: NextPageToken, + } + UpdateDomainRequest = apiv1.UpdateDomainRequest{ + Name: DomainName, + Description: DomainDescription, + OwnerEmail: DomainOwnerEmail, + Data: DomainData, + WorkflowExecutionRetentionPeriod: DomainRetention, + BadBinaries: &BadBinaries, + HistoryArchivalStatus: ArchivalStatus, + HistoryArchivalUri: HistoryArchivalURI, + VisibilityArchivalStatus: ArchivalStatus, + VisibilityArchivalUri: VisibilityArchivalURI, + ActiveClusterName: ClusterName1, + Clusters: ClusterReplicationConfigurationArray, + SecurityToken: SecurityToken, + DeleteBadBinary: DeleteBadBinary, + FailoverTimeout: Duration1, + UpdateMask: &gogo.FieldMask{Paths: []string{"description", "owner_email", "data", "workflow_execution_retention_period", "bad_binaries", "history_archival_status", "history_archival_uri", "visibility_archival_status", "visibility_archival_uri", "active_cluster_name", "clusters", "delete_bad_binary", "failover_timeout"}}, + } + UpdateDomainResponse = apiv1.UpdateDomainResponse{ + Domain: &Domain, + } + DeprecateDomainRequest = apiv1.DeprecateDomainRequest{ + Name: DomainName, + SecurityToken: SecurityToken, + } + ListWorkflowExecutionsRequest = apiv1.ListWorkflowExecutionsRequest{ + Domain: DomainName, + PageSize: PageSize, + NextPageToken: NextPageToken, + Query: VisibilityQuery, + } + ListWorkflowExecutionsResponse = apiv1.ListWorkflowExecutionsResponse{ + Executions: WorkflowExecutionInfoArray, + NextPageToken: NextPageToken, + } + ScanWorkflowExecutionsRequest = apiv1.ScanWorkflowExecutionsRequest{ + Domain: DomainName, + PageSize: PageSize, + NextPageToken: NextPageToken, + Query: VisibilityQuery, + } + ScanWorkflowExecutionsResponse = apiv1.ScanWorkflowExecutionsResponse{ + Executions: WorkflowExecutionInfoArray, + NextPageToken: NextPageToken, + } + ListOpenWorkflowExecutionsRequest_ExecutionFilter = apiv1.ListOpenWorkflowExecutionsRequest{ + Domain: DomainName, + PageSize: PageSize, + NextPageToken: NextPageToken, + StartTimeFilter: &StartTimeFilter, + Filters: &apiv1.ListOpenWorkflowExecutionsRequest_ExecutionFilter{ + ExecutionFilter: &WorkflowExecutionFilter, + }, + } + ListOpenWorkflowExecutionsRequest_TypeFilter = apiv1.ListOpenWorkflowExecutionsRequest{ + Domain: DomainName, + PageSize: PageSize, + NextPageToken: NextPageToken, + StartTimeFilter: &StartTimeFilter, + Filters: &apiv1.ListOpenWorkflowExecutionsRequest_TypeFilter{ + TypeFilter: &WorkflowTypeFilter, + }, + } + ListOpenWorkflowExecutionsResponse = apiv1.ListOpenWorkflowExecutionsResponse{ + Executions: WorkflowExecutionInfoArray, + NextPageToken: NextPageToken, + } + ListClosedWorkflowExecutionsRequest_ExecutionFilter = apiv1.ListClosedWorkflowExecutionsRequest{ + Domain: DomainName, + PageSize: PageSize, + NextPageToken: NextPageToken, + StartTimeFilter: &StartTimeFilter, + Filters: &apiv1.ListClosedWorkflowExecutionsRequest_ExecutionFilter{ + ExecutionFilter: &WorkflowExecutionFilter, + }, + } + ListClosedWorkflowExecutionsRequest_TypeFilter = apiv1.ListClosedWorkflowExecutionsRequest{ + Domain: DomainName, + PageSize: PageSize, + NextPageToken: NextPageToken, + StartTimeFilter: &StartTimeFilter, + Filters: &apiv1.ListClosedWorkflowExecutionsRequest_TypeFilter{ + TypeFilter: &WorkflowTypeFilter, + }, + } + ListClosedWorkflowExecutionsRequest_StatusFilter = apiv1.ListClosedWorkflowExecutionsRequest{ + Domain: DomainName, + PageSize: PageSize, + NextPageToken: NextPageToken, + StartTimeFilter: &StartTimeFilter, + Filters: &apiv1.ListClosedWorkflowExecutionsRequest_StatusFilter{ + StatusFilter: &StatusFilter, + }, + } + ListClosedWorkflowExecutionsResponse = apiv1.ListClosedWorkflowExecutionsResponse{ + Executions: WorkflowExecutionInfoArray, + NextPageToken: NextPageToken, + } + ListArchivedWorkflowExecutionsRequest = apiv1.ListArchivedWorkflowExecutionsRequest{ + Domain: DomainName, + PageSize: PageSize, + NextPageToken: NextPageToken, + Query: VisibilityQuery, + } + ListArchivedWorkflowExecutionsResponse = apiv1.ListArchivedWorkflowExecutionsResponse{ + Executions: WorkflowExecutionInfoArray, + NextPageToken: NextPageToken, + } + CountWorkflowExecutionsRequest = apiv1.CountWorkflowExecutionsRequest{ + Domain: DomainName, + Query: VisibilityQuery, + } + CountWorkflowExecutionsResponse = apiv1.CountWorkflowExecutionsResponse{ + Count: int64(8), + } + GetSearchAttributesResponse = apiv1.GetSearchAttributesResponse{ + Keys: IndexedValueTypeMap, + } + PollForDecisionTaskRequest = apiv1.PollForDecisionTaskRequest{ + Domain: DomainName, + TaskList: &TaskList, + Identity: Identity, + BinaryChecksum: Checksum, + } + PollForDecisionTaskResponse = apiv1.PollForDecisionTaskResponse{ + TaskToken: TaskToken, + WorkflowExecution: &WorkflowExecution, + WorkflowType: &WorkflowType, + PreviousStartedEventId: &gogo.Int64Value{Value: EventID1}, + StartedEventId: EventID2, + Attempt: Attempt, + BacklogCountHint: BacklogCountHint, + History: &History, + NextPageToken: NextPageToken, + Query: &WorkflowQuery, + WorkflowExecutionTaskList: &TaskList, + ScheduledTime: Timestamp1, + StartedTime: Timestamp2, + Queries: WorkflowQueryMap, + NextEventId: EventID3, + } + RespondDecisionTaskCompletedRequest = apiv1.RespondDecisionTaskCompletedRequest{ + TaskToken: TaskToken, + Decisions: DecisionArray, + ExecutionContext: ExecutionContext, + Identity: Identity, + StickyAttributes: &StickyExecutionAttributes, + ReturnNewDecisionTask: true, + ForceCreateNewDecisionTask: true, + BinaryChecksum: Checksum, + QueryResults: WorkflowQueryResultMap, + } + RespondDecisionTaskCompletedResponse = apiv1.RespondDecisionTaskCompletedResponse{ + DecisionTask: &PollForDecisionTaskResponse, + ActivitiesToDispatchLocally: ActivityLocalDispatchInfoMap, + } + RespondDecisionTaskFailedRequest = apiv1.RespondDecisionTaskFailedRequest{ + TaskToken: TaskToken, + Cause: DecisionTaskFailedCause, + Details: &Payload1, + Identity: Identity, + BinaryChecksum: Checksum, + } + PollForActivityTaskRequest = apiv1.PollForActivityTaskRequest{ + Domain: DomainName, + TaskList: &TaskList, + Identity: Identity, + TaskListMetadata: &TaskListMetadata, + } + PollForActivityTaskResponse = apiv1.PollForActivityTaskResponse{ + TaskToken: TaskToken, + WorkflowExecution: &WorkflowExecution, + ActivityId: ActivityID, + ActivityType: &ActivityType, + Input: &Payload1, + ScheduledTime: Timestamp1, + ScheduleToCloseTimeout: Duration1, + StartedTime: Timestamp2, + StartToCloseTimeout: Duration2, + HeartbeatTimeout: Duration3, + Attempt: Attempt, + ScheduledTimeOfThisAttempt: Timestamp3, + HeartbeatDetails: &Payload2, + WorkflowType: &WorkflowType, + WorkflowDomain: DomainName, + Header: &Header, + } + RespondActivityTaskCompletedRequest = apiv1.RespondActivityTaskCompletedRequest{ + TaskToken: TaskToken, + Result: &Payload1, + Identity: Identity, + } + RespondActivityTaskCompletedByIDRequest = apiv1.RespondActivityTaskCompletedByIDRequest{ + Domain: DomainName, + WorkflowExecution: &WorkflowExecution, + ActivityId: ActivityID, + Result: &Payload1, + Identity: Identity, + } + RespondActivityTaskFailedRequest = apiv1.RespondActivityTaskFailedRequest{ + TaskToken: TaskToken, + Failure: &Failure, + Identity: Identity, + } + RespondActivityTaskFailedByIDRequest = apiv1.RespondActivityTaskFailedByIDRequest{ + Domain: DomainName, + WorkflowExecution: &WorkflowExecution, + ActivityId: ActivityID, + Failure: &Failure, + Identity: Identity, + } + RespondActivityTaskCanceledRequest = apiv1.RespondActivityTaskCanceledRequest{ + TaskToken: TaskToken, + Details: &Payload1, + Identity: Identity, + } + RespondActivityTaskCanceledByIDRequest = apiv1.RespondActivityTaskCanceledByIDRequest{ + Domain: DomainName, + WorkflowExecution: &WorkflowExecution, + ActivityId: ActivityID, + Details: &Payload1, + Identity: Identity, + } + RecordActivityTaskHeartbeatRequest = apiv1.RecordActivityTaskHeartbeatRequest{ + TaskToken: TaskToken, + Details: &Payload1, + Identity: Identity, + } + RecordActivityTaskHeartbeatResponse = apiv1.RecordActivityTaskHeartbeatResponse{ + CancelRequested: true, + } + RecordActivityTaskHeartbeatByIDResponse = apiv1.RecordActivityTaskHeartbeatByIDResponse{ + CancelRequested: true, + } + RecordActivityTaskHeartbeatByIDRequest = apiv1.RecordActivityTaskHeartbeatByIDRequest{ + Domain: DomainName, + WorkflowExecution: &WorkflowExecution, + ActivityId: ActivityID, + Details: &Payload1, + Identity: Identity, + } + RespondQueryTaskCompletedRequest = apiv1.RespondQueryTaskCompletedRequest{ + TaskToken: TaskToken, + Result: &apiv1.WorkflowQueryResult{ + ResultType: QueryResultType, + Answer: &Payload1, + ErrorMessage: ErrorMessage, + }, + WorkerVersionInfo: &WorkerVersionInfo, + } + RequestCancelWorkflowExecutionRequest = apiv1.RequestCancelWorkflowExecutionRequest{ + Domain: DomainName, + WorkflowExecution: &WorkflowExecution, + Identity: Identity, + RequestId: RequestID, + } + StartWorkflowExecutionRequest = apiv1.StartWorkflowExecutionRequest{ + Domain: DomainName, + WorkflowId: WorkflowID, + WorkflowType: &WorkflowType, + TaskList: &TaskList, + Input: &Payload1, + ExecutionStartToCloseTimeout: Duration1, + TaskStartToCloseTimeout: Duration2, + Identity: Identity, + RequestId: RequestID, + WorkflowIdReusePolicy: WorkflowIDReusePolicy, + RetryPolicy: &RetryPolicy, + CronSchedule: CronSchedule, + Memo: &Memo, + SearchAttributes: &SearchAttributes, + Header: &Header, + } + StartWorkflowExecutionResponse = apiv1.StartWorkflowExecutionResponse{ + RunId: RunID, + } + SignalWorkflowExecutionRequest = apiv1.SignalWorkflowExecutionRequest{ + Domain: DomainName, + WorkflowExecution: &WorkflowExecution, + SignalName: SignalName, + SignalInput: &Payload1, + Identity: Identity, + RequestId: RequestID, + Control: Control, + } + SignalWithStartWorkflowExecutionRequest = apiv1.SignalWithStartWorkflowExecutionRequest{ + StartRequest: &StartWorkflowExecutionRequest, + SignalName: SignalName, + SignalInput: &Payload2, + Control: Control, + } + SignalWithStartWorkflowExecutionResponse = apiv1.SignalWithStartWorkflowExecutionResponse{ + RunId: RunID, + } + ResetWorkflowExecutionRequest = apiv1.ResetWorkflowExecutionRequest{ + Domain: DomainName, + WorkflowExecution: &WorkflowExecution, + Reason: Reason, + DecisionFinishEventId: EventID1, + RequestId: RequestID, + SkipSignalReapply: true, + } + ResetWorkflowExecutionResponse = apiv1.ResetWorkflowExecutionResponse{ + RunId: RunID, + } + TerminateWorkflowExecutionRequest = apiv1.TerminateWorkflowExecutionRequest{ + Domain: DomainName, + WorkflowExecution: &WorkflowExecution, + Reason: Reason, + Details: &Payload1, + Identity: Identity, + } + DescribeWorkflowExecutionRequest = apiv1.DescribeWorkflowExecutionRequest{ + Domain: DomainName, + WorkflowExecution: &WorkflowExecution, + } + DescribeWorkflowExecutionResponse = apiv1.DescribeWorkflowExecutionResponse{ + ExecutionConfiguration: &WorkflowExecutionConfiguration, + WorkflowExecutionInfo: &WorkflowExecutionInfo, + PendingActivities: PendingActivityInfoArray, + PendingChildren: PendingChildExecutionInfoArray, + PendingDecision: &PendingDecisionInfo, + } + QueryWorkflowRequest = apiv1.QueryWorkflowRequest{ + Domain: DomainName, + WorkflowExecution: &WorkflowExecution, + Query: &WorkflowQuery, + QueryRejectCondition: QueryRejectCondition, + QueryConsistencyLevel: QueryConsistencyLevel, + } + QueryWorkflowResponse = apiv1.QueryWorkflowResponse{ + QueryResult: &Payload1, + QueryRejected: &QueryRejected, + } + DescribeTaskListRequest = apiv1.DescribeTaskListRequest{ + Domain: DomainName, + TaskList: &TaskList, + TaskListType: TaskListType, + IncludeTaskListStatus: true, + } + DescribeTaskListResponse = apiv1.DescribeTaskListResponse{ + Pollers: PollerInfoArray, + TaskListStatus: &TaskListStatus, + } + ListTaskListPartitionsRequest = apiv1.ListTaskListPartitionsRequest{ + Domain: DomainName, + TaskList: &TaskList, + } + ListTaskListPartitionsResponse = apiv1.ListTaskListPartitionsResponse{ + ActivityTaskListPartitions: TaskListPartitionMetadataArray, + DecisionTaskListPartitions: TaskListPartitionMetadataArray, + } + ResetStickyTaskListRequest = apiv1.ResetStickyTaskListRequest{ + Domain: DomainName, + WorkflowExecution: &WorkflowExecution, + } + ResetStickyTaskListResponse = apiv1.ResetStickyTaskListResponse{} + GetWorkflowExecutionHistoryRequest = apiv1.GetWorkflowExecutionHistoryRequest{ + Domain: DomainName, + WorkflowExecution: &WorkflowExecution, + PageSize: PageSize, + NextPageToken: NextPageToken, + WaitForNewEvent: true, + HistoryEventFilterType: HistoryEventFilterType, + SkipArchival: true, + } + GetWorkflowExecutionHistoryResponse = apiv1.GetWorkflowExecutionHistoryResponse{ + History: &History, + RawHistory: DataBlobArray, + NextPageToken: NextPageToken, + Archived: true, + } + + DomainArray = []*apiv1.Domain{ + &Domain, + } + GetClusterInfoResponse = apiv1.GetClusterInfoResponse{ + SupportedClientVersions: &SupportedClientVersions, + } +) diff --git a/internal/compatibility/thrift/decision.go b/internal/compatibility/thrift/decision.go new file mode 100644 index 000000000..36d32c21c --- /dev/null +++ b/internal/compatibility/thrift/decision.go @@ -0,0 +1,179 @@ +// Copyright (c) 2021 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +package thrift + +import ( + "go.uber.org/cadence/.gen/go/shared" + apiv1 "go.uber.org/cadence/.gen/proto/api/v1" +) + +func DecisionArray(t []*apiv1.Decision) []*shared.Decision { + if t == nil { + return nil + } + v := make([]*shared.Decision, len(t)) + for i := range t { + v[i] = Decision(t[i]) + } + return v +} + +func Decision(d *apiv1.Decision) *shared.Decision { + if d == nil { + return nil + } + decision := shared.Decision{} + switch attr := d.Attributes.(type) { + case *apiv1.Decision_ScheduleActivityTaskDecisionAttributes: + decision.DecisionType = shared.DecisionTypeScheduleActivityTask.Ptr() + a := attr.ScheduleActivityTaskDecisionAttributes + decision.ScheduleActivityTaskDecisionAttributes = &shared.ScheduleActivityTaskDecisionAttributes{ + ActivityId: &a.ActivityId, + ActivityType: ActivityType(a.ActivityType), + Domain: &a.Domain, + TaskList: TaskList(a.TaskList), + Input: Payload(a.Input), + ScheduleToCloseTimeoutSeconds: durationToSeconds(a.ScheduleToCloseTimeout), + ScheduleToStartTimeoutSeconds: durationToSeconds(a.ScheduleToStartTimeout), + StartToCloseTimeoutSeconds: durationToSeconds(a.StartToCloseTimeout), + HeartbeatTimeoutSeconds: durationToSeconds(a.HeartbeatTimeout), + RetryPolicy: RetryPolicy(a.RetryPolicy), + Header: Header(a.Header), + RequestLocalDispatch: &a.RequestLocalDispatch, + } + case *apiv1.Decision_StartTimerDecisionAttributes: + decision.DecisionType = shared.DecisionTypeStartTimer.Ptr() + a := attr.StartTimerDecisionAttributes + decision.StartTimerDecisionAttributes = &shared.StartTimerDecisionAttributes{ + TimerId: &a.TimerId, + StartToFireTimeoutSeconds: int32To64(durationToSeconds(a.StartToFireTimeout)), + } + case *apiv1.Decision_CompleteWorkflowExecutionDecisionAttributes: + decision.DecisionType = shared.DecisionTypeCompleteWorkflowExecution.Ptr() + a := attr.CompleteWorkflowExecutionDecisionAttributes + decision.CompleteWorkflowExecutionDecisionAttributes = &shared.CompleteWorkflowExecutionDecisionAttributes{ + Result: Payload(a.Result), + } + case *apiv1.Decision_FailWorkflowExecutionDecisionAttributes: + decision.DecisionType = shared.DecisionTypeFailWorkflowExecution.Ptr() + a := attr.FailWorkflowExecutionDecisionAttributes + decision.FailWorkflowExecutionDecisionAttributes = &shared.FailWorkflowExecutionDecisionAttributes{ + Reason: FailureReason(a.Failure), + Details: FailureDetails(a.Failure), + } + case *apiv1.Decision_RequestCancelActivityTaskDecisionAttributes: + decision.DecisionType = shared.DecisionTypeRequestCancelActivityTask.Ptr() + a := attr.RequestCancelActivityTaskDecisionAttributes + decision.RequestCancelActivityTaskDecisionAttributes = &shared.RequestCancelActivityTaskDecisionAttributes{ + ActivityId: &a.ActivityId, + } + case *apiv1.Decision_CancelTimerDecisionAttributes: + decision.DecisionType = shared.DecisionTypeCancelTimer.Ptr() + a := attr.CancelTimerDecisionAttributes + decision.CancelTimerDecisionAttributes = &shared.CancelTimerDecisionAttributes{ + TimerId: &a.TimerId, + } + case *apiv1.Decision_CancelWorkflowExecutionDecisionAttributes: + decision.DecisionType = shared.DecisionTypeCancelWorkflowExecution.Ptr() + a := attr.CancelWorkflowExecutionDecisionAttributes + decision.CancelWorkflowExecutionDecisionAttributes = &shared.CancelWorkflowExecutionDecisionAttributes{ + Details: Payload(a.Details), + } + case *apiv1.Decision_RequestCancelExternalWorkflowExecutionDecisionAttributes: + decision.DecisionType = shared.DecisionTypeRequestCancelExternalWorkflowExecution.Ptr() + a := attr.RequestCancelExternalWorkflowExecutionDecisionAttributes + decision.RequestCancelExternalWorkflowExecutionDecisionAttributes = &shared.RequestCancelExternalWorkflowExecutionDecisionAttributes{ + Domain: &a.Domain, + WorkflowId: WorkflowId(a.WorkflowExecution), + RunId: RunId(a.WorkflowExecution), + Control: a.Control, + ChildWorkflowOnly: &a.ChildWorkflowOnly, + } + case *apiv1.Decision_RecordMarkerDecisionAttributes: + decision.DecisionType = shared.DecisionTypeRecordMarker.Ptr() + a := attr.RecordMarkerDecisionAttributes + decision.RecordMarkerDecisionAttributes = &shared.RecordMarkerDecisionAttributes{ + MarkerName: &a.MarkerName, + Details: Payload(a.Details), + Header: Header(a.Header), + } + case *apiv1.Decision_ContinueAsNewWorkflowExecutionDecisionAttributes: + decision.DecisionType = shared.DecisionTypeContinueAsNewWorkflowExecution.Ptr() + a := attr.ContinueAsNewWorkflowExecutionDecisionAttributes + decision.ContinueAsNewWorkflowExecutionDecisionAttributes = &shared.ContinueAsNewWorkflowExecutionDecisionAttributes{ + WorkflowType: WorkflowType(a.WorkflowType), + TaskList: TaskList(a.TaskList), + Input: Payload(a.Input), + ExecutionStartToCloseTimeoutSeconds: durationToSeconds(a.ExecutionStartToCloseTimeout), + TaskStartToCloseTimeoutSeconds: durationToSeconds(a.TaskStartToCloseTimeout), + BackoffStartIntervalInSeconds: durationToSeconds(a.BackoffStartInterval), + RetryPolicy: RetryPolicy(a.RetryPolicy), + Initiator: ContinueAsNewInitiator(a.Initiator), + FailureReason: FailureReason(a.Failure), + FailureDetails: FailureDetails(a.Failure), + LastCompletionResult: Payload(a.LastCompletionResult), + CronSchedule: &a.CronSchedule, + Header: Header(a.Header), + Memo: Memo(a.Memo), + SearchAttributes: SearchAttributes(a.SearchAttributes), + } + case *apiv1.Decision_StartChildWorkflowExecutionDecisionAttributes: + decision.DecisionType = shared.DecisionTypeStartChildWorkflowExecution.Ptr() + a := attr.StartChildWorkflowExecutionDecisionAttributes + decision.StartChildWorkflowExecutionDecisionAttributes = &shared.StartChildWorkflowExecutionDecisionAttributes{ + Domain: &a.Domain, + WorkflowId: &a.WorkflowId, + WorkflowType: WorkflowType(a.WorkflowType), + TaskList: TaskList(a.TaskList), + Input: Payload(a.Input), + ExecutionStartToCloseTimeoutSeconds: durationToSeconds(a.ExecutionStartToCloseTimeout), + TaskStartToCloseTimeoutSeconds: durationToSeconds(a.TaskStartToCloseTimeout), + ParentClosePolicy: ParentClosePolicy(a.ParentClosePolicy), + Control: a.Control, + WorkflowIdReusePolicy: WorkflowIdReusePolicy(a.WorkflowIdReusePolicy), + RetryPolicy: RetryPolicy(a.RetryPolicy), + CronSchedule: &a.CronSchedule, + Header: Header(a.Header), + Memo: Memo(a.Memo), + SearchAttributes: SearchAttributes(a.SearchAttributes), + } + case *apiv1.Decision_SignalExternalWorkflowExecutionDecisionAttributes: + decision.DecisionType = shared.DecisionTypeSignalExternalWorkflowExecution.Ptr() + a := attr.SignalExternalWorkflowExecutionDecisionAttributes + decision.SignalExternalWorkflowExecutionDecisionAttributes = &shared.SignalExternalWorkflowExecutionDecisionAttributes{ + Domain: &a.Domain, + Execution: WorkflowExecution(a.WorkflowExecution), + SignalName: &a.SignalName, + Input: Payload(a.Input), + Control: a.Control, + ChildWorkflowOnly: &a.ChildWorkflowOnly, + } + case *apiv1.Decision_UpsertWorkflowSearchAttributesDecisionAttributes: + decision.DecisionType = shared.DecisionTypeUpsertWorkflowSearchAttributes.Ptr() + a := attr.UpsertWorkflowSearchAttributesDecisionAttributes + decision.UpsertWorkflowSearchAttributesDecisionAttributes = &shared.UpsertWorkflowSearchAttributesDecisionAttributes{ + SearchAttributes: SearchAttributes(a.SearchAttributes), + } + default: + panic("unknown decision type") + } + return &decision +} diff --git a/internal/compatibility/thrift/enum.go b/internal/compatibility/thrift/enum.go new file mode 100644 index 000000000..e1a968868 --- /dev/null +++ b/internal/compatibility/thrift/enum.go @@ -0,0 +1,378 @@ +// Copyright (c) 2021 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +package thrift + +import ( + "go.uber.org/cadence/.gen/go/shared" + apiv1 "go.uber.org/cadence/.gen/proto/api/v1" +) + +func TaskListKind(t apiv1.TaskListKind) *shared.TaskListKind { + switch t { + case apiv1.TaskListKind_TASK_LIST_KIND_INVALID: + return nil + case apiv1.TaskListKind_TASK_LIST_KIND_NORMAL: + return shared.TaskListKindNormal.Ptr() + case apiv1.TaskListKind_TASK_LIST_KIND_STICKY: + return shared.TaskListKindSticky.Ptr() + } + panic("unexpected enum value") +} + +func TaskListType(t apiv1.TaskListType) *shared.TaskListType { + if t == apiv1.TaskListType_TASK_LIST_TYPE_INVALID { + return nil + } + switch t { + case apiv1.TaskListType_TASK_LIST_TYPE_DECISION: + return shared.TaskListTypeDecision.Ptr() + case apiv1.TaskListType_TASK_LIST_TYPE_ACTIVITY: + return shared.TaskListTypeActivity.Ptr() + } + panic("unexpected enum value") +} + +func EventFilterType(t apiv1.EventFilterType) *shared.HistoryEventFilterType { + if t == apiv1.EventFilterType_EVENT_FILTER_TYPE_INVALID { + return nil + } + switch t { + case apiv1.EventFilterType_EVENT_FILTER_TYPE_ALL_EVENT: + return shared.HistoryEventFilterTypeAllEvent.Ptr() + case apiv1.EventFilterType_EVENT_FILTER_TYPE_CLOSE_EVENT: + return shared.HistoryEventFilterTypeCloseEvent.Ptr() + } + panic("unexpected enum value") +} + +func QueryRejectCondition(t apiv1.QueryRejectCondition) *shared.QueryRejectCondition { + if t == apiv1.QueryRejectCondition_QUERY_REJECT_CONDITION_INVALID { + return nil + } + switch t { + case apiv1.QueryRejectCondition_QUERY_REJECT_CONDITION_NOT_OPEN: + return shared.QueryRejectConditionNotOpen.Ptr() + case apiv1.QueryRejectCondition_QUERY_REJECT_CONDITION_NOT_COMPLETED_CLEANLY: + return shared.QueryRejectConditionNotCompletedCleanly.Ptr() + } + panic("unexpected enum value") +} + +func QueryConsistencyLevel(t apiv1.QueryConsistencyLevel) *shared.QueryConsistencyLevel { + if t == apiv1.QueryConsistencyLevel_QUERY_CONSISTENCY_LEVEL_INVALID { + return nil + } + switch t { + case apiv1.QueryConsistencyLevel_QUERY_CONSISTENCY_LEVEL_EVENTUAL: + return shared.QueryConsistencyLevelEventual.Ptr() + case apiv1.QueryConsistencyLevel_QUERY_CONSISTENCY_LEVEL_STRONG: + return shared.QueryConsistencyLevelStrong.Ptr() + } + panic("unexpected enum value") +} + +func ContinueAsNewInitiator(t apiv1.ContinueAsNewInitiator) *shared.ContinueAsNewInitiator { + switch t { + case apiv1.ContinueAsNewInitiator_CONTINUE_AS_NEW_INITIATOR_INVALID: + return nil + case apiv1.ContinueAsNewInitiator_CONTINUE_AS_NEW_INITIATOR_DECIDER: + return shared.ContinueAsNewInitiatorDecider.Ptr() + case apiv1.ContinueAsNewInitiator_CONTINUE_AS_NEW_INITIATOR_RETRY_POLICY: + return shared.ContinueAsNewInitiatorRetryPolicy.Ptr() + case apiv1.ContinueAsNewInitiator_CONTINUE_AS_NEW_INITIATOR_CRON_SCHEDULE: + return shared.ContinueAsNewInitiatorCronSchedule.Ptr() + } + panic("unexpected enum value") +} + +func WorkflowIdReusePolicy(t apiv1.WorkflowIdReusePolicy) *shared.WorkflowIdReusePolicy { + switch t { + case apiv1.WorkflowIdReusePolicy_WORKFLOW_ID_REUSE_POLICY_INVALID: + return nil + case apiv1.WorkflowIdReusePolicy_WORKFLOW_ID_REUSE_POLICY_ALLOW_DUPLICATE_FAILED_ONLY: + return shared.WorkflowIdReusePolicyAllowDuplicateFailedOnly.Ptr() + case apiv1.WorkflowIdReusePolicy_WORKFLOW_ID_REUSE_POLICY_ALLOW_DUPLICATE: + return shared.WorkflowIdReusePolicyAllowDuplicate.Ptr() + case apiv1.WorkflowIdReusePolicy_WORKFLOW_ID_REUSE_POLICY_REJECT_DUPLICATE: + return shared.WorkflowIdReusePolicyRejectDuplicate.Ptr() + case apiv1.WorkflowIdReusePolicy_WORKFLOW_ID_REUSE_POLICY_TERMINATE_IF_RUNNING: + return shared.WorkflowIdReusePolicyTerminateIfRunning.Ptr() + } + panic("unexpected enum value") +} + +func QueryResultType(t apiv1.QueryResultType) *shared.QueryResultType { + if t == apiv1.QueryResultType_QUERY_RESULT_TYPE_INVALID { + return nil + } + switch t { + case apiv1.QueryResultType_QUERY_RESULT_TYPE_ANSWERED: + return shared.QueryResultTypeAnswered.Ptr() + case apiv1.QueryResultType_QUERY_RESULT_TYPE_FAILED: + return shared.QueryResultTypeFailed.Ptr() + } + panic("unexpected enum value") +} + +func ArchivalStatus(t apiv1.ArchivalStatus) *shared.ArchivalStatus { + switch t { + case apiv1.ArchivalStatus_ARCHIVAL_STATUS_INVALID: + return nil + case apiv1.ArchivalStatus_ARCHIVAL_STATUS_DISABLED: + return shared.ArchivalStatusDisabled.Ptr() + case apiv1.ArchivalStatus_ARCHIVAL_STATUS_ENABLED: + return shared.ArchivalStatusEnabled.Ptr() + } + panic("unexpected enum value") +} + +func ParentClosePolicy(t apiv1.ParentClosePolicy) *shared.ParentClosePolicy { + switch t { + case apiv1.ParentClosePolicy_PARENT_CLOSE_POLICY_INVALID: + return nil + case apiv1.ParentClosePolicy_PARENT_CLOSE_POLICY_ABANDON: + return shared.ParentClosePolicyAbandon.Ptr() + case apiv1.ParentClosePolicy_PARENT_CLOSE_POLICY_REQUEST_CANCEL: + return shared.ParentClosePolicyRequestCancel.Ptr() + case apiv1.ParentClosePolicy_PARENT_CLOSE_POLICY_TERMINATE: + return shared.ParentClosePolicyTerminate.Ptr() + } + panic("unexpected enum value") +} + +func DecisionTaskFailedCause(t apiv1.DecisionTaskFailedCause) *shared.DecisionTaskFailedCause { + switch t { + case apiv1.DecisionTaskFailedCause_DECISION_TASK_FAILED_CAUSE_INVALID: + return nil + case apiv1.DecisionTaskFailedCause_DECISION_TASK_FAILED_CAUSE_UNHANDLED_DECISION: + return shared.DecisionTaskFailedCauseUnhandledDecision.Ptr() + case apiv1.DecisionTaskFailedCause_DECISION_TASK_FAILED_CAUSE_BAD_SCHEDULE_ACTIVITY_ATTRIBUTES: + return shared.DecisionTaskFailedCauseBadScheduleActivityAttributes.Ptr() + case apiv1.DecisionTaskFailedCause_DECISION_TASK_FAILED_CAUSE_BAD_REQUEST_CANCEL_ACTIVITY_ATTRIBUTES: + return shared.DecisionTaskFailedCauseBadRequestCancelActivityAttributes.Ptr() + case apiv1.DecisionTaskFailedCause_DECISION_TASK_FAILED_CAUSE_BAD_START_TIMER_ATTRIBUTES: + return shared.DecisionTaskFailedCauseBadStartTimerAttributes.Ptr() + case apiv1.DecisionTaskFailedCause_DECISION_TASK_FAILED_CAUSE_BAD_CANCEL_TIMER_ATTRIBUTES: + return shared.DecisionTaskFailedCauseBadCancelTimerAttributes.Ptr() + case apiv1.DecisionTaskFailedCause_DECISION_TASK_FAILED_CAUSE_BAD_RECORD_MARKER_ATTRIBUTES: + return shared.DecisionTaskFailedCauseBadRecordMarkerAttributes.Ptr() + case apiv1.DecisionTaskFailedCause_DECISION_TASK_FAILED_CAUSE_BAD_COMPLETE_WORKFLOW_EXECUTION_ATTRIBUTES: + return shared.DecisionTaskFailedCauseBadCompleteWorkflowExecutionAttributes.Ptr() + case apiv1.DecisionTaskFailedCause_DECISION_TASK_FAILED_CAUSE_BAD_FAIL_WORKFLOW_EXECUTION_ATTRIBUTES: + return shared.DecisionTaskFailedCauseBadFailWorkflowExecutionAttributes.Ptr() + case apiv1.DecisionTaskFailedCause_DECISION_TASK_FAILED_CAUSE_BAD_CANCEL_WORKFLOW_EXECUTION_ATTRIBUTES: + return shared.DecisionTaskFailedCauseBadCancelWorkflowExecutionAttributes.Ptr() + case apiv1.DecisionTaskFailedCause_DECISION_TASK_FAILED_CAUSE_BAD_REQUEST_CANCEL_EXTERNAL_WORKFLOW_EXECUTION_ATTRIBUTES: + return shared.DecisionTaskFailedCauseBadRequestCancelExternalWorkflowExecutionAttributes.Ptr() + case apiv1.DecisionTaskFailedCause_DECISION_TASK_FAILED_CAUSE_BAD_CONTINUE_AS_NEW_ATTRIBUTES: + return shared.DecisionTaskFailedCauseBadContinueAsNewAttributes.Ptr() + case apiv1.DecisionTaskFailedCause_DECISION_TASK_FAILED_CAUSE_START_TIMER_DUPLICATE_ID: + return shared.DecisionTaskFailedCauseStartTimerDuplicateID.Ptr() + case apiv1.DecisionTaskFailedCause_DECISION_TASK_FAILED_CAUSE_RESET_STICKY_TASK_LIST: + return shared.DecisionTaskFailedCauseResetStickyTasklist.Ptr() + case apiv1.DecisionTaskFailedCause_DECISION_TASK_FAILED_CAUSE_WORKFLOW_WORKER_UNHANDLED_FAILURE: + return shared.DecisionTaskFailedCauseWorkflowWorkerUnhandledFailure.Ptr() + case apiv1.DecisionTaskFailedCause_DECISION_TASK_FAILED_CAUSE_BAD_SIGNAL_WORKFLOW_EXECUTION_ATTRIBUTES: + return shared.DecisionTaskFailedCauseBadSignalWorkflowExecutionAttributes.Ptr() + case apiv1.DecisionTaskFailedCause_DECISION_TASK_FAILED_CAUSE_BAD_START_CHILD_EXECUTION_ATTRIBUTES: + return shared.DecisionTaskFailedCauseBadStartChildExecutionAttributes.Ptr() + case apiv1.DecisionTaskFailedCause_DECISION_TASK_FAILED_CAUSE_FORCE_CLOSE_DECISION: + return shared.DecisionTaskFailedCauseForceCloseDecision.Ptr() + case apiv1.DecisionTaskFailedCause_DECISION_TASK_FAILED_CAUSE_FAILOVER_CLOSE_DECISION: + return shared.DecisionTaskFailedCauseFailoverCloseDecision.Ptr() + case apiv1.DecisionTaskFailedCause_DECISION_TASK_FAILED_CAUSE_BAD_SIGNAL_INPUT_SIZE: + return shared.DecisionTaskFailedCauseBadSignalInputSize.Ptr() + case apiv1.DecisionTaskFailedCause_DECISION_TASK_FAILED_CAUSE_RESET_WORKFLOW: + return shared.DecisionTaskFailedCauseResetWorkflow.Ptr() + case apiv1.DecisionTaskFailedCause_DECISION_TASK_FAILED_CAUSE_BAD_BINARY: + return shared.DecisionTaskFailedCauseBadBinary.Ptr() + case apiv1.DecisionTaskFailedCause_DECISION_TASK_FAILED_CAUSE_SCHEDULE_ACTIVITY_DUPLICATE_ID: + return shared.DecisionTaskFailedCauseScheduleActivityDuplicateID.Ptr() + case apiv1.DecisionTaskFailedCause_DECISION_TASK_FAILED_CAUSE_BAD_SEARCH_ATTRIBUTES: + return shared.DecisionTaskFailedCauseBadSearchAttributes.Ptr() + } + panic("unexpected enum value") +} + +func WorkflowExecutionCloseStatus(t apiv1.WorkflowExecutionCloseStatus) *shared.WorkflowExecutionCloseStatus { + switch t { + case apiv1.WorkflowExecutionCloseStatus_WORKFLOW_EXECUTION_CLOSE_STATUS_INVALID: + return nil + case apiv1.WorkflowExecutionCloseStatus_WORKFLOW_EXECUTION_CLOSE_STATUS_COMPLETED: + return shared.WorkflowExecutionCloseStatusCompleted.Ptr() + case apiv1.WorkflowExecutionCloseStatus_WORKFLOW_EXECUTION_CLOSE_STATUS_FAILED: + return shared.WorkflowExecutionCloseStatusFailed.Ptr() + case apiv1.WorkflowExecutionCloseStatus_WORKFLOW_EXECUTION_CLOSE_STATUS_CANCELED: + return shared.WorkflowExecutionCloseStatusCanceled.Ptr() + case apiv1.WorkflowExecutionCloseStatus_WORKFLOW_EXECUTION_CLOSE_STATUS_TERMINATED: + return shared.WorkflowExecutionCloseStatusTerminated.Ptr() + case apiv1.WorkflowExecutionCloseStatus_WORKFLOW_EXECUTION_CLOSE_STATUS_CONTINUED_AS_NEW: + return shared.WorkflowExecutionCloseStatusContinuedAsNew.Ptr() + case apiv1.WorkflowExecutionCloseStatus_WORKFLOW_EXECUTION_CLOSE_STATUS_TIMED_OUT: + return shared.WorkflowExecutionCloseStatusTimedOut.Ptr() + } + panic("unexpected enum value") +} + +func QueryTaskCompletedType(t apiv1.QueryResultType) *shared.QueryTaskCompletedType { + if t == apiv1.QueryResultType_QUERY_RESULT_TYPE_INVALID { + return nil + } + switch t { + case apiv1.QueryResultType_QUERY_RESULT_TYPE_ANSWERED: + return shared.QueryTaskCompletedTypeCompleted.Ptr() + case apiv1.QueryResultType_QUERY_RESULT_TYPE_FAILED: + return shared.QueryTaskCompletedTypeFailed.Ptr() + } + panic("unexpected enum value") +} + +func DomainStatus(t apiv1.DomainStatus) *shared.DomainStatus { + switch t { + case apiv1.DomainStatus_DOMAIN_STATUS_INVALID: + return nil + case apiv1.DomainStatus_DOMAIN_STATUS_REGISTERED: + return shared.DomainStatusRegistered.Ptr() + case apiv1.DomainStatus_DOMAIN_STATUS_DEPRECATED: + return shared.DomainStatusDeprecated.Ptr() + case apiv1.DomainStatus_DOMAIN_STATUS_DELETED: + return shared.DomainStatusDeleted.Ptr() + } + panic("unexpected enum value") +} + +func PendingActivityState(t apiv1.PendingActivityState) *shared.PendingActivityState { + switch t { + case apiv1.PendingActivityState_PENDING_ACTIVITY_STATE_INVALID: + return nil + case apiv1.PendingActivityState_PENDING_ACTIVITY_STATE_SCHEDULED: + return shared.PendingActivityStateScheduled.Ptr() + case apiv1.PendingActivityState_PENDING_ACTIVITY_STATE_STARTED: + return shared.PendingActivityStateStarted.Ptr() + case apiv1.PendingActivityState_PENDING_ACTIVITY_STATE_CANCEL_REQUESTED: + return shared.PendingActivityStateCancelRequested.Ptr() + } + panic("unexpected enum value") +} + +func PendingDecisionState(t apiv1.PendingDecisionState) *shared.PendingDecisionState { + switch t { + case apiv1.PendingDecisionState_PENDING_DECISION_STATE_INVALID: + return nil + case apiv1.PendingDecisionState_PENDING_DECISION_STATE_SCHEDULED: + return shared.PendingDecisionStateScheduled.Ptr() + case apiv1.PendingDecisionState_PENDING_DECISION_STATE_STARTED: + return shared.PendingDecisionStateStarted.Ptr() + } + panic("unexpected enum value") +} + +func IndexedValueType(t apiv1.IndexedValueType) shared.IndexedValueType { + switch t { + case apiv1.IndexedValueType_INDEXED_VALUE_TYPE_INVALID: + panic("received IndexedValueType_INDEXED_VALUE_TYPE_INVALID") + case apiv1.IndexedValueType_INDEXED_VALUE_TYPE_STRING: + return shared.IndexedValueTypeString + case apiv1.IndexedValueType_INDEXED_VALUE_TYPE_KEYWORD: + return shared.IndexedValueTypeKeyword + case apiv1.IndexedValueType_INDEXED_VALUE_TYPE_INT: + return shared.IndexedValueTypeInt + case apiv1.IndexedValueType_INDEXED_VALUE_TYPE_DOUBLE: + return shared.IndexedValueTypeDouble + case apiv1.IndexedValueType_INDEXED_VALUE_TYPE_BOOL: + return shared.IndexedValueTypeBool + case apiv1.IndexedValueType_INDEXED_VALUE_TYPE_DATETIME: + return shared.IndexedValueTypeDatetime + } + panic("unexpected enum value") +} + +func EncodingType(t apiv1.EncodingType) *shared.EncodingType { + switch t { + case apiv1.EncodingType_ENCODING_TYPE_INVALID: + return nil + case apiv1.EncodingType_ENCODING_TYPE_THRIFTRW: + return shared.EncodingTypeThriftRW.Ptr() + case apiv1.EncodingType_ENCODING_TYPE_JSON: + return shared.EncodingTypeJSON.Ptr() + case apiv1.EncodingType_ENCODING_TYPE_PROTO3: + panic("not supported yet") + } + panic("unexpected enum value") +} + +func TimeoutType(t apiv1.TimeoutType) *shared.TimeoutType { + switch t { + case apiv1.TimeoutType_TIMEOUT_TYPE_INVALID: + return nil + case apiv1.TimeoutType_TIMEOUT_TYPE_START_TO_CLOSE: + return shared.TimeoutTypeStartToClose.Ptr() + case apiv1.TimeoutType_TIMEOUT_TYPE_SCHEDULE_TO_START: + return shared.TimeoutTypeScheduleToStart.Ptr() + case apiv1.TimeoutType_TIMEOUT_TYPE_SCHEDULE_TO_CLOSE: + return shared.TimeoutTypeScheduleToClose.Ptr() + case apiv1.TimeoutType_TIMEOUT_TYPE_HEARTBEAT: + return shared.TimeoutTypeHeartbeat.Ptr() + } + panic("unexpected enum value") +} + +func DecisionTaskTimedOutCause(t apiv1.DecisionTaskTimedOutCause) *shared.DecisionTaskTimedOutCause { + switch t { + case apiv1.DecisionTaskTimedOutCause_DECISION_TASK_TIMED_OUT_CAUSE_INVALID: + return nil + case apiv1.DecisionTaskTimedOutCause_DECISION_TASK_TIMED_OUT_CAUSE_TIMEOUT: + return shared.DecisionTaskTimedOutCauseTimeout.Ptr() + case apiv1.DecisionTaskTimedOutCause_DECISION_TASK_TIMED_OUT_CAUSE_RESET: + return shared.DecisionTaskTimedOutCauseReset.Ptr() + } + panic("unexpected enum value") +} + +func CancelExternalWorkflowExecutionFailedCause(t apiv1.CancelExternalWorkflowExecutionFailedCause) *shared.CancelExternalWorkflowExecutionFailedCause { + switch t { + case apiv1.CancelExternalWorkflowExecutionFailedCause_CANCEL_EXTERNAL_WORKFLOW_EXECUTION_FAILED_CAUSE_INVALID: + return nil + case apiv1.CancelExternalWorkflowExecutionFailedCause_CANCEL_EXTERNAL_WORKFLOW_EXECUTION_FAILED_CAUSE_UNKNOWN_EXTERNAL_WORKFLOW_EXECUTION: + return shared.CancelExternalWorkflowExecutionFailedCauseUnknownExternalWorkflowExecution.Ptr() + } + panic("unexpected enum value") +} + +func SignalExternalWorkflowExecutionFailedCause(t apiv1.SignalExternalWorkflowExecutionFailedCause) *shared.SignalExternalWorkflowExecutionFailedCause { + switch t { + case apiv1.SignalExternalWorkflowExecutionFailedCause_SIGNAL_EXTERNAL_WORKFLOW_EXECUTION_FAILED_CAUSE_INVALID: + return nil + case apiv1.SignalExternalWorkflowExecutionFailedCause_SIGNAL_EXTERNAL_WORKFLOW_EXECUTION_FAILED_CAUSE_UNKNOWN_EXTERNAL_WORKFLOW_EXECUTION: + return shared.SignalExternalWorkflowExecutionFailedCauseUnknownExternalWorkflowExecution.Ptr() + } + panic("unexpected enum value") +} + +func ChildWorkflowExecutionFailedCause(t apiv1.ChildWorkflowExecutionFailedCause) *shared.ChildWorkflowExecutionFailedCause { + switch t { + case apiv1.ChildWorkflowExecutionFailedCause_CHILD_WORKFLOW_EXECUTION_FAILED_CAUSE_INVALID: + return nil + case apiv1.ChildWorkflowExecutionFailedCause_CHILD_WORKFLOW_EXECUTION_FAILED_CAUSE_WORKFLOW_ALREADY_RUNNING: + return shared.ChildWorkflowExecutionFailedCauseWorkflowAlreadyRunning.Ptr() + } + panic("unexpected enum value") +} diff --git a/internal/compatibility/error.go b/internal/compatibility/thrift/error.go similarity index 98% rename from internal/compatibility/error.go rename to internal/compatibility/thrift/error.go index 7c6dbd90f..f9afce376 100644 --- a/internal/compatibility/error.go +++ b/internal/compatibility/thrift/error.go @@ -18,7 +18,7 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -package compatibility +package thrift import ( "errors" @@ -30,7 +30,7 @@ import ( "go.uber.org/yarpc/yarpcerrors" ) -func thriftError(err error) error { +func Error(err error) error { status := yarpcerrors.FromError(err) if status == nil || status.Code() == yarpcerrors.CodeOK { return nil @@ -136,4 +136,4 @@ func getErrorDetails(err error) interface{} { return details[0] } return nil -} \ No newline at end of file +} diff --git a/internal/compatibility/helpers.go b/internal/compatibility/thrift/helpers.go similarity index 74% rename from internal/compatibility/helpers.go rename to internal/compatibility/thrift/helpers.go index a1835bbdf..4d3ff7e7c 100644 --- a/internal/compatibility/helpers.go +++ b/internal/compatibility/thrift/helpers.go @@ -18,23 +18,24 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -package compatibility +package thrift import ( + "time" + gogo "github.com/gogo/protobuf/types" "go.uber.org/cadence/internal/common" - "time" ) func boolPtr(b bool) *bool { return &b } -func fromDoubleValue(v *float64) *gogo.DoubleValue { +func toDoubleValue(v *gogo.DoubleValue) *float64 { if v == nil { return nil } - return &gogo.DoubleValue{Value: *v} + return &v.Value } func toInt64Value(v *gogo.Int64Value) *int64 { @@ -44,17 +45,6 @@ func toInt64Value(v *gogo.Int64Value) *int64 { return common.Int64Ptr(v.Value) } -func unixNanoToTime(t *int64) *gogo.Timestamp { - if t == nil { - return nil - } - time, err := gogo.TimestampProto(time.Unix(0, *t)) - if err != nil { - panic(err) - } - return time -} - func timeToUnixNano(t *gogo.Timestamp) *int64 { if t == nil { return nil @@ -66,13 +56,6 @@ func timeToUnixNano(t *gogo.Timestamp) *int64 { return common.Int64Ptr(timestamp.UnixNano()) } -func daysToDuration(d *int32) *gogo.Duration { - if d == nil { - return nil - } - return gogo.DurationProto(time.Duration(*d) * (24 * time.Hour)) -} - func durationToDays(d *gogo.Duration) *int32 { if d == nil { return nil @@ -84,13 +67,6 @@ func durationToDays(d *gogo.Duration) *int32 { return common.Int32Ptr(int32(duration / (24 * time.Hour))) } -func secondsToDuration(d *int32) *gogo.Duration { - if d == nil { - return nil - } - return gogo.DurationProto(time.Duration(*d) * time.Second) -} - func durationToSeconds(d *gogo.Duration) *int32 { if d == nil { return nil @@ -109,13 +85,23 @@ func int32To64(v *int32) *int64 { return common.Int64Ptr(int64(*v)) } -func int64To32(v *int64) *int32 { - if v == nil { +type fieldSet map[string]struct{} + +func newFieldSet(mask *gogo.FieldMask) fieldSet { + if mask == nil { return nil } - return common.Int32Ptr(int32(*v)) + fs := map[string]struct{}{} + for _, field := range mask.Paths { + fs[field] = struct{}{} + } + return fs } -func newFieldMask(fields []string) *gogo.FieldMask { - return &gogo.FieldMask{Paths: fields} +func (fs fieldSet) isSet(field string) bool { + if fs == nil { + return true + } + _, ok := fs[field] + return ok } diff --git a/internal/compatibility/thrift/history.go b/internal/compatibility/thrift/history.go new file mode 100644 index 000000000..ac6275b79 --- /dev/null +++ b/internal/compatibility/thrift/history.go @@ -0,0 +1,766 @@ +// Copyright (c) 2021 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +package thrift + +import ( + "go.uber.org/cadence/.gen/go/shared" + apiv1 "go.uber.org/cadence/.gen/proto/api/v1" + "go.uber.org/cadence/internal/common" +) + +func History(t *apiv1.History) *shared.History { + if t == nil { + return nil + } + return &shared.History{ + Events: HistoryEventArray(t.Events), + } +} + +func HistoryEventArray(t []*apiv1.HistoryEvent) []*shared.HistoryEvent { + if t == nil { + return nil + } + v := make([]*shared.HistoryEvent, len(t)) + for i := range t { + v[i] = HistoryEvent(t[i]) + } + return v +} + +func HistoryEvent(e *apiv1.HistoryEvent) *shared.HistoryEvent { + if e == nil { + return nil + } + event := shared.HistoryEvent{ + EventId: &e.EventId, + Timestamp: timeToUnixNano(e.EventTime), + Version: &e.Version, + TaskId: &e.TaskId, + } + switch attr := e.Attributes.(type) { + case *apiv1.HistoryEvent_WorkflowExecutionStartedEventAttributes: + event.EventType = shared.EventTypeWorkflowExecutionStarted.Ptr() + event.WorkflowExecutionStartedEventAttributes = WorkflowExecutionStartedEventAttributes(attr.WorkflowExecutionStartedEventAttributes) + case *apiv1.HistoryEvent_WorkflowExecutionCompletedEventAttributes: + event.EventType = shared.EventTypeWorkflowExecutionCompleted.Ptr() + event.WorkflowExecutionCompletedEventAttributes = WorkflowExecutionCompletedEventAttributes(attr.WorkflowExecutionCompletedEventAttributes) + case *apiv1.HistoryEvent_WorkflowExecutionFailedEventAttributes: + event.EventType = shared.EventTypeWorkflowExecutionFailed.Ptr() + event.WorkflowExecutionFailedEventAttributes = WorkflowExecutionFailedEventAttributes(attr.WorkflowExecutionFailedEventAttributes) + case *apiv1.HistoryEvent_WorkflowExecutionTimedOutEventAttributes: + event.EventType = shared.EventTypeWorkflowExecutionTimedOut.Ptr() + event.WorkflowExecutionTimedOutEventAttributes = WorkflowExecutionTimedOutEventAttributes(attr.WorkflowExecutionTimedOutEventAttributes) + case *apiv1.HistoryEvent_DecisionTaskScheduledEventAttributes: + event.EventType = shared.EventTypeDecisionTaskScheduled.Ptr() + event.DecisionTaskScheduledEventAttributes = DecisionTaskScheduledEventAttributes(attr.DecisionTaskScheduledEventAttributes) + case *apiv1.HistoryEvent_DecisionTaskStartedEventAttributes: + event.EventType = shared.EventTypeDecisionTaskStarted.Ptr() + event.DecisionTaskStartedEventAttributes = DecisionTaskStartedEventAttributes(attr.DecisionTaskStartedEventAttributes) + case *apiv1.HistoryEvent_DecisionTaskCompletedEventAttributes: + event.EventType = shared.EventTypeDecisionTaskCompleted.Ptr() + event.DecisionTaskCompletedEventAttributes = DecisionTaskCompletedEventAttributes(attr.DecisionTaskCompletedEventAttributes) + case *apiv1.HistoryEvent_DecisionTaskTimedOutEventAttributes: + event.EventType = shared.EventTypeDecisionTaskTimedOut.Ptr() + event.DecisionTaskTimedOutEventAttributes = DecisionTaskTimedOutEventAttributes(attr.DecisionTaskTimedOutEventAttributes) + case *apiv1.HistoryEvent_DecisionTaskFailedEventAttributes: + event.EventType = shared.EventTypeDecisionTaskFailed.Ptr() + event.DecisionTaskFailedEventAttributes = DecisionTaskFailedEventAttributes(attr.DecisionTaskFailedEventAttributes) + case *apiv1.HistoryEvent_ActivityTaskScheduledEventAttributes: + event.EventType = shared.EventTypeActivityTaskScheduled.Ptr() + event.ActivityTaskScheduledEventAttributes = ActivityTaskScheduledEventAttributes(attr.ActivityTaskScheduledEventAttributes) + case *apiv1.HistoryEvent_ActivityTaskStartedEventAttributes: + event.EventType = shared.EventTypeActivityTaskStarted.Ptr() + event.ActivityTaskStartedEventAttributes = ActivityTaskStartedEventAttributes(attr.ActivityTaskStartedEventAttributes) + case *apiv1.HistoryEvent_ActivityTaskCompletedEventAttributes: + event.EventType = shared.EventTypeActivityTaskCompleted.Ptr() + event.ActivityTaskCompletedEventAttributes = ActivityTaskCompletedEventAttributes(attr.ActivityTaskCompletedEventAttributes) + case *apiv1.HistoryEvent_ActivityTaskFailedEventAttributes: + event.EventType = shared.EventTypeActivityTaskFailed.Ptr() + event.ActivityTaskFailedEventAttributes = ActivityTaskFailedEventAttributes(attr.ActivityTaskFailedEventAttributes) + case *apiv1.HistoryEvent_ActivityTaskTimedOutEventAttributes: + event.EventType = shared.EventTypeActivityTaskTimedOut.Ptr() + event.ActivityTaskTimedOutEventAttributes = ActivityTaskTimedOutEventAttributes(attr.ActivityTaskTimedOutEventAttributes) + case *apiv1.HistoryEvent_TimerStartedEventAttributes: + event.EventType = shared.EventTypeTimerStarted.Ptr() + event.TimerStartedEventAttributes = TimerStartedEventAttributes(attr.TimerStartedEventAttributes) + case *apiv1.HistoryEvent_TimerFiredEventAttributes: + event.EventType = shared.EventTypeTimerFired.Ptr() + event.TimerFiredEventAttributes = TimerFiredEventAttributes(attr.TimerFiredEventAttributes) + case *apiv1.HistoryEvent_ActivityTaskCancelRequestedEventAttributes: + event.EventType = shared.EventTypeActivityTaskCancelRequested.Ptr() + event.ActivityTaskCancelRequestedEventAttributes = ActivityTaskCancelRequestedEventAttributes(attr.ActivityTaskCancelRequestedEventAttributes) + case *apiv1.HistoryEvent_RequestCancelActivityTaskFailedEventAttributes: + event.EventType = shared.EventTypeRequestCancelActivityTaskFailed.Ptr() + event.RequestCancelActivityTaskFailedEventAttributes = RequestCancelActivityTaskFailedEventAttributes(attr.RequestCancelActivityTaskFailedEventAttributes) + case *apiv1.HistoryEvent_ActivityTaskCanceledEventAttributes: + event.EventType = shared.EventTypeActivityTaskCanceled.Ptr() + event.ActivityTaskCanceledEventAttributes = ActivityTaskCanceledEventAttributes(attr.ActivityTaskCanceledEventAttributes) + case *apiv1.HistoryEvent_TimerCanceledEventAttributes: + event.EventType = shared.EventTypeTimerCanceled.Ptr() + event.TimerCanceledEventAttributes = TimerCanceledEventAttributes(attr.TimerCanceledEventAttributes) + case *apiv1.HistoryEvent_CancelTimerFailedEventAttributes: + event.EventType = shared.EventTypeCancelTimerFailed.Ptr() + event.CancelTimerFailedEventAttributes = CancelTimerFailedEventAttributes(attr.CancelTimerFailedEventAttributes) + case *apiv1.HistoryEvent_MarkerRecordedEventAttributes: + event.EventType = shared.EventTypeMarkerRecorded.Ptr() + event.MarkerRecordedEventAttributes = MarkerRecordedEventAttributes(attr.MarkerRecordedEventAttributes) + case *apiv1.HistoryEvent_WorkflowExecutionSignaledEventAttributes: + event.EventType = shared.EventTypeWorkflowExecutionSignaled.Ptr() + event.WorkflowExecutionSignaledEventAttributes = WorkflowExecutionSignaledEventAttributes(attr.WorkflowExecutionSignaledEventAttributes) + case *apiv1.HistoryEvent_WorkflowExecutionTerminatedEventAttributes: + event.EventType = shared.EventTypeWorkflowExecutionTerminated.Ptr() + event.WorkflowExecutionTerminatedEventAttributes = WorkflowExecutionTerminatedEventAttributes(attr.WorkflowExecutionTerminatedEventAttributes) + case *apiv1.HistoryEvent_WorkflowExecutionCancelRequestedEventAttributes: + event.EventType = shared.EventTypeWorkflowExecutionCancelRequested.Ptr() + event.WorkflowExecutionCancelRequestedEventAttributes = WorkflowExecutionCancelRequestedEventAttributes(attr.WorkflowExecutionCancelRequestedEventAttributes) + case *apiv1.HistoryEvent_WorkflowExecutionCanceledEventAttributes: + event.EventType = shared.EventTypeWorkflowExecutionCanceled.Ptr() + event.WorkflowExecutionCanceledEventAttributes = WorkflowExecutionCanceledEventAttributes(attr.WorkflowExecutionCanceledEventAttributes) + case *apiv1.HistoryEvent_RequestCancelExternalWorkflowExecutionInitiatedEventAttributes: + event.EventType = shared.EventTypeRequestCancelExternalWorkflowExecutionInitiated.Ptr() + event.RequestCancelExternalWorkflowExecutionInitiatedEventAttributes = RequestCancelExternalWorkflowExecutionInitiatedEventAttributes(attr.RequestCancelExternalWorkflowExecutionInitiatedEventAttributes) + case *apiv1.HistoryEvent_RequestCancelExternalWorkflowExecutionFailedEventAttributes: + event.EventType = shared.EventTypeRequestCancelExternalWorkflowExecutionFailed.Ptr() + event.RequestCancelExternalWorkflowExecutionFailedEventAttributes = RequestCancelExternalWorkflowExecutionFailedEventAttributes(attr.RequestCancelExternalWorkflowExecutionFailedEventAttributes) + case *apiv1.HistoryEvent_ExternalWorkflowExecutionCancelRequestedEventAttributes: + event.EventType = shared.EventTypeExternalWorkflowExecutionCancelRequested.Ptr() + event.ExternalWorkflowExecutionCancelRequestedEventAttributes = ExternalWorkflowExecutionCancelRequestedEventAttributes(attr.ExternalWorkflowExecutionCancelRequestedEventAttributes) + case *apiv1.HistoryEvent_WorkflowExecutionContinuedAsNewEventAttributes: + event.EventType = shared.EventTypeWorkflowExecutionContinuedAsNew.Ptr() + event.WorkflowExecutionContinuedAsNewEventAttributes = WorkflowExecutionContinuedAsNewEventAttributes(attr.WorkflowExecutionContinuedAsNewEventAttributes) + case *apiv1.HistoryEvent_StartChildWorkflowExecutionInitiatedEventAttributes: + event.EventType = shared.EventTypeStartChildWorkflowExecutionInitiated.Ptr() + event.StartChildWorkflowExecutionInitiatedEventAttributes = StartChildWorkflowExecutionInitiatedEventAttributes(attr.StartChildWorkflowExecutionInitiatedEventAttributes) + case *apiv1.HistoryEvent_StartChildWorkflowExecutionFailedEventAttributes: + event.EventType = shared.EventTypeStartChildWorkflowExecutionFailed.Ptr() + event.StartChildWorkflowExecutionFailedEventAttributes = StartChildWorkflowExecutionFailedEventAttributes(attr.StartChildWorkflowExecutionFailedEventAttributes) + case *apiv1.HistoryEvent_ChildWorkflowExecutionStartedEventAttributes: + event.EventType = shared.EventTypeChildWorkflowExecutionStarted.Ptr() + event.ChildWorkflowExecutionStartedEventAttributes = ChildWorkflowExecutionStartedEventAttributes(attr.ChildWorkflowExecutionStartedEventAttributes) + case *apiv1.HistoryEvent_ChildWorkflowExecutionCompletedEventAttributes: + event.EventType = shared.EventTypeChildWorkflowExecutionCompleted.Ptr() + event.ChildWorkflowExecutionCompletedEventAttributes = ChildWorkflowExecutionCompletedEventAttributes(attr.ChildWorkflowExecutionCompletedEventAttributes) + case *apiv1.HistoryEvent_ChildWorkflowExecutionFailedEventAttributes: + event.EventType = shared.EventTypeChildWorkflowExecutionFailed.Ptr() + event.ChildWorkflowExecutionFailedEventAttributes = ChildWorkflowExecutionFailedEventAttributes(attr.ChildWorkflowExecutionFailedEventAttributes) + case *apiv1.HistoryEvent_ChildWorkflowExecutionCanceledEventAttributes: + event.EventType = shared.EventTypeChildWorkflowExecutionCanceled.Ptr() + event.ChildWorkflowExecutionCanceledEventAttributes = ChildWorkflowExecutionCanceledEventAttributes(attr.ChildWorkflowExecutionCanceledEventAttributes) + case *apiv1.HistoryEvent_ChildWorkflowExecutionTimedOutEventAttributes: + event.EventType = shared.EventTypeChildWorkflowExecutionTimedOut.Ptr() + event.ChildWorkflowExecutionTimedOutEventAttributes = ChildWorkflowExecutionTimedOutEventAttributes(attr.ChildWorkflowExecutionTimedOutEventAttributes) + case *apiv1.HistoryEvent_ChildWorkflowExecutionTerminatedEventAttributes: + event.EventType = shared.EventTypeChildWorkflowExecutionTerminated.Ptr() + event.ChildWorkflowExecutionTerminatedEventAttributes = ChildWorkflowExecutionTerminatedEventAttributes(attr.ChildWorkflowExecutionTerminatedEventAttributes) + case *apiv1.HistoryEvent_SignalExternalWorkflowExecutionInitiatedEventAttributes: + event.EventType = shared.EventTypeSignalExternalWorkflowExecutionInitiated.Ptr() + event.SignalExternalWorkflowExecutionInitiatedEventAttributes = SignalExternalWorkflowExecutionInitiatedEventAttributes(attr.SignalExternalWorkflowExecutionInitiatedEventAttributes) + case *apiv1.HistoryEvent_SignalExternalWorkflowExecutionFailedEventAttributes: + event.EventType = shared.EventTypeSignalExternalWorkflowExecutionFailed.Ptr() + event.SignalExternalWorkflowExecutionFailedEventAttributes = SignalExternalWorkflowExecutionFailedEventAttributes(attr.SignalExternalWorkflowExecutionFailedEventAttributes) + case *apiv1.HistoryEvent_ExternalWorkflowExecutionSignaledEventAttributes: + event.EventType = shared.EventTypeExternalWorkflowExecutionSignaled.Ptr() + event.ExternalWorkflowExecutionSignaledEventAttributes = ExternalWorkflowExecutionSignaledEventAttributes(attr.ExternalWorkflowExecutionSignaledEventAttributes) + case *apiv1.HistoryEvent_UpsertWorkflowSearchAttributesEventAttributes: + event.EventType = shared.EventTypeUpsertWorkflowSearchAttributes.Ptr() + event.UpsertWorkflowSearchAttributesEventAttributes = UpsertWorkflowSearchAttributesEventAttributes(attr.UpsertWorkflowSearchAttributesEventAttributes) + default: + panic("unknown event type") + } + + return &event +} + +func ActivityTaskCancelRequestedEventAttributes(t *apiv1.ActivityTaskCancelRequestedEventAttributes) *shared.ActivityTaskCancelRequestedEventAttributes { + if t == nil { + return nil + } + return &shared.ActivityTaskCancelRequestedEventAttributes{ + ActivityId: &t.ActivityId, + DecisionTaskCompletedEventId: &t.DecisionTaskCompletedEventId, + } +} + +func ActivityTaskCanceledEventAttributes(t *apiv1.ActivityTaskCanceledEventAttributes) *shared.ActivityTaskCanceledEventAttributes { + if t == nil { + return nil + } + return &shared.ActivityTaskCanceledEventAttributes{ + Details: Payload(t.Details), + LatestCancelRequestedEventId: &t.LatestCancelRequestedEventId, + ScheduledEventId: &t.ScheduledEventId, + StartedEventId: &t.StartedEventId, + Identity: &t.Identity, + } +} + +func ActivityTaskCompletedEventAttributes(t *apiv1.ActivityTaskCompletedEventAttributes) *shared.ActivityTaskCompletedEventAttributes { + if t == nil { + return nil + } + return &shared.ActivityTaskCompletedEventAttributes{ + Result: Payload(t.Result), + ScheduledEventId: &t.ScheduledEventId, + StartedEventId: &t.StartedEventId, + Identity: &t.Identity, + } +} + +func ActivityTaskFailedEventAttributes(t *apiv1.ActivityTaskFailedEventAttributes) *shared.ActivityTaskFailedEventAttributes { + if t == nil { + return nil + } + return &shared.ActivityTaskFailedEventAttributes{ + Reason: FailureReason(t.Failure), + Details: FailureDetails(t.Failure), + ScheduledEventId: &t.ScheduledEventId, + StartedEventId: &t.StartedEventId, + Identity: &t.Identity, + } +} + +func ActivityTaskScheduledEventAttributes(t *apiv1.ActivityTaskScheduledEventAttributes) *shared.ActivityTaskScheduledEventAttributes { + if t == nil { + return nil + } + return &shared.ActivityTaskScheduledEventAttributes{ + ActivityId: &t.ActivityId, + ActivityType: ActivityType(t.ActivityType), + Domain: &t.Domain, + TaskList: TaskList(t.TaskList), + Input: Payload(t.Input), + ScheduleToCloseTimeoutSeconds: durationToSeconds(t.ScheduleToCloseTimeout), + ScheduleToStartTimeoutSeconds: durationToSeconds(t.ScheduleToStartTimeout), + StartToCloseTimeoutSeconds: durationToSeconds(t.StartToCloseTimeout), + HeartbeatTimeoutSeconds: durationToSeconds(t.HeartbeatTimeout), + DecisionTaskCompletedEventId: &t.DecisionTaskCompletedEventId, + RetryPolicy: RetryPolicy(t.RetryPolicy), + Header: Header(t.Header), + } +} + +func ActivityTaskStartedEventAttributes(t *apiv1.ActivityTaskStartedEventAttributes) *shared.ActivityTaskStartedEventAttributes { + if t == nil { + return nil + } + return &shared.ActivityTaskStartedEventAttributes{ + ScheduledEventId: &t.ScheduledEventId, + Identity: &t.Identity, + RequestId: &t.RequestId, + Attempt: &t.Attempt, + LastFailureReason: FailureReason(t.LastFailure), + LastFailureDetails: FailureDetails(t.LastFailure), + } +} + +func ActivityTaskTimedOutEventAttributes(t *apiv1.ActivityTaskTimedOutEventAttributes) *shared.ActivityTaskTimedOutEventAttributes { + if t == nil { + return nil + } + return &shared.ActivityTaskTimedOutEventAttributes{ + Details: Payload(t.Details), + ScheduledEventId: &t.ScheduledEventId, + StartedEventId: &t.StartedEventId, + TimeoutType: TimeoutType(t.TimeoutType), + LastFailureReason: FailureReason(t.LastFailure), + LastFailureDetails: FailureDetails(t.LastFailure), + } +} + +func CancelTimerFailedEventAttributes(t *apiv1.CancelTimerFailedEventAttributes) *shared.CancelTimerFailedEventAttributes { + if t == nil { + return nil + } + return &shared.CancelTimerFailedEventAttributes{ + TimerId: &t.TimerId, + Cause: &t.Cause, + DecisionTaskCompletedEventId: &t.DecisionTaskCompletedEventId, + Identity: &t.Identity, + } +} + +func ChildWorkflowExecutionCanceledEventAttributes(t *apiv1.ChildWorkflowExecutionCanceledEventAttributes) *shared.ChildWorkflowExecutionCanceledEventAttributes { + if t == nil { + return nil + } + return &shared.ChildWorkflowExecutionCanceledEventAttributes{ + Domain: &t.Domain, + WorkflowExecution: WorkflowExecution(t.WorkflowExecution), + WorkflowType: WorkflowType(t.WorkflowType), + InitiatedEventId: &t.InitiatedEventId, + StartedEventId: &t.StartedEventId, + Details: Payload(t.Details), + } +} + +func ChildWorkflowExecutionCompletedEventAttributes(t *apiv1.ChildWorkflowExecutionCompletedEventAttributes) *shared.ChildWorkflowExecutionCompletedEventAttributes { + if t == nil { + return nil + } + return &shared.ChildWorkflowExecutionCompletedEventAttributes{ + Domain: &t.Domain, + WorkflowExecution: WorkflowExecution(t.WorkflowExecution), + WorkflowType: WorkflowType(t.WorkflowType), + InitiatedEventId: &t.InitiatedEventId, + StartedEventId: &t.StartedEventId, + Result: Payload(t.Result), + } +} + +func ChildWorkflowExecutionFailedEventAttributes(t *apiv1.ChildWorkflowExecutionFailedEventAttributes) *shared.ChildWorkflowExecutionFailedEventAttributes { + if t == nil { + return nil + } + return &shared.ChildWorkflowExecutionFailedEventAttributes{ + Domain: &t.Domain, + WorkflowExecution: WorkflowExecution(t.WorkflowExecution), + WorkflowType: WorkflowType(t.WorkflowType), + InitiatedEventId: &t.InitiatedEventId, + StartedEventId: &t.StartedEventId, + Reason: FailureReason(t.Failure), + Details: FailureDetails(t.Failure), + } +} + +func ChildWorkflowExecutionStartedEventAttributes(t *apiv1.ChildWorkflowExecutionStartedEventAttributes) *shared.ChildWorkflowExecutionStartedEventAttributes { + if t == nil { + return nil + } + return &shared.ChildWorkflowExecutionStartedEventAttributes{ + Domain: &t.Domain, + WorkflowExecution: WorkflowExecution(t.WorkflowExecution), + WorkflowType: WorkflowType(t.WorkflowType), + InitiatedEventId: &t.InitiatedEventId, + Header: Header(t.Header), + } +} + +func ChildWorkflowExecutionTerminatedEventAttributes(t *apiv1.ChildWorkflowExecutionTerminatedEventAttributes) *shared.ChildWorkflowExecutionTerminatedEventAttributes { + if t == nil { + return nil + } + return &shared.ChildWorkflowExecutionTerminatedEventAttributes{ + Domain: &t.Domain, + WorkflowExecution: WorkflowExecution(t.WorkflowExecution), + WorkflowType: WorkflowType(t.WorkflowType), + InitiatedEventId: &t.InitiatedEventId, + StartedEventId: &t.StartedEventId, + } +} + +func ChildWorkflowExecutionTimedOutEventAttributes(t *apiv1.ChildWorkflowExecutionTimedOutEventAttributes) *shared.ChildWorkflowExecutionTimedOutEventAttributes { + if t == nil { + return nil + } + return &shared.ChildWorkflowExecutionTimedOutEventAttributes{ + Domain: &t.Domain, + WorkflowExecution: WorkflowExecution(t.WorkflowExecution), + WorkflowType: WorkflowType(t.WorkflowType), + InitiatedEventId: &t.InitiatedEventId, + StartedEventId: &t.StartedEventId, + TimeoutType: TimeoutType(t.TimeoutType), + } +} + +func DecisionTaskFailedEventAttributes(t *apiv1.DecisionTaskFailedEventAttributes) *shared.DecisionTaskFailedEventAttributes { + if t == nil { + return nil + } + return &shared.DecisionTaskFailedEventAttributes{ + ScheduledEventId: &t.ScheduledEventId, + StartedEventId: &t.StartedEventId, + Cause: DecisionTaskFailedCause(t.Cause), + Reason: FailureReason(t.Failure), + Details: FailureDetails(t.Failure), + Identity: &t.Identity, + BaseRunId: &t.BaseRunId, + NewRunId: &t.NewRunId, + ForkEventVersion: &t.ForkEventVersion, + BinaryChecksum: &t.BinaryChecksum, + } +} + +func DecisionTaskScheduledEventAttributes(t *apiv1.DecisionTaskScheduledEventAttributes) *shared.DecisionTaskScheduledEventAttributes { + if t == nil { + return nil + } + return &shared.DecisionTaskScheduledEventAttributes{ + TaskList: TaskList(t.TaskList), + StartToCloseTimeoutSeconds: durationToSeconds(t.StartToCloseTimeout), + Attempt: common.Int64Ptr(int64(t.Attempt)), + } +} + +func DecisionTaskStartedEventAttributes(t *apiv1.DecisionTaskStartedEventAttributes) *shared.DecisionTaskStartedEventAttributes { + if t == nil { + return nil + } + return &shared.DecisionTaskStartedEventAttributes{ + ScheduledEventId: &t.ScheduledEventId, + Identity: &t.Identity, + RequestId: &t.RequestId, + } +} + +func DecisionTaskCompletedEventAttributes(t *apiv1.DecisionTaskCompletedEventAttributes) *shared.DecisionTaskCompletedEventAttributes { + if t == nil { + return nil + } + return &shared.DecisionTaskCompletedEventAttributes{ + ScheduledEventId: &t.ScheduledEventId, + StartedEventId: &t.StartedEventId, + Identity: &t.Identity, + BinaryChecksum: &t.BinaryChecksum, + ExecutionContext: t.ExecutionContext, + } +} + +func DecisionTaskTimedOutEventAttributes(t *apiv1.DecisionTaskTimedOutEventAttributes) *shared.DecisionTaskTimedOutEventAttributes { + if t == nil { + return nil + } + return &shared.DecisionTaskTimedOutEventAttributes{ + ScheduledEventId: &t.ScheduledEventId, + StartedEventId: &t.StartedEventId, + TimeoutType: TimeoutType(t.TimeoutType), + BaseRunId: &t.BaseRunId, + NewRunId: &t.NewRunId, + ForkEventVersion: &t.ForkEventVersion, + Reason: &t.Reason, + Cause: DecisionTaskTimedOutCause(t.Cause), + } +} + +func ExternalWorkflowExecutionCancelRequestedEventAttributes(t *apiv1.ExternalWorkflowExecutionCancelRequestedEventAttributes) *shared.ExternalWorkflowExecutionCancelRequestedEventAttributes { + if t == nil { + return nil + } + return &shared.ExternalWorkflowExecutionCancelRequestedEventAttributes{ + InitiatedEventId: &t.InitiatedEventId, + Domain: &t.Domain, + WorkflowExecution: WorkflowExecution(t.WorkflowExecution), + } +} + +func ExternalWorkflowExecutionSignaledEventAttributes(t *apiv1.ExternalWorkflowExecutionSignaledEventAttributes) *shared.ExternalWorkflowExecutionSignaledEventAttributes { + if t == nil { + return nil + } + return &shared.ExternalWorkflowExecutionSignaledEventAttributes{ + InitiatedEventId: &t.InitiatedEventId, + Domain: &t.Domain, + WorkflowExecution: WorkflowExecution(t.WorkflowExecution), + Control: t.Control, + } +} + +func MarkerRecordedEventAttributes(t *apiv1.MarkerRecordedEventAttributes) *shared.MarkerRecordedEventAttributes { + if t == nil { + return nil + } + return &shared.MarkerRecordedEventAttributes{ + MarkerName: &t.MarkerName, + Details: Payload(t.Details), + DecisionTaskCompletedEventId: &t.DecisionTaskCompletedEventId, + Header: Header(t.Header), + } +} + +func RequestCancelActivityTaskFailedEventAttributes(t *apiv1.RequestCancelActivityTaskFailedEventAttributes) *shared.RequestCancelActivityTaskFailedEventAttributes { + if t == nil { + return nil + } + return &shared.RequestCancelActivityTaskFailedEventAttributes{ + ActivityId: &t.ActivityId, + Cause: &t.Cause, + DecisionTaskCompletedEventId: &t.DecisionTaskCompletedEventId, + } +} + +func RequestCancelExternalWorkflowExecutionFailedEventAttributes(t *apiv1.RequestCancelExternalWorkflowExecutionFailedEventAttributes) *shared.RequestCancelExternalWorkflowExecutionFailedEventAttributes { + if t == nil { + return nil + } + return &shared.RequestCancelExternalWorkflowExecutionFailedEventAttributes{ + Cause: CancelExternalWorkflowExecutionFailedCause(t.Cause), + DecisionTaskCompletedEventId: &t.DecisionTaskCompletedEventId, + Domain: &t.Domain, + WorkflowExecution: WorkflowExecution(t.WorkflowExecution), + InitiatedEventId: &t.InitiatedEventId, + Control: t.Control, + } +} + +func RequestCancelExternalWorkflowExecutionInitiatedEventAttributes(t *apiv1.RequestCancelExternalWorkflowExecutionInitiatedEventAttributes) *shared.RequestCancelExternalWorkflowExecutionInitiatedEventAttributes { + if t == nil { + return nil + } + return &shared.RequestCancelExternalWorkflowExecutionInitiatedEventAttributes{ + DecisionTaskCompletedEventId: &t.DecisionTaskCompletedEventId, + Domain: &t.Domain, + WorkflowExecution: WorkflowExecution(t.WorkflowExecution), + Control: t.Control, + ChildWorkflowOnly: &t.ChildWorkflowOnly, + } +} + +func SignalExternalWorkflowExecutionFailedEventAttributes(t *apiv1.SignalExternalWorkflowExecutionFailedEventAttributes) *shared.SignalExternalWorkflowExecutionFailedEventAttributes { + if t == nil { + return nil + } + return &shared.SignalExternalWorkflowExecutionFailedEventAttributes{ + Cause: SignalExternalWorkflowExecutionFailedCause(t.Cause), + DecisionTaskCompletedEventId: &t.DecisionTaskCompletedEventId, + Domain: &t.Domain, + WorkflowExecution: WorkflowExecution(t.WorkflowExecution), + InitiatedEventId: &t.InitiatedEventId, + Control: t.Control, + } +} + +func SignalExternalWorkflowExecutionInitiatedEventAttributes(t *apiv1.SignalExternalWorkflowExecutionInitiatedEventAttributes) *shared.SignalExternalWorkflowExecutionInitiatedEventAttributes { + if t == nil { + return nil + } + return &shared.SignalExternalWorkflowExecutionInitiatedEventAttributes{ + DecisionTaskCompletedEventId: &t.DecisionTaskCompletedEventId, + Domain: &t.Domain, + WorkflowExecution: WorkflowExecution(t.WorkflowExecution), + SignalName: &t.SignalName, + Input: Payload(t.Input), + Control: t.Control, + ChildWorkflowOnly: &t.ChildWorkflowOnly, + } +} + +func StartChildWorkflowExecutionFailedEventAttributes(t *apiv1.StartChildWorkflowExecutionFailedEventAttributes) *shared.StartChildWorkflowExecutionFailedEventAttributes { + if t == nil { + return nil + } + return &shared.StartChildWorkflowExecutionFailedEventAttributes{ + Domain: &t.Domain, + WorkflowId: &t.WorkflowId, + WorkflowType: WorkflowType(t.WorkflowType), + Cause: ChildWorkflowExecutionFailedCause(t.Cause), + Control: t.Control, + InitiatedEventId: &t.InitiatedEventId, + DecisionTaskCompletedEventId: &t.DecisionTaskCompletedEventId, + } +} + +func StartChildWorkflowExecutionInitiatedEventAttributes(t *apiv1.StartChildWorkflowExecutionInitiatedEventAttributes) *shared.StartChildWorkflowExecutionInitiatedEventAttributes { + if t == nil { + return nil + } + return &shared.StartChildWorkflowExecutionInitiatedEventAttributes{ + Domain: &t.Domain, + WorkflowId: &t.WorkflowId, + WorkflowType: WorkflowType(t.WorkflowType), + TaskList: TaskList(t.TaskList), + Input: Payload(t.Input), + ExecutionStartToCloseTimeoutSeconds: durationToSeconds(t.ExecutionStartToCloseTimeout), + TaskStartToCloseTimeoutSeconds: durationToSeconds(t.TaskStartToCloseTimeout), + ParentClosePolicy: ParentClosePolicy(t.ParentClosePolicy), + Control: t.Control, + DecisionTaskCompletedEventId: &t.DecisionTaskCompletedEventId, + WorkflowIdReusePolicy: WorkflowIdReusePolicy(t.WorkflowIdReusePolicy), + RetryPolicy: RetryPolicy(t.RetryPolicy), + CronSchedule: &t.CronSchedule, + Header: Header(t.Header), + Memo: Memo(t.Memo), + SearchAttributes: SearchAttributes(t.SearchAttributes), + DelayStartSeconds: durationToSeconds(t.DelayStart), + } +} + +func TimerCanceledEventAttributes(t *apiv1.TimerCanceledEventAttributes) *shared.TimerCanceledEventAttributes { + if t == nil { + return nil + } + return &shared.TimerCanceledEventAttributes{ + TimerId: &t.TimerId, + StartedEventId: &t.StartedEventId, + DecisionTaskCompletedEventId: &t.DecisionTaskCompletedEventId, + Identity: &t.Identity, + } +} + +func TimerFiredEventAttributes(t *apiv1.TimerFiredEventAttributes) *shared.TimerFiredEventAttributes { + if t == nil { + return nil + } + return &shared.TimerFiredEventAttributes{ + TimerId: &t.TimerId, + StartedEventId: &t.StartedEventId, + } +} + +func TimerStartedEventAttributes(t *apiv1.TimerStartedEventAttributes) *shared.TimerStartedEventAttributes { + if t == nil { + return nil + } + return &shared.TimerStartedEventAttributes{ + TimerId: &t.TimerId, + StartToFireTimeoutSeconds: int32To64(durationToSeconds(t.StartToFireTimeout)), + DecisionTaskCompletedEventId: &t.DecisionTaskCompletedEventId, + } +} + +func UpsertWorkflowSearchAttributesEventAttributes(t *apiv1.UpsertWorkflowSearchAttributesEventAttributes) *shared.UpsertWorkflowSearchAttributesEventAttributes { + if t == nil { + return nil + } + return &shared.UpsertWorkflowSearchAttributesEventAttributes{ + DecisionTaskCompletedEventId: &t.DecisionTaskCompletedEventId, + SearchAttributes: SearchAttributes(t.SearchAttributes), + } +} + +func WorkflowExecutionCancelRequestedEventAttributes(t *apiv1.WorkflowExecutionCancelRequestedEventAttributes) *shared.WorkflowExecutionCancelRequestedEventAttributes { + if t == nil { + return nil + } + return &shared.WorkflowExecutionCancelRequestedEventAttributes{ + Cause: &t.Cause, + ExternalInitiatedEventId: ExternalInitiatedId(t.ExternalExecutionInfo), + ExternalWorkflowExecution: ExternalWorkflowExecution(t.ExternalExecutionInfo), + Identity: &t.Identity, + } +} + +func WorkflowExecutionCanceledEventAttributes(t *apiv1.WorkflowExecutionCanceledEventAttributes) *shared.WorkflowExecutionCanceledEventAttributes { + if t == nil { + return nil + } + return &shared.WorkflowExecutionCanceledEventAttributes{ + DecisionTaskCompletedEventId: &t.DecisionTaskCompletedEventId, + Details: Payload(t.Details), + } +} + +func WorkflowExecutionCompletedEventAttributes(t *apiv1.WorkflowExecutionCompletedEventAttributes) *shared.WorkflowExecutionCompletedEventAttributes { + if t == nil { + return nil + } + return &shared.WorkflowExecutionCompletedEventAttributes{ + Result: Payload(t.Result), + DecisionTaskCompletedEventId: &t.DecisionTaskCompletedEventId, + } +} + +func WorkflowExecutionContinuedAsNewEventAttributes(t *apiv1.WorkflowExecutionContinuedAsNewEventAttributes) *shared.WorkflowExecutionContinuedAsNewEventAttributes { + if t == nil { + return nil + } + return &shared.WorkflowExecutionContinuedAsNewEventAttributes{ + NewExecutionRunId: &t.NewExecutionRunId, + WorkflowType: WorkflowType(t.WorkflowType), + TaskList: TaskList(t.TaskList), + Input: Payload(t.Input), + ExecutionStartToCloseTimeoutSeconds: durationToSeconds(t.ExecutionStartToCloseTimeout), + TaskStartToCloseTimeoutSeconds: durationToSeconds(t.TaskStartToCloseTimeout), + DecisionTaskCompletedEventId: &t.DecisionTaskCompletedEventId, + BackoffStartIntervalInSeconds: durationToSeconds(t.BackoffStartInterval), + Initiator: ContinueAsNewInitiator(t.Initiator), + FailureReason: FailureReason(t.Failure), + FailureDetails: FailureDetails(t.Failure), + LastCompletionResult: Payload(t.LastCompletionResult), + Header: Header(t.Header), + Memo: Memo(t.Memo), + SearchAttributes: SearchAttributes(t.SearchAttributes), + } +} + +func WorkflowExecutionFailedEventAttributes(t *apiv1.WorkflowExecutionFailedEventAttributes) *shared.WorkflowExecutionFailedEventAttributes { + if t == nil { + return nil + } + return &shared.WorkflowExecutionFailedEventAttributes{ + Reason: FailureReason(t.Failure), + Details: FailureDetails(t.Failure), + DecisionTaskCompletedEventId: &t.DecisionTaskCompletedEventId, + } +} + +func WorkflowExecutionSignaledEventAttributes(t *apiv1.WorkflowExecutionSignaledEventAttributes) *shared.WorkflowExecutionSignaledEventAttributes { + if t == nil { + return nil + } + return &shared.WorkflowExecutionSignaledEventAttributes{ + SignalName: &t.SignalName, + Input: Payload(t.Input), + Identity: &t.Identity, + } +} + +func WorkflowExecutionStartedEventAttributes(t *apiv1.WorkflowExecutionStartedEventAttributes) *shared.WorkflowExecutionStartedEventAttributes { + if t == nil { + return nil + } + return &shared.WorkflowExecutionStartedEventAttributes{ + WorkflowType: WorkflowType(t.WorkflowType), + ParentWorkflowDomain: ParentDomainName(t.ParentExecutionInfo), + ParentWorkflowExecution: ParentWorkflowExecution(t.ParentExecutionInfo), + ParentInitiatedEventId: ParentInitiatedId(t.ParentExecutionInfo), + TaskList: TaskList(t.TaskList), + Input: Payload(t.Input), + ExecutionStartToCloseTimeoutSeconds: durationToSeconds(t.ExecutionStartToCloseTimeout), + TaskStartToCloseTimeoutSeconds: durationToSeconds(t.TaskStartToCloseTimeout), + ContinuedExecutionRunId: &t.ContinuedExecutionRunId, + Initiator: ContinueAsNewInitiator(t.Initiator), + ContinuedFailureReason: FailureReason(t.ContinuedFailure), + ContinuedFailureDetails: FailureDetails(t.ContinuedFailure), + LastCompletionResult: Payload(t.LastCompletionResult), + OriginalExecutionRunId: &t.OriginalExecutionRunId, + Identity: &t.Identity, + FirstExecutionRunId: &t.FirstExecutionRunId, + RetryPolicy: RetryPolicy(t.RetryPolicy), + Attempt: &t.Attempt, + ExpirationTimestamp: timeToUnixNano(t.ExpirationTime), + CronSchedule: &t.CronSchedule, + FirstDecisionTaskBackoffSeconds: durationToSeconds(t.FirstDecisionTaskBackoff), + Memo: Memo(t.Memo), + SearchAttributes: SearchAttributes(t.SearchAttributes), + PrevAutoResetPoints: ResetPoints(t.PrevAutoResetPoints), + Header: Header(t.Header), + } +} + +func WorkflowExecutionTerminatedEventAttributes(t *apiv1.WorkflowExecutionTerminatedEventAttributes) *shared.WorkflowExecutionTerminatedEventAttributes { + if t == nil { + return nil + } + return &shared.WorkflowExecutionTerminatedEventAttributes{ + Reason: &t.Reason, + Details: Payload(t.Details), + Identity: &t.Identity, + } +} + +func WorkflowExecutionTimedOutEventAttributes(t *apiv1.WorkflowExecutionTimedOutEventAttributes) *shared.WorkflowExecutionTimedOutEventAttributes { + if t == nil { + return nil + } + return &shared.WorkflowExecutionTimedOutEventAttributes{ + TimeoutType: TimeoutType(t.TimeoutType), + } +} diff --git a/internal/compatibility/thrift/request.go b/internal/compatibility/thrift/request.go new file mode 100644 index 000000000..02da8dfbd --- /dev/null +++ b/internal/compatibility/thrift/request.go @@ -0,0 +1,580 @@ +// Copyright (c) 2021 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +package thrift + +import ( + "go.uber.org/cadence/.gen/go/shared" + apiv1 "go.uber.org/cadence/.gen/proto/api/v1" +) + +func CountWorkflowExecutionsRequest(t *apiv1.CountWorkflowExecutionsRequest) *shared.CountWorkflowExecutionsRequest { + if t == nil { + return nil + } + return &shared.CountWorkflowExecutionsRequest{ + Domain: &t.Domain, + Query: &t.Query, + } +} + +func DeprecateDomainRequest(t *apiv1.DeprecateDomainRequest) *shared.DeprecateDomainRequest { + if t == nil { + return nil + } + return &shared.DeprecateDomainRequest{ + Name: &t.Name, + SecurityToken: &t.SecurityToken, + } +} + +func DescribeDomainRequest(t *apiv1.DescribeDomainRequest) *shared.DescribeDomainRequest { + if t == nil { + return nil + } + + switch describeBy := t.DescribeBy.(type) { + case *apiv1.DescribeDomainRequest_Id: + return &shared.DescribeDomainRequest{UUID: &describeBy.Id} + case *apiv1.DescribeDomainRequest_Name: + return &shared.DescribeDomainRequest{Name: &describeBy.Name} + } + panic("unknown oneof field is set for DescribeDomainRequest") +} + +func DescribeTaskListRequest(t *apiv1.DescribeTaskListRequest) *shared.DescribeTaskListRequest { + if t == nil { + return nil + } + return &shared.DescribeTaskListRequest{ + Domain: &t.Domain, + TaskList: TaskList(t.TaskList), + TaskListType: TaskListType(t.TaskListType), + IncludeTaskListStatus: &t.IncludeTaskListStatus, + } +} + +func DescribeWorkflowExecutionRequest(t *apiv1.DescribeWorkflowExecutionRequest) *shared.DescribeWorkflowExecutionRequest { + if t == nil { + return nil + } + return &shared.DescribeWorkflowExecutionRequest{ + Domain: &t.Domain, + Execution: WorkflowExecution(t.WorkflowExecution), + } +} + +func GetWorkflowExecutionHistoryRequest(t *apiv1.GetWorkflowExecutionHistoryRequest) *shared.GetWorkflowExecutionHistoryRequest { + if t == nil { + return nil + } + return &shared.GetWorkflowExecutionHistoryRequest{ + Domain: &t.Domain, + Execution: WorkflowExecution(t.WorkflowExecution), + MaximumPageSize: &t.PageSize, + NextPageToken: t.NextPageToken, + WaitForNewEvent: &t.WaitForNewEvent, + HistoryEventFilterType: EventFilterType(t.HistoryEventFilterType), + SkipArchival: &t.SkipArchival, + } +} + +func ListArchivedWorkflowExecutionsRequest(t *apiv1.ListArchivedWorkflowExecutionsRequest) *shared.ListArchivedWorkflowExecutionsRequest { + if t == nil { + return nil + } + return &shared.ListArchivedWorkflowExecutionsRequest{ + Domain: &t.Domain, + PageSize: &t.PageSize, + NextPageToken: t.NextPageToken, + Query: &t.Query, + } +} + +func ListDomainsRequest(t *apiv1.ListDomainsRequest) *shared.ListDomainsRequest { + if t == nil { + return nil + } + return &shared.ListDomainsRequest{ + PageSize: &t.PageSize, + NextPageToken: t.NextPageToken, + } +} + +func ListTaskListPartitionsRequest(t *apiv1.ListTaskListPartitionsRequest) *shared.ListTaskListPartitionsRequest { + if t == nil { + return nil + } + return &shared.ListTaskListPartitionsRequest{ + Domain: &t.Domain, + TaskList: TaskList(t.TaskList), + } +} + +func ListWorkflowExecutionsRequest(t *apiv1.ListWorkflowExecutionsRequest) *shared.ListWorkflowExecutionsRequest { + if t == nil { + return nil + } + return &shared.ListWorkflowExecutionsRequest{ + Domain: &t.Domain, + PageSize: &t.PageSize, + NextPageToken: t.NextPageToken, + Query: &t.Query, + } +} + +func PollForActivityTaskRequest(t *apiv1.PollForActivityTaskRequest) *shared.PollForActivityTaskRequest { + if t == nil { + return nil + } + return &shared.PollForActivityTaskRequest{ + Domain: &t.Domain, + TaskList: TaskList(t.TaskList), + Identity: &t.Identity, + TaskListMetadata: TaskListMetadata(t.TaskListMetadata), + } +} + +func PollForDecisionTaskRequest(t *apiv1.PollForDecisionTaskRequest) *shared.PollForDecisionTaskRequest { + if t == nil { + return nil + } + return &shared.PollForDecisionTaskRequest{ + Domain: &t.Domain, + TaskList: TaskList(t.TaskList), + Identity: &t.Identity, + BinaryChecksum: &t.BinaryChecksum, + } +} + +func QueryWorkflowRequest(t *apiv1.QueryWorkflowRequest) *shared.QueryWorkflowRequest { + if t == nil { + return nil + } + return &shared.QueryWorkflowRequest{ + Domain: &t.Domain, + Execution: WorkflowExecution(t.WorkflowExecution), + Query: WorkflowQuery(t.Query), + QueryRejectCondition: QueryRejectCondition(t.QueryRejectCondition), + QueryConsistencyLevel: QueryConsistencyLevel(t.QueryConsistencyLevel), + } +} + +func RecordActivityTaskHeartbeatByIdRequest(t *apiv1.RecordActivityTaskHeartbeatByIDRequest) *shared.RecordActivityTaskHeartbeatByIDRequest { + if t == nil { + return nil + } + return &shared.RecordActivityTaskHeartbeatByIDRequest{ + Domain: &t.Domain, + WorkflowID: WorkflowId(t.WorkflowExecution), + RunID: RunId(t.WorkflowExecution), + ActivityID: &t.ActivityId, + Details: Payload(t.Details), + Identity: &t.Identity, + } +} + +func RecordActivityTaskHeartbeatRequest(t *apiv1.RecordActivityTaskHeartbeatRequest) *shared.RecordActivityTaskHeartbeatRequest { + if t == nil { + return nil + } + return &shared.RecordActivityTaskHeartbeatRequest{ + TaskToken: t.TaskToken, + Details: Payload(t.Details), + Identity: &t.Identity, + } +} + +func RegisterDomainRequest(t *apiv1.RegisterDomainRequest) *shared.RegisterDomainRequest { + if t == nil { + return nil + } + return &shared.RegisterDomainRequest{ + Name: &t.Name, + Description: &t.Description, + OwnerEmail: &t.OwnerEmail, + WorkflowExecutionRetentionPeriodInDays: durationToDays(t.WorkflowExecutionRetentionPeriod), + Clusters: ClusterReplicationConfigurationArray(t.Clusters), + ActiveClusterName: &t.ActiveClusterName, + Data: t.Data, + SecurityToken: &t.SecurityToken, + IsGlobalDomain: &t.IsGlobalDomain, + HistoryArchivalStatus: ArchivalStatus(t.HistoryArchivalStatus), + HistoryArchivalURI: &t.HistoryArchivalUri, + VisibilityArchivalStatus: ArchivalStatus(t.VisibilityArchivalStatus), + VisibilityArchivalURI: &t.VisibilityArchivalUri, + } +} + +func RequestCancelWorkflowExecutionRequest(t *apiv1.RequestCancelWorkflowExecutionRequest) *shared.RequestCancelWorkflowExecutionRequest { + if t == nil { + return nil + } + return &shared.RequestCancelWorkflowExecutionRequest{ + Domain: &t.Domain, + WorkflowExecution: WorkflowExecution(t.WorkflowExecution), + Identity: &t.Identity, + RequestId: &t.RequestId, + } +} + +func ResetStickyTaskListRequest(t *apiv1.ResetStickyTaskListRequest) *shared.ResetStickyTaskListRequest { + if t == nil { + return nil + } + return &shared.ResetStickyTaskListRequest{ + Domain: &t.Domain, + Execution: WorkflowExecution(t.WorkflowExecution), + } +} + +func ResetWorkflowExecutionRequest(t *apiv1.ResetWorkflowExecutionRequest) *shared.ResetWorkflowExecutionRequest { + if t == nil { + return nil + } + return &shared.ResetWorkflowExecutionRequest{ + Domain: &t.Domain, + WorkflowExecution: WorkflowExecution(t.WorkflowExecution), + Reason: &t.Reason, + DecisionFinishEventId: &t.DecisionFinishEventId, + RequestId: &t.RequestId, + SkipSignalReapply: &t.SkipSignalReapply, + } +} + +func RespondActivityTaskCanceledByIdRequest(t *apiv1.RespondActivityTaskCanceledByIDRequest) *shared.RespondActivityTaskCanceledByIDRequest { + if t == nil { + return nil + } + return &shared.RespondActivityTaskCanceledByIDRequest{ + Domain: &t.Domain, + WorkflowID: WorkflowId(t.WorkflowExecution), + RunID: RunId(t.WorkflowExecution), + ActivityID: &t.ActivityId, + Details: Payload(t.Details), + Identity: &t.Identity, + } +} + +func RespondActivityTaskCanceledRequest(t *apiv1.RespondActivityTaskCanceledRequest) *shared.RespondActivityTaskCanceledRequest { + if t == nil { + return nil + } + return &shared.RespondActivityTaskCanceledRequest{ + TaskToken: t.TaskToken, + Details: Payload(t.Details), + Identity: &t.Identity, + } +} + +func RespondActivityTaskCompletedByIdRequest(t *apiv1.RespondActivityTaskCompletedByIDRequest) *shared.RespondActivityTaskCompletedByIDRequest { + if t == nil { + return nil + } + return &shared.RespondActivityTaskCompletedByIDRequest{ + Domain: &t.Domain, + WorkflowID: WorkflowId(t.WorkflowExecution), + RunID: RunId(t.WorkflowExecution), + ActivityID: &t.ActivityId, + Result: Payload(t.Result), + Identity: &t.Identity, + } +} + +func RespondActivityTaskCompletedRequest(t *apiv1.RespondActivityTaskCompletedRequest) *shared.RespondActivityTaskCompletedRequest { + if t == nil { + return nil + } + return &shared.RespondActivityTaskCompletedRequest{ + TaskToken: t.TaskToken, + Result: Payload(t.Result), + Identity: &t.Identity, + } +} + +func RespondActivityTaskFailedByIdRequest(t *apiv1.RespondActivityTaskFailedByIDRequest) *shared.RespondActivityTaskFailedByIDRequest { + if t == nil { + return nil + } + return &shared.RespondActivityTaskFailedByIDRequest{ + Domain: &t.Domain, + WorkflowID: WorkflowId(t.WorkflowExecution), + RunID: RunId(t.WorkflowExecution), + ActivityID: &t.ActivityId, + Reason: FailureReason(t.Failure), + Details: FailureDetails(t.Failure), + Identity: &t.Identity, + } +} + +func RespondActivityTaskFailedRequest(t *apiv1.RespondActivityTaskFailedRequest) *shared.RespondActivityTaskFailedRequest { + if t == nil { + return nil + } + return &shared.RespondActivityTaskFailedRequest{ + TaskToken: t.TaskToken, + Reason: FailureReason(t.Failure), + Details: FailureDetails(t.Failure), + Identity: &t.Identity, + } +} + +func RespondDecisionTaskCompletedRequest(t *apiv1.RespondDecisionTaskCompletedRequest) *shared.RespondDecisionTaskCompletedRequest { + if t == nil { + return nil + } + return &shared.RespondDecisionTaskCompletedRequest{ + TaskToken: t.TaskToken, + Decisions: DecisionArray(t.Decisions), + ExecutionContext: t.ExecutionContext, + Identity: &t.Identity, + StickyAttributes: StickyExecutionAttributes(t.StickyAttributes), + ReturnNewDecisionTask: &t.ReturnNewDecisionTask, + ForceCreateNewDecisionTask: &t.ForceCreateNewDecisionTask, + BinaryChecksum: &t.BinaryChecksum, + QueryResults: WorkflowQueryResultMap(t.QueryResults), + } +} + +func RespondDecisionTaskFailedRequest(t *apiv1.RespondDecisionTaskFailedRequest) *shared.RespondDecisionTaskFailedRequest { + if t == nil { + return nil + } + return &shared.RespondDecisionTaskFailedRequest{ + TaskToken: t.TaskToken, + Cause: DecisionTaskFailedCause(t.Cause), + Details: Payload(t.Details), + Identity: &t.Identity, + BinaryChecksum: &t.BinaryChecksum, + } +} + +func RespondQueryTaskCompletedRequest(t *apiv1.RespondQueryTaskCompletedRequest) *shared.RespondQueryTaskCompletedRequest { + if t == nil { + return nil + } + request := &shared.RespondQueryTaskCompletedRequest{ + TaskToken: t.TaskToken, + WorkerVersionInfo: WorkerVersionInfo(t.WorkerVersionInfo), + } + if t.Result != nil { + request.CompletedType = QueryTaskCompletedType(t.Result.ResultType) + request.QueryResult = Payload(t.Result.Answer) + request.ErrorMessage = &t.Result.ErrorMessage + } + return request +} + +func ScanWorkflowExecutionsRequest(t *apiv1.ScanWorkflowExecutionsRequest) *shared.ListWorkflowExecutionsRequest { + if t == nil { + return nil + } + return &shared.ListWorkflowExecutionsRequest{ + Domain: &t.Domain, + PageSize: &t.PageSize, + NextPageToken: t.NextPageToken, + Query: &t.Query, + } +} + +func SignalWithStartWorkflowExecutionRequest(t *apiv1.SignalWithStartWorkflowExecutionRequest) *shared.SignalWithStartWorkflowExecutionRequest { + if t == nil { + return nil + } + request := &shared.SignalWithStartWorkflowExecutionRequest{ + SignalName: &t.SignalName, + SignalInput: Payload(t.SignalInput), + Control: t.Control, + } + + if t.StartRequest != nil { + request.Domain = &t.StartRequest.Domain + request.WorkflowId = &t.StartRequest.WorkflowId + request.WorkflowType = WorkflowType(t.StartRequest.WorkflowType) + request.TaskList = TaskList(t.StartRequest.TaskList) + request.Input = Payload(t.StartRequest.Input) + request.ExecutionStartToCloseTimeoutSeconds = durationToSeconds(t.StartRequest.ExecutionStartToCloseTimeout) + request.TaskStartToCloseTimeoutSeconds = durationToSeconds(t.StartRequest.TaskStartToCloseTimeout) + request.Identity = &t.StartRequest.Identity + request.RequestId = &t.StartRequest.RequestId + request.WorkflowIdReusePolicy = WorkflowIdReusePolicy(t.StartRequest.WorkflowIdReusePolicy) + request.RetryPolicy = RetryPolicy(t.StartRequest.RetryPolicy) + request.CronSchedule = &t.StartRequest.CronSchedule + request.Memo = Memo(t.StartRequest.Memo) + request.SearchAttributes = SearchAttributes(t.StartRequest.SearchAttributes) + request.Header = Header(t.StartRequest.Header) + } + + return request +} + +func SignalWorkflowExecutionRequest(t *apiv1.SignalWorkflowExecutionRequest) *shared.SignalWorkflowExecutionRequest { + if t == nil { + return nil + } + return &shared.SignalWorkflowExecutionRequest{ + Domain: &t.Domain, + WorkflowExecution: WorkflowExecution(t.WorkflowExecution), + SignalName: &t.SignalName, + Input: Payload(t.SignalInput), + Identity: &t.Identity, + RequestId: &t.RequestId, + Control: t.Control, + } +} + +func StartWorkflowExecutionRequest(t *apiv1.StartWorkflowExecutionRequest) *shared.StartWorkflowExecutionRequest { + if t == nil { + return nil + } + return &shared.StartWorkflowExecutionRequest{ + Domain: &t.Domain, + WorkflowId: &t.WorkflowId, + WorkflowType: WorkflowType(t.WorkflowType), + TaskList: TaskList(t.TaskList), + Input: Payload(t.Input), + ExecutionStartToCloseTimeoutSeconds: durationToSeconds(t.ExecutionStartToCloseTimeout), + TaskStartToCloseTimeoutSeconds: durationToSeconds(t.TaskStartToCloseTimeout), + Identity: &t.Identity, + RequestId: &t.RequestId, + WorkflowIdReusePolicy: WorkflowIdReusePolicy(t.WorkflowIdReusePolicy), + RetryPolicy: RetryPolicy(t.RetryPolicy), + CronSchedule: &t.CronSchedule, + Memo: Memo(t.Memo), + SearchAttributes: SearchAttributes(t.SearchAttributes), + Header: Header(t.Header), + DelayStartSeconds: durationToSeconds(t.DelayStart), + } +} + +func TerminateWorkflowExecutionRequest(t *apiv1.TerminateWorkflowExecutionRequest) *shared.TerminateWorkflowExecutionRequest { + if t == nil { + return nil + } + return &shared.TerminateWorkflowExecutionRequest{ + Domain: &t.Domain, + WorkflowExecution: WorkflowExecution(t.WorkflowExecution), + Reason: &t.Reason, + Details: Payload(t.Details), + Identity: &t.Identity, + } +} + +const ( + DomainUpdateDescriptionField = "description" + DomainUpdateOwnerEmailField = "owner_email" + DomainUpdateDataField = "data" + DomainUpdateRetentionPeriodField = "workflow_execution_retention_period" + DomainUpdateBadBinariesField = "bad_binaries" + DomainUpdateHistoryArchivalStatusField = "history_archival_status" + DomainUpdateHistoryArchivalURIField = "history_archival_uri" + DomainUpdateVisibilityArchivalStatusField = "visibility_archival_status" + DomainUpdateVisibilityArchivalURIField = "visibility_archival_uri" + DomainUpdateActiveClusterNameField = "active_cluster_name" + DomainUpdateClustersField = "clusters" + DomainUpdateDeleteBadBinaryField = "delete_bad_binary" + DomainUpdateFailoverTimeoutField = "failover_timeout" +) + +func UpdateDomainRequest(t *apiv1.UpdateDomainRequest) *shared.UpdateDomainRequest { + if t == nil { + return nil + } + request := shared.UpdateDomainRequest{ + Name: &t.Name, + SecurityToken: &t.SecurityToken, + UpdatedInfo: &shared.UpdateDomainInfo{}, + Configuration: &shared.DomainConfiguration{}, + ReplicationConfiguration: &shared.DomainReplicationConfiguration{}, + } + fs := newFieldSet(t.UpdateMask) + + if fs.isSet(DomainUpdateDescriptionField) { + request.UpdatedInfo.Description = &t.Description + } + if fs.isSet(DomainUpdateOwnerEmailField) { + request.UpdatedInfo.OwnerEmail = &t.OwnerEmail + } + if fs.isSet(DomainUpdateDataField) { + request.UpdatedInfo.Data = t.Data + } + if fs.isSet(DomainUpdateRetentionPeriodField) { + request.Configuration.WorkflowExecutionRetentionPeriodInDays = durationToDays(t.WorkflowExecutionRetentionPeriod) + } + if fs.isSet(DomainUpdateBadBinariesField) { + request.Configuration.BadBinaries = BadBinaries(t.BadBinaries) + } + if fs.isSet(DomainUpdateHistoryArchivalStatusField) { + request.Configuration.HistoryArchivalStatus = ArchivalStatus(t.HistoryArchivalStatus) + } + if fs.isSet(DomainUpdateHistoryArchivalURIField) { + request.Configuration.HistoryArchivalURI = &t.HistoryArchivalUri + } + if fs.isSet(DomainUpdateVisibilityArchivalStatusField) { + request.Configuration.VisibilityArchivalStatus = ArchivalStatus(t.VisibilityArchivalStatus) + } + if fs.isSet(DomainUpdateVisibilityArchivalURIField) { + request.Configuration.VisibilityArchivalURI = &t.VisibilityArchivalUri + } + if fs.isSet(DomainUpdateActiveClusterNameField) { + request.ReplicationConfiguration.ActiveClusterName = &t.ActiveClusterName + } + if fs.isSet(DomainUpdateClustersField) { + request.ReplicationConfiguration.Clusters = ClusterReplicationConfigurationArray(t.Clusters) + } + + if fs.isSet(DomainUpdateDeleteBadBinaryField) { + request.DeleteBadBinary = &t.DeleteBadBinary + } + if fs.isSet(DomainUpdateFailoverTimeoutField) { + request.FailoverTimeoutInSeconds = durationToSeconds(t.FailoverTimeout) + } + + return &request +} + +func ListClosedWorkflowExecutionsRequest(r *apiv1.ListClosedWorkflowExecutionsRequest) *shared.ListClosedWorkflowExecutionsRequest { + if r == nil { + return nil + } + return &shared.ListClosedWorkflowExecutionsRequest{ + Domain: &r.Domain, + MaximumPageSize: &r.PageSize, + NextPageToken: r.NextPageToken, + StartTimeFilter: StartTimeFilter(r.StartTimeFilter), + ExecutionFilter: WorkflowExecutionFilter(r.GetExecutionFilter()), + TypeFilter: WorkflowTypeFilter(r.GetTypeFilter()), + StatusFilter: WorkflowExecutionCloseStatus(r.GetStatusFilter().GetStatus()), + } +} + +func ListOpenWorkflowExecutionsRequest(r *apiv1.ListOpenWorkflowExecutionsRequest) *shared.ListOpenWorkflowExecutionsRequest { + if r == nil { + return nil + } + return &shared.ListOpenWorkflowExecutionsRequest{ + Domain: &r.Domain, + MaximumPageSize: &r.PageSize, + NextPageToken: r.NextPageToken, + StartTimeFilter: StartTimeFilter(r.StartTimeFilter), + ExecutionFilter: WorkflowExecutionFilter(r.GetExecutionFilter()), + TypeFilter: WorkflowTypeFilter(r.GetTypeFilter()), + } +} diff --git a/internal/compatibility/thrift/response.go b/internal/compatibility/thrift/response.go new file mode 100644 index 000000000..c852348dd --- /dev/null +++ b/internal/compatibility/thrift/response.go @@ -0,0 +1,332 @@ +// Copyright (c) 2021 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +package thrift + +import ( + "go.uber.org/cadence/.gen/go/shared" + apiv1 "go.uber.org/cadence/.gen/proto/api/v1" +) + +func CountWorkflowExecutionsResponse(t *apiv1.CountWorkflowExecutionsResponse) *shared.CountWorkflowExecutionsResponse { + if t == nil { + return nil + } + return &shared.CountWorkflowExecutionsResponse{ + Count: &t.Count, + } +} + +func DescribeDomainResponse(t *apiv1.DescribeDomainResponse) *shared.DescribeDomainResponse { + if t == nil || t.Domain == nil { + return nil + } + return &shared.DescribeDomainResponse{ + DomainInfo: &shared.DomainInfo{ + Name: &t.Domain.Name, + Status: DomainStatus(t.Domain.Status), + Description: &t.Domain.Description, + OwnerEmail: &t.Domain.OwnerEmail, + Data: t.Domain.Data, + UUID: &t.Domain.Id, + }, + Configuration: &shared.DomainConfiguration{ + WorkflowExecutionRetentionPeriodInDays: durationToDays(t.Domain.WorkflowExecutionRetentionPeriod), + EmitMetric: boolPtr(true), + BadBinaries: BadBinaries(t.Domain.BadBinaries), + HistoryArchivalStatus: ArchivalStatus(t.Domain.HistoryArchivalStatus), + HistoryArchivalURI: &t.Domain.HistoryArchivalUri, + VisibilityArchivalStatus: ArchivalStatus(t.Domain.VisibilityArchivalStatus), + VisibilityArchivalURI: &t.Domain.VisibilityArchivalUri, + }, + ReplicationConfiguration: &shared.DomainReplicationConfiguration{ + ActiveClusterName: &t.Domain.ActiveClusterName, + Clusters: ClusterReplicationConfigurationArray(t.Domain.Clusters), + }, + FailoverVersion: &t.Domain.FailoverVersion, + IsGlobalDomain: &t.Domain.IsGlobalDomain, + } +} + +func DescribeTaskListResponse(t *apiv1.DescribeTaskListResponse) *shared.DescribeTaskListResponse { + if t == nil { + return nil + } + return &shared.DescribeTaskListResponse{ + Pollers: PollerInfoArray(t.Pollers), + TaskListStatus: TaskListStatus(t.TaskListStatus), + } +} + +func DescribeWorkflowExecutionResponse(t *apiv1.DescribeWorkflowExecutionResponse) *shared.DescribeWorkflowExecutionResponse { + if t == nil { + return nil + } + return &shared.DescribeWorkflowExecutionResponse{ + ExecutionConfiguration: WorkflowExecutionConfiguration(t.ExecutionConfiguration), + WorkflowExecutionInfo: WorkflowExecutionInfo(t.WorkflowExecutionInfo), + PendingActivities: PendingActivityInfoArray(t.PendingActivities), + PendingChildren: PendingChildExecutionInfoArray(t.PendingChildren), + PendingDecision: PendingDecisionInfo(t.PendingDecision), + } +} + +func GetClusterInfoResponse(t *apiv1.GetClusterInfoResponse) *shared.ClusterInfo { + if t == nil { + return nil + } + return &shared.ClusterInfo{ + SupportedClientVersions: SupportedClientVersions(t.SupportedClientVersions), + } +} + +func GetSearchAttributesResponse(t *apiv1.GetSearchAttributesResponse) *shared.GetSearchAttributesResponse { + if t == nil { + return nil + } + return &shared.GetSearchAttributesResponse{ + Keys: IndexedValueTypeMap(t.Keys), + } +} + +func GetWorkflowExecutionHistoryResponse(t *apiv1.GetWorkflowExecutionHistoryResponse) *shared.GetWorkflowExecutionHistoryResponse { + if t == nil { + return nil + } + return &shared.GetWorkflowExecutionHistoryResponse{ + History: History(t.History), + RawHistory: DataBlobArray(t.RawHistory), + NextPageToken: t.NextPageToken, + Archived: &t.Archived, + } +} + +func ListArchivedWorkflowExecutionsResponse(t *apiv1.ListArchivedWorkflowExecutionsResponse) *shared.ListArchivedWorkflowExecutionsResponse { + if t == nil { + return nil + } + return &shared.ListArchivedWorkflowExecutionsResponse{ + Executions: WorkflowExecutionInfoArray(t.Executions), + NextPageToken: t.NextPageToken, + } +} + +func ListClosedWorkflowExecutionsResponse(t *apiv1.ListClosedWorkflowExecutionsResponse) *shared.ListClosedWorkflowExecutionsResponse { + if t == nil { + return nil + } + return &shared.ListClosedWorkflowExecutionsResponse{ + Executions: WorkflowExecutionInfoArray(t.Executions), + NextPageToken: t.NextPageToken, + } +} + +func ListDomainsResponse(t *apiv1.ListDomainsResponse) *shared.ListDomainsResponse { + if t == nil { + return nil + } + return &shared.ListDomainsResponse{ + Domains: DescribeDomainResponseArray(t.Domains), + NextPageToken: t.NextPageToken, + } +} + +func ListOpenWorkflowExecutionsResponse(t *apiv1.ListOpenWorkflowExecutionsResponse) *shared.ListOpenWorkflowExecutionsResponse { + if t == nil { + return nil + } + return &shared.ListOpenWorkflowExecutionsResponse{ + Executions: WorkflowExecutionInfoArray(t.Executions), + NextPageToken: t.NextPageToken, + } +} + +func ListTaskListPartitionsResponse(t *apiv1.ListTaskListPartitionsResponse) *shared.ListTaskListPartitionsResponse { + if t == nil { + return nil + } + return &shared.ListTaskListPartitionsResponse{ + ActivityTaskListPartitions: TaskListPartitionMetadataArray(t.ActivityTaskListPartitions), + DecisionTaskListPartitions: TaskListPartitionMetadataArray(t.DecisionTaskListPartitions), + } +} + +func ListWorkflowExecutionsResponse(t *apiv1.ListWorkflowExecutionsResponse) *shared.ListWorkflowExecutionsResponse { + if t == nil { + return nil + } + return &shared.ListWorkflowExecutionsResponse{ + Executions: WorkflowExecutionInfoArray(t.Executions), + NextPageToken: t.NextPageToken, + } +} + +func PollForActivityTaskResponse(t *apiv1.PollForActivityTaskResponse) *shared.PollForActivityTaskResponse { + if t == nil { + return nil + } + return &shared.PollForActivityTaskResponse{ + TaskToken: t.TaskToken, + WorkflowExecution: WorkflowExecution(t.WorkflowExecution), + ActivityId: &t.ActivityId, + ActivityType: ActivityType(t.ActivityType), + Input: Payload(t.Input), + ScheduledTimestamp: timeToUnixNano(t.ScheduledTime), + StartedTimestamp: timeToUnixNano(t.StartedTime), + ScheduleToCloseTimeoutSeconds: durationToSeconds(t.ScheduleToCloseTimeout), + StartToCloseTimeoutSeconds: durationToSeconds(t.StartToCloseTimeout), + HeartbeatTimeoutSeconds: durationToSeconds(t.HeartbeatTimeout), + Attempt: &t.Attempt, + ScheduledTimestampOfThisAttempt: timeToUnixNano(t.ScheduledTimeOfThisAttempt), + HeartbeatDetails: Payload(t.HeartbeatDetails), + WorkflowType: WorkflowType(t.WorkflowType), + WorkflowDomain: &t.WorkflowDomain, + Header: Header(t.Header), + } +} + +func PollForDecisionTaskResponse(t *apiv1.PollForDecisionTaskResponse) *shared.PollForDecisionTaskResponse { + if t == nil { + return nil + } + return &shared.PollForDecisionTaskResponse{ + TaskToken: t.TaskToken, + WorkflowExecution: WorkflowExecution(t.WorkflowExecution), + WorkflowType: WorkflowType(t.WorkflowType), + PreviousStartedEventId: toInt64Value(t.PreviousStartedEventId), + StartedEventId: &t.StartedEventId, + Attempt: &t.Attempt, + BacklogCountHint: &t.BacklogCountHint, + History: History(t.History), + NextPageToken: t.NextPageToken, + Query: WorkflowQuery(t.Query), + WorkflowExecutionTaskList: TaskList(t.WorkflowExecutionTaskList), + ScheduledTimestamp: timeToUnixNano(t.ScheduledTime), + StartedTimestamp: timeToUnixNano(t.StartedTime), + Queries: WorkflowQueryMap(t.Queries), + NextEventId: &t.NextEventId, + } +} + +func QueryWorkflowResponse(t *apiv1.QueryWorkflowResponse) *shared.QueryWorkflowResponse { + if t == nil { + return nil + } + return &shared.QueryWorkflowResponse{ + QueryResult: Payload(t.QueryResult), + QueryRejected: QueryRejected(t.QueryRejected), + } +} + +func RecordActivityTaskHeartbeatByIdResponse(t *apiv1.RecordActivityTaskHeartbeatByIDResponse) *shared.RecordActivityTaskHeartbeatResponse { + if t == nil { + return nil + } + return &shared.RecordActivityTaskHeartbeatResponse{ + CancelRequested: &t.CancelRequested, + } +} + +func RecordActivityTaskHeartbeatResponse(t *apiv1.RecordActivityTaskHeartbeatResponse) *shared.RecordActivityTaskHeartbeatResponse { + if t == nil { + return nil + } + return &shared.RecordActivityTaskHeartbeatResponse{ + CancelRequested: &t.CancelRequested, + } +} + +func ResetWorkflowExecutionResponse(t *apiv1.ResetWorkflowExecutionResponse) *shared.ResetWorkflowExecutionResponse { + if t == nil { + return nil + } + return &shared.ResetWorkflowExecutionResponse{ + RunId: &t.RunId, + } +} + +func RespondDecisionTaskCompletedResponse(t *apiv1.RespondDecisionTaskCompletedResponse) *shared.RespondDecisionTaskCompletedResponse { + if t == nil { + return nil + } + return &shared.RespondDecisionTaskCompletedResponse{ + DecisionTask: PollForDecisionTaskResponse(t.DecisionTask), + ActivitiesToDispatchLocally: ActivityLocalDispatchInfoMap(t.ActivitiesToDispatchLocally), + } +} + +func ScanWorkflowExecutionsResponse(t *apiv1.ScanWorkflowExecutionsResponse) *shared.ListWorkflowExecutionsResponse { + if t == nil { + return nil + } + return &shared.ListWorkflowExecutionsResponse{ + Executions: WorkflowExecutionInfoArray(t.Executions), + NextPageToken: t.NextPageToken, + } +} + +func SignalWithStartWorkflowExecutionResponse(t *apiv1.SignalWithStartWorkflowExecutionResponse) *shared.StartWorkflowExecutionResponse { + if t == nil { + return nil + } + return &shared.StartWorkflowExecutionResponse{ + RunId: &t.RunId, + } +} + +func StartWorkflowExecutionResponse(t *apiv1.StartWorkflowExecutionResponse) *shared.StartWorkflowExecutionResponse { + if t == nil { + return nil + } + return &shared.StartWorkflowExecutionResponse{ + RunId: &t.RunId, + } +} + +func UpdateDomainResponse(t *apiv1.UpdateDomainResponse) *shared.UpdateDomainResponse { + if t == nil || t.Domain == nil { + return nil + } + return &shared.UpdateDomainResponse{ + DomainInfo: &shared.DomainInfo{ + Name: &t.Domain.Name, + Status: DomainStatus(t.Domain.Status), + Description: &t.Domain.Description, + OwnerEmail: &t.Domain.OwnerEmail, + Data: t.Domain.Data, + UUID: &t.Domain.Id, + }, + Configuration: &shared.DomainConfiguration{ + WorkflowExecutionRetentionPeriodInDays: durationToDays(t.Domain.WorkflowExecutionRetentionPeriod), + EmitMetric: boolPtr(true), + BadBinaries: BadBinaries(t.Domain.BadBinaries), + HistoryArchivalStatus: ArchivalStatus(t.Domain.HistoryArchivalStatus), + HistoryArchivalURI: &t.Domain.HistoryArchivalUri, + VisibilityArchivalStatus: ArchivalStatus(t.Domain.VisibilityArchivalStatus), + VisibilityArchivalURI: &t.Domain.VisibilityArchivalUri, + }, + ReplicationConfiguration: &shared.DomainReplicationConfiguration{ + ActiveClusterName: &t.Domain.ActiveClusterName, + Clusters: ClusterReplicationConfigurationArray(t.Domain.Clusters), + }, + FailoverVersion: &t.Domain.FailoverVersion, + IsGlobalDomain: &t.Domain.IsGlobalDomain, + } +} diff --git a/internal/compatibility/thrift/types.go b/internal/compatibility/thrift/types.go new file mode 100644 index 000000000..9948d5cca --- /dev/null +++ b/internal/compatibility/thrift/types.go @@ -0,0 +1,690 @@ +// Copyright (c) 2021 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +package thrift + +import ( + "go.uber.org/cadence/.gen/go/shared" + apiv1 "go.uber.org/cadence/.gen/proto/api/v1" + "go.uber.org/cadence/internal/common" +) + +func Payload(p *apiv1.Payload) []byte { + if p == nil { + return nil + } + if p.Data == nil { + // protoPayload will not generate this case + // however, Data field will be dropped by the encoding if it's empty + // and receiver side will see nil for the Data field + // since we already know p is not nil, Data field must be an empty byte array + return []byte{} + } + return p.Data +} + +func FailureReason(failure *apiv1.Failure) *string { + if failure == nil { + return nil + } + return &failure.Reason +} + +func FailureDetails(failure *apiv1.Failure) []byte { + if failure == nil { + return nil + } + return failure.Details +} + +func WorkflowExecution(t *apiv1.WorkflowExecution) *shared.WorkflowExecution { + if t == nil { + return nil + } + return &shared.WorkflowExecution{ + WorkflowId: &t.WorkflowId, + RunId: &t.RunId, + } +} + +func WorkflowId(t *apiv1.WorkflowExecution) *string { + if t == nil { + return nil + } + return &t.WorkflowId +} + +func RunId(t *apiv1.WorkflowExecution) *string { + if t == nil { + return nil + } + return &t.RunId +} + +func ActivityType(t *apiv1.ActivityType) *shared.ActivityType { + if t == nil { + return nil + } + return &shared.ActivityType{ + Name: &t.Name, + } +} + +func WorkflowType(t *apiv1.WorkflowType) *shared.WorkflowType { + if t == nil { + return nil + } + return &shared.WorkflowType{ + Name: &t.Name, + } +} + +func TaskList(t *apiv1.TaskList) *shared.TaskList { + if t == nil { + return nil + } + return &shared.TaskList{ + Name: &t.Name, + Kind: TaskListKind(t.Kind), + } +} + +func TaskListMetadata(t *apiv1.TaskListMetadata) *shared.TaskListMetadata { + if t == nil { + return nil + } + return &shared.TaskListMetadata{ + MaxTasksPerSecond: toDoubleValue(t.MaxTasksPerSecond), + } +} + +func RetryPolicy(t *apiv1.RetryPolicy) *shared.RetryPolicy { + if t == nil { + return nil + } + return &shared.RetryPolicy{ + InitialIntervalInSeconds: durationToSeconds(t.InitialInterval), + BackoffCoefficient: &t.BackoffCoefficient, + MaximumIntervalInSeconds: durationToSeconds(t.MaximumInterval), + MaximumAttempts: &t.MaximumAttempts, + NonRetriableErrorReasons: t.NonRetryableErrorReasons, + ExpirationIntervalInSeconds: durationToSeconds(t.ExpirationInterval), + } +} + +func Header(t *apiv1.Header) *shared.Header { + if t == nil { + return nil + } + return &shared.Header{ + Fields: PayloadMap(t.Fields), + } +} + +func Memo(t *apiv1.Memo) *shared.Memo { + if t == nil { + return nil + } + return &shared.Memo{ + Fields: PayloadMap(t.Fields), + } +} + +func SearchAttributes(t *apiv1.SearchAttributes) *shared.SearchAttributes { + if t == nil { + return nil + } + return &shared.SearchAttributes{ + IndexedFields: PayloadMap(t.IndexedFields), + } +} + +func BadBinaries(t *apiv1.BadBinaries) *shared.BadBinaries { + if t == nil { + return nil + } + return &shared.BadBinaries{ + Binaries: BadBinaryInfoMap(t.Binaries), + } +} + +func BadBinaryInfo(t *apiv1.BadBinaryInfo) *shared.BadBinaryInfo { + if t == nil { + return nil + } + return &shared.BadBinaryInfo{ + Reason: &t.Reason, + Operator: &t.Operator, + CreatedTimeNano: timeToUnixNano(t.CreatedTime), + } +} + +func ClusterReplicationConfiguration(t *apiv1.ClusterReplicationConfiguration) *shared.ClusterReplicationConfiguration { + if t == nil { + return nil + } + return &shared.ClusterReplicationConfiguration{ + ClusterName: &t.ClusterName, + } +} + +func WorkflowQuery(t *apiv1.WorkflowQuery) *shared.WorkflowQuery { + if t == nil { + return nil + } + return &shared.WorkflowQuery{ + QueryType: &t.QueryType, + QueryArgs: Payload(t.QueryArgs), + } +} + +func WorkflowQueryResult(t *apiv1.WorkflowQueryResult) *shared.WorkflowQueryResult { + if t == nil { + return nil + } + return &shared.WorkflowQueryResult{ + ResultType: QueryResultType(t.ResultType), + Answer: Payload(t.Answer), + ErrorMessage: &t.ErrorMessage, + } +} + +func StickyExecutionAttributes(t *apiv1.StickyExecutionAttributes) *shared.StickyExecutionAttributes { + if t == nil { + return nil + } + return &shared.StickyExecutionAttributes{ + WorkerTaskList: TaskList(t.WorkerTaskList), + ScheduleToStartTimeoutSeconds: durationToSeconds(t.ScheduleToStartTimeout), + } +} + +func WorkerVersionInfo(t *apiv1.WorkerVersionInfo) *shared.WorkerVersionInfo { + if t == nil { + return nil + } + return &shared.WorkerVersionInfo{ + Impl: &t.Impl, + FeatureVersion: &t.FeatureVersion, + } +} + +func StartTimeFilter(t *apiv1.StartTimeFilter) *shared.StartTimeFilter { + if t == nil { + return nil + } + return &shared.StartTimeFilter{ + EarliestTime: timeToUnixNano(t.EarliestTime), + LatestTime: timeToUnixNano(t.LatestTime), + } +} + +func WorkflowExecutionFilter(t *apiv1.WorkflowExecutionFilter) *shared.WorkflowExecutionFilter { + if t == nil { + return nil + } + return &shared.WorkflowExecutionFilter{ + WorkflowId: &t.WorkflowId, + RunId: &t.RunId, + } +} + +func WorkflowTypeFilter(t *apiv1.WorkflowTypeFilter) *shared.WorkflowTypeFilter { + if t == nil { + return nil + } + return &shared.WorkflowTypeFilter{ + Name: &t.Name, + } +} + +func StatusFilter(t *apiv1.StatusFilter) *shared.WorkflowExecutionCloseStatus { + if t == nil { + return nil + } + return WorkflowExecutionCloseStatus(t.Status) +} + +func PayloadMap(t map[string]*apiv1.Payload) map[string][]byte { + if t == nil { + return nil + } + v := make(map[string][]byte, len(t)) + for key := range t { + v[key] = Payload(t[key]) + } + return v +} + +func BadBinaryInfoMap(t map[string]*apiv1.BadBinaryInfo) map[string]*shared.BadBinaryInfo { + if t == nil { + return nil + } + v := make(map[string]*shared.BadBinaryInfo, len(t)) + for key := range t { + v[key] = BadBinaryInfo(t[key]) + } + return v +} + +func ClusterReplicationConfigurationArray(t []*apiv1.ClusterReplicationConfiguration) []*shared.ClusterReplicationConfiguration { + if t == nil { + return nil + } + v := make([]*shared.ClusterReplicationConfiguration, len(t)) + for i := range t { + v[i] = ClusterReplicationConfiguration(t[i]) + } + return v +} + +func WorkflowQueryResultMap(t map[string]*apiv1.WorkflowQueryResult) map[string]*shared.WorkflowQueryResult { + if t == nil { + return nil + } + v := make(map[string]*shared.WorkflowQueryResult, len(t)) + for key := range t { + v[key] = WorkflowQueryResult(t[key]) + } + return v +} + +func DataBlob(t *apiv1.DataBlob) *shared.DataBlob { + if t == nil { + return nil + } + return &shared.DataBlob{ + EncodingType: EncodingType(t.EncodingType), + Data: t.Data, + } +} + +func ExternalInitiatedId(t *apiv1.ExternalExecutionInfo) *int64 { + if t == nil { + return nil + } + return &t.InitiatedId +} + +func ExternalWorkflowExecution(t *apiv1.ExternalExecutionInfo) *shared.WorkflowExecution { + if t == nil { + return nil + } + return WorkflowExecution(t.WorkflowExecution) +} + +func ResetPoints(t *apiv1.ResetPoints) *shared.ResetPoints { + if t == nil { + return nil + } + return &shared.ResetPoints{ + Points: ResetPointInfoArray(t.Points), + } +} + +func ResetPointInfo(t *apiv1.ResetPointInfo) *shared.ResetPointInfo { + if t == nil { + return nil + } + return &shared.ResetPointInfo{ + BinaryChecksum: &t.BinaryChecksum, + RunId: &t.RunId, + FirstDecisionCompletedId: &t.FirstDecisionCompletedId, + CreatedTimeNano: timeToUnixNano(t.CreatedTime), + ExpiringTimeNano: timeToUnixNano(t.ExpiringTime), + Resettable: &t.Resettable, + } +} + +func PollerInfo(t *apiv1.PollerInfo) *shared.PollerInfo { + if t == nil { + return nil + } + return &shared.PollerInfo{ + LastAccessTime: timeToUnixNano(t.LastAccessTime), + Identity: &t.Identity, + RatePerSecond: &t.RatePerSecond, + } +} + +func TaskListStatus(t *apiv1.TaskListStatus) *shared.TaskListStatus { + if t == nil { + return nil + } + return &shared.TaskListStatus{ + BacklogCountHint: &t.BacklogCountHint, + ReadLevel: &t.ReadLevel, + AckLevel: &t.AckLevel, + RatePerSecond: &t.RatePerSecond, + TaskIDBlock: TaskIdBlock(t.TaskIdBlock), + } +} + +func TaskIdBlock(t *apiv1.TaskIDBlock) *shared.TaskIDBlock { + if t == nil { + return nil + } + return &shared.TaskIDBlock{ + StartID: &t.StartId, + EndID: &t.EndId, + } +} + +func WorkflowExecutionConfiguration(t *apiv1.WorkflowExecutionConfiguration) *shared.WorkflowExecutionConfiguration { + if t == nil { + return nil + } + return &shared.WorkflowExecutionConfiguration{ + TaskList: TaskList(t.TaskList), + ExecutionStartToCloseTimeoutSeconds: durationToSeconds(t.ExecutionStartToCloseTimeout), + TaskStartToCloseTimeoutSeconds: durationToSeconds(t.TaskStartToCloseTimeout), + } +} + +func WorkflowExecutionInfo(t *apiv1.WorkflowExecutionInfo) *shared.WorkflowExecutionInfo { + if t == nil { + return nil + } + return &shared.WorkflowExecutionInfo{ + Execution: WorkflowExecution(t.WorkflowExecution), + Type: WorkflowType(t.Type), + StartTime: timeToUnixNano(t.StartTime), + CloseTime: timeToUnixNano(t.CloseTime), + CloseStatus: WorkflowExecutionCloseStatus(t.CloseStatus), + HistoryLength: &t.HistoryLength, + ParentDomainId: ParentDomainId(t.ParentExecutionInfo), + ParentExecution: ParentWorkflowExecution(t.ParentExecutionInfo), + ExecutionTime: timeToUnixNano(t.ExecutionTime), + Memo: Memo(t.Memo), + SearchAttributes: SearchAttributes(t.SearchAttributes), + AutoResetPoints: ResetPoints(t.AutoResetPoints), + TaskList: &t.TaskList, + IsCron: &t.IsCron, + } +} + +func ParentDomainId(pei *apiv1.ParentExecutionInfo) *string { + if pei == nil { + return nil + } + return &pei.DomainId +} + +func ParentDomainName(pei *apiv1.ParentExecutionInfo) *string { + if pei == nil { + return nil + } + return &pei.DomainName +} + +func ParentInitiatedId(pei *apiv1.ParentExecutionInfo) *int64 { + if pei == nil { + return nil + } + return &pei.InitiatedId +} + +func ParentWorkflowExecution(pei *apiv1.ParentExecutionInfo) *shared.WorkflowExecution { + if pei == nil { + return nil + } + return WorkflowExecution(pei.WorkflowExecution) +} + +func PendingActivityInfo(t *apiv1.PendingActivityInfo) *shared.PendingActivityInfo { + if t == nil { + return nil + } + return &shared.PendingActivityInfo{ + ActivityID: &t.ActivityId, + ActivityType: ActivityType(t.ActivityType), + State: PendingActivityState(t.State), + HeartbeatDetails: Payload(t.HeartbeatDetails), + LastHeartbeatTimestamp: timeToUnixNano(t.LastHeartbeatTime), + LastStartedTimestamp: timeToUnixNano(t.LastStartedTime), + Attempt: &t.Attempt, + MaximumAttempts: &t.MaximumAttempts, + ScheduledTimestamp: timeToUnixNano(t.ScheduledTime), + ExpirationTimestamp: timeToUnixNano(t.ExpirationTime), + LastFailureReason: FailureReason(t.LastFailure), + LastFailureDetails: FailureDetails(t.LastFailure), + LastWorkerIdentity: &t.LastWorkerIdentity, + } +} + +func PendingChildExecutionInfo(t *apiv1.PendingChildExecutionInfo) *shared.PendingChildExecutionInfo { + if t == nil { + return nil + } + return &shared.PendingChildExecutionInfo{ + WorkflowID: WorkflowId(t.WorkflowExecution), + RunID: RunId(t.WorkflowExecution), + WorkflowTypName: &t.WorkflowTypeName, + InitiatedID: &t.InitiatedId, + ParentClosePolicy: ParentClosePolicy(t.ParentClosePolicy), + } +} + +func PendingDecisionInfo(t *apiv1.PendingDecisionInfo) *shared.PendingDecisionInfo { + if t == nil { + return nil + } + return &shared.PendingDecisionInfo{ + State: PendingDecisionState(t.State), + ScheduledTimestamp: timeToUnixNano(t.ScheduledTime), + StartedTimestamp: timeToUnixNano(t.StartedTime), + Attempt: common.Int64Ptr(int64(t.Attempt)), + OriginalScheduledTimestamp: timeToUnixNano(t.OriginalScheduledTime), + } +} + +func ActivityLocalDispatchInfo(t *apiv1.ActivityLocalDispatchInfo) *shared.ActivityLocalDispatchInfo { + if t == nil { + return nil + } + return &shared.ActivityLocalDispatchInfo{ + ActivityId: &t.ActivityId, + ScheduledTimestamp: timeToUnixNano(t.ScheduledTime), + StartedTimestamp: timeToUnixNano(t.StartedTime), + ScheduledTimestampOfThisAttempt: timeToUnixNano(t.ScheduledTimeOfThisAttempt), + TaskToken: t.TaskToken, + } +} + +func SupportedClientVersions(t *apiv1.SupportedClientVersions) *shared.SupportedClientVersions { + if t == nil { + return nil + } + return &shared.SupportedClientVersions{ + GoSdk: &t.GoSdk, + JavaSdk: &t.JavaSdk, + } +} + +func DescribeDomainResponseDomain(t *apiv1.Domain) *shared.DescribeDomainResponse { + if t == nil { + return nil + } + return &shared.DescribeDomainResponse{ + DomainInfo: &shared.DomainInfo{ + Name: &t.Name, + Status: DomainStatus(t.Status), + Description: &t.Description, + OwnerEmail: &t.OwnerEmail, + Data: t.Data, + UUID: &t.Id, + }, + Configuration: &shared.DomainConfiguration{ + WorkflowExecutionRetentionPeriodInDays: durationToDays(t.WorkflowExecutionRetentionPeriod), + EmitMetric: boolPtr(true), + BadBinaries: BadBinaries(t.BadBinaries), + HistoryArchivalStatus: ArchivalStatus(t.HistoryArchivalStatus), + HistoryArchivalURI: &t.HistoryArchivalUri, + VisibilityArchivalStatus: ArchivalStatus(t.VisibilityArchivalStatus), + VisibilityArchivalURI: &t.VisibilityArchivalUri, + }, + ReplicationConfiguration: &shared.DomainReplicationConfiguration{ + ActiveClusterName: &t.ActiveClusterName, + Clusters: ClusterReplicationConfigurationArray(t.Clusters), + }, + FailoverVersion: &t.FailoverVersion, + IsGlobalDomain: &t.IsGlobalDomain, + } +} + +func TaskListPartitionMetadata(t *apiv1.TaskListPartitionMetadata) *shared.TaskListPartitionMetadata { + if t == nil { + return nil + } + return &shared.TaskListPartitionMetadata{ + Key: &t.Key, + OwnerHostName: &t.OwnerHostName, + } +} + +func QueryRejected(t *apiv1.QueryRejected) *shared.QueryRejected { + if t == nil { + return nil + } + return &shared.QueryRejected{ + CloseStatus: WorkflowExecutionCloseStatus(t.CloseStatus), + } +} + +func PollerInfoArray(t []*apiv1.PollerInfo) []*shared.PollerInfo { + if t == nil { + return nil + } + v := make([]*shared.PollerInfo, len(t)) + for i := range t { + v[i] = PollerInfo(t[i]) + } + return v +} + +func ResetPointInfoArray(t []*apiv1.ResetPointInfo) []*shared.ResetPointInfo { + if t == nil { + return nil + } + v := make([]*shared.ResetPointInfo, len(t)) + for i := range t { + v[i] = ResetPointInfo(t[i]) + } + return v +} + +func PendingActivityInfoArray(t []*apiv1.PendingActivityInfo) []*shared.PendingActivityInfo { + if t == nil { + return nil + } + v := make([]*shared.PendingActivityInfo, len(t)) + for i := range t { + v[i] = PendingActivityInfo(t[i]) + } + return v +} + +func PendingChildExecutionInfoArray(t []*apiv1.PendingChildExecutionInfo) []*shared.PendingChildExecutionInfo { + if t == nil { + return nil + } + v := make([]*shared.PendingChildExecutionInfo, len(t)) + for i := range t { + v[i] = PendingChildExecutionInfo(t[i]) + } + return v +} + +func IndexedValueTypeMap(t map[string]apiv1.IndexedValueType) map[string]shared.IndexedValueType { + if t == nil { + return nil + } + v := make(map[string]shared.IndexedValueType, len(t)) + for key := range t { + v[key] = IndexedValueType(t[key]) + } + return v +} + +func DataBlobArray(t []*apiv1.DataBlob) []*shared.DataBlob { + if t == nil { + return nil + } + v := make([]*shared.DataBlob, len(t)) + for i := range t { + v[i] = DataBlob(t[i]) + } + return v +} + +func WorkflowExecutionInfoArray(t []*apiv1.WorkflowExecutionInfo) []*shared.WorkflowExecutionInfo { + if t == nil { + return nil + } + v := make([]*shared.WorkflowExecutionInfo, len(t)) + for i := range t { + v[i] = WorkflowExecutionInfo(t[i]) + } + return v +} + +func DescribeDomainResponseArray(t []*apiv1.Domain) []*shared.DescribeDomainResponse { + if t == nil { + return nil + } + v := make([]*shared.DescribeDomainResponse, len(t)) + for i := range t { + v[i] = DescribeDomainResponseDomain(t[i]) + } + return v +} + +func TaskListPartitionMetadataArray(t []*apiv1.TaskListPartitionMetadata) []*shared.TaskListPartitionMetadata { + if t == nil { + return nil + } + v := make([]*shared.TaskListPartitionMetadata, len(t)) + for i := range t { + v[i] = TaskListPartitionMetadata(t[i]) + } + return v +} + +func WorkflowQueryMap(t map[string]*apiv1.WorkflowQuery) map[string]*shared.WorkflowQuery { + if t == nil { + return nil + } + v := make(map[string]*shared.WorkflowQuery, len(t)) + for key := range t { + v[key] = WorkflowQuery(t[key]) + } + return v +} + +func ActivityLocalDispatchInfoMap(t map[string]*apiv1.ActivityLocalDispatchInfo) map[string]*shared.ActivityLocalDispatchInfo { + if t == nil { + return nil + } + v := make(map[string]*shared.ActivityLocalDispatchInfo, len(t)) + for key := range t { + v[key] = ActivityLocalDispatchInfo(t[key]) + } + return v +}