From 5e9c49d24e6e68ff6c75f54c99bbbd52ec54dbed Mon Sep 17 00:00:00 2001 From: wxing1292 Date: Wed, 3 Jan 2018 13:12:34 -0800 Subject: [PATCH] implement filter which allow caller choose all events or only close event of when dumping history events (#489) when long poll on end event, use history service for end event --- .gen/go/shared/idl.go | 4 +- .gen/go/shared/types.go | 196 +++++++++++++++++- common/constants.go | 2 + common/persistence/cassandraPersistence.go | 5 + .../persistence/cassandraPersistence_test.go | 3 + common/persistence/dataInterfaces.go | 1 + host/integration_test.go | 184 +++++++++++++++- idl/github.com/uber/cadence/shared.thrift | 6 + schema/cadence/schema.cql | 1 + .../v0.3/add_last_first_event_id.cql | 1 + schema/cadence/versioned/v0.3/manifest.json | 3 +- service/frontend/handler.go | 105 ++++++---- service/history/historyEngine.go | 7 +- service/history/historyEngineInterfaces.go | 1 + service/history/historyEventNotifier.go | 3 +- service/history/historyEventNotifier_test.go | 6 +- service/history/mutableStateBuilder.go | 6 + service/history/workflowExecutionContext.go | 3 + 18 files changed, 472 insertions(+), 65 deletions(-) create mode 100644 schema/cadence/versioned/v0.3/add_last_first_event_id.cql diff --git a/.gen/go/shared/idl.go b/.gen/go/shared/idl.go index 77c977b489e..3b3bd172d75 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: "92064b24fb2c235e3acc8045765b8fd602226426", + SHA1: "c066d327e24384e16775fb9fccd5eb435f382a02", 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\nenum PendingActivityState {\n SCHEDULED,\n STARTED,\n CANCEL_REQUESTED,\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 PendingActivityInfo {\n 10: optional string activityID\n 20: optional ActivityType activityType\n 30: optional PendingActivityState state\n 40: optional binary heartbeatDetails\n 50: optional i64 (js.type = \"Long\") lastHeartbeatTimestamp\n}\n\nstruct DescribeWorkflowExecutionResponse {\n 10: optional WorkflowExecutionConfiguration executionConfiguration\n 20: optional WorkflowExecutionInfo workflowExecutionInfo\n 30: optional list pendingActivities\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\nenum PendingActivityState {\n SCHEDULED,\n STARTED,\n CANCEL_REQUESTED,\n}\n\nenum HistoryEventFilterType {\n ALL_EVENT,\n CLOSE_EVENT,\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 60: optional HistoryEventFilterType HistoryEventFilterType\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 PendingActivityInfo {\n 10: optional string activityID\n 20: optional ActivityType activityType\n 30: optional PendingActivityState state\n 40: optional binary heartbeatDetails\n 50: optional i64 (js.type = \"Long\") lastHeartbeatTimestamp\n}\n\nstruct DescribeWorkflowExecutionResponse {\n 10: optional WorkflowExecutionConfiguration executionConfiguration\n 20: optional WorkflowExecutionInfo workflowExecutionInfo\n 30: optional list pendingActivities\n}\n" diff --git a/.gen/go/shared/types.go b/.gen/go/shared/types.go index bc6a22d029b..6fd789de256 100644 --- a/.gen/go/shared/types.go +++ b/.gen/go/shared/types.go @@ -8996,11 +8996,12 @@ func (v *FailWorkflowExecutionDecisionAttributes) GetReason() (o string) { } type GetWorkflowExecutionHistoryRequest struct { - Domain *string `json:"domain,omitempty"` - Execution *WorkflowExecution `json:"execution,omitempty"` - MaximumPageSize *int32 `json:"maximumPageSize,omitempty"` - NextPageToken []byte `json:"nextPageToken,omitempty"` - WaitForNewEvent *bool `json:"waitForNewEvent,omitempty"` + Domain *string `json:"domain,omitempty"` + Execution *WorkflowExecution `json:"execution,omitempty"` + MaximumPageSize *int32 `json:"maximumPageSize,omitempty"` + NextPageToken []byte `json:"nextPageToken,omitempty"` + WaitForNewEvent *bool `json:"waitForNewEvent,omitempty"` + HistoryEventFilterType *HistoryEventFilterType `json:"HistoryEventFilterType,omitempty"` } // ToWire translates a GetWorkflowExecutionHistoryRequest struct into a Thrift-level intermediate @@ -9020,7 +9021,7 @@ type GetWorkflowExecutionHistoryRequest struct { // } func (v *GetWorkflowExecutionHistoryRequest) ToWire() (wire.Value, error) { var ( - fields [5]wire.Field + fields [6]wire.Field i int = 0 w wire.Value err error @@ -9066,10 +9067,24 @@ func (v *GetWorkflowExecutionHistoryRequest) ToWire() (wire.Value, error) { fields[i] = wire.Field{ID: 50, Value: w} i++ } + if v.HistoryEventFilterType != nil { + w, err = v.HistoryEventFilterType.ToWire() + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 60, Value: w} + i++ + } return wire.NewValueStruct(wire.Struct{Fields: fields[:i]}), nil } +func _HistoryEventFilterType_Read(w wire.Value) (HistoryEventFilterType, error) { + var v HistoryEventFilterType + err := v.FromWire(w) + return v, err +} + // FromWire deserializes a GetWorkflowExecutionHistoryRequest struct from its Thrift-level // representation. The Thrift-level representation may be obtained // from a ThriftRW protocol implementation. @@ -9137,6 +9152,16 @@ func (v *GetWorkflowExecutionHistoryRequest) FromWire(w wire.Value) error { return err } + } + case 60: + if field.Value.Type() == wire.TI32 { + var x HistoryEventFilterType + x, err = _HistoryEventFilterType_Read(field.Value) + v.HistoryEventFilterType = &x + if err != nil { + return err + } + } } } @@ -9151,7 +9176,7 @@ func (v *GetWorkflowExecutionHistoryRequest) String() string { return "" } - var fields [5]string + var fields [6]string i := 0 if v.Domain != nil { fields[i] = fmt.Sprintf("Domain: %v", *(v.Domain)) @@ -9173,10 +9198,24 @@ func (v *GetWorkflowExecutionHistoryRequest) String() string { fields[i] = fmt.Sprintf("WaitForNewEvent: %v", *(v.WaitForNewEvent)) i++ } + if v.HistoryEventFilterType != nil { + fields[i] = fmt.Sprintf("HistoryEventFilterType: %v", *(v.HistoryEventFilterType)) + i++ + } return fmt.Sprintf("GetWorkflowExecutionHistoryRequest{%v}", strings.Join(fields[:i], ", ")) } +func _HistoryEventFilterType_EqualsPtr(lhs, rhs *HistoryEventFilterType) 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 GetWorkflowExecutionHistoryRequest match the // provided GetWorkflowExecutionHistoryRequest. // @@ -9197,6 +9236,9 @@ func (v *GetWorkflowExecutionHistoryRequest) Equals(rhs *GetWorkflowExecutionHis if !_Bool_EqualsPtr(v.WaitForNewEvent, rhs.WaitForNewEvent) { return false } + if !_HistoryEventFilterType_EqualsPtr(v.HistoryEventFilterType, rhs.HistoryEventFilterType) { + return false + } return true } @@ -9231,6 +9273,16 @@ func (v *GetWorkflowExecutionHistoryRequest) GetWaitForNewEvent() (o bool) { return } +// GetHistoryEventFilterType returns the value of HistoryEventFilterType if it is set or its +// zero value if it is unset. +func (v *GetWorkflowExecutionHistoryRequest) GetHistoryEventFilterType() (o HistoryEventFilterType) { + if v.HistoryEventFilterType != nil { + return *v.HistoryEventFilterType + } + + return +} + type GetWorkflowExecutionHistoryResponse struct { History *History `json:"history,omitempty"` NextPageToken []byte `json:"nextPageToken,omitempty"` @@ -10881,6 +10933,136 @@ func (v *HistoryEvent) GetEventType() (o EventType) { return } +type HistoryEventFilterType int32 + +const ( + HistoryEventFilterTypeAllEvent HistoryEventFilterType = 0 + HistoryEventFilterTypeCloseEvent HistoryEventFilterType = 1 +) + +// HistoryEventFilterType_Values returns all recognized values of HistoryEventFilterType. +func HistoryEventFilterType_Values() []HistoryEventFilterType { + return []HistoryEventFilterType{ + HistoryEventFilterTypeAllEvent, + HistoryEventFilterTypeCloseEvent, + } +} + +// UnmarshalText tries to decode HistoryEventFilterType from a byte slice +// containing its name. +// +// var v HistoryEventFilterType +// err := v.UnmarshalText([]byte("ALL_EVENT")) +func (v *HistoryEventFilterType) UnmarshalText(value []byte) error { + switch string(value) { + case "ALL_EVENT": + *v = HistoryEventFilterTypeAllEvent + return nil + case "CLOSE_EVENT": + *v = HistoryEventFilterTypeCloseEvent + return nil + default: + return fmt.Errorf("unknown enum value %q for %q", value, "HistoryEventFilterType") + } +} + +// ToWire translates HistoryEventFilterType 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 HistoryEventFilterType) ToWire() (wire.Value, error) { + return wire.NewValueI32(int32(v)), nil +} + +// FromWire deserializes HistoryEventFilterType from its Thrift-level +// representation. +// +// x, err := binaryProtocol.Decode(reader, wire.TI32) +// if err != nil { +// return HistoryEventFilterType(0), err +// } +// +// var v HistoryEventFilterType +// if err := v.FromWire(x); err != nil { +// return HistoryEventFilterType(0), err +// } +// return v, nil +func (v *HistoryEventFilterType) FromWire(w wire.Value) error { + *v = (HistoryEventFilterType)(w.GetI32()) + return nil +} + +// String returns a readable string representation of HistoryEventFilterType. +func (v HistoryEventFilterType) String() string { + w := int32(v) + switch w { + case 0: + return "ALL_EVENT" + case 1: + return "CLOSE_EVENT" + } + return fmt.Sprintf("HistoryEventFilterType(%d)", w) +} + +// Equals returns true if this HistoryEventFilterType value matches the provided +// value. +func (v HistoryEventFilterType) Equals(rhs HistoryEventFilterType) bool { + return v == rhs +} + +// MarshalJSON serializes HistoryEventFilterType into JSON. +// +// If the enum value is recognized, its name is returned. Otherwise, +// its integer value is returned. +// +// This implements json.Marshaler. +func (v HistoryEventFilterType) MarshalJSON() ([]byte, error) { + switch int32(v) { + case 0: + return ([]byte)("\"ALL_EVENT\""), nil + case 1: + return ([]byte)("\"CLOSE_EVENT\""), nil + } + return ([]byte)(strconv.FormatInt(int64(v), 10)), nil +} + +// UnmarshalJSON attempts to decode HistoryEventFilterType 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 *HistoryEventFilterType) 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, "HistoryEventFilterType") + } + if x < math.MinInt32 { + return fmt.Errorf("enum underflow from JSON %q for %q", text, "HistoryEventFilterType") + } + *v = (HistoryEventFilterType)(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, "HistoryEventFilterType") + } +} + type InternalServiceError struct { Message string `json:"message,required"` } diff --git a/common/constants.go b/common/constants.go index b108c6c1d21..9412c20b2e3 100644 --- a/common/constants.go +++ b/common/constants.go @@ -25,6 +25,8 @@ const ( FirstEventID int64 = 1 // EmptyEventID is the id of the empty event EmptyEventID int64 = -23 + // EndEventID is the id of the end event, here we use the int64 max + EndEventID int64 = 1<<63 - 1 ) const ( diff --git a/common/persistence/cassandraPersistence.go b/common/persistence/cassandraPersistence.go index 1c4dfd1d9f7..5628dd78b19 100644 --- a/common/persistence/cassandraPersistence.go +++ b/common/persistence/cassandraPersistence.go @@ -118,6 +118,7 @@ const ( `execution_context: ?, ` + `state: ?, ` + `close_status: ?, ` + + `last_first_event_id: ?, ` + `next_event_id: ?, ` + `last_processed_event: ?, ` + `start_time: ?, ` + @@ -903,6 +904,7 @@ func (d *cassandraPersistence) CreateWorkflowExecutionWithinBatch(request *Creat request.ExecutionContext, WorkflowStateCreated, WorkflowCloseStatusNone, + common.FirstEventID, request.NextEventID, request.LastProcessedEvent, cqlNowTimestamp, @@ -1024,6 +1026,7 @@ func (d *cassandraPersistence) UpdateWorkflowExecution(request *UpdateWorkflowEx executionInfo.ExecutionContext, executionInfo.State, executionInfo.CloseStatus, + executionInfo.LastFirstEventID, executionInfo.NextEventID, executionInfo.LastProcessedEvent, executionInfo.StartTimestamp, @@ -2013,6 +2016,8 @@ func createWorkflowExecutionInfo(result map[string]interface{}) *WorkflowExecuti info.State = v.(int) case "close_status": info.CloseStatus = v.(int) + case "last_first_event_id": + info.LastFirstEventID = v.(int64) case "next_event_id": info.NextEventID = v.(int64) case "last_processed_event": diff --git a/common/persistence/cassandraPersistence_test.go b/common/persistence/cassandraPersistence_test.go index 69927df3f9c..e1755f8a659 100644 --- a/common/persistence/cassandraPersistence_test.go +++ b/common/persistence/cassandraPersistence_test.go @@ -173,6 +173,7 @@ func (s *cassandraPersistenceSuite) TestUpdateWorkflow() { s.Equal(int32(13), info0.DecisionTimeoutValue) s.Equal([]byte(nil), info0.ExecutionContext) s.Equal(WorkflowStateCreated, info0.State) + s.Equal(int64(1), info0.LastFirstEventID) s.Equal(int64(3), info0.NextEventID) s.Equal(int64(0), info0.LastProcessedEvent) s.Equal(true, validateTimeRange(info0.LastUpdatedTimestamp, time.Hour)) @@ -190,6 +191,7 @@ func (s *cassandraPersistenceSuite) TestUpdateWorkflow() { log.Infof("Workflow execution last updated: %v", info0.LastUpdatedTimestamp) updatedInfo := copyWorkflowExecutionInfo(info0) + updatedInfo.LastFirstEventID = int64(3) updatedInfo.NextEventID = int64(5) updatedInfo.LastProcessedEvent = int64(2) updatedInfo.DecisionAttempt = int64(123) @@ -215,6 +217,7 @@ func (s *cassandraPersistenceSuite) TestUpdateWorkflow() { s.Equal(int32(13), info1.DecisionTimeoutValue) s.Equal([]byte(nil), info1.ExecutionContext) s.Equal(WorkflowStateCreated, info1.State) + s.Equal(int64(3), info1.LastFirstEventID) s.Equal(int64(5), info1.NextEventID) s.Equal(int64(2), info1.LastProcessedEvent) s.Equal(true, validateTimeRange(info1.LastUpdatedTimestamp, time.Hour)) diff --git a/common/persistence/dataInterfaces.go b/common/persistence/dataInterfaces.go index ab7206d51a2..58f1dd9cef0 100644 --- a/common/persistence/dataInterfaces.go +++ b/common/persistence/dataInterfaces.go @@ -136,6 +136,7 @@ type ( ExecutionContext []byte State int CloseStatus int + LastFirstEventID int64 NextEventID int64 LastProcessedEvent int64 StartTimestamp time.Time diff --git a/host/integration_test.go b/host/integration_test.go index 26e640e70a3..0ca4e6a4364 100644 --- a/host/integration_test.go +++ b/host/integration_test.go @@ -3457,7 +3457,7 @@ func (s *integrationSuite) TestDecisionTaskFailed() { s.Equal(workflow.EventTypeWorkflowExecutionCompleted, lastEvent.GetEventType()) } -func (s *integrationSuite) TestGetWorkflowExecutionHistoryLongPoll() { +func (s *integrationSuite) TestGetWorkflowExecutionHistory_All() { workflowID := "interation-get-workflow-history-events-long-poll-test" identity := "worker1" activityName := "activity_type1" @@ -3542,7 +3542,7 @@ func (s *integrationSuite) TestGetWorkflowExecutionHistoryLongPoll() { } // this function poll events from history side - testLongPoll := func(domain string, workflowID string, token []byte) ([]*workflow.HistoryEvent, []byte) { + getHistory := func(domain string, workflowID string, token []byte, isLongPoll bool) ([]*workflow.HistoryEvent, []byte) { responseInner, _ := s.engine.GetWorkflowExecutionHistory(createContext(), &workflow.GetWorkflowExecutionHistoryRequest{ Domain: common.StringPtr(domain), Execution: &workflow.WorkflowExecution{ @@ -3551,10 +3551,9 @@ func (s *integrationSuite) TestGetWorkflowExecutionHistoryLongPoll() { // since the page size have essential no relation with number of events.. // so just use a really larger number, to test whether long poll works MaximumPageSize: common.Int32Ptr(100), - WaitForNewEvent: common.BoolPtr(true), // long poll + WaitForNewEvent: common.BoolPtr(isLongPoll), NextPageToken: token, }) - return responseInner.History.Events, responseInner.NextPageToken } @@ -3564,7 +3563,7 @@ func (s *integrationSuite) TestGetWorkflowExecutionHistoryLongPoll() { // here do a long pull (which return immediately with at least the WorkflowExecutionStarted) start := time.Now() - events, token = testLongPoll(s.domainName, workflowID, token) + events, token = getHistory(s.domainName, workflowID, token, true) allEvents = append(allEvents, events...) s.True(time.Now().Before(start.Add(time.Second * 5))) s.NotEmpty(events) @@ -3577,7 +3576,7 @@ func (s *integrationSuite) TestGetWorkflowExecutionHistoryLongPoll() { s.logger.Infof("pollAndProcessDecisionTask: %v", errDecision1) }) start = time.Now() - events, token = testLongPoll(s.domainName, workflowID, token) + events, token = getHistory(s.domainName, workflowID, token, true) allEvents = append(allEvents, events...) s.True(time.Now().After(start.Add(time.Second * 5))) s.NotEmpty(events) @@ -3593,7 +3592,7 @@ func (s *integrationSuite) TestGetWorkflowExecutionHistoryLongPoll() { s.logger.Infof("pollAndProcessDecisionTask: %v", errDecision2) }) for token != nil { - events, token = testLongPoll(s.domainName, workflowID, token) + events, token = getHistory(s.domainName, workflowID, token, true) allEvents = append(allEvents, events...) } @@ -3610,6 +3609,177 @@ func (s *integrationSuite) TestGetWorkflowExecutionHistoryLongPoll() { // 10. DecisionTaskCompleted // 11. WorkflowExecutionCompleted s.Equal(11, len(allEvents)) + + // test non long poll + allEvents = nil + token = nil + for { + events, token = getHistory(s.domainName, workflowID, token, false) + allEvents = append(allEvents, events...) + if token == nil { + break + } + } + s.Equal(11, len(allEvents)) +} + +func (s *integrationSuite) TestGetWorkflowExecutionHistory_Close() { + workflowID := "interation-get-workflow-history-events-long-poll-test" + identity := "worker1" + activityName := "activity_type1" + + workflowType := &workflow.WorkflowType{} + workflowType.Name = common.StringPtr("interation-get-workflow-history-events-long-poll-test-type") + + taskList := &workflow.TaskList{} + taskList.Name = common.StringPtr("interation-get-workflow-history-events-long-poll-test-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 + getHistory := func(domain string, workflowID string, token []byte, isLongPoll bool) ([]*workflow.HistoryEvent, []byte) { + closeEventOnly := workflow.HistoryEventFilterTypeCloseEvent + responseInner, _ := s.engine.GetWorkflowExecutionHistory(createContext(), &workflow.GetWorkflowExecutionHistoryRequest{ + Domain: common.StringPtr(domain), + Execution: &workflow.WorkflowExecution{ + WorkflowId: common.StringPtr(workflowID), + }, + // since the page size have essential no relation with number of events.. + // so just use a really larger number, to test whether long poll works + MaximumPageSize: common.Int32Ptr(100), + WaitForNewEvent: common.BoolPtr(isLongPoll), + NextPageToken: token, + HistoryEventFilterType: &closeEventOnly, + }) + + return responseInner.History.Events, responseInner.NextPageToken + } + + var events []*workflow.HistoryEvent + var token []byte + + // here do a long pull (which return immediately with at least the WorkflowExecutionStarted) + start := time.Now() + events, token = getHistory(s.domainName, workflowID, token, true) + s.True(time.Now().After(start.Add(time.Second * 10))) + // since we are only interested in close event + s.Empty(events) + s.NotNil(token) + + // here do a long pull and check # of events and time elapsed + // make first decision to schedule activity, this should affect the long poll above + time.AfterFunc(time.Second*8, func() { + _, errDecision1 := poller.pollAndProcessDecisionTask(false, false) + s.logger.Infof("pollAndProcessDecisionTask: %v", errDecision1) + }) + start = time.Now() + events, token = getHistory(s.domainName, workflowID, token, true) + s.True(time.Now().After(start.Add(time.Second * 10))) + // since we are only interested in close event + s.Empty(events) + s.NotNil(token) + + // finish the activity and poll all events + time.AfterFunc(time.Second*5, func() { + errActivity := poller.pollAndProcessActivityTask(false) + s.logger.Infof("pollAndProcessDecisionTask: %v", errActivity) + }) + time.AfterFunc(time.Second*8, func() { + _, errDecision2 := poller.pollAndProcessDecisionTask(false, false) + s.logger.Infof("pollAndProcessDecisionTask: %v", errDecision2) + }) + for token != nil { + events, token = getHistory(s.domainName, workflowID, token, true) + + // since we are only interested in close event + if token == nil { + s.Equal(1, len(events)) + s.Equal(workflow.EventTypeWorkflowExecutionCompleted, *events[0].EventType) + } else { + s.Empty(events) + } + } + + // test non long poll for only closed events + token = nil + for { + events, token = getHistory(s.domainName, workflowID, token, false) + if token == nil { + break + } + } + s.Equal(1, len(events)) } func (s *integrationSuite) setupShards() { diff --git a/idl/github.com/uber/cadence/shared.thrift b/idl/github.com/uber/cadence/shared.thrift index 7debb5b0027..f2bc46bbf8b 100644 --- a/idl/github.com/uber/cadence/shared.thrift +++ b/idl/github.com/uber/cadence/shared.thrift @@ -191,6 +191,11 @@ enum PendingActivityState { CANCEL_REQUESTED, } +enum HistoryEventFilterType { + ALL_EVENT, + CLOSE_EVENT, +} + struct WorkflowType { 10: optional string name } @@ -853,6 +858,7 @@ struct GetWorkflowExecutionHistoryRequest { 30: optional i32 maximumPageSize 40: optional binary nextPageToken 50: optional bool waitForNewEvent + 60: optional HistoryEventFilterType HistoryEventFilterType } struct GetWorkflowExecutionHistoryResponse { diff --git a/schema/cadence/schema.cql b/schema/cadence/schema.cql index af9a9d555e8..dac15984d1e 100644 --- a/schema/cadence/schema.cql +++ b/schema/cadence/schema.cql @@ -28,6 +28,7 @@ CREATE TYPE workflow_execution ( execution_context blob, state int, -- enum WorkflowState {Created, Running, Completed} close_status int, -- enum WorkflowCloseStatus {None, Completed, Failed, Canceled, Terminated, ContinuedAsNew, TimedOut} + last_first_event_id bigint, next_event_id bigint, last_processed_event bigint, start_time timestamp, diff --git a/schema/cadence/versioned/v0.3/add_last_first_event_id.cql b/schema/cadence/versioned/v0.3/add_last_first_event_id.cql new file mode 100644 index 00000000000..94c66f8bf60 --- /dev/null +++ b/schema/cadence/versioned/v0.3/add_last_first_event_id.cql @@ -0,0 +1 @@ +ALTER TYPE workflow_execution ADD last_first_event_id bigint; \ No newline at end of file diff --git a/schema/cadence/versioned/v0.3/manifest.json b/schema/cadence/versioned/v0.3/manifest.json index c4c8aa670ff..ebaa230dc87 100644 --- a/schema/cadence/versioned/v0.3/manifest.json +++ b/schema/cadence/versioned/v0.3/manifest.json @@ -3,6 +3,7 @@ "MinCompatibleVersion": "0.3", "Description": "add client_library_version, client_feature_version and client_impl to mutable state", "SchemaUpdateCqlFiles": [ - "add_client_version.cql" + "add_client_version.cql", + "add_last_first_event_id.cql" ] } diff --git a/service/frontend/handler.go b/service/frontend/handler.go index e7a8223780d..0c2a22d3408 100644 --- a/service/frontend/handler.go +++ b/service/frontend/handler.go @@ -921,42 +921,34 @@ func (wh *WorkflowHandler) GetWorkflowExecutionHistory( // this function return the following 3 things, // 1. the workflow run ID - // 2. the next event ID - // 3. whether the workflow is closed - getNextEventID := func(domainUUID string, execution *gen.WorkflowExecution, expectedNextEventID *int64) (string, int64, bool, error) { + // 2. the last first event ID (the event ID of the last batch of events in the history) + // 3. the next event ID + // 4. whether the workflow is closed + queryHistory := func(domainUUID string, execution *gen.WorkflowExecution, expectedNextEventID int64) (string, int64, int64, bool, error) { response, err := wh.history.GetMutableState(ctx, &h.GetMutableStateRequest{ DomainUUID: common.StringPtr(domainUUID), Execution: execution, - ExpectedNextEventId: expectedNextEventID, + ExpectedNextEventId: common.Int64Ptr(expectedNextEventID), }) - if err == nil { - return response.Execution.GetRunId(), response.GetNextEventId(), response.GetIsWorkflowRunning(), nil - } - - if _, ok := err.(*gen.EntityNotExistsError); !ok || execution.RunId == nil { - return "", 0, false, err - } - // here we have error == EntityNotExistsError && run ID != nil - // (validateExecution guaranee that when run ID != nil, run ID is a valid UUID) - - // It is possible that we still have the events in the table even though the mutable state is gone - // Get the nextEventID from visibility store if we still have it. - visibilityResp, err := wh.visibitiltyMgr.GetClosedWorkflowExecution(&persistence.GetClosedWorkflowExecutionRequest{ - DomainUUID: domainUUID, - Execution: *execution, - }) if err != nil { - return "", 0, false, err + return "", 0, 0, false, err } - return *visibilityResp.Execution.Execution.RunId, *visibilityResp.Execution.HistoryLength, false, nil + return response.Execution.GetRunId(), response.GetLastFirstEventId(), response.GetNextEventId(), response.GetIsWorkflowRunning(), nil } isLongPoll := getRequest.GetWaitForNewEvent() + isCloseEventOnly := getRequest.GetHistoryEventFilterType() == gen.HistoryEventFilterTypeCloseEvent execution := getRequest.Execution token := &getHistoryContinuationToken{} + var runID string + var lastFirstEventID int64 + var nextEventID int64 + var isWorkflowRunning bool + // process the token for paging + queryNextEventID := common.EndEventID if getRequest.NextPageToken != nil { token, err = deserializeHistoryToken(getRequest.NextPageToken) if err != nil { @@ -970,17 +962,23 @@ func (wh *WorkflowHandler) GetWorkflowExecutionHistory( // we need to update the current next event ID and whether workflow is running if len(token.PersistenceToken) == 0 && isLongPoll && token.IsWorkflowRunning { - token.FirstEventID = token.NextEventID - _, nextEventID, isRunning, err := getNextEventID(domainInfo.ID, execution, &token.NextEventID) + if !isCloseEventOnly { + queryNextEventID = token.NextEventID + } + _, lastFirstEventID, nextEventID, isWorkflowRunning, err = queryHistory(domainInfo.ID, execution, queryNextEventID) if err != nil { return nil, wh.error(err, scope) } + token.FirstEventID = token.NextEventID token.NextEventID = nextEventID - token.IsWorkflowRunning = isRunning + token.IsWorkflowRunning = isWorkflowRunning } } else { - runID, nextEventID, isRunning, err := getNextEventID(domainInfo.ID, execution, nil) + if !isCloseEventOnly { + queryNextEventID = common.FirstEventID + } + runID, lastFirstEventID, nextEventID, isWorkflowRunning, err = queryHistory(domainInfo.ID, execution, queryNextEventID) if err != nil { return nil, wh.error(err, scope) } @@ -988,33 +986,52 @@ func (wh *WorkflowHandler) GetWorkflowExecutionHistory( execution.RunId = &runID token.RunID = runID - token.FirstEventID = 0 + token.FirstEventID = common.FirstEventID token.NextEventID = nextEventID - token.IsWorkflowRunning = isRunning + token.IsWorkflowRunning = isWorkflowRunning token.PersistenceToken = nil } history := &gen.History{} - if token.FirstEventID >= token.NextEventID { - // currently there is no new event - events := []*gen.HistoryEvent{} - history.Events = events - if !token.IsWorkflowRunning { + history.Events = []*gen.HistoryEvent{} + if isCloseEventOnly { + if !isWorkflowRunning { + history, _, err = wh.getHistory(domainInfo.ID, *execution, lastFirstEventID, nextEventID, + *getRequest.MaximumPageSize, nil, token.TransientDecision) + if err != nil { + return nil, wh.error(err, scope) + } + // since getHistory func will not return empty history, so the below is safe + history.Events = history.Events[len(history.Events)-1 : len(history.Events)] + token = nil + } else if isLongPoll { + // set the persistance token to be nil so next time we will query history for updates + token.PersistenceToken = nil + } else { token = nil } } else { - history, token.PersistenceToken, err = - wh.getHistory(domainInfo.ID, *execution, token.FirstEventID, token.NextEventID, - *getRequest.MaximumPageSize, token.PersistenceToken, token.TransientDecision) - if err != nil { - return nil, wh.error(err, scope) - } + // return all events + if token.FirstEventID >= token.NextEventID { + // currently there is no new event + history.Events = []*gen.HistoryEvent{} + if !isWorkflowRunning { + token = nil + } + } else { + history, token.PersistenceToken, err = + wh.getHistory(domainInfo.ID, *execution, token.FirstEventID, token.NextEventID, + *getRequest.MaximumPageSize, token.PersistenceToken, token.TransientDecision) + if err != nil { + return nil, wh.error(err, scope) + } - // here, for long pull on history events, we need to intercept the paging token from cassandra - // and do something clever - if len(token.PersistenceToken) == 0 && (!token.IsWorkflowRunning || !isLongPoll) { - // meaning, there is no more history to be returned - token = nil + // here, for long pull on history events, we need to intercept the paging token from cassandra + // and do something clever + if len(token.PersistenceToken) == 0 && (!token.IsWorkflowRunning || !isLongPoll) { + // meaning, there is no more history to be returned + token = nil + } } } diff --git a/service/history/historyEngine.go b/service/history/historyEngine.go index 7858ce15183..d902e5b12d7 100644 --- a/service/history/historyEngine.go +++ b/service/history/historyEngine.go @@ -225,12 +225,13 @@ func (e *historyEngineImpl) StartWorkflowExecution(startRequest *h.StartWorkflow // It is ok to use 0 for TransactionID because RunID is unique so there are // no potential duplicates to override. TransactionID: 0, - FirstEventID: *startedEvent.EventId, + FirstEventID: startedEvent.GetEventId(), Events: serializedHistory, }) if err != nil { return nil, err } + msBuilder.executionInfo.LastFirstEventID = startedEvent.GetEventId() deleteEvents := func() { // We created the history events but failed to create workflow execution, so cleanup the history which could cause @@ -366,6 +367,8 @@ func (e *historyEngineImpl) GetMutableState(ctx context.Context, if err != nil { return nil, err } + // set the run id in case query the current running workflwo + execution.RunId = response.Execution.RunId // expectedNextEventID is 0 when caller want to get the current next event ID without blocking expectedNextEventID := common.FirstEventID @@ -397,6 +400,7 @@ func (e *historyEngineImpl) GetMutableState(ctx context.Context, for { select { case event := <-channel: + response.LastFirstEventId = common.Int64Ptr(event.lastFirstEventID) response.NextEventId = common.Int64Ptr(event.nextEventID) response.IsWorkflowRunning = common.BoolPtr(event.isWorkflowRunning) if expectedNextEventID < response.GetNextEventId() || !response.GetIsWorkflowRunning() { @@ -431,6 +435,7 @@ func (e *historyEngineImpl) getMutableState( result := &h.GetMutableStateResponse{ Execution: &execution, WorkflowType: &workflow.WorkflowType{Name: common.StringPtr(msBuilder.executionInfo.WorkflowTypeName)}, + LastFirstEventId: common.Int64Ptr(msBuilder.GetLastFirstEventID()), NextEventId: common.Int64Ptr(msBuilder.GetNextEventID()), TaskList: &workflow.TaskList{Name: common.StringPtr(context.msBuilder.executionInfo.TaskList)}, StickyTaskList: &workflow.TaskList{Name: common.StringPtr(msBuilder.executionInfo.StickyTaskList)}, diff --git a/service/history/historyEngineInterfaces.go b/service/history/historyEngineInterfaces.go index 4edcb7e2961..7a6bb0dabc0 100644 --- a/service/history/historyEngineInterfaces.go +++ b/service/history/historyEngineInterfaces.go @@ -39,6 +39,7 @@ type ( historyEventNotification struct { workflowIdentifier + lastFirstEventID int64 nextEventID int64 isWorkflowRunning bool timestamp time.Time diff --git a/service/history/historyEventNotifier.go b/service/history/historyEventNotifier.go index 9c30d3bd316..88e0090b5e6 100644 --- a/service/history/historyEventNotifier.go +++ b/service/history/historyEventNotifier.go @@ -70,13 +70,14 @@ func newWorkflowIdentifier(domainID string, workflowExecution *gen.WorkflowExecu } func newHistoryEventNotification(domainID string, workflowExecution *gen.WorkflowExecution, - nextEventID int64, isWorkflowRunning bool) *historyEventNotification { + lastFirstEventID int64, nextEventID int64, isWorkflowRunning bool) *historyEventNotification { return &historyEventNotification{ workflowIdentifier: workflowIdentifier{ domainID: domainID, workflowID: *workflowExecution.WorkflowId, runID: *workflowExecution.RunId, }, + lastFirstEventID: lastFirstEventID, nextEventID: nextEventID, isWorkflowRunning: isWorkflowRunning, } diff --git a/service/history/historyEventNotifier_test.go b/service/history/historyEventNotifier_test.go index c2455449308..9a25f18f2e3 100644 --- a/service/history/historyEventNotifier_test.go +++ b/service/history/historyEventNotifier_test.go @@ -77,9 +77,10 @@ func (s *historyEventNotifierSuite) TestSingleSubscriberWatchingEvents() { WorkflowId: common.StringPtr("workflow ID"), RunId: common.StringPtr("run ID"), } + var lastFirstEventID int64 = 3 var nextEventID int64 = 18 isRunning := true - historyEvent := newHistoryEventNotification(domainID, execution, nextEventID, isRunning) + historyEvent := newHistoryEventNotification(domainID, execution, lastFirstEventID, nextEventID, isRunning) timerChan := time.NewTimer(time.Second * 2).C subscriberID, channel, err := s.historyEventNotifier.WatchHistoryEvent(newWorkflowIdentifier(domainID, execution)) @@ -110,9 +111,10 @@ func (s *historyEventNotifierSuite) TestMultipleSubscriberWatchingEvents() { RunId: common.StringPtr("run ID"), } + var lastFirstEventID int64 = 3 var nextEventID int64 = 18 isRunning := true - historyEvent := newHistoryEventNotification(domainID, execution, nextEventID, isRunning) + historyEvent := newHistoryEventNotification(domainID, execution, lastFirstEventID, nextEventID, isRunning) timerChan := time.NewTimer(time.Second * 5).C subscriberCount := 100 diff --git a/service/history/mutableStateBuilder.go b/service/history/mutableStateBuilder.go index 6e514a99fe9..4975ebccbc7 100644 --- a/service/history/mutableStateBuilder.go +++ b/service/history/mutableStateBuilder.go @@ -685,6 +685,12 @@ func (e *mutableStateBuilder) clearStickyness() { e.executionInfo.ClientImpl = "" } +// GetLastFirstEventID returns last first event ID +// first event ID is the ID of a batch of events in a single history events record +func (e *mutableStateBuilder) GetLastFirstEventID() int64 { + return e.executionInfo.LastFirstEventID +} + // GetNextEventID returns next event ID func (e *mutableStateBuilder) GetNextEventID() int64 { return e.executionInfo.NextEventID diff --git a/service/history/workflowExecutionContext.go b/service/history/workflowExecutionContext.go index ffff57965d8..c4fbd8a31e5 100644 --- a/service/history/workflowExecutionContext.go +++ b/service/history/workflowExecutionContext.go @@ -157,6 +157,7 @@ func (c *workflowExecutionContext) updateWorkflowExecution(transferTasks []persi fmt.Sprintf("{updateCondition: %v}", c.updateCondition)) return err0 } + c.msBuilder.executionInfo.LastFirstEventID = *firstEvent.EventId } continueAsNew := updates.continueAsNew @@ -210,6 +211,7 @@ func (c *workflowExecutionContext) updateWorkflowExecution(transferTasks []persi c.shard.NotifyNewHistoryEvent(newHistoryEventNotification( c.domainID, &c.workflowExecution, + c.msBuilder.GetLastFirstEventID(), c.msBuilder.GetNextEventID(), c.msBuilder.isWorkflowExecutionRunning(), )) @@ -248,6 +250,7 @@ func (c *workflowExecutionContext) continueAsNewWorkflowExecution(context []byte if err1 != nil { return err1 } + c.msBuilder.executionInfo.LastFirstEventID = *firstEvent.EventId err2 := c.updateWorkflowExecutionWithContext(context, transferTasks, timerTasks, transactionID)