diff --git a/.gen/go/cadence/idl.go b/.gen/go/cadence/idl.go index 80d4669a4d7..ed899bf2526 100644 --- a/.gen/go/cadence/idl.go +++ b/.gen/go/cadence/idl.go @@ -33,11 +33,11 @@ var ThriftModule = &thriftreflect.ThriftModule{ Name: "cadence", Package: "github.com/uber/cadence/.gen/go/cadence", FilePath: "cadence.thrift", - SHA1: "e9edfcf677c37b94326911601c9219f173427a8f", + SHA1: "f5cf46872436104150b2c697241f4b3abfd9405d", Includes: []*thriftreflect.ThriftModule{ shared.ThriftModule, }, Raw: rawIDL, } -const rawIDL = "// Copyright (c) 2017 Uber Technologies, Inc.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n\ninclude \"shared.thrift\"\n\nnamespace java com.uber.cadence\n\n/**\n* WorkflowService API is exposed to provide support for long running applications. Application is expected to call\n* StartWorkflowExecution to create an instance for each instance of long running workflow. Such applications are expected\n* to have a worker which regularly polls for DecisionTask and ActivityTask from the WorkflowService. For each\n* DecisionTask, application is expected to process the history of events for that session and respond back with next\n* decisions. For each ActivityTask, application is expected to execute the actual logic for that task and respond back\n* with completion or failure. Worker is expected to regularly heartbeat while activity task is running.\n**/\nservice WorkflowService {\n /**\n * RegisterDomain creates a new domain which can be used as a container for all resources. Domain is a top level\n * entity within Cadence, used as a container for all resources like workflow executions, tasklists, etc. Domain\n * acts as a sandbox and provides isolation for all resources within the domain. All resources belongs to exactly one\n * domain.\n **/\n void RegisterDomain(1: shared.RegisterDomainRequest registerRequest)\n throws (\n 1: shared.BadRequestError badRequestError,\n 2: shared.InternalServiceError internalServiceError,\n 3: shared.DomainAlreadyExistsError domainExistsError,\n )\n\n /**\n * DescribeDomain returns the information and configuration for a registered domain.\n **/\n shared.DescribeDomainResponse DescribeDomain(1: shared.DescribeDomainRequest describeRequest)\n throws (\n 1: shared.BadRequestError badRequestError,\n 2: shared.InternalServiceError internalServiceError,\n 3: shared.EntityNotExistsError entityNotExistError,\n )\n\n /**\n * UpdateDomain is used to update the information and configuration for a registered domain.\n **/\n shared.UpdateDomainResponse UpdateDomain(1: shared.UpdateDomainRequest updateRequest)\n throws (\n 1: shared.BadRequestError badRequestError,\n 2: shared.InternalServiceError internalServiceError,\n 3: shared.EntityNotExistsError entityNotExistError,\n )\n\n /**\n * DeprecateDomain us used to update status of a registered domain to DEPRECATED. Once the domain is deprecated\n * it cannot be used to start new workflow executions. Existing workflow executions will continue to run on\n * deprecated domains.\n **/\n void DeprecateDomain(1: shared.DeprecateDomainRequest deprecateRequest)\n throws (\n 1: shared.BadRequestError badRequestError,\n 2: shared.InternalServiceError internalServiceError,\n 3: shared.EntityNotExistsError entityNotExistError,\n )\n\n /**\n * StartWorkflowExecution starts a new long running workflow instance. It will create the instance with\n * 'WorkflowExecutionStarted' event in history and also schedule the first DecisionTask for the worker to make the\n * first decision for this instance. It will return 'WorkflowExecutionAlreadyStartedError', if an instance already\n * exists with same workflowId.\n **/\n shared.StartWorkflowExecutionResponse StartWorkflowExecution(1: shared.StartWorkflowExecutionRequest startRequest)\n throws (\n 1: shared.BadRequestError badRequestError,\n 2: shared.InternalServiceError internalServiceError,\n 3: shared.WorkflowExecutionAlreadyStartedError sessionAlreadyExistError,\n 4: shared.ServiceBusyError serviceBusyError,\n )\n\n /**\n * Returns the history of specified workflow execution. It fails with 'EntityNotExistError' if speficied workflow\n * execution in unknown to the service.\n **/\n shared.GetWorkflowExecutionHistoryResponse GetWorkflowExecutionHistory(1: shared.GetWorkflowExecutionHistoryRequest getRequest)\n throws (\n 1: shared.BadRequestError badRequestError,\n 2: shared.InternalServiceError internalServiceError,\n 3: shared.EntityNotExistsError entityNotExistError,\n 4: shared.ServiceBusyError serviceBusyError,\n )\n\n /**\n * PollForDecisionTask is called by application worker to process DecisionTask from a specific taskList. A\n * DecisionTask is dispatched to callers for active workflow executions, with pending decisions.\n * Application is then expected to call 'RespondDecisionTaskCompleted' API when it is done processing the DecisionTask.\n * It will also create a 'DecisionTaskStarted' event in the history for that session before handing off DecisionTask to\n * application worker.\n **/\n shared.PollForDecisionTaskResponse PollForDecisionTask(1: shared.PollForDecisionTaskRequest pollRequest)\n throws (\n 1: shared.BadRequestError badRequestError,\n 2: shared.InternalServiceError internalServiceError,\n 3: shared.ServiceBusyError serviceBusyError,\n )\n\n /**\n * RespondDecisionTaskCompleted is called by application worker to complete a DecisionTask handed as a result of\n * 'PollForDecisionTask' API call. Completing a DecisionTask will result in new events for the workflow execution and\n * potentially new ActivityTask being created for corresponding decisions. It will also create a DecisionTaskCompleted\n * event in the history for that session. Use the 'taskToken' provided as response of PollForDecisionTask API call\n * for completing the DecisionTask.\n **/\n void RespondDecisionTaskCompleted(1: shared.RespondDecisionTaskCompletedRequest completeRequest)\n throws (\n 1: shared.BadRequestError badRequestError,\n 2: shared.InternalServiceError internalServiceError,\n 3: shared.EntityNotExistsError entityNotExistError,\n )\n\n /**\n * RespondDecisionTaskFailed is called by application worker to indicate failure. This results in\n * DecisionTaskFailedEvent written to the history and a new DecisionTask created. This API can be used by client to\n * either clear sticky tasklist or report any panics during DecisionTask processing. Cadence will only append first\n * DecisionTaskFailed event to the history of workflow execution for consecutive failures.\n **/\n void RespondDecisionTaskFailed(1: shared.RespondDecisionTaskFailedRequest failedRequest)\n throws (\n 1: shared.BadRequestError badRequestError,\n 2: shared.InternalServiceError internalServiceError,\n 3: shared.EntityNotExistsError entityNotExistError,\n )\n\n /**\n * PollForActivityTask is called by application worker to process ActivityTask from a specific taskList. ActivityTask\n * is dispatched to callers whenever a ScheduleTask decision is made for a workflow execution.\n * Application is expected to call 'RespondActivityTaskCompleted' or 'RespondActivityTaskFailed' once it is done\n * processing the task.\n * Application also needs to call 'RecordActivityTaskHeartbeat' API within 'heartbeatTimeoutSeconds' interval to\n * prevent the task from getting timed out. An event 'ActivityTaskStarted' event is also written to workflow execution\n * history before the ActivityTask is dispatched to application worker.\n **/\n shared.PollForActivityTaskResponse PollForActivityTask(1: shared.PollForActivityTaskRequest pollRequest)\n throws (\n 1: shared.BadRequestError badRequestError,\n 2: shared.InternalServiceError internalServiceError,\n 3: shared.ServiceBusyError serviceBusyError,\n )\n\n /**\n * RecordActivityTaskHeartbeat is called by application worker while it is processing an ActivityTask. If worker fails\n * to heartbeat within 'heartbeatTimeoutSeconds' interval for the ActivityTask, then it will be marked as timedout and\n * 'ActivityTaskTimedOut' event will be written to the workflow history. Calling 'RecordActivityTaskHeartbeat' will\n * fail with 'EntityNotExistsError' in such situations. Use the 'taskToken' provided as response of\n * PollForActivityTask API call for heartbeating.\n **/\n shared.RecordActivityTaskHeartbeatResponse RecordActivityTaskHeartbeat(1: shared.RecordActivityTaskHeartbeatRequest heartbeatRequest)\n throws (\n 1: shared.BadRequestError badRequestError,\n 2: shared.InternalServiceError internalServiceError,\n 3: shared.EntityNotExistsError entityNotExistError,\n )\n\n /**\n * RespondActivityTaskCompleted is called by application worker when it is done processing an ActivityTask. It will\n * result in a new 'ActivityTaskCompleted' event being written to the workflow history and a new DecisionTask\n * created for the workflow so new decisions could be made. Use the 'taskToken' provided as response of\n * PollForActivityTask API call for completion. It fails with 'EntityNotExistsError' if the taskToken is not valid\n * anymore due to activity timeout.\n **/\n void RespondActivityTaskCompleted(1: shared.RespondActivityTaskCompletedRequest completeRequest)\n throws (\n 1: shared.BadRequestError badRequestError,\n 2: shared.InternalServiceError internalServiceError,\n 3: shared.EntityNotExistsError entityNotExistError,\n )\n\n /**\n * RespondActivityTaskCompletedByID is called by application worker when it is done processing an ActivityTask.\n * It will result in a new 'ActivityTaskCompleted' event being written to the workflow history and a new DecisionTask\n * created for the workflow so new decisions could be made. Similar to RespondActivityTaskCompleted but use DomainID,\n * WorkflowID and ActivityID instead of 'taskToken' for completion. It fails with 'EntityNotExistsError'\n * if the these IDs are not valid anymore due to activity timeout.\n **/\n void RespondActivityTaskCompletedByID(1: shared.RespondActivityTaskCompletedByIDRequest completeRequest)\n throws (\n 1: shared.BadRequestError badRequestError,\n 2: shared.InternalServiceError internalServiceError,\n 3: shared.EntityNotExistsError entityNotExistError,\n )\n\n /**\n * RespondActivityTaskFailed is called by application worker when it is done processing an ActivityTask. It will\n * result in a new 'ActivityTaskFailed' event being written to the workflow history and a new DecisionTask\n * created for the workflow instance so new decisions could be made. Use the 'taskToken' provided as response of\n * PollForActivityTask API call for completion. It fails with 'EntityNotExistsError' if the taskToken is not valid\n * anymore due to activity timeout.\n **/\n void RespondActivityTaskFailed(1: shared.RespondActivityTaskFailedRequest failRequest)\n throws (\n 1: shared.BadRequestError badRequestError,\n 2: shared.InternalServiceError internalServiceError,\n 3: shared.EntityNotExistsError entityNotExistError,\n )\n\n /**\n * RespondActivityTaskFailedByID is called by application worker when it is done processing an ActivityTask.\n * It will result in a new 'ActivityTaskFailed' event being written to the workflow history and a new DecisionTask\n * created for the workflow instance so new decisions could be made. Similar to RespondActivityTaskFailed but use\n * DomainID, WorkflowID and ActivityID instead of 'taskToken' for completion. It fails with 'EntityNotExistsError'\n * if the these IDs are not valid anymore due to activity timeout.\n **/\n void RespondActivityTaskFailedByID(1: shared.RespondActivityTaskFailedByIDRequest failRequest)\n throws (\n 1: shared.BadRequestError badRequestError,\n 2: shared.InternalServiceError internalServiceError,\n 3: shared.EntityNotExistsError entityNotExistError,\n )\n\n /**\n * RespondActivityTaskCanceled is called by application worker when it is successfully canceled an ActivityTask. It will\n * result in a new 'ActivityTaskCanceled' event being written to the workflow history and a new DecisionTask\n * created for the workflow instance so new decisions could be made. Use the 'taskToken' provided as response of\n * PollForActivityTask API call for completion. It fails with 'EntityNotExistsError' if the taskToken is not valid\n * anymore due to activity timeout.\n **/\n void RespondActivityTaskCanceled(1: shared.RespondActivityTaskCanceledRequest canceledRequest)\n throws (\n 1: shared.BadRequestError badRequestError,\n 2: shared.InternalServiceError internalServiceError,\n 3: shared.EntityNotExistsError entityNotExistError,\n )\n\n /**\n * RespondActivityTaskCanceledByID is called by application worker when it is successfully canceled an ActivityTask.\n * It will result in a new 'ActivityTaskCanceled' event being written to the workflow history and a new DecisionTask\n * created for the workflow instance so new decisions could be made. Similar to RespondActivityTaskCanceled but use\n * DomainID, WorkflowID and ActivityID instead of 'taskToken' for completion. It fails with 'EntityNotExistsError'\n * if the these IDs are not valid anymore due to activity timeout.\n **/\n void RespondActivityTaskCanceledByID(1: shared.RespondActivityTaskCanceledByIDRequest canceledRequest)\n throws (\n 1: shared.BadRequestError badRequestError,\n 2: shared.InternalServiceError internalServiceError,\n 3: shared.EntityNotExistsError entityNotExistError,\n )\n\n /**\n * RequestCancelWorkflowExecution is called by application worker when it wants to request cancellation of a workflow instance.\n * It will result in a new 'WorkflowExecutionCancelRequested' event being written to the workflow history and a new DecisionTask\n * created for the workflow instance so new decisions could be made. It fails with 'EntityNotExistsError' if the workflow is not valid\n * anymore due to completion or doesn't exist.\n **/\n void RequestCancelWorkflowExecution(1: shared.RequestCancelWorkflowExecutionRequest cancelRequest)\n throws (\n 1: shared.BadRequestError badRequestError,\n 2: shared.InternalServiceError internalServiceError,\n 3: shared.EntityNotExistsError entityNotExistError,\n 4: shared.CancellationAlreadyRequestedError cancellationAlreadyRequestedError,\n 5: shared.ServiceBusyError serviceBusyError,\n )\n\n /**\n * SignalWorkflowExecution is used to send a signal event to running workflow execution. This results in\n * WorkflowExecutionSignaled event recorded in the history and a decision task being created for the execution.\n **/\n void SignalWorkflowExecution(1: shared.SignalWorkflowExecutionRequest signalRequest)\n throws (\n 1: shared.BadRequestError badRequestError,\n 2: shared.InternalServiceError internalServiceError,\n 3: shared.EntityNotExistsError entityNotExistError,\n 4: shared.ServiceBusyError serviceBusyError,\n )\n\n /**\n * TerminateWorkflowExecution terminates an existing workflow execution by recording WorkflowExecutionTerminated event\n * in the history and immediately terminating the execution instance.\n **/\n void TerminateWorkflowExecution(1: shared.TerminateWorkflowExecutionRequest terminateRequest)\n throws (\n 1: shared.BadRequestError badRequestError,\n 2: shared.InternalServiceError internalServiceError,\n 3: shared.EntityNotExistsError entityNotExistError,\n 4: shared.ServiceBusyError serviceBusyError,\n )\n\n /**\n * ListOpenWorkflowExecutions is a visibility API to list the open executions in a specific domain.\n **/\n shared.ListOpenWorkflowExecutionsResponse ListOpenWorkflowExecutions(1: shared.ListOpenWorkflowExecutionsRequest listRequest)\n throws (\n 1: shared.BadRequestError badRequestError,\n 2: shared.InternalServiceError internalServiceError,\n 3: shared.EntityNotExistsError entityNotExistError,\n 4: shared.ServiceBusyError serviceBusyError,\n )\n\n /**\n * ListClosedWorkflowExecutions is a visibility API to list the closed executions in a specific domain.\n **/\n shared.ListClosedWorkflowExecutionsResponse ListClosedWorkflowExecutions(1: shared.ListClosedWorkflowExecutionsRequest listRequest)\n throws (\n 1: shared.BadRequestError badRequestError,\n 2: shared.InternalServiceError internalServiceError,\n 3: shared.EntityNotExistsError entityNotExistError,\n 4: shared.ServiceBusyError serviceBusyError,\n )\n\n /**\n * RespondQueryTaskCompleted is called by application worker to complete a QueryTask (which is a DecisionTask for query)\n * as a result of 'PollForDecisionTask' API call. Completing a QueryTask will unblock the client call to 'QueryWorkflow'\n * API and return the query result to client as a response to 'QueryWorkflow' API call.\n **/\n void RespondQueryTaskCompleted(1: shared.RespondQueryTaskCompletedRequest completeRequest)\n throws (\n 1: shared.BadRequestError badRequestError,\n 2: shared.InternalServiceError internalServiceError,\n 3: shared.EntityNotExistsError entityNotExistError,\n )\n\n /**\n * QueryWorkflow returns query result for a specified workflow execution\n **/\n shared.QueryWorkflowResponse QueryWorkflow(1: shared.QueryWorkflowRequest queryRequest)\n\tthrows (\n\t 1: shared.BadRequestError badRequestError,\n\t 2: shared.InternalServiceError internalServiceError,\n\t 3: shared.EntityNotExistsError entityNotExistError,\n\t 4: shared.QueryFailedError queryFailedError,\n\t)\n\n /**\n * DescribeWorkflowExecution returns information about the specified workflow execution.\n **/\n shared.DescribeWorkflowExecutionResponse DescribeWorkflowExecution(1: shared.DescribeWorkflowExecutionRequest describeRequest)\n throws (\n 1: shared.BadRequestError badRequestError,\n 2: shared.InternalServiceError internalServiceError,\n 3: shared.EntityNotExistsError entityNotExistError,\n )\n\n}\n" +const rawIDL = "// Copyright (c) 2017 Uber Technologies, Inc.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n\ninclude \"shared.thrift\"\n\nnamespace java com.uber.cadence\n\n/**\n* WorkflowService API is exposed to provide support for long running applications. Application is expected to call\n* StartWorkflowExecution to create an instance for each instance of long running workflow. Such applications are expected\n* to have a worker which regularly polls for DecisionTask and ActivityTask from the WorkflowService. For each\n* DecisionTask, application is expected to process the history of events for that session and respond back with next\n* decisions. For each ActivityTask, application is expected to execute the actual logic for that task and respond back\n* with completion or failure. Worker is expected to regularly heartbeat while activity task is running.\n**/\nservice WorkflowService {\n /**\n * RegisterDomain creates a new domain which can be used as a container for all resources. Domain is a top level\n * entity within Cadence, used as a container for all resources like workflow executions, tasklists, etc. Domain\n * acts as a sandbox and provides isolation for all resources within the domain. All resources belongs to exactly one\n * domain.\n **/\n void RegisterDomain(1: shared.RegisterDomainRequest registerRequest)\n throws (\n 1: shared.BadRequestError badRequestError,\n 2: shared.InternalServiceError internalServiceError,\n 3: shared.DomainAlreadyExistsError domainExistsError,\n )\n\n /**\n * DescribeDomain returns the information and configuration for a registered domain.\n **/\n shared.DescribeDomainResponse DescribeDomain(1: shared.DescribeDomainRequest describeRequest)\n throws (\n 1: shared.BadRequestError badRequestError,\n 2: shared.InternalServiceError internalServiceError,\n 3: shared.EntityNotExistsError entityNotExistError,\n )\n\n /**\n * UpdateDomain is used to update the information and configuration for a registered domain.\n **/\n shared.UpdateDomainResponse UpdateDomain(1: shared.UpdateDomainRequest updateRequest)\n throws (\n 1: shared.BadRequestError badRequestError,\n 2: shared.InternalServiceError internalServiceError,\n 3: shared.EntityNotExistsError entityNotExistError,\n )\n\n /**\n * DeprecateDomain us used to update status of a registered domain to DEPRECATED. Once the domain is deprecated\n * it cannot be used to start new workflow executions. Existing workflow executions will continue to run on\n * deprecated domains.\n **/\n void DeprecateDomain(1: shared.DeprecateDomainRequest deprecateRequest)\n throws (\n 1: shared.BadRequestError badRequestError,\n 2: shared.InternalServiceError internalServiceError,\n 3: shared.EntityNotExistsError entityNotExistError,\n )\n\n /**\n * StartWorkflowExecution starts a new long running workflow instance. It will create the instance with\n * 'WorkflowExecutionStarted' event in history and also schedule the first DecisionTask for the worker to make the\n * first decision for this instance. It will return 'WorkflowExecutionAlreadyStartedError', if an instance already\n * exists with same workflowId.\n **/\n shared.StartWorkflowExecutionResponse StartWorkflowExecution(1: shared.StartWorkflowExecutionRequest startRequest)\n throws (\n 1: shared.BadRequestError badRequestError,\n 2: shared.InternalServiceError internalServiceError,\n 3: shared.WorkflowExecutionAlreadyStartedError sessionAlreadyExistError,\n 4: shared.ServiceBusyError serviceBusyError,\n )\n\n /**\n * Returns the history of specified workflow execution. It fails with 'EntityNotExistError' if speficied workflow\n * execution in unknown to the service.\n **/\n shared.GetWorkflowExecutionHistoryResponse GetWorkflowExecutionHistory(1: shared.GetWorkflowExecutionHistoryRequest getRequest)\n throws (\n 1: shared.BadRequestError badRequestError,\n 2: shared.InternalServiceError internalServiceError,\n 3: shared.EntityNotExistsError entityNotExistError,\n 4: shared.ServiceBusyError serviceBusyError,\n )\n\n /**\n * PollForDecisionTask is called by application worker to process DecisionTask from a specific taskList. A\n * DecisionTask is dispatched to callers for active workflow executions, with pending decisions.\n * Application is then expected to call 'RespondDecisionTaskCompleted' API when it is done processing the DecisionTask.\n * It will also create a 'DecisionTaskStarted' event in the history for that session before handing off DecisionTask to\n * application worker.\n **/\n shared.PollForDecisionTaskResponse PollForDecisionTask(1: shared.PollForDecisionTaskRequest pollRequest)\n throws (\n 1: shared.BadRequestError badRequestError,\n 2: shared.InternalServiceError internalServiceError,\n 3: shared.ServiceBusyError serviceBusyError,\n )\n\n /**\n * RespondDecisionTaskCompleted is called by application worker to complete a DecisionTask handed as a result of\n * 'PollForDecisionTask' API call. Completing a DecisionTask will result in new events for the workflow execution and\n * potentially new ActivityTask being created for corresponding decisions. It will also create a DecisionTaskCompleted\n * event in the history for that session. Use the 'taskToken' provided as response of PollForDecisionTask API call\n * for completing the DecisionTask.\n **/\n void RespondDecisionTaskCompleted(1: shared.RespondDecisionTaskCompletedRequest completeRequest)\n throws (\n 1: shared.BadRequestError badRequestError,\n 2: shared.InternalServiceError internalServiceError,\n 3: shared.EntityNotExistsError entityNotExistError,\n )\n\n /**\n * RespondDecisionTaskFailed is called by application worker to indicate failure. This results in\n * DecisionTaskFailedEvent written to the history and a new DecisionTask created. This API can be used by client to\n * either clear sticky tasklist or report any panics during DecisionTask processing. Cadence will only append first\n * DecisionTaskFailed event to the history of workflow execution for consecutive failures.\n **/\n void RespondDecisionTaskFailed(1: shared.RespondDecisionTaskFailedRequest failedRequest)\n throws (\n 1: shared.BadRequestError badRequestError,\n 2: shared.InternalServiceError internalServiceError,\n 3: shared.EntityNotExistsError entityNotExistError,\n )\n\n /**\n * PollForActivityTask is called by application worker to process ActivityTask from a specific taskList. ActivityTask\n * is dispatched to callers whenever a ScheduleTask decision is made for a workflow execution.\n * Application is expected to call 'RespondActivityTaskCompleted' or 'RespondActivityTaskFailed' once it is done\n * processing the task.\n * Application also needs to call 'RecordActivityTaskHeartbeat' API within 'heartbeatTimeoutSeconds' interval to\n * prevent the task from getting timed out. An event 'ActivityTaskStarted' event is also written to workflow execution\n * history before the ActivityTask is dispatched to application worker.\n **/\n shared.PollForActivityTaskResponse PollForActivityTask(1: shared.PollForActivityTaskRequest pollRequest)\n throws (\n 1: shared.BadRequestError badRequestError,\n 2: shared.InternalServiceError internalServiceError,\n 3: shared.ServiceBusyError serviceBusyError,\n )\n\n /**\n * RecordActivityTaskHeartbeat is called by application worker while it is processing an ActivityTask. If worker fails\n * to heartbeat within 'heartbeatTimeoutSeconds' interval for the ActivityTask, then it will be marked as timedout and\n * 'ActivityTaskTimedOut' event will be written to the workflow history. Calling 'RecordActivityTaskHeartbeat' will\n * fail with 'EntityNotExistsError' in such situations. Use the 'taskToken' provided as response of\n * PollForActivityTask API call for heartbeating.\n **/\n shared.RecordActivityTaskHeartbeatResponse RecordActivityTaskHeartbeat(1: shared.RecordActivityTaskHeartbeatRequest heartbeatRequest)\n throws (\n 1: shared.BadRequestError badRequestError,\n 2: shared.InternalServiceError internalServiceError,\n 3: shared.EntityNotExistsError entityNotExistError,\n )\n\n /**\n * RespondActivityTaskCompleted is called by application worker when it is done processing an ActivityTask. It will\n * result in a new 'ActivityTaskCompleted' event being written to the workflow history and a new DecisionTask\n * created for the workflow so new decisions could be made. Use the 'taskToken' provided as response of\n * PollForActivityTask API call for completion. It fails with 'EntityNotExistsError' if the taskToken is not valid\n * anymore due to activity timeout.\n **/\n void RespondActivityTaskCompleted(1: shared.RespondActivityTaskCompletedRequest completeRequest)\n throws (\n 1: shared.BadRequestError badRequestError,\n 2: shared.InternalServiceError internalServiceError,\n 3: shared.EntityNotExistsError entityNotExistError,\n )\n\n /**\n * RespondActivityTaskCompletedByID is called by application worker when it is done processing an ActivityTask.\n * It will result in a new 'ActivityTaskCompleted' event being written to the workflow history and a new DecisionTask\n * created for the workflow so new decisions could be made. Similar to RespondActivityTaskCompleted but use DomainID,\n * WorkflowID and ActivityID instead of 'taskToken' for completion. It fails with 'EntityNotExistsError'\n * if the these IDs are not valid anymore due to activity timeout.\n **/\n void RespondActivityTaskCompletedByID(1: shared.RespondActivityTaskCompletedByIDRequest completeRequest)\n throws (\n 1: shared.BadRequestError badRequestError,\n 2: shared.InternalServiceError internalServiceError,\n 3: shared.EntityNotExistsError entityNotExistError,\n )\n\n /**\n * RespondActivityTaskFailed is called by application worker when it is done processing an ActivityTask. It will\n * result in a new 'ActivityTaskFailed' event being written to the workflow history and a new DecisionTask\n * created for the workflow instance so new decisions could be made. Use the 'taskToken' provided as response of\n * PollForActivityTask API call for completion. It fails with 'EntityNotExistsError' if the taskToken is not valid\n * anymore due to activity timeout.\n **/\n void RespondActivityTaskFailed(1: shared.RespondActivityTaskFailedRequest failRequest)\n throws (\n 1: shared.BadRequestError badRequestError,\n 2: shared.InternalServiceError internalServiceError,\n 3: shared.EntityNotExistsError entityNotExistError,\n )\n\n /**\n * RespondActivityTaskFailedByID is called by application worker when it is done processing an ActivityTask.\n * It will result in a new 'ActivityTaskFailed' event being written to the workflow history and a new DecisionTask\n * created for the workflow instance so new decisions could be made. Similar to RespondActivityTaskFailed but use\n * DomainID, WorkflowID and ActivityID instead of 'taskToken' for completion. It fails with 'EntityNotExistsError'\n * if the these IDs are not valid anymore due to activity timeout.\n **/\n void RespondActivityTaskFailedByID(1: shared.RespondActivityTaskFailedByIDRequest failRequest)\n throws (\n 1: shared.BadRequestError badRequestError,\n 2: shared.InternalServiceError internalServiceError,\n 3: shared.EntityNotExistsError entityNotExistError,\n )\n\n /**\n * RespondActivityTaskCanceled is called by application worker when it is successfully canceled an ActivityTask. It will\n * result in a new 'ActivityTaskCanceled' event being written to the workflow history and a new DecisionTask\n * created for the workflow instance so new decisions could be made. Use the 'taskToken' provided as response of\n * PollForActivityTask API call for completion. It fails with 'EntityNotExistsError' if the taskToken is not valid\n * anymore due to activity timeout.\n **/\n void RespondActivityTaskCanceled(1: shared.RespondActivityTaskCanceledRequest canceledRequest)\n throws (\n 1: shared.BadRequestError badRequestError,\n 2: shared.InternalServiceError internalServiceError,\n 3: shared.EntityNotExistsError entityNotExistError,\n )\n\n /**\n * RespondActivityTaskCanceledByID is called by application worker when it is successfully canceled an ActivityTask.\n * It will result in a new 'ActivityTaskCanceled' event being written to the workflow history and a new DecisionTask\n * created for the workflow instance so new decisions could be made. Similar to RespondActivityTaskCanceled but use\n * DomainID, WorkflowID and ActivityID instead of 'taskToken' for completion. It fails with 'EntityNotExistsError'\n * if the these IDs are not valid anymore due to activity timeout.\n **/\n void RespondActivityTaskCanceledByID(1: shared.RespondActivityTaskCanceledByIDRequest canceledRequest)\n throws (\n 1: shared.BadRequestError badRequestError,\n 2: shared.InternalServiceError internalServiceError,\n 3: shared.EntityNotExistsError entityNotExistError,\n )\n\n /**\n * RequestCancelWorkflowExecution is called by application worker when it wants to request cancellation of a workflow instance.\n * It will result in a new 'WorkflowExecutionCancelRequested' event being written to the workflow history and a new DecisionTask\n * created for the workflow instance so new decisions could be made. It fails with 'EntityNotExistsError' if the workflow is not valid\n * anymore due to completion or doesn't exist.\n **/\n void RequestCancelWorkflowExecution(1: shared.RequestCancelWorkflowExecutionRequest cancelRequest)\n throws (\n 1: shared.BadRequestError badRequestError,\n 2: shared.InternalServiceError internalServiceError,\n 3: shared.EntityNotExistsError entityNotExistError,\n 4: shared.CancellationAlreadyRequestedError cancellationAlreadyRequestedError,\n 5: shared.ServiceBusyError serviceBusyError,\n )\n\n /**\n * SignalWorkflowExecution is used to send a signal event to running workflow execution. This results in\n * WorkflowExecutionSignaled event recorded in the history and a decision task being created for the execution.\n **/\n void SignalWorkflowExecution(1: shared.SignalWorkflowExecutionRequest signalRequest)\n throws (\n 1: shared.BadRequestError badRequestError,\n 2: shared.InternalServiceError internalServiceError,\n 3: shared.EntityNotExistsError entityNotExistError,\n 4: shared.ServiceBusyError serviceBusyError,\n )\n\n /**\n * TerminateWorkflowExecution terminates an existing workflow execution by recording WorkflowExecutionTerminated event\n * in the history and immediately terminating the execution instance.\n **/\n void TerminateWorkflowExecution(1: shared.TerminateWorkflowExecutionRequest terminateRequest)\n throws (\n 1: shared.BadRequestError badRequestError,\n 2: shared.InternalServiceError internalServiceError,\n 3: shared.EntityNotExistsError entityNotExistError,\n 4: shared.ServiceBusyError serviceBusyError,\n )\n\n /**\n * ListOpenWorkflowExecutions is a visibility API to list the open executions in a specific domain.\n **/\n shared.ListOpenWorkflowExecutionsResponse ListOpenWorkflowExecutions(1: shared.ListOpenWorkflowExecutionsRequest listRequest)\n throws (\n 1: shared.BadRequestError badRequestError,\n 2: shared.InternalServiceError internalServiceError,\n 3: shared.EntityNotExistsError entityNotExistError,\n 4: shared.ServiceBusyError serviceBusyError,\n )\n\n /**\n * ListClosedWorkflowExecutions is a visibility API to list the closed executions in a specific domain.\n **/\n shared.ListClosedWorkflowExecutionsResponse ListClosedWorkflowExecutions(1: shared.ListClosedWorkflowExecutionsRequest listRequest)\n throws (\n 1: shared.BadRequestError badRequestError,\n 2: shared.InternalServiceError internalServiceError,\n 3: shared.EntityNotExistsError entityNotExistError,\n 4: shared.ServiceBusyError serviceBusyError,\n )\n\n /**\n * RespondQueryTaskCompleted is called by application worker to complete a QueryTask (which is a DecisionTask for query)\n * as a result of 'PollForDecisionTask' API call. Completing a QueryTask will unblock the client call to 'QueryWorkflow'\n * API and return the query result to client as a response to 'QueryWorkflow' API call.\n **/\n void RespondQueryTaskCompleted(1: shared.RespondQueryTaskCompletedRequest completeRequest)\n throws (\n 1: shared.BadRequestError badRequestError,\n 2: shared.InternalServiceError internalServiceError,\n 3: shared.EntityNotExistsError entityNotExistError,\n )\n\n /**\n * QueryWorkflow returns query result for a specified workflow execution\n **/\n shared.QueryWorkflowResponse QueryWorkflow(1: shared.QueryWorkflowRequest queryRequest)\n\tthrows (\n\t 1: shared.BadRequestError badRequestError,\n\t 2: shared.InternalServiceError internalServiceError,\n\t 3: shared.EntityNotExistsError entityNotExistError,\n\t 4: shared.QueryFailedError queryFailedError,\n\t)\n\n /**\n * DescribeWorkflowExecution returns information about the specified workflow execution.\n **/\n shared.DescribeWorkflowExecutionResponse DescribeWorkflowExecution(1: shared.DescribeWorkflowExecutionRequest describeRequest)\n throws (\n 1: shared.BadRequestError badRequestError,\n 2: shared.InternalServiceError internalServiceError,\n 3: shared.EntityNotExistsError entityNotExistError,\n )\n\n /**\n * GetPollerHistory returns pollers which poll from given tasklist in last few minutes.\n **/\n shared.GetPollerHistoryResponse GetPollerHistory(1: shared.GetPollerHistoryRequest request)\n throws (\n 1: shared.BadRequestError badRequestError,\n 2: shared.InternalServiceError internalServiceError,\n 3: shared.EntityNotExistsError entityNotExistError,\n )\n\n}\n" diff --git a/.gen/go/cadence/workflowservice_getpollerhistory.go b/.gen/go/cadence/workflowservice_getpollerhistory.go new file mode 100644 index 00000000000..b2798eed837 --- /dev/null +++ b/.gen/go/cadence/workflowservice_getpollerhistory.go @@ -0,0 +1,501 @@ +// Copyright (c) 2017 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. + +// Code generated by thriftrw v1.8.0. DO NOT EDIT. +// @generated + +package cadence + +import ( + "errors" + "fmt" + "github.com/uber/cadence/.gen/go/shared" + "go.uber.org/thriftrw/wire" + "strings" +) + +// WorkflowService_GetPollerHistory_Args represents the arguments for the WorkflowService.GetPollerHistory function. +// +// The arguments for GetPollerHistory are sent and received over the wire as this struct. +type WorkflowService_GetPollerHistory_Args struct { + Request *shared.GetPollerHistoryRequest `json:"request,omitempty"` +} + +// ToWire translates a WorkflowService_GetPollerHistory_Args struct into a Thrift-level intermediate +// representation. This intermediate representation may be serialized +// into bytes using a ThriftRW protocol implementation. +// +// An error is returned if the struct or any of its fields failed to +// validate. +// +// x, err := v.ToWire() +// if err != nil { +// return err +// } +// +// if err := binaryProtocol.Encode(x, writer); err != nil { +// return err +// } +func (v *WorkflowService_GetPollerHistory_Args) ToWire() (wire.Value, error) { + var ( + fields [1]wire.Field + i int = 0 + w wire.Value + err error + ) + + if v.Request != nil { + w, err = v.Request.ToWire() + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 1, Value: w} + i++ + } + + return wire.NewValueStruct(wire.Struct{Fields: fields[:i]}), nil +} + +func _GetPollerHistoryRequest_Read(w wire.Value) (*shared.GetPollerHistoryRequest, error) { + var v shared.GetPollerHistoryRequest + err := v.FromWire(w) + return &v, err +} + +// FromWire deserializes a WorkflowService_GetPollerHistory_Args struct from its Thrift-level +// representation. The Thrift-level representation may be obtained +// from a ThriftRW protocol implementation. +// +// An error is returned if we were unable to build a WorkflowService_GetPollerHistory_Args struct +// from the provided intermediate representation. +// +// x, err := binaryProtocol.Decode(reader, wire.TStruct) +// if err != nil { +// return nil, err +// } +// +// var v WorkflowService_GetPollerHistory_Args +// if err := v.FromWire(x); err != nil { +// return nil, err +// } +// return &v, nil +func (v *WorkflowService_GetPollerHistory_Args) FromWire(w wire.Value) error { + var err error + + for _, field := range w.GetStruct().Fields { + switch field.ID { + case 1: + if field.Value.Type() == wire.TStruct { + v.Request, err = _GetPollerHistoryRequest_Read(field.Value) + if err != nil { + return err + } + + } + } + } + + return nil +} + +// String returns a readable string representation of a WorkflowService_GetPollerHistory_Args +// struct. +func (v *WorkflowService_GetPollerHistory_Args) String() string { + if v == nil { + return "" + } + + var fields [1]string + i := 0 + if v.Request != nil { + fields[i] = fmt.Sprintf("Request: %v", v.Request) + i++ + } + + return fmt.Sprintf("WorkflowService_GetPollerHistory_Args{%v}", strings.Join(fields[:i], ", ")) +} + +// Equals returns true if all the fields of this WorkflowService_GetPollerHistory_Args match the +// provided WorkflowService_GetPollerHistory_Args. +// +// This function performs a deep comparison. +func (v *WorkflowService_GetPollerHistory_Args) Equals(rhs *WorkflowService_GetPollerHistory_Args) bool { + if !((v.Request == nil && rhs.Request == nil) || (v.Request != nil && rhs.Request != nil && v.Request.Equals(rhs.Request))) { + return false + } + + return true +} + +// MethodName returns the name of the Thrift function as specified in +// the IDL, for which this struct represent the arguments. +// +// This will always be "GetPollerHistory" for this struct. +func (v *WorkflowService_GetPollerHistory_Args) MethodName() string { + return "GetPollerHistory" +} + +// EnvelopeType returns the kind of value inside this struct. +// +// This will always be Call for this struct. +func (v *WorkflowService_GetPollerHistory_Args) EnvelopeType() wire.EnvelopeType { + return wire.Call +} + +// WorkflowService_GetPollerHistory_Helper provides functions that aid in handling the +// parameters and return values of the WorkflowService.GetPollerHistory +// function. +var WorkflowService_GetPollerHistory_Helper = struct { + // Args accepts the parameters of GetPollerHistory in-order and returns + // the arguments struct for the function. + Args func( + request *shared.GetPollerHistoryRequest, + ) *WorkflowService_GetPollerHistory_Args + + // IsException returns true if the given error can be thrown + // by GetPollerHistory. + // + // An error can be thrown by GetPollerHistory only if the + // corresponding exception type was mentioned in the 'throws' + // section for it in the Thrift file. + IsException func(error) bool + + // WrapResponse returns the result struct for GetPollerHistory + // given its return value and error. + // + // This allows mapping values and errors returned by + // GetPollerHistory into a serializable result struct. + // WrapResponse returns a non-nil error if the provided + // error cannot be thrown by GetPollerHistory + // + // value, err := GetPollerHistory(args) + // result, err := WorkflowService_GetPollerHistory_Helper.WrapResponse(value, err) + // if err != nil { + // return fmt.Errorf("unexpected error from GetPollerHistory: %v", err) + // } + // serialize(result) + WrapResponse func(*shared.GetPollerHistoryResponse, error) (*WorkflowService_GetPollerHistory_Result, error) + + // UnwrapResponse takes the result struct for GetPollerHistory + // and returns the value or error returned by it. + // + // The error is non-nil only if GetPollerHistory threw an + // exception. + // + // result := deserialize(bytes) + // value, err := WorkflowService_GetPollerHistory_Helper.UnwrapResponse(result) + UnwrapResponse func(*WorkflowService_GetPollerHistory_Result) (*shared.GetPollerHistoryResponse, error) +}{} + +func init() { + WorkflowService_GetPollerHistory_Helper.Args = func( + request *shared.GetPollerHistoryRequest, + ) *WorkflowService_GetPollerHistory_Args { + return &WorkflowService_GetPollerHistory_Args{ + Request: request, + } + } + + WorkflowService_GetPollerHistory_Helper.IsException = func(err error) bool { + switch err.(type) { + case *shared.BadRequestError: + return true + case *shared.InternalServiceError: + return true + case *shared.EntityNotExistsError: + return true + default: + return false + } + } + + WorkflowService_GetPollerHistory_Helper.WrapResponse = func(success *shared.GetPollerHistoryResponse, err error) (*WorkflowService_GetPollerHistory_Result, error) { + if err == nil { + return &WorkflowService_GetPollerHistory_Result{Success: success}, nil + } + + switch e := err.(type) { + case *shared.BadRequestError: + if e == nil { + return nil, errors.New("WrapResponse received non-nil error type with nil value for WorkflowService_GetPollerHistory_Result.BadRequestError") + } + return &WorkflowService_GetPollerHistory_Result{BadRequestError: e}, nil + case *shared.InternalServiceError: + if e == nil { + return nil, errors.New("WrapResponse received non-nil error type with nil value for WorkflowService_GetPollerHistory_Result.InternalServiceError") + } + return &WorkflowService_GetPollerHistory_Result{InternalServiceError: e}, nil + case *shared.EntityNotExistsError: + if e == nil { + return nil, errors.New("WrapResponse received non-nil error type with nil value for WorkflowService_GetPollerHistory_Result.EntityNotExistError") + } + return &WorkflowService_GetPollerHistory_Result{EntityNotExistError: e}, nil + } + + return nil, err + } + WorkflowService_GetPollerHistory_Helper.UnwrapResponse = func(result *WorkflowService_GetPollerHistory_Result) (success *shared.GetPollerHistoryResponse, err error) { + if result.BadRequestError != nil { + err = result.BadRequestError + return + } + if result.InternalServiceError != nil { + err = result.InternalServiceError + return + } + if result.EntityNotExistError != nil { + err = result.EntityNotExistError + return + } + + if result.Success != nil { + success = result.Success + return + } + + err = errors.New("expected a non-void result") + return + } + +} + +// WorkflowService_GetPollerHistory_Result represents the result of a WorkflowService.GetPollerHistory function call. +// +// The result of a GetPollerHistory execution is sent and received over the wire as this struct. +// +// Success is set only if the function did not throw an exception. +type WorkflowService_GetPollerHistory_Result struct { + // Value returned by GetPollerHistory after a successful execution. + Success *shared.GetPollerHistoryResponse `json:"success,omitempty"` + BadRequestError *shared.BadRequestError `json:"badRequestError,omitempty"` + InternalServiceError *shared.InternalServiceError `json:"internalServiceError,omitempty"` + EntityNotExistError *shared.EntityNotExistsError `json:"entityNotExistError,omitempty"` +} + +// ToWire translates a WorkflowService_GetPollerHistory_Result struct into a Thrift-level intermediate +// representation. This intermediate representation may be serialized +// into bytes using a ThriftRW protocol implementation. +// +// An error is returned if the struct or any of its fields failed to +// validate. +// +// x, err := v.ToWire() +// if err != nil { +// return err +// } +// +// if err := binaryProtocol.Encode(x, writer); err != nil { +// return err +// } +func (v *WorkflowService_GetPollerHistory_Result) ToWire() (wire.Value, error) { + var ( + fields [4]wire.Field + i int = 0 + w wire.Value + err error + ) + + if v.Success != nil { + w, err = v.Success.ToWire() + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 0, Value: w} + i++ + } + if v.BadRequestError != nil { + w, err = v.BadRequestError.ToWire() + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 1, Value: w} + i++ + } + if v.InternalServiceError != nil { + w, err = v.InternalServiceError.ToWire() + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 2, Value: w} + i++ + } + if v.EntityNotExistError != nil { + w, err = v.EntityNotExistError.ToWire() + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 3, Value: w} + i++ + } + + if i != 1 { + return wire.Value{}, fmt.Errorf("WorkflowService_GetPollerHistory_Result should have exactly one field: got %v fields", i) + } + + return wire.NewValueStruct(wire.Struct{Fields: fields[:i]}), nil +} + +func _GetPollerHistoryResponse_Read(w wire.Value) (*shared.GetPollerHistoryResponse, error) { + var v shared.GetPollerHistoryResponse + err := v.FromWire(w) + return &v, err +} + +// FromWire deserializes a WorkflowService_GetPollerHistory_Result struct from its Thrift-level +// representation. The Thrift-level representation may be obtained +// from a ThriftRW protocol implementation. +// +// An error is returned if we were unable to build a WorkflowService_GetPollerHistory_Result struct +// from the provided intermediate representation. +// +// x, err := binaryProtocol.Decode(reader, wire.TStruct) +// if err != nil { +// return nil, err +// } +// +// var v WorkflowService_GetPollerHistory_Result +// if err := v.FromWire(x); err != nil { +// return nil, err +// } +// return &v, nil +func (v *WorkflowService_GetPollerHistory_Result) FromWire(w wire.Value) error { + var err error + + for _, field := range w.GetStruct().Fields { + switch field.ID { + case 0: + if field.Value.Type() == wire.TStruct { + v.Success, err = _GetPollerHistoryResponse_Read(field.Value) + if err != nil { + return err + } + + } + case 1: + if field.Value.Type() == wire.TStruct { + v.BadRequestError, err = _BadRequestError_Read(field.Value) + if err != nil { + return err + } + + } + case 2: + if field.Value.Type() == wire.TStruct { + v.InternalServiceError, err = _InternalServiceError_Read(field.Value) + if err != nil { + return err + } + + } + case 3: + if field.Value.Type() == wire.TStruct { + v.EntityNotExistError, err = _EntityNotExistsError_Read(field.Value) + if err != nil { + return err + } + + } + } + } + + count := 0 + if v.Success != nil { + count++ + } + if v.BadRequestError != nil { + count++ + } + if v.InternalServiceError != nil { + count++ + } + if v.EntityNotExistError != nil { + count++ + } + if count != 1 { + return fmt.Errorf("WorkflowService_GetPollerHistory_Result should have exactly one field: got %v fields", count) + } + + return nil +} + +// String returns a readable string representation of a WorkflowService_GetPollerHistory_Result +// struct. +func (v *WorkflowService_GetPollerHistory_Result) String() string { + if v == nil { + return "" + } + + var fields [4]string + i := 0 + if v.Success != nil { + fields[i] = fmt.Sprintf("Success: %v", v.Success) + i++ + } + if v.BadRequestError != nil { + fields[i] = fmt.Sprintf("BadRequestError: %v", v.BadRequestError) + i++ + } + if v.InternalServiceError != nil { + fields[i] = fmt.Sprintf("InternalServiceError: %v", v.InternalServiceError) + i++ + } + if v.EntityNotExistError != nil { + fields[i] = fmt.Sprintf("EntityNotExistError: %v", v.EntityNotExistError) + i++ + } + + return fmt.Sprintf("WorkflowService_GetPollerHistory_Result{%v}", strings.Join(fields[:i], ", ")) +} + +// Equals returns true if all the fields of this WorkflowService_GetPollerHistory_Result match the +// provided WorkflowService_GetPollerHistory_Result. +// +// This function performs a deep comparison. +func (v *WorkflowService_GetPollerHistory_Result) Equals(rhs *WorkflowService_GetPollerHistory_Result) bool { + if !((v.Success == nil && rhs.Success == nil) || (v.Success != nil && rhs.Success != nil && v.Success.Equals(rhs.Success))) { + return false + } + if !((v.BadRequestError == nil && rhs.BadRequestError == nil) || (v.BadRequestError != nil && rhs.BadRequestError != nil && v.BadRequestError.Equals(rhs.BadRequestError))) { + return false + } + if !((v.InternalServiceError == nil && rhs.InternalServiceError == nil) || (v.InternalServiceError != nil && rhs.InternalServiceError != nil && v.InternalServiceError.Equals(rhs.InternalServiceError))) { + return false + } + if !((v.EntityNotExistError == nil && rhs.EntityNotExistError == nil) || (v.EntityNotExistError != nil && rhs.EntityNotExistError != nil && v.EntityNotExistError.Equals(rhs.EntityNotExistError))) { + return false + } + + return true +} + +// MethodName returns the name of the Thrift function as specified in +// the IDL, for which this struct represent the result. +// +// This will always be "GetPollerHistory" for this struct. +func (v *WorkflowService_GetPollerHistory_Result) MethodName() string { + return "GetPollerHistory" +} + +// EnvelopeType returns the kind of value inside this struct. +// +// This will always be Reply for this struct. +func (v *WorkflowService_GetPollerHistory_Result) EnvelopeType() wire.EnvelopeType { + return wire.Reply +} diff --git a/.gen/go/cadence/workflowserviceclient/client.go b/.gen/go/cadence/workflowserviceclient/client.go index cf00d9538f5..2c3b1ae0f4d 100644 --- a/.gen/go/cadence/workflowserviceclient/client.go +++ b/.gen/go/cadence/workflowserviceclient/client.go @@ -54,6 +54,12 @@ type Interface interface { opts ...yarpc.CallOption, ) (*shared.DescribeWorkflowExecutionResponse, error) + GetPollerHistory( + ctx context.Context, + Request *shared.GetPollerHistoryRequest, + opts ...yarpc.CallOption, + ) (*shared.GetPollerHistoryResponse, error) + GetWorkflowExecutionHistory( ctx context.Context, GetRequest *shared.GetWorkflowExecutionHistoryRequest, @@ -280,6 +286,29 @@ func (c client) DescribeWorkflowExecution( return } +func (c client) GetPollerHistory( + ctx context.Context, + _Request *shared.GetPollerHistoryRequest, + opts ...yarpc.CallOption, +) (success *shared.GetPollerHistoryResponse, err error) { + + args := cadence.WorkflowService_GetPollerHistory_Helper.Args(_Request) + + var body wire.Value + body, err = c.c.Call(ctx, args, opts...) + if err != nil { + return + } + + var result cadence.WorkflowService_GetPollerHistory_Result + if err = result.FromWire(body); err != nil { + return + } + + success, err = cadence.WorkflowService_GetPollerHistory_Helper.UnwrapResponse(&result) + return +} + func (c client) GetWorkflowExecutionHistory( ctx context.Context, _GetRequest *shared.GetWorkflowExecutionHistoryRequest, diff --git a/.gen/go/cadence/workflowserviceserver/server.go b/.gen/go/cadence/workflowserviceserver/server.go index e4988c5b428..05af53644ef 100644 --- a/.gen/go/cadence/workflowserviceserver/server.go +++ b/.gen/go/cadence/workflowserviceserver/server.go @@ -49,6 +49,11 @@ type Interface interface { DescribeRequest *shared.DescribeWorkflowExecutionRequest, ) (*shared.DescribeWorkflowExecutionResponse, error) + GetPollerHistory( + ctx context.Context, + Request *shared.GetPollerHistoryRequest, + ) (*shared.GetPollerHistoryResponse, error) + GetWorkflowExecutionHistory( ctx context.Context, GetRequest *shared.GetWorkflowExecutionHistoryRequest, @@ -204,6 +209,17 @@ func New(impl Interface, opts ...thrift.RegisterOption) []transport.Procedure { ThriftModule: cadence.ThriftModule, }, + thrift.Method{ + Name: "GetPollerHistory", + HandlerSpec: thrift.HandlerSpec{ + + Type: transport.Unary, + Unary: thrift.UnaryHandler(h.GetPollerHistory), + }, + Signature: "GetPollerHistory(Request *shared.GetPollerHistoryRequest) (*shared.GetPollerHistoryResponse)", + ThriftModule: cadence.ThriftModule, + }, + thrift.Method{ Name: "GetWorkflowExecutionHistory", HandlerSpec: thrift.HandlerSpec{ @@ -448,7 +464,7 @@ func New(impl Interface, opts ...thrift.RegisterOption) []transport.Procedure { }, } - procedures := make([]transport.Procedure, 0, 25) + procedures := make([]transport.Procedure, 0, 26) procedures = append(procedures, thrift.BuildProcedures(service, opts...)...) return procedures } @@ -512,6 +528,25 @@ func (h handler) DescribeWorkflowExecution(ctx context.Context, body wire.Value) return response, err } +func (h handler) GetPollerHistory(ctx context.Context, body wire.Value) (thrift.Response, error) { + var args cadence.WorkflowService_GetPollerHistory_Args + if err := args.FromWire(body); err != nil { + return thrift.Response{}, err + } + + success, err := h.impl.GetPollerHistory(ctx, args.Request) + + hadError := err != nil + result, err := cadence.WorkflowService_GetPollerHistory_Helper.WrapResponse(success, err) + + var response thrift.Response + if err == nil { + response.IsApplicationError = hadError + response.Body = result + } + return response, err +} + func (h handler) GetWorkflowExecutionHistory(ctx context.Context, body wire.Value) (thrift.Response, error) { var args cadence.WorkflowService_GetWorkflowExecutionHistory_Args if err := args.FromWire(body); err != nil { diff --git a/.gen/go/cadence/workflowservicetest/client.go b/.gen/go/cadence/workflowservicetest/client.go index 0a0d60eb0c5..9cff175fe73 100644 --- a/.gen/go/cadence/workflowservicetest/client.go +++ b/.gen/go/cadence/workflowservicetest/client.go @@ -159,6 +159,39 @@ func (mr *_MockClientRecorder) DescribeWorkflowExecution( return mr.mock.ctrl.RecordCall(mr.mock, "DescribeWorkflowExecution", args...) } +// GetPollerHistory responds to a GetPollerHistory call based on the mock expectations. This +// call will fail if the mock does not expect this call. Use EXPECT to expect +// a call to this function. +// +// client.EXPECT().GetPollerHistory(gomock.Any(), ...).Return(...) +// ... := client.GetPollerHistory(...) +func (m *MockClient) GetPollerHistory( + ctx context.Context, + _Request *shared.GetPollerHistoryRequest, + opts ...yarpc.CallOption, +) (success *shared.GetPollerHistoryResponse, err error) { + + args := []interface{}{ctx, _Request} + for _, o := range opts { + args = append(args, o) + } + i := 0 + ret := m.ctrl.Call(m, "GetPollerHistory", args...) + success, _ = ret[i].(*shared.GetPollerHistoryResponse) + i++ + err, _ = ret[i].(error) + return +} + +func (mr *_MockClientRecorder) GetPollerHistory( + ctx interface{}, + _Request interface{}, + opts ...interface{}, +) *gomock.Call { + args := append([]interface{}{ctx, _Request}, opts...) + return mr.mock.ctrl.RecordCall(mr.mock, "GetPollerHistory", args...) +} + // GetWorkflowExecutionHistory responds to a GetWorkflowExecutionHistory call based on the mock expectations. This // call will fail if the mock does not expect this call. Use EXPECT to expect // a call to this function. diff --git a/.gen/go/matching/idl.go b/.gen/go/matching/idl.go index 50a65c1d283..26daa846658 100644 --- a/.gen/go/matching/idl.go +++ b/.gen/go/matching/idl.go @@ -33,11 +33,11 @@ var ThriftModule = &thriftreflect.ThriftModule{ Name: "matching", Package: "github.com/uber/cadence/.gen/go/matching", FilePath: "matching.thrift", - SHA1: "62f0b6bfd139230541a6ba51852469cf0a68ea4c", + SHA1: "b08e6bd582787dc8c99e67a39673e77fe8df086b", Includes: []*thriftreflect.ThriftModule{ shared.ThriftModule, }, Raw: rawIDL, } -const rawIDL = "// Copyright (c) 2017 Uber Technologies, Inc.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n\ninclude \"shared.thrift\"\n\nnamespace java com.uber.cadence.matching\n\nstruct PollForDecisionTaskRequest {\n 10: optional string domainUUID\n 15: optional string pollerID\n 20: optional shared.PollForDecisionTaskRequest pollRequest\n}\n\nstruct PollForDecisionTaskResponse {\n 10: optional binary taskToken\n 20: optional shared.WorkflowExecution workflowExecution\n 30: optional shared.WorkflowType workflowType\n 40: optional i64 (js.type = \"Long\") previousStartedEventId\n 50: optional i64 (js.type = \"Long\") startedEventId\n 51: optional i64 (js.type = \"Long\") attempt\n 60: optional i64 (js.type = \"Long\") nextEventId\n 65: optional i64 (js.type = \"Long\") backlogCountHint\n 70: optional bool stickyExecutionEnabled\n 80: optional shared.WorkflowQuery query\n 90: optional shared.TransientDecisionInfo decisionInfo\n}\n\nstruct PollForActivityTaskRequest {\n 10: optional string domainUUID\n 15: optional string pollerID\n 20: optional shared.PollForActivityTaskRequest pollRequest\n}\n\nstruct AddDecisionTaskRequest {\n 10: optional string domainUUID\n 20: optional shared.WorkflowExecution execution\n 30: optional shared.TaskList taskList\n 40: optional i64 (js.type = \"Long\") scheduleId\n 50: optional i32 scheduleToStartTimeoutSeconds\n}\n\nstruct AddActivityTaskRequest {\n 10: optional string domainUUID\n 20: optional shared.WorkflowExecution execution\n 30: optional string sourceDomainUUID\n 40: optional shared.TaskList taskList\n 50: optional i64 (js.type = \"Long\") scheduleId\n 60: optional i32 scheduleToStartTimeoutSeconds\n}\n\nstruct QueryWorkflowRequest {\n 10: optional string domainUUID\n 20: optional shared.TaskList taskList\n 30: optional shared.QueryWorkflowRequest queryRequest\n}\n\nstruct RespondQueryTaskCompletedRequest {\n 10: optional string domainUUID\n 20: optional shared.TaskList taskList\n 30: optional string taskID\n 40: optional shared.RespondQueryTaskCompletedRequest completedRequest\n}\n\nstruct CancelOutstandingPollRequest {\n 10: optional string domainUUID\n 20: optional i32 taskListType\n 30: optional shared.TaskList taskList\n 40: optional string pollerID\n}\n\n/**\n* MatchingService API is exposed to provide support for polling from long running applications.\n* Such applications are expected to have a worker which regularly polls for DecisionTask and ActivityTask. For each\n* DecisionTask, application is expected to process the history of events for that session and respond back with next\n* decisions. For each ActivityTask, application is expected to execute the actual logic for that task and respond back\n* with completion or failure.\n**/\nservice MatchingService {\n /**\n * PollForDecisionTask is called by frontend to process DecisionTask from a specific taskList. A\n * DecisionTask is dispatched to callers for active workflow executions, with pending decisions.\n **/\n PollForDecisionTaskResponse PollForDecisionTask(1: PollForDecisionTaskRequest pollRequest)\n throws (\n 1: shared.BadRequestError badRequestError,\n 2: shared.InternalServiceError internalServiceError,\n )\n\n /**\n * PollForActivityTask is called by frontend to process ActivityTask from a specific taskList. ActivityTask\n * is dispatched to callers whenever a ScheduleTask decision is made for a workflow execution.\n **/\n shared.PollForActivityTaskResponse PollForActivityTask(1: PollForActivityTaskRequest pollRequest)\n throws (\n 1: shared.BadRequestError badRequestError,\n 2: shared.InternalServiceError internalServiceError,\n )\n\n /**\n * AddDecisionTask is called by the history service when a decision task is scheduled, so that it can be dispatched\n * by the MatchingEngine.\n **/\n void AddDecisionTask(1: AddDecisionTaskRequest addRequest)\n throws (\n 1: shared.BadRequestError badRequestError,\n 2: shared.InternalServiceError internalServiceError,\n 3: shared.ServiceBusyError serviceBusyError,\n )\n\n /**\n * AddActivityTask is called by the history service when a decision task is scheduled, so that it can be dispatched\n * by the MatchingEngine.\n **/\n void AddActivityTask(1: AddActivityTaskRequest addRequest)\n throws (\n 1: shared.BadRequestError badRequestError,\n 2: shared.InternalServiceError internalServiceError,\n 3: shared.ServiceBusyError serviceBusyError,\n )\n\n /**\n * QueryWorkflow is called by frontend to query a workflow.\n **/\n shared.QueryWorkflowResponse QueryWorkflow(1: QueryWorkflowRequest queryRequest)\n\tthrows (\n\t 1: shared.BadRequestError badRequestError,\n\t 2: shared.InternalServiceError internalServiceError,\n\t 3: shared.EntityNotExistsError entityNotExistError,\n\t 4: shared.QueryFailedError queryFailedError,\n\t)\n\n /**\n * RespondQueryTaskCompleted is called by frontend to respond query completed.\n **/\n void RespondQueryTaskCompleted(1: RespondQueryTaskCompletedRequest request)\n\tthrows (\n\t 1: shared.BadRequestError badRequestError,\n\t 2: shared.InternalServiceError internalServiceError,\n\t 3: shared.EntityNotExistsError entityNotExistError,\n\t)\n\n /**\n * CancelOutstandingPoll is called by frontend to unblock long polls on matching for zombie pollers.\n * Our rpc stack does not support context propagation, so when a client connection goes away frontend sees\n * cancellation of context for that handler, but any corresponding calls (long-poll) to matching service does not\n * see the cancellation propagated so it can unblock corresponding long-polls on its end. This results is tasks\n * being dispatched to zombie pollers in this situation. This API is added so everytime frontend makes a long-poll\n * api call to matching it passes in a pollerID and then calls this API when it detects client connection is closed\n * to unblock long polls for this poller and prevent tasks being sent to these zombie pollers.\n **/\n void CancelOutstandingPoll(1: CancelOutstandingPollRequest request)\n throws (\n 1: shared.BadRequestError badRequestError,\n 2: shared.InternalServiceError internalServiceError,\n )\n\n}\n" +const rawIDL = "// Copyright (c) 2017 Uber Technologies, Inc.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n\ninclude \"shared.thrift\"\n\nnamespace java com.uber.cadence.matching\n\nstruct PollForDecisionTaskRequest {\n 10: optional string domainUUID\n 15: optional string pollerID\n 20: optional shared.PollForDecisionTaskRequest pollRequest\n}\n\nstruct PollForDecisionTaskResponse {\n 10: optional binary taskToken\n 20: optional shared.WorkflowExecution workflowExecution\n 30: optional shared.WorkflowType workflowType\n 40: optional i64 (js.type = \"Long\") previousStartedEventId\n 50: optional i64 (js.type = \"Long\") startedEventId\n 51: optional i64 (js.type = \"Long\") attempt\n 60: optional i64 (js.type = \"Long\") nextEventId\n 65: optional i64 (js.type = \"Long\") backlogCountHint\n 70: optional bool stickyExecutionEnabled\n 80: optional shared.WorkflowQuery query\n 90: optional shared.TransientDecisionInfo decisionInfo\n}\n\nstruct PollForActivityTaskRequest {\n 10: optional string domainUUID\n 15: optional string pollerID\n 20: optional shared.PollForActivityTaskRequest pollRequest\n}\n\nstruct AddDecisionTaskRequest {\n 10: optional string domainUUID\n 20: optional shared.WorkflowExecution execution\n 30: optional shared.TaskList taskList\n 40: optional i64 (js.type = \"Long\") scheduleId\n 50: optional i32 scheduleToStartTimeoutSeconds\n}\n\nstruct AddActivityTaskRequest {\n 10: optional string domainUUID\n 20: optional shared.WorkflowExecution execution\n 30: optional string sourceDomainUUID\n 40: optional shared.TaskList taskList\n 50: optional i64 (js.type = \"Long\") scheduleId\n 60: optional i32 scheduleToStartTimeoutSeconds\n}\n\nstruct QueryWorkflowRequest {\n 10: optional string domainUUID\n 20: optional shared.TaskList taskList\n 30: optional shared.QueryWorkflowRequest queryRequest\n}\n\nstruct RespondQueryTaskCompletedRequest {\n 10: optional string domainUUID\n 20: optional shared.TaskList taskList\n 30: optional string taskID\n 40: optional shared.RespondQueryTaskCompletedRequest completedRequest\n}\n\nstruct CancelOutstandingPollRequest {\n 10: optional string domainUUID\n 20: optional i32 taskListType\n 30: optional shared.TaskList taskList\n 40: optional string pollerID\n}\n\nstruct GetPollerHistoryRequest {\n 10: optional string domainUUID\n 20: optional shared.GetPollerHistoryRequest getRequest\n}\n\n/**\n* MatchingService API is exposed to provide support for polling from long running applications.\n* Such applications are expected to have a worker which regularly polls for DecisionTask and ActivityTask. For each\n* DecisionTask, application is expected to process the history of events for that session and respond back with next\n* decisions. For each ActivityTask, application is expected to execute the actual logic for that task and respond back\n* with completion or failure.\n**/\nservice MatchingService {\n /**\n * PollForDecisionTask is called by frontend to process DecisionTask from a specific taskList. A\n * DecisionTask is dispatched to callers for active workflow executions, with pending decisions.\n **/\n PollForDecisionTaskResponse PollForDecisionTask(1: PollForDecisionTaskRequest pollRequest)\n throws (\n 1: shared.BadRequestError badRequestError,\n 2: shared.InternalServiceError internalServiceError,\n )\n\n /**\n * PollForActivityTask is called by frontend to process ActivityTask from a specific taskList. ActivityTask\n * is dispatched to callers whenever a ScheduleTask decision is made for a workflow execution.\n **/\n shared.PollForActivityTaskResponse PollForActivityTask(1: PollForActivityTaskRequest pollRequest)\n throws (\n 1: shared.BadRequestError badRequestError,\n 2: shared.InternalServiceError internalServiceError,\n )\n\n /**\n * AddDecisionTask is called by the history service when a decision task is scheduled, so that it can be dispatched\n * by the MatchingEngine.\n **/\n void AddDecisionTask(1: AddDecisionTaskRequest addRequest)\n throws (\n 1: shared.BadRequestError badRequestError,\n 2: shared.InternalServiceError internalServiceError,\n 3: shared.ServiceBusyError serviceBusyError,\n )\n\n /**\n * AddActivityTask is called by the history service when a decision task is scheduled, so that it can be dispatched\n * by the MatchingEngine.\n **/\n void AddActivityTask(1: AddActivityTaskRequest addRequest)\n throws (\n 1: shared.BadRequestError badRequestError,\n 2: shared.InternalServiceError internalServiceError,\n 3: shared.ServiceBusyError serviceBusyError,\n )\n\n /**\n * QueryWorkflow is called by frontend to query a workflow.\n **/\n shared.QueryWorkflowResponse QueryWorkflow(1: QueryWorkflowRequest queryRequest)\n throws (\n 1: shared.BadRequestError badRequestError,\n 2: shared.InternalServiceError internalServiceError,\n 3: shared.EntityNotExistsError entityNotExistError,\n 4: shared.QueryFailedError queryFailedError,\n )\n\n /**\n * RespondQueryTaskCompleted is called by frontend to respond query completed.\n **/\n void RespondQueryTaskCompleted(1: RespondQueryTaskCompletedRequest request)\n throws (\n 1: shared.BadRequestError badRequestError,\n 2: shared.InternalServiceError internalServiceError,\n 3: shared.EntityNotExistsError entityNotExistError,\n )\n\n /**\n * CancelOutstandingPoll is called by frontend to unblock long polls on matching for zombie pollers.\n * Our rpc stack does not support context propagation, so when a client connection goes away frontend sees\n * cancellation of context for that handler, but any corresponding calls (long-poll) to matching service does not\n * see the cancellation propagated so it can unblock corresponding long-polls on its end. This results is tasks\n * being dispatched to zombie pollers in this situation. This API is added so everytime frontend makes a long-poll\n * api call to matching it passes in a pollerID and then calls this API when it detects client connection is closed\n * to unblock long polls for this poller and prevent tasks being sent to these zombie pollers.\n **/\n void CancelOutstandingPoll(1: CancelOutstandingPollRequest request)\n throws (\n 1: shared.BadRequestError badRequestError,\n 2: shared.InternalServiceError internalServiceError,\n )\n\n /**\n * GetPollerHistory returns pollers which poll from given tasklist in last few minutes.\n **/\n shared.GetPollerHistoryResponse GetPollerHistory(1: GetPollerHistoryRequest request)\n throws (\n 1: shared.BadRequestError badRequestError,\n 2: shared.InternalServiceError internalServiceError,\n 3: shared.EntityNotExistsError entityNotExistError,\n )\n}\n" diff --git a/.gen/go/matching/matchingservice_getpollerhistory.go b/.gen/go/matching/matchingservice_getpollerhistory.go new file mode 100644 index 00000000000..903d73007c0 --- /dev/null +++ b/.gen/go/matching/matchingservice_getpollerhistory.go @@ -0,0 +1,507 @@ +// Copyright (c) 2017 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. + +// Code generated by thriftrw v1.8.0. DO NOT EDIT. +// @generated + +package matching + +import ( + "errors" + "fmt" + "github.com/uber/cadence/.gen/go/shared" + "go.uber.org/thriftrw/wire" + "strings" +) + +// MatchingService_GetPollerHistory_Args represents the arguments for the MatchingService.GetPollerHistory function. +// +// The arguments for GetPollerHistory are sent and received over the wire as this struct. +type MatchingService_GetPollerHistory_Args struct { + Request *GetPollerHistoryRequest `json:"request,omitempty"` +} + +// ToWire translates a MatchingService_GetPollerHistory_Args struct into a Thrift-level intermediate +// representation. This intermediate representation may be serialized +// into bytes using a ThriftRW protocol implementation. +// +// An error is returned if the struct or any of its fields failed to +// validate. +// +// x, err := v.ToWire() +// if err != nil { +// return err +// } +// +// if err := binaryProtocol.Encode(x, writer); err != nil { +// return err +// } +func (v *MatchingService_GetPollerHistory_Args) ToWire() (wire.Value, error) { + var ( + fields [1]wire.Field + i int = 0 + w wire.Value + err error + ) + + if v.Request != nil { + w, err = v.Request.ToWire() + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 1, Value: w} + i++ + } + + return wire.NewValueStruct(wire.Struct{Fields: fields[:i]}), nil +} + +func _GetPollerHistoryRequest_1_Read(w wire.Value) (*GetPollerHistoryRequest, error) { + var v GetPollerHistoryRequest + err := v.FromWire(w) + return &v, err +} + +// FromWire deserializes a MatchingService_GetPollerHistory_Args struct from its Thrift-level +// representation. The Thrift-level representation may be obtained +// from a ThriftRW protocol implementation. +// +// An error is returned if we were unable to build a MatchingService_GetPollerHistory_Args struct +// from the provided intermediate representation. +// +// x, err := binaryProtocol.Decode(reader, wire.TStruct) +// if err != nil { +// return nil, err +// } +// +// var v MatchingService_GetPollerHistory_Args +// if err := v.FromWire(x); err != nil { +// return nil, err +// } +// return &v, nil +func (v *MatchingService_GetPollerHistory_Args) FromWire(w wire.Value) error { + var err error + + for _, field := range w.GetStruct().Fields { + switch field.ID { + case 1: + if field.Value.Type() == wire.TStruct { + v.Request, err = _GetPollerHistoryRequest_1_Read(field.Value) + if err != nil { + return err + } + + } + } + } + + return nil +} + +// String returns a readable string representation of a MatchingService_GetPollerHistory_Args +// struct. +func (v *MatchingService_GetPollerHistory_Args) String() string { + if v == nil { + return "" + } + + var fields [1]string + i := 0 + if v.Request != nil { + fields[i] = fmt.Sprintf("Request: %v", v.Request) + i++ + } + + return fmt.Sprintf("MatchingService_GetPollerHistory_Args{%v}", strings.Join(fields[:i], ", ")) +} + +// Equals returns true if all the fields of this MatchingService_GetPollerHistory_Args match the +// provided MatchingService_GetPollerHistory_Args. +// +// This function performs a deep comparison. +func (v *MatchingService_GetPollerHistory_Args) Equals(rhs *MatchingService_GetPollerHistory_Args) bool { + if !((v.Request == nil && rhs.Request == nil) || (v.Request != nil && rhs.Request != nil && v.Request.Equals(rhs.Request))) { + return false + } + + return true +} + +// MethodName returns the name of the Thrift function as specified in +// the IDL, for which this struct represent the arguments. +// +// This will always be "GetPollerHistory" for this struct. +func (v *MatchingService_GetPollerHistory_Args) MethodName() string { + return "GetPollerHistory" +} + +// EnvelopeType returns the kind of value inside this struct. +// +// This will always be Call for this struct. +func (v *MatchingService_GetPollerHistory_Args) EnvelopeType() wire.EnvelopeType { + return wire.Call +} + +// MatchingService_GetPollerHistory_Helper provides functions that aid in handling the +// parameters and return values of the MatchingService.GetPollerHistory +// function. +var MatchingService_GetPollerHistory_Helper = struct { + // Args accepts the parameters of GetPollerHistory in-order and returns + // the arguments struct for the function. + Args func( + request *GetPollerHistoryRequest, + ) *MatchingService_GetPollerHistory_Args + + // IsException returns true if the given error can be thrown + // by GetPollerHistory. + // + // An error can be thrown by GetPollerHistory only if the + // corresponding exception type was mentioned in the 'throws' + // section for it in the Thrift file. + IsException func(error) bool + + // WrapResponse returns the result struct for GetPollerHistory + // given its return value and error. + // + // This allows mapping values and errors returned by + // GetPollerHistory into a serializable result struct. + // WrapResponse returns a non-nil error if the provided + // error cannot be thrown by GetPollerHistory + // + // value, err := GetPollerHistory(args) + // result, err := MatchingService_GetPollerHistory_Helper.WrapResponse(value, err) + // if err != nil { + // return fmt.Errorf("unexpected error from GetPollerHistory: %v", err) + // } + // serialize(result) + WrapResponse func(*shared.GetPollerHistoryResponse, error) (*MatchingService_GetPollerHistory_Result, error) + + // UnwrapResponse takes the result struct for GetPollerHistory + // and returns the value or error returned by it. + // + // The error is non-nil only if GetPollerHistory threw an + // exception. + // + // result := deserialize(bytes) + // value, err := MatchingService_GetPollerHistory_Helper.UnwrapResponse(result) + UnwrapResponse func(*MatchingService_GetPollerHistory_Result) (*shared.GetPollerHistoryResponse, error) +}{} + +func init() { + MatchingService_GetPollerHistory_Helper.Args = func( + request *GetPollerHistoryRequest, + ) *MatchingService_GetPollerHistory_Args { + return &MatchingService_GetPollerHistory_Args{ + Request: request, + } + } + + MatchingService_GetPollerHistory_Helper.IsException = func(err error) bool { + switch err.(type) { + case *shared.BadRequestError: + return true + case *shared.InternalServiceError: + return true + case *shared.EntityNotExistsError: + return true + default: + return false + } + } + + MatchingService_GetPollerHistory_Helper.WrapResponse = func(success *shared.GetPollerHistoryResponse, err error) (*MatchingService_GetPollerHistory_Result, error) { + if err == nil { + return &MatchingService_GetPollerHistory_Result{Success: success}, nil + } + + switch e := err.(type) { + case *shared.BadRequestError: + if e == nil { + return nil, errors.New("WrapResponse received non-nil error type with nil value for MatchingService_GetPollerHistory_Result.BadRequestError") + } + return &MatchingService_GetPollerHistory_Result{BadRequestError: e}, nil + case *shared.InternalServiceError: + if e == nil { + return nil, errors.New("WrapResponse received non-nil error type with nil value for MatchingService_GetPollerHistory_Result.InternalServiceError") + } + return &MatchingService_GetPollerHistory_Result{InternalServiceError: e}, nil + case *shared.EntityNotExistsError: + if e == nil { + return nil, errors.New("WrapResponse received non-nil error type with nil value for MatchingService_GetPollerHistory_Result.EntityNotExistError") + } + return &MatchingService_GetPollerHistory_Result{EntityNotExistError: e}, nil + } + + return nil, err + } + MatchingService_GetPollerHistory_Helper.UnwrapResponse = func(result *MatchingService_GetPollerHistory_Result) (success *shared.GetPollerHistoryResponse, err error) { + if result.BadRequestError != nil { + err = result.BadRequestError + return + } + if result.InternalServiceError != nil { + err = result.InternalServiceError + return + } + if result.EntityNotExistError != nil { + err = result.EntityNotExistError + return + } + + if result.Success != nil { + success = result.Success + return + } + + err = errors.New("expected a non-void result") + return + } + +} + +// MatchingService_GetPollerHistory_Result represents the result of a MatchingService.GetPollerHistory function call. +// +// The result of a GetPollerHistory execution is sent and received over the wire as this struct. +// +// Success is set only if the function did not throw an exception. +type MatchingService_GetPollerHistory_Result struct { + // Value returned by GetPollerHistory after a successful execution. + Success *shared.GetPollerHistoryResponse `json:"success,omitempty"` + BadRequestError *shared.BadRequestError `json:"badRequestError,omitempty"` + InternalServiceError *shared.InternalServiceError `json:"internalServiceError,omitempty"` + EntityNotExistError *shared.EntityNotExistsError `json:"entityNotExistError,omitempty"` +} + +// ToWire translates a MatchingService_GetPollerHistory_Result struct into a Thrift-level intermediate +// representation. This intermediate representation may be serialized +// into bytes using a ThriftRW protocol implementation. +// +// An error is returned if the struct or any of its fields failed to +// validate. +// +// x, err := v.ToWire() +// if err != nil { +// return err +// } +// +// if err := binaryProtocol.Encode(x, writer); err != nil { +// return err +// } +func (v *MatchingService_GetPollerHistory_Result) ToWire() (wire.Value, error) { + var ( + fields [4]wire.Field + i int = 0 + w wire.Value + err error + ) + + if v.Success != nil { + w, err = v.Success.ToWire() + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 0, Value: w} + i++ + } + if v.BadRequestError != nil { + w, err = v.BadRequestError.ToWire() + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 1, Value: w} + i++ + } + if v.InternalServiceError != nil { + w, err = v.InternalServiceError.ToWire() + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 2, Value: w} + i++ + } + if v.EntityNotExistError != nil { + w, err = v.EntityNotExistError.ToWire() + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 3, Value: w} + i++ + } + + if i != 1 { + return wire.Value{}, fmt.Errorf("MatchingService_GetPollerHistory_Result should have exactly one field: got %v fields", i) + } + + return wire.NewValueStruct(wire.Struct{Fields: fields[:i]}), nil +} + +func _GetPollerHistoryResponse_Read(w wire.Value) (*shared.GetPollerHistoryResponse, error) { + var v shared.GetPollerHistoryResponse + err := v.FromWire(w) + return &v, err +} + +func _EntityNotExistsError_Read(w wire.Value) (*shared.EntityNotExistsError, error) { + var v shared.EntityNotExistsError + err := v.FromWire(w) + return &v, err +} + +// FromWire deserializes a MatchingService_GetPollerHistory_Result struct from its Thrift-level +// representation. The Thrift-level representation may be obtained +// from a ThriftRW protocol implementation. +// +// An error is returned if we were unable to build a MatchingService_GetPollerHistory_Result struct +// from the provided intermediate representation. +// +// x, err := binaryProtocol.Decode(reader, wire.TStruct) +// if err != nil { +// return nil, err +// } +// +// var v MatchingService_GetPollerHistory_Result +// if err := v.FromWire(x); err != nil { +// return nil, err +// } +// return &v, nil +func (v *MatchingService_GetPollerHistory_Result) FromWire(w wire.Value) error { + var err error + + for _, field := range w.GetStruct().Fields { + switch field.ID { + case 0: + if field.Value.Type() == wire.TStruct { + v.Success, err = _GetPollerHistoryResponse_Read(field.Value) + if err != nil { + return err + } + + } + case 1: + if field.Value.Type() == wire.TStruct { + v.BadRequestError, err = _BadRequestError_Read(field.Value) + if err != nil { + return err + } + + } + case 2: + if field.Value.Type() == wire.TStruct { + v.InternalServiceError, err = _InternalServiceError_Read(field.Value) + if err != nil { + return err + } + + } + case 3: + if field.Value.Type() == wire.TStruct { + v.EntityNotExistError, err = _EntityNotExistsError_Read(field.Value) + if err != nil { + return err + } + + } + } + } + + count := 0 + if v.Success != nil { + count++ + } + if v.BadRequestError != nil { + count++ + } + if v.InternalServiceError != nil { + count++ + } + if v.EntityNotExistError != nil { + count++ + } + if count != 1 { + return fmt.Errorf("MatchingService_GetPollerHistory_Result should have exactly one field: got %v fields", count) + } + + return nil +} + +// String returns a readable string representation of a MatchingService_GetPollerHistory_Result +// struct. +func (v *MatchingService_GetPollerHistory_Result) String() string { + if v == nil { + return "" + } + + var fields [4]string + i := 0 + if v.Success != nil { + fields[i] = fmt.Sprintf("Success: %v", v.Success) + i++ + } + if v.BadRequestError != nil { + fields[i] = fmt.Sprintf("BadRequestError: %v", v.BadRequestError) + i++ + } + if v.InternalServiceError != nil { + fields[i] = fmt.Sprintf("InternalServiceError: %v", v.InternalServiceError) + i++ + } + if v.EntityNotExistError != nil { + fields[i] = fmt.Sprintf("EntityNotExistError: %v", v.EntityNotExistError) + i++ + } + + return fmt.Sprintf("MatchingService_GetPollerHistory_Result{%v}", strings.Join(fields[:i], ", ")) +} + +// Equals returns true if all the fields of this MatchingService_GetPollerHistory_Result match the +// provided MatchingService_GetPollerHistory_Result. +// +// This function performs a deep comparison. +func (v *MatchingService_GetPollerHistory_Result) Equals(rhs *MatchingService_GetPollerHistory_Result) bool { + if !((v.Success == nil && rhs.Success == nil) || (v.Success != nil && rhs.Success != nil && v.Success.Equals(rhs.Success))) { + return false + } + if !((v.BadRequestError == nil && rhs.BadRequestError == nil) || (v.BadRequestError != nil && rhs.BadRequestError != nil && v.BadRequestError.Equals(rhs.BadRequestError))) { + return false + } + if !((v.InternalServiceError == nil && rhs.InternalServiceError == nil) || (v.InternalServiceError != nil && rhs.InternalServiceError != nil && v.InternalServiceError.Equals(rhs.InternalServiceError))) { + return false + } + if !((v.EntityNotExistError == nil && rhs.EntityNotExistError == nil) || (v.EntityNotExistError != nil && rhs.EntityNotExistError != nil && v.EntityNotExistError.Equals(rhs.EntityNotExistError))) { + return false + } + + return true +} + +// MethodName returns the name of the Thrift function as specified in +// the IDL, for which this struct represent the result. +// +// This will always be "GetPollerHistory" for this struct. +func (v *MatchingService_GetPollerHistory_Result) MethodName() string { + return "GetPollerHistory" +} + +// EnvelopeType returns the kind of value inside this struct. +// +// This will always be Reply for this struct. +func (v *MatchingService_GetPollerHistory_Result) EnvelopeType() wire.EnvelopeType { + return wire.Reply +} diff --git a/.gen/go/matching/matchingservice_queryworkflow.go b/.gen/go/matching/matchingservice_queryworkflow.go index db3b8a88e68..77396343af1 100644 --- a/.gen/go/matching/matchingservice_queryworkflow.go +++ b/.gen/go/matching/matchingservice_queryworkflow.go @@ -378,12 +378,6 @@ func _QueryWorkflowResponse_Read(w wire.Value) (*shared.QueryWorkflowResponse, e return &v, err } -func _EntityNotExistsError_Read(w wire.Value) (*shared.EntityNotExistsError, error) { - var v shared.EntityNotExistsError - err := v.FromWire(w) - return &v, err -} - func _QueryFailedError_Read(w wire.Value) (*shared.QueryFailedError, error) { var v shared.QueryFailedError err := v.FromWire(w) diff --git a/.gen/go/matching/matchingserviceclient/client.go b/.gen/go/matching/matchingserviceclient/client.go index d1088a748cf..05debbc41f4 100644 --- a/.gen/go/matching/matchingserviceclient/client.go +++ b/.gen/go/matching/matchingserviceclient/client.go @@ -54,6 +54,12 @@ type Interface interface { opts ...yarpc.CallOption, ) error + GetPollerHistory( + ctx context.Context, + Request *matching.GetPollerHistoryRequest, + opts ...yarpc.CallOption, + ) (*shared.GetPollerHistoryResponse, error) + PollForActivityTask( ctx context.Context, PollRequest *matching.PollForActivityTaskRequest, @@ -172,6 +178,29 @@ func (c client) CancelOutstandingPoll( return } +func (c client) GetPollerHistory( + ctx context.Context, + _Request *matching.GetPollerHistoryRequest, + opts ...yarpc.CallOption, +) (success *shared.GetPollerHistoryResponse, err error) { + + args := matching.MatchingService_GetPollerHistory_Helper.Args(_Request) + + var body wire.Value + body, err = c.c.Call(ctx, args, opts...) + if err != nil { + return + } + + var result matching.MatchingService_GetPollerHistory_Result + if err = result.FromWire(body); err != nil { + return + } + + success, err = matching.MatchingService_GetPollerHistory_Helper.UnwrapResponse(&result) + return +} + func (c client) PollForActivityTask( ctx context.Context, _PollRequest *matching.PollForActivityTaskRequest, diff --git a/.gen/go/matching/matchingserviceserver/server.go b/.gen/go/matching/matchingserviceserver/server.go index 686a8b0df1a..87879a5f490 100644 --- a/.gen/go/matching/matchingserviceserver/server.go +++ b/.gen/go/matching/matchingserviceserver/server.go @@ -49,6 +49,11 @@ type Interface interface { Request *matching.CancelOutstandingPollRequest, ) error + GetPollerHistory( + ctx context.Context, + Request *matching.GetPollerHistoryRequest, + ) (*shared.GetPollerHistoryResponse, error) + PollForActivityTask( ctx context.Context, PollRequest *matching.PollForActivityTaskRequest, @@ -114,6 +119,17 @@ func New(impl Interface, opts ...thrift.RegisterOption) []transport.Procedure { ThriftModule: matching.ThriftModule, }, + thrift.Method{ + Name: "GetPollerHistory", + HandlerSpec: thrift.HandlerSpec{ + + Type: transport.Unary, + Unary: thrift.UnaryHandler(h.GetPollerHistory), + }, + Signature: "GetPollerHistory(Request *matching.GetPollerHistoryRequest) (*shared.GetPollerHistoryResponse)", + ThriftModule: matching.ThriftModule, + }, + thrift.Method{ Name: "PollForActivityTask", HandlerSpec: thrift.HandlerSpec{ @@ -160,7 +176,7 @@ func New(impl Interface, opts ...thrift.RegisterOption) []transport.Procedure { }, } - procedures := make([]transport.Procedure, 0, 7) + procedures := make([]transport.Procedure, 0, 8) procedures = append(procedures, thrift.BuildProcedures(service, opts...)...) return procedures } @@ -224,6 +240,25 @@ func (h handler) CancelOutstandingPoll(ctx context.Context, body wire.Value) (th return response, err } +func (h handler) GetPollerHistory(ctx context.Context, body wire.Value) (thrift.Response, error) { + var args matching.MatchingService_GetPollerHistory_Args + if err := args.FromWire(body); err != nil { + return thrift.Response{}, err + } + + success, err := h.impl.GetPollerHistory(ctx, args.Request) + + hadError := err != nil + result, err := matching.MatchingService_GetPollerHistory_Helper.WrapResponse(success, err) + + var response thrift.Response + if err == nil { + response.IsApplicationError = hadError + response.Body = result + } + return response, err +} + func (h handler) PollForActivityTask(ctx context.Context, body wire.Value) (thrift.Response, error) { var args matching.MatchingService_PollForActivityTask_Args if err := args.FromWire(body); err != nil { diff --git a/.gen/go/matching/matchingservicetest/client.go b/.gen/go/matching/matchingservicetest/client.go index d19af0f3bde..f5fee34fe30 100644 --- a/.gen/go/matching/matchingservicetest/client.go +++ b/.gen/go/matching/matchingservicetest/client.go @@ -156,6 +156,39 @@ func (mr *_MockClientRecorder) CancelOutstandingPoll( return mr.mock.ctrl.RecordCall(mr.mock, "CancelOutstandingPoll", args...) } +// GetPollerHistory responds to a GetPollerHistory call based on the mock expectations. This +// call will fail if the mock does not expect this call. Use EXPECT to expect +// a call to this function. +// +// client.EXPECT().GetPollerHistory(gomock.Any(), ...).Return(...) +// ... := client.GetPollerHistory(...) +func (m *MockClient) GetPollerHistory( + ctx context.Context, + _Request *matching.GetPollerHistoryRequest, + opts ...yarpc.CallOption, +) (success *shared.GetPollerHistoryResponse, err error) { + + args := []interface{}{ctx, _Request} + for _, o := range opts { + args = append(args, o) + } + i := 0 + ret := m.ctrl.Call(m, "GetPollerHistory", args...) + success, _ = ret[i].(*shared.GetPollerHistoryResponse) + i++ + err, _ = ret[i].(error) + return +} + +func (mr *_MockClientRecorder) GetPollerHistory( + ctx interface{}, + _Request interface{}, + opts ...interface{}, +) *gomock.Call { + args := append([]interface{}{ctx, _Request}, opts...) + return mr.mock.ctrl.RecordCall(mr.mock, "GetPollerHistory", args...) +} + // PollForActivityTask responds to a PollForActivityTask call based on the mock expectations. This // call will fail if the mock does not expect this call. Use EXPECT to expect // a call to this function. diff --git a/.gen/go/matching/types.go b/.gen/go/matching/types.go index a3009ef31c2..1df0bd6db3c 100644 --- a/.gen/go/matching/types.go +++ b/.gen/go/matching/types.go @@ -793,6 +793,152 @@ func (v *CancelOutstandingPollRequest) GetPollerID() (o string) { return } +type GetPollerHistoryRequest struct { + DomainUUID *string `json:"domainUUID,omitempty"` + GetRequest *shared.GetPollerHistoryRequest `json:"getRequest,omitempty"` +} + +// ToWire translates a GetPollerHistoryRequest struct into a Thrift-level intermediate +// representation. This intermediate representation may be serialized +// into bytes using a ThriftRW protocol implementation. +// +// An error is returned if the struct or any of its fields failed to +// validate. +// +// x, err := v.ToWire() +// if err != nil { +// return err +// } +// +// if err := binaryProtocol.Encode(x, writer); err != nil { +// return err +// } +func (v *GetPollerHistoryRequest) ToWire() (wire.Value, error) { + var ( + fields [2]wire.Field + i int = 0 + w wire.Value + err error + ) + + if v.DomainUUID != nil { + w, err = wire.NewValueString(*(v.DomainUUID)), error(nil) + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 10, Value: w} + i++ + } + if v.GetRequest != nil { + w, err = v.GetRequest.ToWire() + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 20, Value: w} + i++ + } + + return wire.NewValueStruct(wire.Struct{Fields: fields[:i]}), nil +} + +func _GetPollerHistoryRequest_Read(w wire.Value) (*shared.GetPollerHistoryRequest, error) { + var v shared.GetPollerHistoryRequest + err := v.FromWire(w) + return &v, err +} + +// FromWire deserializes a GetPollerHistoryRequest struct from its Thrift-level +// representation. The Thrift-level representation may be obtained +// from a ThriftRW protocol implementation. +// +// An error is returned if we were unable to build a GetPollerHistoryRequest struct +// from the provided intermediate representation. +// +// x, err := binaryProtocol.Decode(reader, wire.TStruct) +// if err != nil { +// return nil, err +// } +// +// var v GetPollerHistoryRequest +// if err := v.FromWire(x); err != nil { +// return nil, err +// } +// return &v, nil +func (v *GetPollerHistoryRequest) FromWire(w wire.Value) error { + var err error + + for _, field := range w.GetStruct().Fields { + switch field.ID { + case 10: + if field.Value.Type() == wire.TBinary { + var x string + x, err = field.Value.GetString(), error(nil) + v.DomainUUID = &x + if err != nil { + return err + } + + } + case 20: + if field.Value.Type() == wire.TStruct { + v.GetRequest, err = _GetPollerHistoryRequest_Read(field.Value) + if err != nil { + return err + } + + } + } + } + + return nil +} + +// String returns a readable string representation of a GetPollerHistoryRequest +// struct. +func (v *GetPollerHistoryRequest) String() string { + if v == nil { + return "" + } + + var fields [2]string + i := 0 + if v.DomainUUID != nil { + fields[i] = fmt.Sprintf("DomainUUID: %v", *(v.DomainUUID)) + i++ + } + if v.GetRequest != nil { + fields[i] = fmt.Sprintf("GetRequest: %v", v.GetRequest) + i++ + } + + return fmt.Sprintf("GetPollerHistoryRequest{%v}", strings.Join(fields[:i], ", ")) +} + +// Equals returns true if all the fields of this GetPollerHistoryRequest match the +// provided GetPollerHistoryRequest. +// +// This function performs a deep comparison. +func (v *GetPollerHistoryRequest) Equals(rhs *GetPollerHistoryRequest) bool { + if !_String_EqualsPtr(v.DomainUUID, rhs.DomainUUID) { + return false + } + if !((v.GetRequest == nil && rhs.GetRequest == nil) || (v.GetRequest != nil && rhs.GetRequest != nil && v.GetRequest.Equals(rhs.GetRequest))) { + return false + } + + return true +} + +// GetDomainUUID returns the value of DomainUUID if it is set or its +// zero value if it is unset. +func (v *GetPollerHistoryRequest) GetDomainUUID() (o string) { + if v.DomainUUID != nil { + return *v.DomainUUID + } + + return +} + type PollForActivityTaskRequest struct { DomainUUID *string `json:"domainUUID,omitempty"` PollerID *string `json:"pollerID,omitempty"` diff --git a/.gen/go/shared/idl.go b/.gen/go/shared/idl.go index ace0c4bb7b1..fb97be53967 100644 --- a/.gen/go/shared/idl.go +++ b/.gen/go/shared/idl.go @@ -30,8 +30,8 @@ var ThriftModule = &thriftreflect.ThriftModule{ Name: "shared", Package: "github.com/uber/cadence/.gen/go/shared", FilePath: "shared.thrift", - SHA1: "b99e79243700c10b446aa60ecac70d4e1d567759", + SHA1: "c8e3b24f64d226104d5dbcd6ece100a756e869d5", Raw: rawIDL, } -const rawIDL = "// Copyright (c) 2017 Uber Technologies, Inc.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n\nnamespace java com.uber.cadence\n\nexception BadRequestError {\n 1: required string message\n}\n\nexception InternalServiceError {\n 1: required string message\n}\n\nexception DomainAlreadyExistsError {\n 1: required string message\n}\n\nexception WorkflowExecutionAlreadyStartedError {\n 10: optional string message\n 20: optional string startRequestId\n 30: optional string runId\n}\n\nexception EntityNotExistsError {\n 1: required string message\n}\n\nexception ServiceBusyError {\n 1: required string message\n}\n\nexception CancellationAlreadyRequestedError {\n 1: required string message\n}\n\nexception QueryFailedError {\n 1: required string message\n}\n\nenum WorkflowIdReusePolicy {\n /*\n * allow start a workflow execution using the same workflow ID,\n * when workflow not running, and the last execution close state is in\n * [terminated, cancelled, timeouted, failed].\n */\n AllowDuplicateFailedOnly,\n /*\n * allow start a workflow execution using the same workflow ID,\n * when workflow not running.\n */\n AllowDuplicate,\n /*\n * do not allow start a workflow execution using the same workflow ID at all\n */\n RejectDuplicate,\n}\n\nenum DomainStatus {\n REGISTERED,\n DEPRECATED,\n DELETED,\n}\n\nenum TimeoutType {\n START_TO_CLOSE,\n SCHEDULE_TO_START,\n SCHEDULE_TO_CLOSE,\n HEARTBEAT,\n}\n\nenum DecisionType {\n ScheduleActivityTask,\n RequestCancelActivityTask,\n StartTimer,\n CompleteWorkflowExecution,\n FailWorkflowExecution,\n CancelTimer,\n CancelWorkflowExecution,\n RequestCancelExternalWorkflowExecution,\n RecordMarker,\n ContinueAsNewWorkflowExecution,\n StartChildWorkflowExecution,\n}\n\nenum EventType {\n WorkflowExecutionStarted,\n WorkflowExecutionCompleted,\n WorkflowExecutionFailed,\n WorkflowExecutionTimedOut,\n DecisionTaskScheduled,\n DecisionTaskStarted,\n DecisionTaskCompleted,\n DecisionTaskTimedOut\n DecisionTaskFailed,\n ActivityTaskScheduled,\n ActivityTaskStarted,\n ActivityTaskCompleted,\n ActivityTaskFailed,\n ActivityTaskTimedOut,\n ActivityTaskCancelRequested,\n RequestCancelActivityTaskFailed,\n ActivityTaskCanceled,\n TimerStarted,\n TimerFired,\n CancelTimerFailed,\n TimerCanceled,\n WorkflowExecutionCancelRequested,\n WorkflowExecutionCanceled,\n RequestCancelExternalWorkflowExecutionInitiated,\n RequestCancelExternalWorkflowExecutionFailed,\n ExternalWorkflowExecutionCancelRequested,\n MarkerRecorded,\n WorkflowExecutionSignaled,\n WorkflowExecutionTerminated,\n WorkflowExecutionContinuedAsNew,\n StartChildWorkflowExecutionInitiated,\n StartChildWorkflowExecutionFailed,\n ChildWorkflowExecutionStarted,\n ChildWorkflowExecutionCompleted,\n ChildWorkflowExecutionFailed,\n ChildWorkflowExecutionCanceled,\n ChildWorkflowExecutionTimedOut,\n ChildWorkflowExecutionTerminated,\n}\n\nenum DecisionTaskFailedCause {\n UNHANDLED_DECISION,\n BAD_SCHEDULE_ACTIVITY_ATTRIBUTES,\n BAD_REQUEST_CANCEL_ACTIVITY_ATTRIBUTES,\n BAD_START_TIMER_ATTRIBUTES,\n BAD_CANCEL_TIMER_ATTRIBUTES,\n BAD_RECORD_MARKER_ATTRIBUTES,\n BAD_COMPLETE_WORKFLOW_EXECUTION_ATTRIBUTES,\n BAD_FAIL_WORKFLOW_EXECUTION_ATTRIBUTES,\n BAD_CANCEL_WORKFLOW_EXECUTION_ATTRIBUTES,\n BAD_REQUEST_CANCEL_EXTERNAL_WORKFLOW_EXECUTION_ATTRIBUTES,\n BAD_CONTINUE_AS_NEW_ATTRIBUTES,\n START_TIMER_DUPLICATE_ID,\n RESET_STICKY_TASKLIST,\n WORKFLOW_WORKER_UNHANDLED_FAILURE\n}\n\nenum CancelExternalWorkflowExecutionFailedCause {\n UNKNOWN_EXTERNAL_WORKFLOW_EXECUTION,\n}\n\nenum ChildWorkflowExecutionFailedCause {\n WORKFLOW_ALREADY_RUNNING,\n}\n\nenum WorkflowExecutionCloseStatus {\n COMPLETED,\n FAILED,\n CANCELED,\n TERMINATED,\n CONTINUED_AS_NEW,\n TIMED_OUT,\n}\n\nenum ChildPolicy {\n TERMINATE,\n REQUEST_CANCEL,\n ABANDON,\n}\n\nenum QueryTaskCompletedType {\n COMPLETED,\n FAILED,\n}\n\nstruct WorkflowType {\n 10: optional string name\n}\n\nstruct ActivityType {\n 10: optional string name\n}\n\nstruct TaskList {\n 10: optional string name\n}\n\nstruct TaskListMetadata {\n 10: optional double maxTasksPerSecond\n}\n\nstruct WorkflowExecution {\n 10: optional string workflowId\n 20: optional string runId\n}\n\nstruct WorkflowExecutionInfo {\n 10: optional WorkflowExecution execution\n 20: optional WorkflowType type\n 30: optional i64 (js.type = \"Long\") startTime\n 40: optional i64 (js.type = \"Long\") closeTime\n 50: optional WorkflowExecutionCloseStatus closeStatus\n 60: optional i64 (js.type = \"Long\") historyLength\n}\n\nstruct WorkflowExecutionConfiguration {\n 10: optional TaskList taskList\n 20: optional i32 executionStartToCloseTimeoutSeconds\n 30: optional i32 taskStartToCloseTimeoutSeconds\n 40: optional ChildPolicy childPolicy\n}\n\nstruct TransientDecisionInfo {\n 10: optional HistoryEvent scheduledEvent\n 20: optional HistoryEvent startedEvent\n}\n\nstruct ScheduleActivityTaskDecisionAttributes {\n 10: optional string activityId\n 20: optional ActivityType activityType\n 25: optional string domain\n 30: optional TaskList taskList\n 40: optional binary input\n 45: optional i32 scheduleToCloseTimeoutSeconds\n 50: optional i32 scheduleToStartTimeoutSeconds\n 55: optional i32 startToCloseTimeoutSeconds\n 60: optional i32 heartbeatTimeoutSeconds\n}\n\nstruct RequestCancelActivityTaskDecisionAttributes {\n 10: optional string activityId\n}\n\nstruct StartTimerDecisionAttributes {\n 10: optional string timerId\n 20: optional i64 (js.type = \"Long\") startToFireTimeoutSeconds\n}\n\nstruct CompleteWorkflowExecutionDecisionAttributes {\n 10: optional binary result\n}\n\nstruct FailWorkflowExecutionDecisionAttributes {\n 10: optional string reason\n 20: optional binary details\n}\n\nstruct CancelTimerDecisionAttributes {\n 10: optional string timerId\n}\n\nstruct CancelWorkflowExecutionDecisionAttributes {\n 10: optional binary details\n}\n\nstruct RequestCancelExternalWorkflowExecutionDecisionAttributes {\n 10: optional string domain\n 20: optional string workflowId\n 30: optional string runId\n 40: optional binary control\n}\n\nstruct RecordMarkerDecisionAttributes {\n 10: optional string markerName\n 20: optional binary details\n}\n\nstruct ContinueAsNewWorkflowExecutionDecisionAttributes {\n 10: optional WorkflowType workflowType\n 20: optional TaskList taskList\n 30: optional binary input\n 40: optional i32 executionStartToCloseTimeoutSeconds\n 50: optional i32 taskStartToCloseTimeoutSeconds\n}\n\nstruct StartChildWorkflowExecutionDecisionAttributes {\n 10: optional string domain\n 20: optional string workflowId\n 30: optional WorkflowType workflowType\n 40: optional TaskList taskList\n 50: optional binary input\n 60: optional i32 executionStartToCloseTimeoutSeconds\n 70: optional i32 taskStartToCloseTimeoutSeconds\n 80: optional ChildPolicy childPolicy\n 90: optional binary control\n}\n\nstruct Decision {\n 10: optional DecisionType decisionType\n 20: optional ScheduleActivityTaskDecisionAttributes scheduleActivityTaskDecisionAttributes\n 25: optional StartTimerDecisionAttributes startTimerDecisionAttributes\n 30: optional CompleteWorkflowExecutionDecisionAttributes completeWorkflowExecutionDecisionAttributes\n 35: optional FailWorkflowExecutionDecisionAttributes failWorkflowExecutionDecisionAttributes\n 40: optional RequestCancelActivityTaskDecisionAttributes requestCancelActivityTaskDecisionAttributes\n 50: optional CancelTimerDecisionAttributes cancelTimerDecisionAttributes\n 60: optional CancelWorkflowExecutionDecisionAttributes cancelWorkflowExecutionDecisionAttributes\n 70: optional RequestCancelExternalWorkflowExecutionDecisionAttributes requestCancelExternalWorkflowExecutionDecisionAttributes\n 80: optional RecordMarkerDecisionAttributes recordMarkerDecisionAttributes\n 90: optional ContinueAsNewWorkflowExecutionDecisionAttributes continueAsNewWorkflowExecutionDecisionAttributes\n 100: optional StartChildWorkflowExecutionDecisionAttributes startChildWorkflowExecutionDecisionAttributes\n}\n\nstruct WorkflowExecutionStartedEventAttributes {\n 10: optional WorkflowType workflowType\n 20: optional TaskList taskList\n 30: optional binary input\n 40: optional i32 executionStartToCloseTimeoutSeconds\n 50: optional i32 taskStartToCloseTimeoutSeconds\n 60: optional string identity\n}\n\nstruct WorkflowExecutionCompletedEventAttributes {\n 10: optional binary result\n 20: optional i64 (js.type = \"Long\") decisionTaskCompletedEventId\n}\n\nstruct WorkflowExecutionFailedEventAttributes {\n 10: optional string reason\n 20: optional binary details\n 30: optional i64 (js.type = \"Long\") decisionTaskCompletedEventId\n}\n\nstruct WorkflowExecutionTimedOutEventAttributes {\n 10: optional TimeoutType timeoutType\n}\n\nstruct WorkflowExecutionContinuedAsNewEventAttributes {\n 10: optional string newExecutionRunId\n 20: optional WorkflowType workflowType\n 30: optional TaskList taskList\n 40: optional binary input\n 50: optional i32 executionStartToCloseTimeoutSeconds\n 60: optional i32 taskStartToCloseTimeoutSeconds\n 70: optional i64 (js.type = \"Long\") decisionTaskCompletedEventId\n}\n\nstruct DecisionTaskScheduledEventAttributes {\n 10: optional TaskList taskList\n 20: optional i32 startToCloseTimeoutSeconds\n 30: optional i64 (js.type = \"Long\") attempt\n}\n\nstruct DecisionTaskStartedEventAttributes {\n 10: optional i64 (js.type = \"Long\") scheduledEventId\n 20: optional string identity\n 30: optional string requestId\n}\n\nstruct DecisionTaskCompletedEventAttributes {\n 10: optional binary executionContext\n 20: optional i64 (js.type = \"Long\") scheduledEventId\n 30: optional i64 (js.type = \"Long\") startedEventId\n 40: optional string identity\n}\n\nstruct DecisionTaskTimedOutEventAttributes {\n 10: optional i64 (js.type = \"Long\") scheduledEventId\n 20: optional i64 (js.type = \"Long\") startedEventId\n 30: optional TimeoutType timeoutType\n}\n\nstruct DecisionTaskFailedEventAttributes {\n 10: optional i64 (js.type = \"Long\") scheduledEventId\n 20: optional i64 (js.type = \"Long\") startedEventId\n 30: optional DecisionTaskFailedCause cause\n 35: optional binary details\n 40: optional string identity\n}\n\nstruct ActivityTaskScheduledEventAttributes {\n 10: optional string activityId\n 20: optional ActivityType activityType\n 25: optional string domain\n 30: optional TaskList taskList\n 40: optional binary input\n 45: optional i32 scheduleToCloseTimeoutSeconds\n 50: optional i32 scheduleToStartTimeoutSeconds\n 55: optional i32 startToCloseTimeoutSeconds\n 60: optional i32 heartbeatTimeoutSeconds\n 90: optional i64 (js.type = \"Long\") decisionTaskCompletedEventId\n}\n\nstruct ActivityTaskStartedEventAttributes {\n 10: optional i64 (js.type = \"Long\") scheduledEventId\n 20: optional string identity\n 30: optional string requestId\n}\n\nstruct ActivityTaskCompletedEventAttributes {\n 10: optional binary result\n 20: optional i64 (js.type = \"Long\") scheduledEventId\n 30: optional i64 (js.type = \"Long\") startedEventId\n 40: optional string identity\n}\n\nstruct ActivityTaskFailedEventAttributes {\n 10: optional string reason\n 20: optional binary details\n 30: optional i64 (js.type = \"Long\") scheduledEventId\n 40: optional i64 (js.type = \"Long\") startedEventId\n 50: optional string identity\n}\n\nstruct ActivityTaskTimedOutEventAttributes {\n 05: optional binary details\n 10: optional i64 (js.type = \"Long\") scheduledEventId\n 20: optional i64 (js.type = \"Long\") startedEventId\n 30: optional TimeoutType timeoutType\n}\n\nstruct ActivityTaskCancelRequestedEventAttributes {\n 10: optional string activityId\n 20: optional i64 (js.type = \"Long\") decisionTaskCompletedEventId\n}\n\nstruct RequestCancelActivityTaskFailedEventAttributes{\n 10: optional string activityId\n 20: optional string cause\n 30: optional i64 (js.type = \"Long\") decisionTaskCompletedEventId\n}\n\nstruct ActivityTaskCanceledEventAttributes {\n 10: optional binary details\n 20: optional i64 (js.type = \"Long\") latestCancelRequestedEventId\n 30: optional i64 (js.type = \"Long\") scheduledEventId\n 40: optional i64 (js.type = \"Long\") startedEventId\n 50: optional string identity\n}\n\nstruct TimerStartedEventAttributes {\n 10: optional string timerId\n 20: optional i64 (js.type = \"Long\") startToFireTimeoutSeconds\n 30: optional i64 (js.type = \"Long\") decisionTaskCompletedEventId\n}\n\nstruct TimerFiredEventAttributes {\n 10: optional string timerId\n 20: optional i64 (js.type = \"Long\") startedEventId\n}\n\nstruct TimerCanceledEventAttributes {\n 10: optional string timerId\n 20: optional i64 (js.type = \"Long\") startedEventId\n 30: optional i64 (js.type = \"Long\") decisionTaskCompletedEventId\n 40: optional string identity\n}\n\nstruct CancelTimerFailedEventAttributes {\n 10: optional string timerId\n 20: optional string cause\n 30: optional i64 (js.type = \"Long\") decisionTaskCompletedEventId\n 40: optional string identity\n}\n\nstruct WorkflowExecutionCancelRequestedEventAttributes {\n 10: optional string cause\n 20: optional i64 (js.type = \"Long\") externalInitiatedEventId\n 30: optional WorkflowExecution externalWorkflowExecution\n 40: optional string identity\n}\n\nstruct WorkflowExecutionCanceledEventAttributes {\n 10: optional i64 (js.type = \"Long\") decisionTaskCompletedEventId\n 20: optional binary details\n}\n\nstruct MarkerRecordedEventAttributes {\n 10: optional string markerName\n 20: optional binary details\n 30: optional i64 (js.type = \"Long\") decisionTaskCompletedEventId\n}\n\nstruct WorkflowExecutionSignaledEventAttributes {\n 10: optional string signalName\n 20: optional binary input\n 30: optional string identity\n}\n\nstruct WorkflowExecutionTerminatedEventAttributes {\n 10: optional string reason\n 20: optional binary details\n 30: optional string identity\n}\n\nstruct RequestCancelExternalWorkflowExecutionInitiatedEventAttributes {\n 10: optional i64 (js.type = \"Long\") decisionTaskCompletedEventId\n 20: optional string domain\n 30: optional WorkflowExecution workflowExecution\n 40: optional binary control\n}\n\nstruct RequestCancelExternalWorkflowExecutionFailedEventAttributes {\n 10: optional CancelExternalWorkflowExecutionFailedCause cause\n 20: optional i64 (js.type = \"Long\") decisionTaskCompletedEventId\n 30: optional string domain\n 40: optional WorkflowExecution workflowExecution\n 50: optional i64 (js.type = \"Long\") initiatedEventId\n 60: optional binary control\n}\n\nstruct ExternalWorkflowExecutionCancelRequestedEventAttributes {\n 10: optional i64 (js.type = \"Long\") initiatedEventId\n 20: optional string domain\n 30: optional WorkflowExecution workflowExecution\n}\n\nstruct StartChildWorkflowExecutionInitiatedEventAttributes {\n 10: optional string domain\n 20: optional string workflowId\n 30: optional WorkflowType workflowType\n 40: optional TaskList taskList\n 50: optional binary input\n 60: optional i32 executionStartToCloseTimeoutSeconds\n 70: optional i32 taskStartToCloseTimeoutSeconds\n 80: optional ChildPolicy childPolicy\n 90: optional binary control\n 100: optional i64 (js.type = \"Long\") decisionTaskCompletedEventId\n}\n\nstruct StartChildWorkflowExecutionFailedEventAttributes {\n 10: optional string domain\n 20: optional string workflowId\n 30: optional WorkflowType workflowType\n 40: optional ChildWorkflowExecutionFailedCause cause\n 50: optional binary control\n 60: optional i64 (js.type = \"Long\") initiatedEventId\n 70: optional i64 (js.type = \"Long\") decisionTaskCompletedEventId\n}\n\nstruct ChildWorkflowExecutionStartedEventAttributes {\n 10: optional string domain\n 20: optional i64 (js.type = \"Long\") initiatedEventId\n 30: optional WorkflowExecution workflowExecution\n 40: optional WorkflowType workflowType\n}\n\nstruct ChildWorkflowExecutionCompletedEventAttributes {\n 10: optional binary result\n 20: optional string domain\n 30: optional WorkflowExecution workflowExecution\n 40: optional WorkflowType workflowType\n 50: optional i64 (js.type = \"Long\") initiatedEventId\n 60: optional i64 (js.type = \"Long\") startedEventId\n}\n\nstruct ChildWorkflowExecutionFailedEventAttributes {\n 10: optional string reason\n 20: optional binary details\n 30: optional string domain\n 40: optional WorkflowExecution workflowExecution\n 50: optional WorkflowType workflowType\n 60: optional i64 (js.type = \"Long\") initiatedEventId\n 70: optional i64 (js.type = \"Long\") startedEventId\n}\n\nstruct ChildWorkflowExecutionCanceledEventAttributes {\n 10: optional binary details\n 20: optional string domain\n 30: optional WorkflowExecution workflowExecution\n 40: optional WorkflowType workflowType\n 50: optional i64 (js.type = \"Long\") initiatedEventId\n 60: optional i64 (js.type = \"Long\") startedEventId\n}\n\nstruct ChildWorkflowExecutionTimedOutEventAttributes {\n 10: optional TimeoutType timeoutType\n 20: optional string domain\n 30: optional WorkflowExecution workflowExecution\n 40: optional WorkflowType workflowType\n 50: optional i64 (js.type = \"Long\") initiatedEventId\n 60: optional i64 (js.type = \"Long\") startedEventId\n}\n\nstruct ChildWorkflowExecutionTerminatedEventAttributes {\n 10: optional string domain\n 20: optional WorkflowExecution workflowExecution\n 30: optional WorkflowType workflowType\n 40: optional i64 (js.type = \"Long\") initiatedEventId\n 50: optional i64 (js.type = \"Long\") startedEventId\n}\n\nstruct HistoryEvent {\n 10: optional i64 (js.type = \"Long\") eventId\n 20: optional i64 (js.type = \"Long\") timestamp\n 30: optional EventType eventType\n 40: optional WorkflowExecutionStartedEventAttributes workflowExecutionStartedEventAttributes\n 50: optional WorkflowExecutionCompletedEventAttributes workflowExecutionCompletedEventAttributes\n 60: optional WorkflowExecutionFailedEventAttributes workflowExecutionFailedEventAttributes\n 70: optional WorkflowExecutionTimedOutEventAttributes workflowExecutionTimedOutEventAttributes\n 80: optional DecisionTaskScheduledEventAttributes decisionTaskScheduledEventAttributes\n 90: optional DecisionTaskStartedEventAttributes decisionTaskStartedEventAttributes\n 100: optional DecisionTaskCompletedEventAttributes decisionTaskCompletedEventAttributes\n 110: optional DecisionTaskTimedOutEventAttributes decisionTaskTimedOutEventAttributes\n 120: optional DecisionTaskFailedEventAttributes decisionTaskFailedEventAttributes\n 130: optional ActivityTaskScheduledEventAttributes activityTaskScheduledEventAttributes\n 140: optional ActivityTaskStartedEventAttributes activityTaskStartedEventAttributes\n 150: optional ActivityTaskCompletedEventAttributes activityTaskCompletedEventAttributes\n 160: optional ActivityTaskFailedEventAttributes activityTaskFailedEventAttributes\n 170: optional ActivityTaskTimedOutEventAttributes activityTaskTimedOutEventAttributes\n 180: optional TimerStartedEventAttributes timerStartedEventAttributes\n 190: optional TimerFiredEventAttributes timerFiredEventAttributes\n 200: optional ActivityTaskCancelRequestedEventAttributes activityTaskCancelRequestedEventAttributes\n 210: optional RequestCancelActivityTaskFailedEventAttributes requestCancelActivityTaskFailedEventAttributes\n 220: optional ActivityTaskCanceledEventAttributes activityTaskCanceledEventAttributes\n 230: optional TimerCanceledEventAttributes timerCanceledEventAttributes\n 240: optional CancelTimerFailedEventAttributes cancelTimerFailedEventAttributes\n 250: optional MarkerRecordedEventAttributes markerRecordedEventAttributes\n 260: optional WorkflowExecutionSignaledEventAttributes workflowExecutionSignaledEventAttributes\n 270: optional WorkflowExecutionTerminatedEventAttributes workflowExecutionTerminatedEventAttributes\n 280: optional WorkflowExecutionCancelRequestedEventAttributes workflowExecutionCancelRequestedEventAttributes\n 290: optional WorkflowExecutionCanceledEventAttributes workflowExecutionCanceledEventAttributes\n 300: optional RequestCancelExternalWorkflowExecutionInitiatedEventAttributes requestCancelExternalWorkflowExecutionInitiatedEventAttributes\n 310: optional RequestCancelExternalWorkflowExecutionFailedEventAttributes requestCancelExternalWorkflowExecutionFailedEventAttributes\n 320: optional ExternalWorkflowExecutionCancelRequestedEventAttributes externalWorkflowExecutionCancelRequestedEventAttributes\n 330: optional WorkflowExecutionContinuedAsNewEventAttributes workflowExecutionContinuedAsNewEventAttributes\n 340: optional StartChildWorkflowExecutionInitiatedEventAttributes startChildWorkflowExecutionInitiatedEventAttributes\n 350: optional StartChildWorkflowExecutionFailedEventAttributes startChildWorkflowExecutionFailedEventAttributes\n 360: optional ChildWorkflowExecutionStartedEventAttributes childWorkflowExecutionStartedEventAttributes\n 370: optional ChildWorkflowExecutionCompletedEventAttributes childWorkflowExecutionCompletedEventAttributes\n 380: optional ChildWorkflowExecutionFailedEventAttributes childWorkflowExecutionFailedEventAttributes\n 390: optional ChildWorkflowExecutionCanceledEventAttributes childWorkflowExecutionCanceledEventAttributes\n 400: optional ChildWorkflowExecutionTimedOutEventAttributes childWorkflowExecutionTimedOutEventAttributes\n 410: optional ChildWorkflowExecutionTerminatedEventAttributes childWorkflowExecutionTerminatedEventAttributes\n}\n\nstruct History {\n 10: optional list events\n}\n\nstruct WorkflowExecutionFilter {\n 10: optional string workflowId\n}\n\nstruct WorkflowTypeFilter {\n 10: optional string name\n}\n\nstruct StartTimeFilter {\n 10: optional i64 (js.type = \"Long\") earliestTime\n 20: optional i64 (js.type = \"Long\") latestTime\n}\n\nstruct DomainInfo {\n 10: optional string name\n 20: optional DomainStatus status\n 30: optional string description\n 40: optional string ownerEmail\n}\n\nstruct DomainConfiguration {\n 10: optional i32 workflowExecutionRetentionPeriodInDays\n 20: optional bool emitMetric\n}\n\nstruct UpdateDomainInfo {\n 10: optional string description\n 20: optional string ownerEmail\n}\n\nstruct RegisterDomainRequest {\n 10: optional string name\n 20: optional string description\n 30: optional string ownerEmail\n 40: optional i32 workflowExecutionRetentionPeriodInDays\n 50: optional bool emitMetric\n}\n\nstruct DescribeDomainRequest {\n 10: optional string name\n}\n\nstruct DescribeDomainResponse {\n 10: optional DomainInfo domainInfo\n 20: optional DomainConfiguration configuration\n}\n\nstruct UpdateDomainRequest {\n 10: optional string name\n 20: optional UpdateDomainInfo updatedInfo\n 30: optional DomainConfiguration configuration\n}\n\nstruct UpdateDomainResponse {\n 10: optional DomainInfo domainInfo\n 20: optional DomainConfiguration configuration\n}\n\nstruct DeprecateDomainRequest {\n 10: optional string name\n}\n\nstruct StartWorkflowExecutionRequest {\n 10: optional string domain\n 20: optional string workflowId\n 30: optional WorkflowType workflowType\n 40: optional TaskList taskList\n 50: optional binary input\n 60: optional i32 executionStartToCloseTimeoutSeconds\n 70: optional i32 taskStartToCloseTimeoutSeconds\n 80: optional string identity\n 90: optional string requestId\n 100: optional WorkflowIdReusePolicy workflowIdReusePolicy\n}\n\nstruct StartWorkflowExecutionResponse {\n 10: optional string runId\n}\n\nstruct PollForDecisionTaskRequest {\n 10: optional string domain\n 20: optional TaskList taskList\n 30: optional string identity\n}\n\nstruct PollForDecisionTaskResponse {\n 10: optional binary taskToken\n 20: optional WorkflowExecution workflowExecution\n 30: optional WorkflowType workflowType\n 40: optional i64 (js.type = \"Long\") previousStartedEventId\n 50: optional i64 (js.type = \"Long\") startedEventId\n 51: optional i64 (js.type = 'Long') attempt\n 54: optional i64 (js.type = \"Long\") backlogCountHint\n 60: optional History history\n 70: optional binary nextPageToken\n 80: optional WorkflowQuery query\n}\n\nstruct StickyExecutionAttributes {\n 10: optional TaskList workerTaskList\n 20: optional i32 scheduleToStartTimeoutSeconds\n}\n\nstruct RespondDecisionTaskCompletedRequest {\n 10: optional binary taskToken\n 20: optional list decisions\n 30: optional binary executionContext\n 40: optional string identity\n 50: optional StickyExecutionAttributes stickyAttributes\n}\n\nstruct RespondDecisionTaskFailedRequest {\n 10: optional binary taskToken\n 20: optional DecisionTaskFailedCause cause\n 30: optional binary details\n 40: optional string identity\n}\n\nstruct PollForActivityTaskRequest {\n 10: optional string domain\n 20: optional TaskList taskList\n 30: optional string identity\n 40: optional TaskListMetadata taskListMetadata\n}\n\nstruct PollForActivityTaskResponse {\n 10: optional binary taskToken\n 20: optional WorkflowExecution workflowExecution\n 30: optional string activityId\n 40: optional ActivityType activityType\n 50: optional binary input\n 70: optional i64 (js.type = \"Long\") scheduledTimestamp\n 80: optional i32 scheduleToCloseTimeoutSeconds\n 90: optional i64 (js.type = \"Long\") startedTimestamp\n 100: optional i32 startToCloseTimeoutSeconds\n 110: optional i32 heartbeatTimeoutSeconds\n}\n\nstruct RecordActivityTaskHeartbeatRequest {\n 10: optional binary taskToken\n 20: optional binary details\n 30: optional string identity\n}\n\nstruct RecordActivityTaskHeartbeatResponse {\n 10: optional bool cancelRequested\n}\n\nstruct RespondActivityTaskCompletedRequest {\n 10: optional binary taskToken\n 20: optional binary result\n 30: optional string identity\n}\n\nstruct RespondActivityTaskFailedRequest {\n 10: optional binary taskToken\n 20: optional string reason\n 30: optional binary details\n 40: optional string identity\n}\n\nstruct RespondActivityTaskCanceledRequest {\n 10: optional binary taskToken\n 20: optional binary details\n 30: optional string identity\n}\n\nstruct RespondActivityTaskCompletedByIDRequest {\n 10: optional string domainID\n 20: optional string workflowID\n 30: optional string runID\n 40: optional string activityID\n 50: optional binary result\n 60: optional string identity\n}\n\nstruct RespondActivityTaskFailedByIDRequest {\n 10: optional string domainID\n 20: optional string workflowID\n 30: optional string runID\n 40: optional string activityID\n 50: optional string reason\n 60: optional binary details\n 70: optional string identity\n}\n\nstruct RespondActivityTaskCanceledByIDRequest {\n 10: optional string domainID\n 20: optional string workflowID\n 30: optional string runID\n 40: optional string activityID\n 50: optional binary details\n 60: optional string identity\n}\n\nstruct RequestCancelWorkflowExecutionRequest {\n 10: optional string domain\n 20: optional WorkflowExecution workflowExecution\n 30: optional string identity\n 40: optional string requestId\n}\n\nstruct GetWorkflowExecutionHistoryRequest {\n 10: optional string domain\n 20: optional WorkflowExecution execution\n 30: optional i32 maximumPageSize\n 40: optional binary nextPageToken\n 50: optional bool waitForNewEvent\n}\n\nstruct GetWorkflowExecutionHistoryResponse {\n 10: optional History history\n 20: optional binary nextPageToken\n}\n\nstruct SignalWorkflowExecutionRequest {\n 10: optional string domain\n 20: optional WorkflowExecution workflowExecution\n 30: optional string signalName\n 40: optional binary input\n 50: optional string identity\n}\n\nstruct TerminateWorkflowExecutionRequest {\n 10: optional string domain\n 20: optional WorkflowExecution workflowExecution\n 30: optional string reason\n 40: optional binary details\n 50: optional string identity\n}\n\nstruct ListOpenWorkflowExecutionsRequest {\n 10: optional string domain\n 20: optional i32 maximumPageSize\n 30: optional binary nextPageToken\n 40: optional StartTimeFilter StartTimeFilter\n 50: optional WorkflowExecutionFilter executionFilter\n 60: optional WorkflowTypeFilter typeFilter\n}\n\nstruct ListOpenWorkflowExecutionsResponse {\n 10: optional list executions\n 20: optional binary nextPageToken\n}\n\nstruct ListClosedWorkflowExecutionsRequest {\n 10: optional string domain\n 20: optional i32 maximumPageSize\n 30: optional binary nextPageToken\n 40: optional StartTimeFilter StartTimeFilter\n 50: optional WorkflowExecutionFilter executionFilter\n 60: optional WorkflowTypeFilter typeFilter\n 70: optional WorkflowExecutionCloseStatus statusFilter\n}\n\nstruct ListClosedWorkflowExecutionsResponse {\n 10: optional list executions\n 20: optional binary nextPageToken\n}\n\nstruct QueryWorkflowRequest {\n 10: optional string domain\n 20: optional WorkflowExecution execution\n 30: optional WorkflowQuery query\n}\n\nstruct QueryWorkflowResponse {\n 10: optional binary queryResult\n}\n\nstruct WorkflowQuery {\n 10: optional string queryType\n 20: optional binary queryArgs\n}\n\nstruct RespondQueryTaskCompletedRequest {\n 10: optional binary taskToken\n 20: optional QueryTaskCompletedType completedType\n 30: optional binary queryResult\n 40: optional string errorMessage\n}\n\nstruct DescribeWorkflowExecutionRequest {\n 10: optional string domain\n 20: optional WorkflowExecution execution\n}\n\nstruct DescribeWorkflowExecutionResponse {\n 10: optional WorkflowExecutionConfiguration executionConfiguration\n 20: optional WorkflowExecutionInfo workflowExecutionInfo\n}\n" +const rawIDL = "// Copyright (c) 2017 Uber Technologies, Inc.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n\nnamespace java com.uber.cadence\n\nexception BadRequestError {\n 1: required string message\n}\n\nexception InternalServiceError {\n 1: required string message\n}\n\nexception DomainAlreadyExistsError {\n 1: required string message\n}\n\nexception WorkflowExecutionAlreadyStartedError {\n 10: optional string message\n 20: optional string startRequestId\n 30: optional string runId\n}\n\nexception EntityNotExistsError {\n 1: required string message\n}\n\nexception ServiceBusyError {\n 1: required string message\n}\n\nexception CancellationAlreadyRequestedError {\n 1: required string message\n}\n\nexception QueryFailedError {\n 1: required string message\n}\n\nenum WorkflowIdReusePolicy {\n /*\n * allow start a workflow execution using the same workflow ID,\n * when workflow not running, and the last execution close state is in\n * [terminated, cancelled, timeouted, failed].\n */\n AllowDuplicateFailedOnly,\n /*\n * allow start a workflow execution using the same workflow ID,\n * when workflow not running.\n */\n AllowDuplicate,\n /*\n * do not allow start a workflow execution using the same workflow ID at all\n */\n RejectDuplicate,\n}\n\nenum DomainStatus {\n REGISTERED,\n DEPRECATED,\n DELETED,\n}\n\nenum TimeoutType {\n START_TO_CLOSE,\n SCHEDULE_TO_START,\n SCHEDULE_TO_CLOSE,\n HEARTBEAT,\n}\n\nenum DecisionType {\n ScheduleActivityTask,\n RequestCancelActivityTask,\n StartTimer,\n CompleteWorkflowExecution,\n FailWorkflowExecution,\n CancelTimer,\n CancelWorkflowExecution,\n RequestCancelExternalWorkflowExecution,\n RecordMarker,\n ContinueAsNewWorkflowExecution,\n StartChildWorkflowExecution,\n}\n\nenum EventType {\n WorkflowExecutionStarted,\n WorkflowExecutionCompleted,\n WorkflowExecutionFailed,\n WorkflowExecutionTimedOut,\n DecisionTaskScheduled,\n DecisionTaskStarted,\n DecisionTaskCompleted,\n DecisionTaskTimedOut\n DecisionTaskFailed,\n ActivityTaskScheduled,\n ActivityTaskStarted,\n ActivityTaskCompleted,\n ActivityTaskFailed,\n ActivityTaskTimedOut,\n ActivityTaskCancelRequested,\n RequestCancelActivityTaskFailed,\n ActivityTaskCanceled,\n TimerStarted,\n TimerFired,\n CancelTimerFailed,\n TimerCanceled,\n WorkflowExecutionCancelRequested,\n WorkflowExecutionCanceled,\n RequestCancelExternalWorkflowExecutionInitiated,\n RequestCancelExternalWorkflowExecutionFailed,\n ExternalWorkflowExecutionCancelRequested,\n MarkerRecorded,\n WorkflowExecutionSignaled,\n WorkflowExecutionTerminated,\n WorkflowExecutionContinuedAsNew,\n StartChildWorkflowExecutionInitiated,\n StartChildWorkflowExecutionFailed,\n ChildWorkflowExecutionStarted,\n ChildWorkflowExecutionCompleted,\n ChildWorkflowExecutionFailed,\n ChildWorkflowExecutionCanceled,\n ChildWorkflowExecutionTimedOut,\n ChildWorkflowExecutionTerminated,\n}\n\nenum DecisionTaskFailedCause {\n UNHANDLED_DECISION,\n BAD_SCHEDULE_ACTIVITY_ATTRIBUTES,\n BAD_REQUEST_CANCEL_ACTIVITY_ATTRIBUTES,\n BAD_START_TIMER_ATTRIBUTES,\n BAD_CANCEL_TIMER_ATTRIBUTES,\n BAD_RECORD_MARKER_ATTRIBUTES,\n BAD_COMPLETE_WORKFLOW_EXECUTION_ATTRIBUTES,\n BAD_FAIL_WORKFLOW_EXECUTION_ATTRIBUTES,\n BAD_CANCEL_WORKFLOW_EXECUTION_ATTRIBUTES,\n BAD_REQUEST_CANCEL_EXTERNAL_WORKFLOW_EXECUTION_ATTRIBUTES,\n BAD_CONTINUE_AS_NEW_ATTRIBUTES,\n START_TIMER_DUPLICATE_ID,\n RESET_STICKY_TASKLIST,\n WORKFLOW_WORKER_UNHANDLED_FAILURE\n}\n\nenum CancelExternalWorkflowExecutionFailedCause {\n UNKNOWN_EXTERNAL_WORKFLOW_EXECUTION,\n}\n\nenum ChildWorkflowExecutionFailedCause {\n WORKFLOW_ALREADY_RUNNING,\n}\n\nenum WorkflowExecutionCloseStatus {\n COMPLETED,\n FAILED,\n CANCELED,\n TERMINATED,\n CONTINUED_AS_NEW,\n TIMED_OUT,\n}\n\nenum ChildPolicy {\n TERMINATE,\n REQUEST_CANCEL,\n ABANDON,\n}\n\nenum QueryTaskCompletedType {\n COMPLETED,\n FAILED,\n}\n\nstruct WorkflowType {\n 10: optional string name\n}\n\nstruct ActivityType {\n 10: optional string name\n}\n\nstruct TaskList {\n 10: optional string name\n}\n\nstruct TaskListMetadata {\n 10: optional double maxTasksPerSecond\n}\n\nstruct WorkflowExecution {\n 10: optional string workflowId\n 20: optional string runId\n}\n\nstruct WorkflowExecutionInfo {\n 10: optional WorkflowExecution execution\n 20: optional WorkflowType type\n 30: optional i64 (js.type = \"Long\") startTime\n 40: optional i64 (js.type = \"Long\") closeTime\n 50: optional WorkflowExecutionCloseStatus closeStatus\n 60: optional i64 (js.type = \"Long\") historyLength\n}\n\nstruct WorkflowExecutionConfiguration {\n 10: optional TaskList taskList\n 20: optional i32 executionStartToCloseTimeoutSeconds\n 30: optional i32 taskStartToCloseTimeoutSeconds\n 40: optional ChildPolicy childPolicy\n}\n\nstruct TransientDecisionInfo {\n 10: optional HistoryEvent scheduledEvent\n 20: optional HistoryEvent startedEvent\n}\n\nstruct ScheduleActivityTaskDecisionAttributes {\n 10: optional string activityId\n 20: optional ActivityType activityType\n 25: optional string domain\n 30: optional TaskList taskList\n 40: optional binary input\n 45: optional i32 scheduleToCloseTimeoutSeconds\n 50: optional i32 scheduleToStartTimeoutSeconds\n 55: optional i32 startToCloseTimeoutSeconds\n 60: optional i32 heartbeatTimeoutSeconds\n}\n\nstruct RequestCancelActivityTaskDecisionAttributes {\n 10: optional string activityId\n}\n\nstruct StartTimerDecisionAttributes {\n 10: optional string timerId\n 20: optional i64 (js.type = \"Long\") startToFireTimeoutSeconds\n}\n\nstruct CompleteWorkflowExecutionDecisionAttributes {\n 10: optional binary result\n}\n\nstruct FailWorkflowExecutionDecisionAttributes {\n 10: optional string reason\n 20: optional binary details\n}\n\nstruct CancelTimerDecisionAttributes {\n 10: optional string timerId\n}\n\nstruct CancelWorkflowExecutionDecisionAttributes {\n 10: optional binary details\n}\n\nstruct RequestCancelExternalWorkflowExecutionDecisionAttributes {\n 10: optional string domain\n 20: optional string workflowId\n 30: optional string runId\n 40: optional binary control\n}\n\nstruct RecordMarkerDecisionAttributes {\n 10: optional string markerName\n 20: optional binary details\n}\n\nstruct ContinueAsNewWorkflowExecutionDecisionAttributes {\n 10: optional WorkflowType workflowType\n 20: optional TaskList taskList\n 30: optional binary input\n 40: optional i32 executionStartToCloseTimeoutSeconds\n 50: optional i32 taskStartToCloseTimeoutSeconds\n}\n\nstruct StartChildWorkflowExecutionDecisionAttributes {\n 10: optional string domain\n 20: optional string workflowId\n 30: optional WorkflowType workflowType\n 40: optional TaskList taskList\n 50: optional binary input\n 60: optional i32 executionStartToCloseTimeoutSeconds\n 70: optional i32 taskStartToCloseTimeoutSeconds\n 80: optional ChildPolicy childPolicy\n 90: optional binary control\n}\n\nstruct Decision {\n 10: optional DecisionType decisionType\n 20: optional ScheduleActivityTaskDecisionAttributes scheduleActivityTaskDecisionAttributes\n 25: optional StartTimerDecisionAttributes startTimerDecisionAttributes\n 30: optional CompleteWorkflowExecutionDecisionAttributes completeWorkflowExecutionDecisionAttributes\n 35: optional FailWorkflowExecutionDecisionAttributes failWorkflowExecutionDecisionAttributes\n 40: optional RequestCancelActivityTaskDecisionAttributes requestCancelActivityTaskDecisionAttributes\n 50: optional CancelTimerDecisionAttributes cancelTimerDecisionAttributes\n 60: optional CancelWorkflowExecutionDecisionAttributes cancelWorkflowExecutionDecisionAttributes\n 70: optional RequestCancelExternalWorkflowExecutionDecisionAttributes requestCancelExternalWorkflowExecutionDecisionAttributes\n 80: optional RecordMarkerDecisionAttributes recordMarkerDecisionAttributes\n 90: optional ContinueAsNewWorkflowExecutionDecisionAttributes continueAsNewWorkflowExecutionDecisionAttributes\n 100: optional StartChildWorkflowExecutionDecisionAttributes startChildWorkflowExecutionDecisionAttributes\n}\n\nstruct WorkflowExecutionStartedEventAttributes {\n 10: optional WorkflowType workflowType\n 20: optional TaskList taskList\n 30: optional binary input\n 40: optional i32 executionStartToCloseTimeoutSeconds\n 50: optional i32 taskStartToCloseTimeoutSeconds\n 60: optional string identity\n}\n\nstruct WorkflowExecutionCompletedEventAttributes {\n 10: optional binary result\n 20: optional i64 (js.type = \"Long\") decisionTaskCompletedEventId\n}\n\nstruct WorkflowExecutionFailedEventAttributes {\n 10: optional string reason\n 20: optional binary details\n 30: optional i64 (js.type = \"Long\") decisionTaskCompletedEventId\n}\n\nstruct WorkflowExecutionTimedOutEventAttributes {\n 10: optional TimeoutType timeoutType\n}\n\nstruct WorkflowExecutionContinuedAsNewEventAttributes {\n 10: optional string newExecutionRunId\n 20: optional WorkflowType workflowType\n 30: optional TaskList taskList\n 40: optional binary input\n 50: optional i32 executionStartToCloseTimeoutSeconds\n 60: optional i32 taskStartToCloseTimeoutSeconds\n 70: optional i64 (js.type = \"Long\") decisionTaskCompletedEventId\n}\n\nstruct DecisionTaskScheduledEventAttributes {\n 10: optional TaskList taskList\n 20: optional i32 startToCloseTimeoutSeconds\n 30: optional i64 (js.type = \"Long\") attempt\n}\n\nstruct DecisionTaskStartedEventAttributes {\n 10: optional i64 (js.type = \"Long\") scheduledEventId\n 20: optional string identity\n 30: optional string requestId\n}\n\nstruct DecisionTaskCompletedEventAttributes {\n 10: optional binary executionContext\n 20: optional i64 (js.type = \"Long\") scheduledEventId\n 30: optional i64 (js.type = \"Long\") startedEventId\n 40: optional string identity\n}\n\nstruct DecisionTaskTimedOutEventAttributes {\n 10: optional i64 (js.type = \"Long\") scheduledEventId\n 20: optional i64 (js.type = \"Long\") startedEventId\n 30: optional TimeoutType timeoutType\n}\n\nstruct DecisionTaskFailedEventAttributes {\n 10: optional i64 (js.type = \"Long\") scheduledEventId\n 20: optional i64 (js.type = \"Long\") startedEventId\n 30: optional DecisionTaskFailedCause cause\n 35: optional binary details\n 40: optional string identity\n}\n\nstruct ActivityTaskScheduledEventAttributes {\n 10: optional string activityId\n 20: optional ActivityType activityType\n 25: optional string domain\n 30: optional TaskList taskList\n 40: optional binary input\n 45: optional i32 scheduleToCloseTimeoutSeconds\n 50: optional i32 scheduleToStartTimeoutSeconds\n 55: optional i32 startToCloseTimeoutSeconds\n 60: optional i32 heartbeatTimeoutSeconds\n 90: optional i64 (js.type = \"Long\") decisionTaskCompletedEventId\n}\n\nstruct ActivityTaskStartedEventAttributes {\n 10: optional i64 (js.type = \"Long\") scheduledEventId\n 20: optional string identity\n 30: optional string requestId\n}\n\nstruct ActivityTaskCompletedEventAttributes {\n 10: optional binary result\n 20: optional i64 (js.type = \"Long\") scheduledEventId\n 30: optional i64 (js.type = \"Long\") startedEventId\n 40: optional string identity\n}\n\nstruct ActivityTaskFailedEventAttributes {\n 10: optional string reason\n 20: optional binary details\n 30: optional i64 (js.type = \"Long\") scheduledEventId\n 40: optional i64 (js.type = \"Long\") startedEventId\n 50: optional string identity\n}\n\nstruct ActivityTaskTimedOutEventAttributes {\n 05: optional binary details\n 10: optional i64 (js.type = \"Long\") scheduledEventId\n 20: optional i64 (js.type = \"Long\") startedEventId\n 30: optional TimeoutType timeoutType\n}\n\nstruct ActivityTaskCancelRequestedEventAttributes {\n 10: optional string activityId\n 20: optional i64 (js.type = \"Long\") decisionTaskCompletedEventId\n}\n\nstruct RequestCancelActivityTaskFailedEventAttributes{\n 10: optional string activityId\n 20: optional string cause\n 30: optional i64 (js.type = \"Long\") decisionTaskCompletedEventId\n}\n\nstruct ActivityTaskCanceledEventAttributes {\n 10: optional binary details\n 20: optional i64 (js.type = \"Long\") latestCancelRequestedEventId\n 30: optional i64 (js.type = \"Long\") scheduledEventId\n 40: optional i64 (js.type = \"Long\") startedEventId\n 50: optional string identity\n}\n\nstruct TimerStartedEventAttributes {\n 10: optional string timerId\n 20: optional i64 (js.type = \"Long\") startToFireTimeoutSeconds\n 30: optional i64 (js.type = \"Long\") decisionTaskCompletedEventId\n}\n\nstruct TimerFiredEventAttributes {\n 10: optional string timerId\n 20: optional i64 (js.type = \"Long\") startedEventId\n}\n\nstruct TimerCanceledEventAttributes {\n 10: optional string timerId\n 20: optional i64 (js.type = \"Long\") startedEventId\n 30: optional i64 (js.type = \"Long\") decisionTaskCompletedEventId\n 40: optional string identity\n}\n\nstruct CancelTimerFailedEventAttributes {\n 10: optional string timerId\n 20: optional string cause\n 30: optional i64 (js.type = \"Long\") decisionTaskCompletedEventId\n 40: optional string identity\n}\n\nstruct WorkflowExecutionCancelRequestedEventAttributes {\n 10: optional string cause\n 20: optional i64 (js.type = \"Long\") externalInitiatedEventId\n 30: optional WorkflowExecution externalWorkflowExecution\n 40: optional string identity\n}\n\nstruct WorkflowExecutionCanceledEventAttributes {\n 10: optional i64 (js.type = \"Long\") decisionTaskCompletedEventId\n 20: optional binary details\n}\n\nstruct MarkerRecordedEventAttributes {\n 10: optional string markerName\n 20: optional binary details\n 30: optional i64 (js.type = \"Long\") decisionTaskCompletedEventId\n}\n\nstruct WorkflowExecutionSignaledEventAttributes {\n 10: optional string signalName\n 20: optional binary input\n 30: optional string identity\n}\n\nstruct WorkflowExecutionTerminatedEventAttributes {\n 10: optional string reason\n 20: optional binary details\n 30: optional string identity\n}\n\nstruct RequestCancelExternalWorkflowExecutionInitiatedEventAttributes {\n 10: optional i64 (js.type = \"Long\") decisionTaskCompletedEventId\n 20: optional string domain\n 30: optional WorkflowExecution workflowExecution\n 40: optional binary control\n}\n\nstruct RequestCancelExternalWorkflowExecutionFailedEventAttributes {\n 10: optional CancelExternalWorkflowExecutionFailedCause cause\n 20: optional i64 (js.type = \"Long\") decisionTaskCompletedEventId\n 30: optional string domain\n 40: optional WorkflowExecution workflowExecution\n 50: optional i64 (js.type = \"Long\") initiatedEventId\n 60: optional binary control\n}\n\nstruct ExternalWorkflowExecutionCancelRequestedEventAttributes {\n 10: optional i64 (js.type = \"Long\") initiatedEventId\n 20: optional string domain\n 30: optional WorkflowExecution workflowExecution\n}\n\nstruct StartChildWorkflowExecutionInitiatedEventAttributes {\n 10: optional string domain\n 20: optional string workflowId\n 30: optional WorkflowType workflowType\n 40: optional TaskList taskList\n 50: optional binary input\n 60: optional i32 executionStartToCloseTimeoutSeconds\n 70: optional i32 taskStartToCloseTimeoutSeconds\n 80: optional ChildPolicy childPolicy\n 90: optional binary control\n 100: optional i64 (js.type = \"Long\") decisionTaskCompletedEventId\n}\n\nstruct StartChildWorkflowExecutionFailedEventAttributes {\n 10: optional string domain\n 20: optional string workflowId\n 30: optional WorkflowType workflowType\n 40: optional ChildWorkflowExecutionFailedCause cause\n 50: optional binary control\n 60: optional i64 (js.type = \"Long\") initiatedEventId\n 70: optional i64 (js.type = \"Long\") decisionTaskCompletedEventId\n}\n\nstruct ChildWorkflowExecutionStartedEventAttributes {\n 10: optional string domain\n 20: optional i64 (js.type = \"Long\") initiatedEventId\n 30: optional WorkflowExecution workflowExecution\n 40: optional WorkflowType workflowType\n}\n\nstruct ChildWorkflowExecutionCompletedEventAttributes {\n 10: optional binary result\n 20: optional string domain\n 30: optional WorkflowExecution workflowExecution\n 40: optional WorkflowType workflowType\n 50: optional i64 (js.type = \"Long\") initiatedEventId\n 60: optional i64 (js.type = \"Long\") startedEventId\n}\n\nstruct ChildWorkflowExecutionFailedEventAttributes {\n 10: optional string reason\n 20: optional binary details\n 30: optional string domain\n 40: optional WorkflowExecution workflowExecution\n 50: optional WorkflowType workflowType\n 60: optional i64 (js.type = \"Long\") initiatedEventId\n 70: optional i64 (js.type = \"Long\") startedEventId\n}\n\nstruct ChildWorkflowExecutionCanceledEventAttributes {\n 10: optional binary details\n 20: optional string domain\n 30: optional WorkflowExecution workflowExecution\n 40: optional WorkflowType workflowType\n 50: optional i64 (js.type = \"Long\") initiatedEventId\n 60: optional i64 (js.type = \"Long\") startedEventId\n}\n\nstruct ChildWorkflowExecutionTimedOutEventAttributes {\n 10: optional TimeoutType timeoutType\n 20: optional string domain\n 30: optional WorkflowExecution workflowExecution\n 40: optional WorkflowType workflowType\n 50: optional i64 (js.type = \"Long\") initiatedEventId\n 60: optional i64 (js.type = \"Long\") startedEventId\n}\n\nstruct ChildWorkflowExecutionTerminatedEventAttributes {\n 10: optional string domain\n 20: optional WorkflowExecution workflowExecution\n 30: optional WorkflowType workflowType\n 40: optional i64 (js.type = \"Long\") initiatedEventId\n 50: optional i64 (js.type = \"Long\") startedEventId\n}\n\nstruct HistoryEvent {\n 10: optional i64 (js.type = \"Long\") eventId\n 20: optional i64 (js.type = \"Long\") timestamp\n 30: optional EventType eventType\n 40: optional WorkflowExecutionStartedEventAttributes workflowExecutionStartedEventAttributes\n 50: optional WorkflowExecutionCompletedEventAttributes workflowExecutionCompletedEventAttributes\n 60: optional WorkflowExecutionFailedEventAttributes workflowExecutionFailedEventAttributes\n 70: optional WorkflowExecutionTimedOutEventAttributes workflowExecutionTimedOutEventAttributes\n 80: optional DecisionTaskScheduledEventAttributes decisionTaskScheduledEventAttributes\n 90: optional DecisionTaskStartedEventAttributes decisionTaskStartedEventAttributes\n 100: optional DecisionTaskCompletedEventAttributes decisionTaskCompletedEventAttributes\n 110: optional DecisionTaskTimedOutEventAttributes decisionTaskTimedOutEventAttributes\n 120: optional DecisionTaskFailedEventAttributes decisionTaskFailedEventAttributes\n 130: optional ActivityTaskScheduledEventAttributes activityTaskScheduledEventAttributes\n 140: optional ActivityTaskStartedEventAttributes activityTaskStartedEventAttributes\n 150: optional ActivityTaskCompletedEventAttributes activityTaskCompletedEventAttributes\n 160: optional ActivityTaskFailedEventAttributes activityTaskFailedEventAttributes\n 170: optional ActivityTaskTimedOutEventAttributes activityTaskTimedOutEventAttributes\n 180: optional TimerStartedEventAttributes timerStartedEventAttributes\n 190: optional TimerFiredEventAttributes timerFiredEventAttributes\n 200: optional ActivityTaskCancelRequestedEventAttributes activityTaskCancelRequestedEventAttributes\n 210: optional RequestCancelActivityTaskFailedEventAttributes requestCancelActivityTaskFailedEventAttributes\n 220: optional ActivityTaskCanceledEventAttributes activityTaskCanceledEventAttributes\n 230: optional TimerCanceledEventAttributes timerCanceledEventAttributes\n 240: optional CancelTimerFailedEventAttributes cancelTimerFailedEventAttributes\n 250: optional MarkerRecordedEventAttributes markerRecordedEventAttributes\n 260: optional WorkflowExecutionSignaledEventAttributes workflowExecutionSignaledEventAttributes\n 270: optional WorkflowExecutionTerminatedEventAttributes workflowExecutionTerminatedEventAttributes\n 280: optional WorkflowExecutionCancelRequestedEventAttributes workflowExecutionCancelRequestedEventAttributes\n 290: optional WorkflowExecutionCanceledEventAttributes workflowExecutionCanceledEventAttributes\n 300: optional RequestCancelExternalWorkflowExecutionInitiatedEventAttributes requestCancelExternalWorkflowExecutionInitiatedEventAttributes\n 310: optional RequestCancelExternalWorkflowExecutionFailedEventAttributes requestCancelExternalWorkflowExecutionFailedEventAttributes\n 320: optional ExternalWorkflowExecutionCancelRequestedEventAttributes externalWorkflowExecutionCancelRequestedEventAttributes\n 330: optional WorkflowExecutionContinuedAsNewEventAttributes workflowExecutionContinuedAsNewEventAttributes\n 340: optional StartChildWorkflowExecutionInitiatedEventAttributes startChildWorkflowExecutionInitiatedEventAttributes\n 350: optional StartChildWorkflowExecutionFailedEventAttributes startChildWorkflowExecutionFailedEventAttributes\n 360: optional ChildWorkflowExecutionStartedEventAttributes childWorkflowExecutionStartedEventAttributes\n 370: optional ChildWorkflowExecutionCompletedEventAttributes childWorkflowExecutionCompletedEventAttributes\n 380: optional ChildWorkflowExecutionFailedEventAttributes childWorkflowExecutionFailedEventAttributes\n 390: optional ChildWorkflowExecutionCanceledEventAttributes childWorkflowExecutionCanceledEventAttributes\n 400: optional ChildWorkflowExecutionTimedOutEventAttributes childWorkflowExecutionTimedOutEventAttributes\n 410: optional ChildWorkflowExecutionTerminatedEventAttributes childWorkflowExecutionTerminatedEventAttributes\n}\n\nstruct History {\n 10: optional list events\n}\n\nstruct WorkflowExecutionFilter {\n 10: optional string workflowId\n}\n\nstruct WorkflowTypeFilter {\n 10: optional string name\n}\n\nstruct StartTimeFilter {\n 10: optional i64 (js.type = \"Long\") earliestTime\n 20: optional i64 (js.type = \"Long\") latestTime\n}\n\nstruct DomainInfo {\n 10: optional string name\n 20: optional DomainStatus status\n 30: optional string description\n 40: optional string ownerEmail\n}\n\nstruct DomainConfiguration {\n 10: optional i32 workflowExecutionRetentionPeriodInDays\n 20: optional bool emitMetric\n}\n\nstruct UpdateDomainInfo {\n 10: optional string description\n 20: optional string ownerEmail\n}\n\nstruct RegisterDomainRequest {\n 10: optional string name\n 20: optional string description\n 30: optional string ownerEmail\n 40: optional i32 workflowExecutionRetentionPeriodInDays\n 50: optional bool emitMetric\n}\n\nstruct DescribeDomainRequest {\n 10: optional string name\n}\n\nstruct DescribeDomainResponse {\n 10: optional DomainInfo domainInfo\n 20: optional DomainConfiguration configuration\n}\n\nstruct UpdateDomainRequest {\n 10: optional string name\n 20: optional UpdateDomainInfo updatedInfo\n 30: optional DomainConfiguration configuration\n}\n\nstruct UpdateDomainResponse {\n 10: optional DomainInfo domainInfo\n 20: optional DomainConfiguration configuration\n}\n\nstruct DeprecateDomainRequest {\n 10: optional string name\n}\n\nstruct StartWorkflowExecutionRequest {\n 10: optional string domain\n 20: optional string workflowId\n 30: optional WorkflowType workflowType\n 40: optional TaskList taskList\n 50: optional binary input\n 60: optional i32 executionStartToCloseTimeoutSeconds\n 70: optional i32 taskStartToCloseTimeoutSeconds\n 80: optional string identity\n 90: optional string requestId\n 100: optional WorkflowIdReusePolicy workflowIdReusePolicy\n}\n\nstruct StartWorkflowExecutionResponse {\n 10: optional string runId\n}\n\nstruct PollForDecisionTaskRequest {\n 10: optional string domain\n 20: optional TaskList taskList\n 30: optional string identity\n}\n\nstruct PollForDecisionTaskResponse {\n 10: optional binary taskToken\n 20: optional WorkflowExecution workflowExecution\n 30: optional WorkflowType workflowType\n 40: optional i64 (js.type = \"Long\") previousStartedEventId\n 50: optional i64 (js.type = \"Long\") startedEventId\n 51: optional i64 (js.type = 'Long') attempt\n 54: optional i64 (js.type = \"Long\") backlogCountHint\n 60: optional History history\n 70: optional binary nextPageToken\n 80: optional WorkflowQuery query\n}\n\nstruct StickyExecutionAttributes {\n 10: optional TaskList workerTaskList\n 20: optional i32 scheduleToStartTimeoutSeconds\n}\n\nstruct RespondDecisionTaskCompletedRequest {\n 10: optional binary taskToken\n 20: optional list decisions\n 30: optional binary executionContext\n 40: optional string identity\n 50: optional StickyExecutionAttributes stickyAttributes\n}\n\nstruct RespondDecisionTaskFailedRequest {\n 10: optional binary taskToken\n 20: optional DecisionTaskFailedCause cause\n 30: optional binary details\n 40: optional string identity\n}\n\nstruct PollForActivityTaskRequest {\n 10: optional string domain\n 20: optional TaskList taskList\n 30: optional string identity\n 40: optional TaskListMetadata taskListMetadata\n}\n\nstruct PollForActivityTaskResponse {\n 10: optional binary taskToken\n 20: optional WorkflowExecution workflowExecution\n 30: optional string activityId\n 40: optional ActivityType activityType\n 50: optional binary input\n 70: optional i64 (js.type = \"Long\") scheduledTimestamp\n 80: optional i32 scheduleToCloseTimeoutSeconds\n 90: optional i64 (js.type = \"Long\") startedTimestamp\n 100: optional i32 startToCloseTimeoutSeconds\n 110: optional i32 heartbeatTimeoutSeconds\n}\n\nstruct RecordActivityTaskHeartbeatRequest {\n 10: optional binary taskToken\n 20: optional binary details\n 30: optional string identity\n}\n\nstruct RecordActivityTaskHeartbeatResponse {\n 10: optional bool cancelRequested\n}\n\nstruct RespondActivityTaskCompletedRequest {\n 10: optional binary taskToken\n 20: optional binary result\n 30: optional string identity\n}\n\nstruct RespondActivityTaskFailedRequest {\n 10: optional binary taskToken\n 20: optional string reason\n 30: optional binary details\n 40: optional string identity\n}\n\nstruct RespondActivityTaskCanceledRequest {\n 10: optional binary taskToken\n 20: optional binary details\n 30: optional string identity\n}\n\nstruct RespondActivityTaskCompletedByIDRequest {\n 10: optional string domainID\n 20: optional string workflowID\n 30: optional string runID\n 40: optional string activityID\n 50: optional binary result\n 60: optional string identity\n}\n\nstruct RespondActivityTaskFailedByIDRequest {\n 10: optional string domainID\n 20: optional string workflowID\n 30: optional string runID\n 40: optional string activityID\n 50: optional string reason\n 60: optional binary details\n 70: optional string identity\n}\n\nstruct RespondActivityTaskCanceledByIDRequest {\n 10: optional string domainID\n 20: optional string workflowID\n 30: optional string runID\n 40: optional string activityID\n 50: optional binary details\n 60: optional string identity\n}\n\nstruct RequestCancelWorkflowExecutionRequest {\n 10: optional string domain\n 20: optional WorkflowExecution workflowExecution\n 30: optional string identity\n 40: optional string requestId\n}\n\nstruct GetWorkflowExecutionHistoryRequest {\n 10: optional string domain\n 20: optional WorkflowExecution execution\n 30: optional i32 maximumPageSize\n 40: optional binary nextPageToken\n 50: optional bool waitForNewEvent\n}\n\nstruct GetWorkflowExecutionHistoryResponse {\n 10: optional History history\n 20: optional binary nextPageToken\n}\n\nstruct SignalWorkflowExecutionRequest {\n 10: optional string domain\n 20: optional WorkflowExecution workflowExecution\n 30: optional string signalName\n 40: optional binary input\n 50: optional string identity\n}\n\nstruct TerminateWorkflowExecutionRequest {\n 10: optional string domain\n 20: optional WorkflowExecution workflowExecution\n 30: optional string reason\n 40: optional binary details\n 50: optional string identity\n}\n\nstruct ListOpenWorkflowExecutionsRequest {\n 10: optional string domain\n 20: optional i32 maximumPageSize\n 30: optional binary nextPageToken\n 40: optional StartTimeFilter StartTimeFilter\n 50: optional WorkflowExecutionFilter executionFilter\n 60: optional WorkflowTypeFilter typeFilter\n}\n\nstruct ListOpenWorkflowExecutionsResponse {\n 10: optional list executions\n 20: optional binary nextPageToken\n}\n\nstruct ListClosedWorkflowExecutionsRequest {\n 10: optional string domain\n 20: optional i32 maximumPageSize\n 30: optional binary nextPageToken\n 40: optional StartTimeFilter StartTimeFilter\n 50: optional WorkflowExecutionFilter executionFilter\n 60: optional WorkflowTypeFilter typeFilter\n 70: optional WorkflowExecutionCloseStatus statusFilter\n}\n\nstruct ListClosedWorkflowExecutionsResponse {\n 10: optional list executions\n 20: optional binary nextPageToken\n}\n\nstruct QueryWorkflowRequest {\n 10: optional string domain\n 20: optional WorkflowExecution execution\n 30: optional WorkflowQuery query\n}\n\nstruct QueryWorkflowResponse {\n 10: optional binary queryResult\n}\n\nstruct WorkflowQuery {\n 10: optional string queryType\n 20: optional binary queryArgs\n}\n\nstruct RespondQueryTaskCompletedRequest {\n 10: optional binary taskToken\n 20: optional QueryTaskCompletedType completedType\n 30: optional binary queryResult\n 40: optional string errorMessage\n}\n\nstruct DescribeWorkflowExecutionRequest {\n 10: optional string domain\n 20: optional WorkflowExecution execution\n}\n\nstruct DescribeWorkflowExecutionResponse {\n 10: optional WorkflowExecutionConfiguration executionConfiguration\n 20: optional WorkflowExecutionInfo workflowExecutionInfo\n}\n\nstruct GetPollerHistoryRequest {\n 10: optional string domain\n 20: optional TaskList taskList\n 30: optional TaskListType taskListType\n}\n\nstruct GetPollerHistoryResponse {\n 10: optional list pollers\n}\n\nenum TaskListType {\n /*\n * Decision type of tasklist\n */\n Decision,\n /*\n * Activity type of tasklist\n */\n Activity,\n}\n\nstruct PollerInfo {\n // ISO 8601 format\n 10: optional string timestamp\n 20: optional string identity\n}\n" diff --git a/.gen/go/shared/types.go b/.gen/go/shared/types.go index 995b826fa4e..9380dae7afb 100644 --- a/.gen/go/shared/types.go +++ b/.gen/go/shared/types.go @@ -8903,6 +8903,370 @@ func (v *FailWorkflowExecutionDecisionAttributes) GetReason() (o string) { return } +type GetPollerHistoryRequest struct { + Domain *string `json:"domain,omitempty"` + TaskList *TaskList `json:"taskList,omitempty"` + TaskListType *TaskListType `json:"taskListType,omitempty"` +} + +// ToWire translates a GetPollerHistoryRequest struct into a Thrift-level intermediate +// representation. This intermediate representation may be serialized +// into bytes using a ThriftRW protocol implementation. +// +// An error is returned if the struct or any of its fields failed to +// validate. +// +// x, err := v.ToWire() +// if err != nil { +// return err +// } +// +// if err := binaryProtocol.Encode(x, writer); err != nil { +// return err +// } +func (v *GetPollerHistoryRequest) ToWire() (wire.Value, error) { + var ( + fields [3]wire.Field + i int = 0 + w wire.Value + err error + ) + + if v.Domain != nil { + w, err = wire.NewValueString(*(v.Domain)), error(nil) + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 10, Value: w} + i++ + } + if v.TaskList != nil { + w, err = v.TaskList.ToWire() + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 20, Value: w} + i++ + } + if v.TaskListType != nil { + w, err = v.TaskListType.ToWire() + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 30, Value: w} + i++ + } + + return wire.NewValueStruct(wire.Struct{Fields: fields[:i]}), nil +} + +func _TaskListType_Read(w wire.Value) (TaskListType, error) { + var v TaskListType + err := v.FromWire(w) + return v, err +} + +// FromWire deserializes a GetPollerHistoryRequest struct from its Thrift-level +// representation. The Thrift-level representation may be obtained +// from a ThriftRW protocol implementation. +// +// An error is returned if we were unable to build a GetPollerHistoryRequest struct +// from the provided intermediate representation. +// +// x, err := binaryProtocol.Decode(reader, wire.TStruct) +// if err != nil { +// return nil, err +// } +// +// var v GetPollerHistoryRequest +// if err := v.FromWire(x); err != nil { +// return nil, err +// } +// return &v, nil +func (v *GetPollerHistoryRequest) FromWire(w wire.Value) error { + var err error + + for _, field := range w.GetStruct().Fields { + switch field.ID { + case 10: + if field.Value.Type() == wire.TBinary { + var x string + x, err = field.Value.GetString(), error(nil) + v.Domain = &x + if err != nil { + return err + } + + } + case 20: + if field.Value.Type() == wire.TStruct { + v.TaskList, err = _TaskList_Read(field.Value) + if err != nil { + return err + } + + } + case 30: + if field.Value.Type() == wire.TI32 { + var x TaskListType + x, err = _TaskListType_Read(field.Value) + v.TaskListType = &x + if err != nil { + return err + } + + } + } + } + + return nil +} + +// String returns a readable string representation of a GetPollerHistoryRequest +// struct. +func (v *GetPollerHistoryRequest) String() string { + if v == nil { + return "" + } + + var fields [3]string + i := 0 + if v.Domain != nil { + fields[i] = fmt.Sprintf("Domain: %v", *(v.Domain)) + i++ + } + if v.TaskList != nil { + fields[i] = fmt.Sprintf("TaskList: %v", v.TaskList) + i++ + } + if v.TaskListType != nil { + fields[i] = fmt.Sprintf("TaskListType: %v", *(v.TaskListType)) + i++ + } + + return fmt.Sprintf("GetPollerHistoryRequest{%v}", strings.Join(fields[:i], ", ")) +} + +func _TaskListType_EqualsPtr(lhs, rhs *TaskListType) bool { + if lhs != nil && rhs != nil { + + x := *lhs + y := *rhs + return x.Equals(y) + } + return lhs == nil && rhs == nil +} + +// Equals returns true if all the fields of this GetPollerHistoryRequest match the +// provided GetPollerHistoryRequest. +// +// This function performs a deep comparison. +func (v *GetPollerHistoryRequest) Equals(rhs *GetPollerHistoryRequest) bool { + if !_String_EqualsPtr(v.Domain, rhs.Domain) { + return false + } + if !((v.TaskList == nil && rhs.TaskList == nil) || (v.TaskList != nil && rhs.TaskList != nil && v.TaskList.Equals(rhs.TaskList))) { + return false + } + if !_TaskListType_EqualsPtr(v.TaskListType, rhs.TaskListType) { + return false + } + + return true +} + +// GetDomain returns the value of Domain if it is set or its +// zero value if it is unset. +func (v *GetPollerHistoryRequest) GetDomain() (o string) { + if v.Domain != nil { + return *v.Domain + } + + return +} + +// GetTaskListType returns the value of TaskListType if it is set or its +// zero value if it is unset. +func (v *GetPollerHistoryRequest) GetTaskListType() (o TaskListType) { + if v.TaskListType != nil { + return *v.TaskListType + } + + return +} + +type GetPollerHistoryResponse struct { + Pollers []*PollerInfo `json:"pollers,omitempty"` +} + +type _List_PollerInfo_ValueList []*PollerInfo + +func (v _List_PollerInfo_ValueList) ForEach(f func(wire.Value) error) error { + for i, x := range v { + if x == nil { + return fmt.Errorf("invalid [%v]: value is nil", i) + } + w, err := x.ToWire() + if err != nil { + return err + } + err = f(w) + if err != nil { + return err + } + } + return nil +} + +func (v _List_PollerInfo_ValueList) Size() int { + return len(v) +} + +func (_List_PollerInfo_ValueList) ValueType() wire.Type { + return wire.TStruct +} + +func (_List_PollerInfo_ValueList) Close() {} + +// ToWire translates a GetPollerHistoryResponse struct into a Thrift-level intermediate +// representation. This intermediate representation may be serialized +// into bytes using a ThriftRW protocol implementation. +// +// An error is returned if the struct or any of its fields failed to +// validate. +// +// x, err := v.ToWire() +// if err != nil { +// return err +// } +// +// if err := binaryProtocol.Encode(x, writer); err != nil { +// return err +// } +func (v *GetPollerHistoryResponse) ToWire() (wire.Value, error) { + var ( + fields [1]wire.Field + i int = 0 + w wire.Value + err error + ) + + if v.Pollers != nil { + w, err = wire.NewValueList(_List_PollerInfo_ValueList(v.Pollers)), error(nil) + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 10, Value: w} + i++ + } + + return wire.NewValueStruct(wire.Struct{Fields: fields[:i]}), nil +} + +func _PollerInfo_Read(w wire.Value) (*PollerInfo, error) { + var v PollerInfo + err := v.FromWire(w) + return &v, err +} + +func _List_PollerInfo_Read(l wire.ValueList) ([]*PollerInfo, error) { + if l.ValueType() != wire.TStruct { + return nil, nil + } + + o := make([]*PollerInfo, 0, l.Size()) + err := l.ForEach(func(x wire.Value) error { + i, err := _PollerInfo_Read(x) + if err != nil { + return err + } + o = append(o, i) + return nil + }) + l.Close() + return o, err +} + +// FromWire deserializes a GetPollerHistoryResponse struct from its Thrift-level +// representation. The Thrift-level representation may be obtained +// from a ThriftRW protocol implementation. +// +// An error is returned if we were unable to build a GetPollerHistoryResponse struct +// from the provided intermediate representation. +// +// x, err := binaryProtocol.Decode(reader, wire.TStruct) +// if err != nil { +// return nil, err +// } +// +// var v GetPollerHistoryResponse +// if err := v.FromWire(x); err != nil { +// return nil, err +// } +// return &v, nil +func (v *GetPollerHistoryResponse) FromWire(w wire.Value) error { + var err error + + for _, field := range w.GetStruct().Fields { + switch field.ID { + case 10: + if field.Value.Type() == wire.TList { + v.Pollers, err = _List_PollerInfo_Read(field.Value.GetList()) + if err != nil { + return err + } + + } + } + } + + return nil +} + +// String returns a readable string representation of a GetPollerHistoryResponse +// struct. +func (v *GetPollerHistoryResponse) String() string { + if v == nil { + return "" + } + + var fields [1]string + i := 0 + if v.Pollers != nil { + fields[i] = fmt.Sprintf("Pollers: %v", v.Pollers) + i++ + } + + return fmt.Sprintf("GetPollerHistoryResponse{%v}", strings.Join(fields[:i], ", ")) +} + +func _List_PollerInfo_Equals(lhs, rhs []*PollerInfo) bool { + if len(lhs) != len(rhs) { + return false + } + + for i, lv := range lhs { + rv := rhs[i] + if !lv.Equals(rv) { + return false + } + } + + return true +} + +// Equals returns true if all the fields of this GetPollerHistoryResponse match the +// provided GetPollerHistoryResponse. +// +// This function performs a deep comparison. +func (v *GetPollerHistoryResponse) Equals(rhs *GetPollerHistoryResponse) bool { + if !((v.Pollers == nil && rhs.Pollers == nil) || (v.Pollers != nil && rhs.Pollers != nil && _List_PollerInfo_Equals(v.Pollers, rhs.Pollers))) { + return false + } + + return true +} + type GetWorkflowExecutionHistoryRequest struct { Domain *string `json:"domain,omitempty"` Execution *WorkflowExecution `json:"execution,omitempty"` @@ -13107,6 +13471,158 @@ func (v *PollForDecisionTaskResponse) GetBacklogCountHint() (o int64) { return } +type PollerInfo struct { + Timestamp *string `json:"timestamp,omitempty"` + Identity *string `json:"identity,omitempty"` +} + +// ToWire translates a PollerInfo struct into a Thrift-level intermediate +// representation. This intermediate representation may be serialized +// into bytes using a ThriftRW protocol implementation. +// +// An error is returned if the struct or any of its fields failed to +// validate. +// +// x, err := v.ToWire() +// if err != nil { +// return err +// } +// +// if err := binaryProtocol.Encode(x, writer); err != nil { +// return err +// } +func (v *PollerInfo) ToWire() (wire.Value, error) { + var ( + fields [2]wire.Field + i int = 0 + w wire.Value + err error + ) + + if v.Timestamp != nil { + w, err = wire.NewValueString(*(v.Timestamp)), error(nil) + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 10, Value: w} + i++ + } + if v.Identity != nil { + w, err = wire.NewValueString(*(v.Identity)), error(nil) + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 20, Value: w} + i++ + } + + return wire.NewValueStruct(wire.Struct{Fields: fields[:i]}), nil +} + +// FromWire deserializes a PollerInfo struct from its Thrift-level +// representation. The Thrift-level representation may be obtained +// from a ThriftRW protocol implementation. +// +// An error is returned if we were unable to build a PollerInfo struct +// from the provided intermediate representation. +// +// x, err := binaryProtocol.Decode(reader, wire.TStruct) +// if err != nil { +// return nil, err +// } +// +// var v PollerInfo +// if err := v.FromWire(x); err != nil { +// return nil, err +// } +// return &v, nil +func (v *PollerInfo) FromWire(w wire.Value) error { + var err error + + for _, field := range w.GetStruct().Fields { + switch field.ID { + case 10: + if field.Value.Type() == wire.TBinary { + var x string + x, err = field.Value.GetString(), error(nil) + v.Timestamp = &x + if err != nil { + return err + } + + } + case 20: + if field.Value.Type() == wire.TBinary { + var x string + x, err = field.Value.GetString(), error(nil) + v.Identity = &x + if err != nil { + return err + } + + } + } + } + + return nil +} + +// String returns a readable string representation of a PollerInfo +// struct. +func (v *PollerInfo) String() string { + if v == nil { + return "" + } + + var fields [2]string + i := 0 + if v.Timestamp != nil { + fields[i] = fmt.Sprintf("Timestamp: %v", *(v.Timestamp)) + i++ + } + if v.Identity != nil { + fields[i] = fmt.Sprintf("Identity: %v", *(v.Identity)) + i++ + } + + return fmt.Sprintf("PollerInfo{%v}", strings.Join(fields[:i], ", ")) +} + +// Equals returns true if all the fields of this PollerInfo match the +// provided PollerInfo. +// +// This function performs a deep comparison. +func (v *PollerInfo) Equals(rhs *PollerInfo) bool { + if !_String_EqualsPtr(v.Timestamp, rhs.Timestamp) { + return false + } + if !_String_EqualsPtr(v.Identity, rhs.Identity) { + return false + } + + return true +} + +// GetTimestamp returns the value of Timestamp if it is set or its +// zero value if it is unset. +func (v *PollerInfo) GetTimestamp() (o string) { + if v.Timestamp != nil { + return *v.Timestamp + } + + return +} + +// GetIdentity returns the value of Identity if it is set or its +// zero value if it is unset. +func (v *PollerInfo) GetIdentity() (o string) { + if v.Identity != nil { + return *v.Identity + } + + return +} + type QueryFailedError struct { Message string `json:"message,required"` } @@ -20653,6 +21169,136 @@ func (v *TaskListMetadata) GetMaxTasksPerSecond() (o float64) { return } +type TaskListType int32 + +const ( + TaskListTypeDecision TaskListType = 0 + TaskListTypeActivity TaskListType = 1 +) + +// TaskListType_Values returns all recognized values of TaskListType. +func TaskListType_Values() []TaskListType { + return []TaskListType{ + TaskListTypeDecision, + TaskListTypeActivity, + } +} + +// UnmarshalText tries to decode TaskListType from a byte slice +// containing its name. +// +// var v TaskListType +// err := v.UnmarshalText([]byte("Decision")) +func (v *TaskListType) UnmarshalText(value []byte) error { + switch string(value) { + case "Decision": + *v = TaskListTypeDecision + return nil + case "Activity": + *v = TaskListTypeActivity + return nil + default: + return fmt.Errorf("unknown enum value %q for %q", value, "TaskListType") + } +} + +// ToWire translates TaskListType into a Thrift-level intermediate +// representation. This intermediate representation may be serialized +// into bytes using a ThriftRW protocol implementation. +// +// Enums are represented as 32-bit integers over the wire. +func (v TaskListType) ToWire() (wire.Value, error) { + return wire.NewValueI32(int32(v)), nil +} + +// FromWire deserializes TaskListType from its Thrift-level +// representation. +// +// x, err := binaryProtocol.Decode(reader, wire.TI32) +// if err != nil { +// return TaskListType(0), err +// } +// +// var v TaskListType +// if err := v.FromWire(x); err != nil { +// return TaskListType(0), err +// } +// return v, nil +func (v *TaskListType) FromWire(w wire.Value) error { + *v = (TaskListType)(w.GetI32()) + return nil +} + +// String returns a readable string representation of TaskListType. +func (v TaskListType) String() string { + w := int32(v) + switch w { + case 0: + return "Decision" + case 1: + return "Activity" + } + return fmt.Sprintf("TaskListType(%d)", w) +} + +// Equals returns true if this TaskListType value matches the provided +// value. +func (v TaskListType) Equals(rhs TaskListType) bool { + return v == rhs +} + +// MarshalJSON serializes TaskListType into JSON. +// +// If the enum value is recognized, its name is returned. Otherwise, +// its integer value is returned. +// +// This implements json.Marshaler. +func (v TaskListType) MarshalJSON() ([]byte, error) { + switch int32(v) { + case 0: + return ([]byte)("\"Decision\""), nil + case 1: + return ([]byte)("\"Activity\""), nil + } + return ([]byte)(strconv.FormatInt(int64(v), 10)), nil +} + +// UnmarshalJSON attempts to decode TaskListType from its JSON +// representation. +// +// This implementation supports both, numeric and string inputs. If a +// string is provided, it must be a known enum name. +// +// This implements json.Unmarshaler. +func (v *TaskListType) UnmarshalJSON(text []byte) error { + d := json.NewDecoder(bytes.NewReader(text)) + d.UseNumber() + t, err := d.Token() + if err != nil { + return err + } + + switch w := t.(type) { + case json.Number: + x, err := w.Int64() + if err != nil { + return err + } + if x > math.MaxInt32 { + return fmt.Errorf("enum overflow from JSON %q for %q", text, "TaskListType") + } + if x < math.MinInt32 { + return fmt.Errorf("enum underflow from JSON %q for %q", text, "TaskListType") + } + *v = (TaskListType)(x) + return nil + case string: + return v.UnmarshalText([]byte(w)) + default: + return fmt.Errorf("invalid JSON value %q (%T) to unmarshal into %q", t, t, "TaskListType") + } +} + type TerminateWorkflowExecutionRequest struct { Domain *string `json:"domain,omitempty"` WorkflowExecution *WorkflowExecution `json:"workflowExecution,omitempty"` diff --git a/client/matching/client.go b/client/matching/client.go index 73f88df3441..12d94697f6c 100644 --- a/client/matching/client.go +++ b/client/matching/client.go @@ -146,6 +146,17 @@ func (c *clientImpl) CancelOutstandingPoll(ctx context.Context, request *m.Cance return client.CancelOutstandingPoll(ctx, request, opts...) } +func (c *clientImpl) GetPollerHistory(ctx context.Context, request *m.GetPollerHistoryRequest, opts ...yarpc.CallOption) (*workflow.GetPollerHistoryResponse, error) { + opts = common.AggregateYarpcOptions(ctx, opts...) + client, err := c.getHostForRequest(request.GetRequest.TaskList.GetName()) + if err != nil { + return nil, err + } + ctx, cancel := c.createContext(ctx) + defer cancel() + return client.GetPollerHistory(ctx, request, opts...) +} + func (c *clientImpl) getHostForRequest(key string) (matchingserviceclient.Interface, error) { host, err := c.resolver.Lookup(key) if err != nil { diff --git a/client/matching/metricClient.go b/client/matching/metricClient.go index 7caa8c9dbb2..526e4cea92a 100644 --- a/client/matching/metricClient.go +++ b/client/matching/metricClient.go @@ -162,3 +162,20 @@ func (c *metricClient) CancelOutstandingPoll( return err } + +func (c *metricClient) GetPollerHistory( + ctx context.Context, + request *m.GetPollerHistoryRequest, + opts ...yarpc.CallOption) (*workflow.GetPollerHistoryResponse, error) { + c.metricsClient.IncCounter(metrics.MatchingClientGetPollerHistoryScope, metrics.CadenceRequests) + + sw := c.metricsClient.StartTimer(metrics.MatchingClientGetPollerHistoryScope, metrics.CadenceLatency) + resp, err := c.client.GetPollerHistory(ctx, request, opts...) + sw.Stop() + + if err != nil { + c.metricsClient.IncCounter(metrics.MatchingClientGetPollerHistoryScope, metrics.CadenceFailures) + } + + return resp, err +} diff --git a/common/cache/cache.go b/common/cache/cache.go index a63d3f6d3f3..74c08e53384 100644 --- a/common/cache/cache.go +++ b/common/cache/cache.go @@ -44,6 +44,9 @@ type Cache interface { // drops to 0, the element can be evicted from the cache. Release(key interface{}) + // Iterator returns the iterator of the cache + Iterator() Iterator + // Size returns the number of entries currently stored in the Cache Size() int } @@ -70,3 +73,23 @@ type Options struct { // appropriate signature and i is the interface{} scheduled for // deletion, Cache calls go f(i) type RemovedFunc func(interface{}) + +// Iterator represents the interface for cache iterators +type Iterator interface { + // Close closes the iterator + // and releases any allocated resources + Close() + // Entries returns a channel of MapEntry + // objects that can be used in a range loop + Entries() <-chan Entry +} + +// Entry represents a key-value entry within the map +type Entry interface { + // Key represents the key + Key() interface{} + // Value represents the value + Value() interface{} + // Timestamp represents the time when the value is updated + Timestamp() time.Time +} diff --git a/common/cache/lru.go b/common/cache/lru.go index a6107dbdf12..d40e7603699 100644 --- a/common/cache/lru.go +++ b/common/cache/lru.go @@ -33,14 +33,90 @@ var ( ) // lru is a concurrent fixed size cache that evicts elements in lru order -type lru struct { - mut sync.Mutex - byAccess *list.List - byKey map[interface{}]*list.Element - maxSize int - ttl time.Duration - pin bool - rmFunc RemovedFunc +type ( + lru struct { + mut sync.Mutex + byAccess *list.List + byKey map[interface{}]*list.Element + maxSize int + ttl time.Duration + pin bool + rmFunc RemovedFunc + } + + iteratorImpl struct { + stopCh chan struct{} + dataCh chan Entry + } + + entryImpl struct { + key interface{} + timestamp time.Time + value interface{} + refCount int + } +) + +// Close closes the iterator +func (it *iteratorImpl) Close() { + close(it.stopCh) +} + +// Entries returns a channel of map entries +func (it *iteratorImpl) Entries() <-chan Entry { + return it.dataCh +} + +// Iterator returns an iterator to the map. This map +// does not use re-entrant locks, so access or modification +// to the map during iteration can cause a dead lock. +func (c *lru) Iterator() Iterator { + + iterator := &iteratorImpl{ + dataCh: make(chan Entry, 8), + stopCh: make(chan struct{}), + } + + go func(iterator *iteratorImpl) { + c.mut.Lock() + for _, element := range c.byKey { + entry := element.Value.(*entryImpl) + if c.isEntryExpired(entry) { + // Entry has expired + c.deleteInternal(element) + continue + } + // make a copy of the entry so there will be no concurrent access to this entry + entry = &entryImpl{ + key: entry.key, + value: entry.value, + timestamp: entry.timestamp, + } + select { + case iterator.dataCh <- entry: + case <-iterator.stopCh: + c.mut.Unlock() + close(iterator.dataCh) + return + } + } + c.mut.Unlock() + close(iterator.dataCh) + }(iterator) + + return iterator +} + +func (entry *entryImpl) Key() interface{} { + return entry.key +} + +func (entry *entryImpl) Value() interface{} { + return entry.value +} + +func (entry *entryImpl) Timestamp() time.Time { + return entry.timestamp } // New creates a new cache with the given options @@ -78,29 +154,25 @@ func (c *lru) Get(key interface{}) interface{} { c.mut.Lock() defer c.mut.Unlock() - elt := c.byKey[key] - if elt == nil { + element := c.byKey[key] + if element == nil { return nil } - cacheEntry := elt.Value.(*cacheEntry) + entry := element.Value.(*entryImpl) if c.pin { - cacheEntry.refCount++ + entry.refCount++ } - if cacheEntry.refCount == 0 && !cacheEntry.expiration.IsZero() && time.Now().After(cacheEntry.expiration) { + if c.isEntryExpired(entry) { // Entry has expired - if c.rmFunc != nil { - go c.rmFunc(cacheEntry.value) - } - c.byAccess.Remove(elt) - delete(c.byKey, cacheEntry.key) + c.deleteInternal(element) return nil } - c.byAccess.MoveToFront(elt) - return cacheEntry.value + c.byAccess.MoveToFront(element) + return entry.value } // Put puts a new value associated with a given key, returning the existing value (if present) @@ -132,13 +204,9 @@ func (c *lru) Delete(key interface{}) { c.mut.Lock() defer c.mut.Unlock() - elt := c.byKey[key] - if elt != nil { - entry := c.byAccess.Remove(elt).(*cacheEntry) - if c.rmFunc != nil { - go c.rmFunc(entry.value) - } - delete(c.byKey, key) + element := c.byKey[key] + if element != nil { + c.deleteInternal(element) } } @@ -148,8 +216,8 @@ func (c *lru) Release(key interface{}) { defer c.mut.Unlock() elt := c.byKey[key] - cacheEntry := elt.Value.(*cacheEntry) - cacheEntry.refCount-- + entry := elt.Value.(*entryImpl) + entry.refCount-- } // Size returns the number of entries currently in the lru, useful if cache is not full @@ -168,13 +236,13 @@ func (c *lru) putInternal(key interface{}, value interface{}, allowUpdate bool) elt := c.byKey[key] if elt != nil { - entry := elt.Value.(*cacheEntry) + entry := elt.Value.(*entryImpl) existing := entry.value if allowUpdate { entry.value = value } if c.ttl != 0 { - entry.expiration = time.Now().Add(c.ttl) + entry.timestamp = time.Now() } c.byAccess.MoveToFront(elt) if c.pin { @@ -183,7 +251,7 @@ func (c *lru) putInternal(key interface{}, value interface{}, allowUpdate bool) return existing, nil } - entry := &cacheEntry{ + entry := &entryImpl{ key: key, value: value, } @@ -193,34 +261,34 @@ func (c *lru) putInternal(key interface{}, value interface{}, allowUpdate bool) } if c.ttl != 0 { - entry.expiration = time.Now().Add(c.ttl) + entry.timestamp = time.Now() } c.byKey[key] = c.byAccess.PushFront(entry) if len(c.byKey) == c.maxSize { - oldest := c.byAccess.Back().Value.(*cacheEntry) + oldest := c.byAccess.Back().Value.(*entryImpl) if oldest.refCount > 0 { // Cache is full with pinned elements // revert the insert and return - c.byAccess.Remove(c.byAccess.Front()) - delete(c.byKey, key) + c.deleteInternal(c.byAccess.Front()) return nil, ErrCacheFull } - c.byAccess.Remove(c.byAccess.Back()) - if c.rmFunc != nil { - go c.rmFunc(oldest.value) - } - delete(c.byKey, oldest.key) + c.deleteInternal(c.byAccess.Back()) } return nil, nil } -type cacheEntry struct { - key interface{} - expiration time.Time - value interface{} - refCount int +func (c *lru) deleteInternal(element *list.Element) { + entry := c.byAccess.Remove(element).(*entryImpl) + if c.rmFunc != nil { + go c.rmFunc(entry.value) + } + delete(c.byKey, entry.key) +} + +func (c *lru) isEntryExpired(entry *entryImpl) bool { + return entry.refCount == 0 && !entry.timestamp.IsZero() && time.Now().After(entry.timestamp.Add(c.ttl)) } diff --git a/common/cache/lru_test.go b/common/cache/lru_test.go index 328f6887287..3cca5613d9e 100644 --- a/common/cache/lru_test.go +++ b/common/cache/lru_test.go @@ -180,3 +180,28 @@ func TestRemovedFuncWithTTL(t *testing.T) { t.Error("RemovedFunc did not send true on channel ch") } } + +func TestIterator(t *testing.T) { + expected := map[string]string{ + "A": "Alpha", + "B": "Beta", + "G": "Gamma", + "D": "Delta", + } + + cache := NewLRU(5) + + for k, v := range expected { + cache.Put(k, v) + } + + actual := map[string]string{} + + ite := cache.Iterator() + defer ite.Close() + for entry := range ite.Entries() { + actual[entry.Key().(string)] = entry.Value().(string) + } + + assert.Equal(t, expected, actual) +} diff --git a/common/convert.go b/common/convert.go index 90dda0331ce..4346ba596e8 100644 --- a/common/convert.go +++ b/common/convert.go @@ -20,7 +20,11 @@ package common -import s "github.com/uber/cadence/.gen/go/shared" +import ( + "time" + + s "github.com/uber/cadence/.gen/go/shared" +) // IntPtr makes a copy and returns the pointer to an int. func IntPtr(v int) *int { @@ -57,6 +61,12 @@ func BoolPtr(v bool) *bool { return &v } +// TimePtr makes a copy and returns the pointer to a string for time.Time, as ISO 8601 format. +func TimePtr(v time.Time) *string { + time := v.UTC().Format(time.RFC3339) + return &time +} + // StringPtr makes a copy and returns the pointer to a string. func StringPtr(v string) *string { return &v diff --git a/common/metrics/defs.go b/common/metrics/defs.go index f44c5686056..f40d9dec154 100644 --- a/common/metrics/defs.go +++ b/common/metrics/defs.go @@ -207,6 +207,8 @@ const ( MatchingClientRespondQueryTaskCompletedScope // MatchingClientCancelOutstandingPollScope tracks RPC calls to matching service MatchingClientCancelOutstandingPollScope + // MatchingClientGetPollerHistoryScope tracks RPC calls to matching service + MatchingClientGetPollerHistoryScope NumCommonScopes ) @@ -263,6 +265,8 @@ const ( FrontendQueryWorkflowScope // FrontendDescribeWorkflowExecutionScope is the metric scope for frontend.DescribeWorkflowExecution FrontendDescribeWorkflowExecutionScope + // FrontendGetPollerHistoryScope is the metric scope for frontend.GetPollerHistory + FrontendGetPollerHistoryScope NumFrontendScopes ) @@ -351,6 +355,8 @@ const ( MatchingRespondQueryTaskCompletedScope // MatchingCancelOutstandingPollScope tracks CancelOutstandingPoll API calls received by service MatchingCancelOutstandingPollScope + // MatchingGetPollerHistoryScope tracks GetPollerHistory API calls received by service + MatchingGetPollerHistoryScope NumMatchingScopes ) @@ -408,6 +414,7 @@ var ScopeDefs = map[ServiceIdx]map[int]scopeDefinition{ MatchingClientQueryWorkflowScope: {operation: "MatchingClientQueryWorkflow"}, MatchingClientRespondQueryTaskCompletedScope: {operation: "MatchingClientRespondQueryTaskCompleted"}, MatchingClientCancelOutstandingPollScope: {operation: "MatchingClientCancelOutstandingPoll"}, + MatchingClientGetPollerHistoryScope: {operation: "MatchingClientGetPollerHistory"}, }, // Frontend Scope Names Frontend: { @@ -436,6 +443,7 @@ var ScopeDefs = map[ServiceIdx]map[int]scopeDefinition{ FrontendDeprecateDomainScope: {operation: "DeprecateDomain"}, FrontendQueryWorkflowScope: {operation: "QueryWorkflow"}, FrontendDescribeWorkflowExecutionScope: {operation: "DescribeWorkflowExecution"}, + FrontendGetPollerHistoryScope: {operation: "GetPollerHistory"}, }, // History Scope Names History: { @@ -480,6 +488,7 @@ var ScopeDefs = map[ServiceIdx]map[int]scopeDefinition{ MatchingQueryWorkflowScope: {operation: "QueryWorkflow"}, MatchingRespondQueryTaskCompletedScope: {operation: "RespondQueryTaskCompleted"}, MatchingCancelOutstandingPollScope: {operation: "CancelOutstandingPoll"}, + MatchingGetPollerHistoryScope: {operation: "GetPollerHistory"}, }, } diff --git a/common/mocks/MatchingClient.go b/common/mocks/MatchingClient.go index 95a3277f198..b40f33b2d1e 100644 --- a/common/mocks/MatchingClient.go +++ b/common/mocks/MatchingClient.go @@ -164,3 +164,27 @@ func (_m *MatchingClient) CancelOutstandingPoll(ctx context.Context, return r0 } + +// GetPollerHistory provides a mock function with given fields: ctx, request +func (_m *MatchingClient) GetPollerHistory(ctx context.Context, + request *matching.GetPollerHistoryRequest, opts ...yarpc.CallOption) (*shared.GetPollerHistoryResponse, error) { + ret := _m.Called(ctx, request) + + var r0 *shared.GetPollerHistoryResponse + if rf, ok := ret.Get(0).(func(context.Context, *matching.GetPollerHistoryRequest) *shared.GetPollerHistoryResponse); ok { + r0 = rf(ctx, request) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*shared.GetPollerHistoryResponse) + } + } + + var r1 error + if rf, ok := ret.Get(1).(func(context.Context, *matching.GetPollerHistoryRequest) error); ok { + r1 = rf(ctx, request) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} diff --git a/host/integration_test.go b/host/integration_test.go index ee4ce1c8554..a7391295945 100644 --- a/host/integration_test.go +++ b/host/integration_test.go @@ -3621,6 +3621,129 @@ func (s *integrationSuite) TestGetWorkflowExecutionHistoryLongPoll() { s.Equal(11, len(allEvents)) } +func (s *integrationSuite) TestGetPollerHistory() { + workflowID := "interation-get-poller-history" + identity := "worker1" + activityName := "activity_type1" + + workflowType := &workflow.WorkflowType{} + workflowType.Name = common.StringPtr("interation-get-poller-history-type") + + taskList := &workflow.TaskList{} + taskList.Name = common.StringPtr("interation-get-poller-history-tasklist") + + // Start workflow execution + request := &workflow.StartWorkflowExecutionRequest{ + RequestId: common.StringPtr(uuid.New()), + Domain: common.StringPtr(s.domainName), + WorkflowId: common.StringPtr(workflowID), + WorkflowType: workflowType, + TaskList: taskList, + Input: nil, + ExecutionStartToCloseTimeoutSeconds: common.Int32Ptr(100), + TaskStartToCloseTimeoutSeconds: common.Int32Ptr(1), + Identity: common.StringPtr(identity), + } + + we, err0 := s.engine.StartWorkflowExecution(createContext(), request) + s.Nil(err0) + + s.logger.Infof("StartWorkflowExecution: response: %v \n", *we.RunId) + + // decider logic + workflowComplete := false + activityScheduled := false + activityData := int32(1) + // var signalEvent *workflow.HistoryEvent + dtHandler := func(execution *workflow.WorkflowExecution, wt *workflow.WorkflowType, + previousStartedEventID, startedEventID int64, history *workflow.History) ([]byte, []*workflow.Decision, error) { + + if !activityScheduled { + activityScheduled = true + buf := new(bytes.Buffer) + s.Nil(binary.Write(buf, binary.LittleEndian, activityData)) + + return nil, []*workflow.Decision{{ + DecisionType: common.DecisionTypePtr(workflow.DecisionTypeScheduleActivityTask), + ScheduleActivityTaskDecisionAttributes: &workflow.ScheduleActivityTaskDecisionAttributes{ + ActivityId: common.StringPtr(strconv.Itoa(int(1))), + ActivityType: &workflow.ActivityType{Name: common.StringPtr(activityName)}, + TaskList: taskList, + Input: buf.Bytes(), + ScheduleToCloseTimeoutSeconds: common.Int32Ptr(100), + ScheduleToStartTimeoutSeconds: common.Int32Ptr(25), + StartToCloseTimeoutSeconds: common.Int32Ptr(50), + HeartbeatTimeoutSeconds: common.Int32Ptr(25), + }, + }}, nil + } + + workflowComplete = true + return nil, []*workflow.Decision{{ + DecisionType: common.DecisionTypePtr(workflow.DecisionTypeCompleteWorkflowExecution), + CompleteWorkflowExecutionDecisionAttributes: &workflow.CompleteWorkflowExecutionDecisionAttributes{ + Result: []byte("Done."), + }, + }}, nil + } + + // activity handler + atHandler := func(execution *workflow.WorkflowExecution, activityType *workflow.ActivityType, + activityID string, input []byte, taskToken []byte) ([]byte, bool, error) { + + return []byte("Activity Result."), false, nil + } + + poller := &taskPoller{ + engine: s.engine, + domain: s.domainName, + taskList: taskList, + identity: identity, + decisionHandler: dtHandler, + activityHandler: atHandler, + logger: s.logger, + suite: s, + } + + // this function poll events from history side + testGetPollerHistory := func(domain string, tasklist *workflow.TaskList, tasklistType workflow.TaskListType) []*workflow.PollerInfo { + responseInner, errInner := s.engine.GetPollerHistory(createContext(), &workflow.GetPollerHistoryRequest{ + Domain: common.StringPtr(domain), + TaskList: taskList, + TaskListType: &tasklistType, + }) + + s.Nil(errInner) + return responseInner.Pollers + } + + // when no one polling on the tasklist (activity or decition), there shall be no poller information + pollerInfos := testGetPollerHistory(s.domainName, taskList, workflow.TaskListTypeActivity) + s.Empty(pollerInfos) + pollerInfos = testGetPollerHistory(s.domainName, taskList, workflow.TaskListTypeDecision) + s.Empty(pollerInfos) + + _, errDecision := poller.pollAndProcessDecisionTask(false, false) + s.Nil(errDecision) + pollerInfos = testGetPollerHistory(s.domainName, taskList, workflow.TaskListTypeActivity) + s.Empty(pollerInfos) + pollerInfos = testGetPollerHistory(s.domainName, taskList, workflow.TaskListTypeDecision) + s.Equal(1, len(pollerInfos)) + s.Equal(identity, pollerInfos[0].GetIdentity()) + s.NotEmpty(pollerInfos[0].GetTimestamp()) + + errActivity := poller.pollAndProcessActivityTask(false) + s.Nil(errActivity) + pollerInfos = testGetPollerHistory(s.domainName, taskList, workflow.TaskListTypeActivity) + s.Equal(1, len(pollerInfos)) + s.Equal(identity, pollerInfos[0].GetIdentity()) + s.NotEmpty(pollerInfos[0].GetTimestamp()) + pollerInfos = testGetPollerHistory(s.domainName, taskList, workflow.TaskListTypeDecision) + s.Equal(1, len(pollerInfos)) + s.Equal(identity, pollerInfos[0].GetIdentity()) + s.NotEmpty(pollerInfos[0].GetTimestamp()) +} + func (s *integrationSuite) setupShards() { // shard 0 is always created, we create additional shards if needed for shardID := 1; shardID < testNumberOfHistoryShards; shardID++ { diff --git a/idl/github.com/uber/cadence/cadence.thrift b/idl/github.com/uber/cadence/cadence.thrift index ee3362ea2cd..466a822abef 100644 --- a/idl/github.com/uber/cadence/cadence.thrift +++ b/idl/github.com/uber/cadence/cadence.thrift @@ -351,4 +351,14 @@ service WorkflowService { 3: shared.EntityNotExistsError entityNotExistError, ) + /** + * GetPollerHistory returns pollers which poll from given tasklist in last few minutes. + **/ + shared.GetPollerHistoryResponse GetPollerHistory(1: shared.GetPollerHistoryRequest request) + throws ( + 1: shared.BadRequestError badRequestError, + 2: shared.InternalServiceError internalServiceError, + 3: shared.EntityNotExistsError entityNotExistError, + ) + } diff --git a/idl/github.com/uber/cadence/matching.thrift b/idl/github.com/uber/cadence/matching.thrift index ad1e829e234..c557befd9d6 100644 --- a/idl/github.com/uber/cadence/matching.thrift +++ b/idl/github.com/uber/cadence/matching.thrift @@ -85,6 +85,11 @@ struct CancelOutstandingPollRequest { 40: optional string pollerID } +struct GetPollerHistoryRequest { + 10: optional string domainUUID + 20: optional shared.GetPollerHistoryRequest getRequest +} + /** * MatchingService API is exposed to provide support for polling from long running applications. * Such applications are expected to have a worker which regularly polls for DecisionTask and ActivityTask. For each @@ -139,22 +144,22 @@ service MatchingService { * QueryWorkflow is called by frontend to query a workflow. **/ shared.QueryWorkflowResponse QueryWorkflow(1: QueryWorkflowRequest queryRequest) - throws ( - 1: shared.BadRequestError badRequestError, - 2: shared.InternalServiceError internalServiceError, - 3: shared.EntityNotExistsError entityNotExistError, - 4: shared.QueryFailedError queryFailedError, - ) + throws ( + 1: shared.BadRequestError badRequestError, + 2: shared.InternalServiceError internalServiceError, + 3: shared.EntityNotExistsError entityNotExistError, + 4: shared.QueryFailedError queryFailedError, + ) /** * RespondQueryTaskCompleted is called by frontend to respond query completed. **/ void RespondQueryTaskCompleted(1: RespondQueryTaskCompletedRequest request) - throws ( - 1: shared.BadRequestError badRequestError, - 2: shared.InternalServiceError internalServiceError, - 3: shared.EntityNotExistsError entityNotExistError, - ) + throws ( + 1: shared.BadRequestError badRequestError, + 2: shared.InternalServiceError internalServiceError, + 3: shared.EntityNotExistsError entityNotExistError, + ) /** * CancelOutstandingPoll is called by frontend to unblock long polls on matching for zombie pollers. @@ -171,4 +176,13 @@ service MatchingService { 2: shared.InternalServiceError internalServiceError, ) + /** + * GetPollerHistory returns pollers which poll from given tasklist in last few minutes. + **/ + shared.GetPollerHistoryResponse GetPollerHistory(1: GetPollerHistoryRequest request) + throws ( + 1: shared.BadRequestError badRequestError, + 2: shared.InternalServiceError internalServiceError, + 3: shared.EntityNotExistsError entityNotExistError, + ) } diff --git a/idl/github.com/uber/cadence/shared.thrift b/idl/github.com/uber/cadence/shared.thrift index 9784dd219cb..d05c99cd8c6 100644 --- a/idl/github.com/uber/cadence/shared.thrift +++ b/idl/github.com/uber/cadence/shared.thrift @@ -930,3 +930,30 @@ struct DescribeWorkflowExecutionResponse { 10: optional WorkflowExecutionConfiguration executionConfiguration 20: optional WorkflowExecutionInfo workflowExecutionInfo } + +struct GetPollerHistoryRequest { + 10: optional string domain + 20: optional TaskList taskList + 30: optional TaskListType taskListType +} + +struct GetPollerHistoryResponse { + 10: optional list pollers +} + +enum TaskListType { + /* + * Decision type of tasklist + */ + Decision, + /* + * Activity type of tasklist + */ + Activity, +} + +struct PollerInfo { + // ISO 8601 format + 10: optional string timestamp + 20: optional string identity +} diff --git a/service/frontend/handler.go b/service/frontend/handler.go index e7a8223780d..4ff45b979f6 100644 --- a/service/frontend/handler.go +++ b/service/frontend/handler.go @@ -81,6 +81,7 @@ var ( errInvalidTaskToken = &gen.BadRequestError{Message: "Invalid TaskToken."} errInvalidRequestType = &gen.BadRequestError{Message: "Invalid request type."} errTaskListNotSet = &gen.BadRequestError{Message: "TaskList is not set on request."} + errTaskListTypeNotSet = &gen.BadRequestError{Message: "TaskListType is not set on request."} errExecutionNotSet = &gen.BadRequestError{Message: "Execution is not set on request."} errWorkflowIDNotSet = &gen.BadRequestError{Message: "WorkflowId is not set on request."} errRunIDNotSet = &gen.BadRequestError{Message: "RunId is not set on request."} @@ -1422,6 +1423,45 @@ func (wh *WorkflowHandler) DescribeWorkflowExecution(ctx context.Context, reques return response, nil } +// GetPollerHistory get poller information for given tasklist +func (wh *WorkflowHandler) GetPollerHistory(ctx context.Context, request *gen.GetPollerHistoryRequest) (*gen.GetPollerHistoryResponse, error) { + + scope := metrics.FrontendGetPollerHistoryScope + sw := wh.startRequestProfile(scope) + defer sw.Stop() + + if ok, _ := wh.rateLimiter.TryConsume(1); !ok { + return nil, wh.error(createServiceBusyError(), scope) + } + + if request.Domain == nil { + return nil, wh.error(errDomainNotSet, scope) + } + domainInfo, _, err := wh.domainCache.GetDomain(request.GetDomain()) + if err != nil { + return nil, wh.error(err, scope) + } + + if err := wh.validateTaskList(request.TaskList, scope); err != nil { + return nil, err + } + + if err := wh.validateTaskListType(request.TaskListType, scope); err != nil { + return nil, err + } + + response, err := wh.matching.GetPollerHistory(ctx, &m.GetPollerHistoryRequest{ + DomainUUID: common.StringPtr(domainInfo.ID), + GetRequest: request, + }) + + if err != nil { + return nil, wh.error(err, scope) + } + + return response, nil +} + func (wh *WorkflowHandler) getHistory(domainID string, execution gen.WorkflowExecution, firstEventID, nextEventID int64, pageSize int32, nextPageToken []byte, transientDecision *gen.TransientDecisionInfo) (*gen.History, []byte, error) { @@ -1527,6 +1567,13 @@ func (wh *WorkflowHandler) error(err error, scope int) error { } } +func (wh *WorkflowHandler) validateTaskListType(t *gen.TaskListType, scope int) error { + if t == nil { + return wh.error(errTaskListTypeNotSet, scope) + } + return nil +} + func (wh *WorkflowHandler) validateTaskList(t *gen.TaskList, scope int) error { if t == nil || t.Name == nil || *t.Name == "" { return wh.error(errTaskListNotSet, scope) diff --git a/service/matching/handler.go b/service/matching/handler.go index d346fa229ba..3c2a996882a 100644 --- a/service/matching/handler.go +++ b/service/matching/handler.go @@ -169,6 +169,16 @@ func (h *Handler) CancelOutstandingPoll(ctx context.Context, return h.handleErr(err, scope) } +// GetPollerHistory get poller information for given tasklist +func (h *Handler) GetPollerHistory(ctx context.Context, request *m.GetPollerHistoryRequest) (*gen.GetPollerHistoryResponse, error) { + scope := metrics.MatchingGetPollerHistoryScope + sw := h.startRequestProfile("GetPollerHistory", scope) + defer sw.Stop() + + response, err := h.engine.GetPollerHistory(ctx, request) + return response, h.handleErr(err, scope) +} + func (h *Handler) handleErr(err error, scope int) error { if err == nil { diff --git a/service/matching/matchingEngine.go b/service/matching/matchingEngine.go index 1ca93c8d859..5cf8f4a75ef 100644 --- a/service/matching/matchingEngine.go +++ b/service/matching/matchingEngine.go @@ -65,6 +65,7 @@ type taskListID struct { } type pollerIDCtxKey string +type identityCtxKey string var ( // EmptyPollForDecisionTaskResponse is the response when there are no decision tasks to hand out @@ -79,6 +80,7 @@ var ( errPumpClosed = errors.New("Task list pump closed its channel") pollerIDKey pollerIDCtxKey = "pollerID" + identityKey identityCtxKey = "identity" ) func (t *taskListID) String() string { @@ -246,6 +248,7 @@ pollLoop: // Add frontend generated pollerID to context so tasklistMgr can support cancellation of // long-poll when frontend calls CancelOutstandingPoll API pollerCtx := context.WithValue(ctx, pollerIDKey, pollerID) + pollerCtx = context.WithValue(pollerCtx, identityKey, request.GetIdentity()) taskList := newTaskListID(domainID, taskListName, persistence.TaskListTypeDecision) tCtx, err := e.getTask(pollerCtx, taskList) if err != nil { @@ -344,6 +347,7 @@ pollLoop: // Add frontend generated pollerID to context so tasklistMgr can support cancellation of // long-poll when frontend calls CancelOutstandingPoll API pollerCtx := context.WithValue(ctx, pollerIDKey, pollerID) + pollerCtx = context.WithValue(pollerCtx, identityKey, request.GetIdentity()) tCtx, err := e.getTask(pollerCtx, taskList) if err != nil { // TODO: Is empty poll the best reply for errPumpClosed? @@ -449,6 +453,30 @@ func (e *matchingEngineImpl) CancelOutstandingPoll(ctx context.Context, request return nil } +func (e *matchingEngineImpl) GetPollerHistory(ctx context.Context, request *m.GetPollerHistoryRequest) (*workflow.GetPollerHistoryResponse, error) { + domainID := request.GetDomainUUID() + taskListType := persistence.TaskListTypeDecision + if request.GetRequest.GetTaskListType() == workflow.TaskListTypeActivity { + taskListType = persistence.TaskListTypeActivity + } + taskListName := request.GetRequest.TaskList.GetName() + + taskList := newTaskListID(domainID, taskListName, taskListType) + tlMgr, err := e.getTaskListManager(taskList) + if err != nil { + return nil, err + } + + pollers := []*workflow.PollerInfo{} + for _, poller := range tlMgr.GetAllPollerInfo() { + pollers = append(pollers, &workflow.PollerInfo{ + Identity: common.StringPtr(poller.identity), + Timestamp: common.TimePtr(poller.timestamp), + }) + } + return &workflow.GetPollerHistoryResponse{Pollers: pollers}, nil +} + // Loads a task from persistence and wraps it in a task context func (e *matchingEngineImpl) getTask(ctx context.Context, taskList *taskListID) (*taskContext, error) { tlMgr, err := e.getTaskListManager(taskList) diff --git a/service/matching/matchingEngineInterfaces.go b/service/matching/matchingEngineInterfaces.go index a011a7f512e..7844682e55e 100644 --- a/service/matching/matchingEngineInterfaces.go +++ b/service/matching/matchingEngineInterfaces.go @@ -38,5 +38,6 @@ type ( QueryWorkflow(ctx context.Context, request *m.QueryWorkflowRequest) (*workflow.QueryWorkflowResponse, error) RespondQueryTaskCompleted(ctx context.Context, request *m.RespondQueryTaskCompletedRequest) error CancelOutstandingPoll(ctx context.Context, request *m.CancelOutstandingPollRequest) error + GetPollerHistory(ctx context.Context, request *m.GetPollerHistoryRequest) (*workflow.GetPollerHistoryResponse, error) } ) diff --git a/service/matching/matchingEngine_test.go b/service/matching/matchingEngine_test.go index 8f047024ac2..301908e182d 100644 --- a/service/matching/matchingEngine_test.go +++ b/service/matching/matchingEngine_test.go @@ -193,19 +193,23 @@ func (s *matchingEngineSuite) PollForTasksEmptyResultTest(taskType int) { taskList := &workflow.TaskList{} taskList.Name = &tl + tasklistType := workflow.TaskListTypeDecision tlID := newTaskListID(domainID, tl, taskType) //const rangeID = 123 const pollCount = 10 for i := 0; i < pollCount; i++ { if taskType == persistence.TaskListTypeActivity { - resp, err := s.matchingEngine.PollForActivityTask(s.callContext, &matching.PollForActivityTaskRequest{ + pollResp, err := s.matchingEngine.PollForActivityTask(s.callContext, &matching.PollForActivityTaskRequest{ DomainUUID: common.StringPtr(domainID), PollRequest: &workflow.PollForActivityTaskRequest{ TaskList: taskList, - Identity: &identity}, + Identity: &identity, + }, }) s.NoError(err) - s.Equal(emptyPollForActivityTaskResponse, resp) + s.Equal(emptyPollForActivityTaskResponse, pollResp) + + tasklistType = workflow.TaskListTypeActivity } else { resp, err := s.matchingEngine.PollForDecisionTask(s.callContext, &matching.PollForDecisionTaskRequest{ DomainUUID: common.StringPtr(domainID), @@ -215,7 +219,21 @@ func (s *matchingEngineSuite) PollForTasksEmptyResultTest(taskType int) { }) s.NoError(err) s.Equal(emptyPollForDecisionTaskResponse, resp) + + tasklistType = workflow.TaskListTypeDecision } + // check the poller information + getResp, err := s.matchingEngine.GetPollerHistory(s.callContext, &matching.GetPollerHistoryRequest{ + DomainUUID: common.StringPtr(domainID), + GetRequest: &workflow.GetPollerHistoryRequest{ + TaskList: taskList, + TaskListType: &tasklistType, + }, + }) + s.NoError(err) + s.Equal(1, len(getResp.Pollers)) + s.Equal(identity, getResp.Pollers[0].GetIdentity()) + s.NotEmpty(getResp.Pollers[0].GetTimestamp()) } s.EqualValues(1, s.taskManager.taskLists[*tlID].rangeID) } diff --git a/service/matching/pollerHistory.go b/service/matching/pollerHistory.go new file mode 100644 index 00000000000..910558087e2 --- /dev/null +++ b/service/matching/pollerHistory.go @@ -0,0 +1,85 @@ +// Copyright (c) 2017 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 matching + +import ( + "time" + + "github.com/uber/cadence/common/cache" +) + +const ( + pollerHistoryInitSize = 0 + pollerHistoryInitMaxSize = 1000 + pollerHistoryTTL = 5 * time.Minute +) + +type ( + pollerIdentity struct { + identity string + // TODO add IP, T1396795 + } + + pollerInfo struct { + identity string + // TODO add IP, T1396795 + timestamp time.Time + } +) + +type pollerHistory struct { + // // poller ID -> last access time + // pollers map[pollerID]time.Time + history cache.Cache +} + +func newPollerHistory() *pollerHistory { + opts := &cache.Options{} + opts.InitialCapacity = pollerHistoryInitSize + opts.TTL = pollerHistoryTTL + opts.Pin = false + + return &pollerHistory{ + history: cache.New(pollerHistoryInitMaxSize, opts), + } +} + +func (pollers *pollerHistory) updatePollerInfo(id pollerIdentity) { + pollers.history.Put(id, nil) +} + +func (pollers *pollerHistory) getAllPollerInfo() []*pollerInfo { + result := []*pollerInfo{} + + ite := pollers.history.Iterator() + defer ite.Close() + for entry := range ite.Entries() { + key := entry.Key().(pollerIdentity) + timestamp := entry.Timestamp() + result = append(result, &pollerInfo{ + identity: key.identity, + // TODO add IP, T1396795 + timestamp: timestamp, + }) + } + + return result +} diff --git a/service/matching/taskListManager.go b/service/matching/taskListManager.go index b7082a882b9..379c0c877df 100644 --- a/service/matching/taskListManager.go +++ b/service/matching/taskListManager.go @@ -49,6 +49,7 @@ type taskListManager interface { GetTaskContext(ctx context.Context) (*taskContext, error) SyncMatchQueryTask(ctx context.Context, queryTask *queryTaskInfo) error CancelPoller(pollerID string) + GetAllPollerInfo() []*pollerInfo String() string } @@ -70,6 +71,7 @@ func newTaskListManager(e *matchingEngineImpl, taskList *taskListID, config *Con taskAckManager: newAckManager(e.logger), syncMatch: make(chan *getTaskResult), config: config, + pollerHistory: newPollerHistory(), outstandingPollsMap: make(map[string]context.CancelFunc), } tlMgr.taskWriter = newTaskWriter(tlMgr) @@ -99,6 +101,10 @@ type taskListManagerImpl struct { metricsClient metrics.Client engine *matchingEngineImpl config *Config + + // pollerHistory stores poller which poll from this tasklist in last few minutes + pollerHistory *pollerHistory + // serializes all writes to persistence // This is needed because of a known Cassandra issue where concurrent LWT to the same partition // cause timeout errors. @@ -323,6 +329,13 @@ func (c *taskListManagerImpl) getTask(ctx context.Context) (*getTaskResult, erro }() } + identity, ok := ctx.Value(identityKey).(string) + if ok && identity != "" { + c.pollerHistory.updatePollerInfo(pollerIdentity{ + identity: identity, + }) + } + select { case task, ok := <-c.taskBuffer: if !ok { // Task list getTasks pump is shutdown @@ -464,6 +477,16 @@ func (c *taskListManagerImpl) String() string { return r } +// updatePollerInfo update the poller information for this tasklist +func (c *taskListManagerImpl) updatePollerInfo(id pollerIdentity) { + c.pollerHistory.updatePollerInfo(id) +} + +// getAllPollerInfo return poller which poll from this tasklist in last few minutes +func (c *taskListManagerImpl) GetAllPollerInfo() []*pollerInfo { + return c.pollerHistory.getAllPollerInfo() +} + // Tries to match task to a poller that is already waiting on getTask. // When this method returns non nil response without error it is guaranteed that the task is started // and sent to a poller. So it not necessary to persist it.