From af2f92b8a0e83aa73d0c7c1e7f1e1d2b8a001593 Mon Sep 17 00:00:00 2001 From: Dan Davison Date: Mon, 22 Apr 2024 09:11:33 -0400 Subject: [PATCH 1/6] Edits --- .../internal/replay/ReplayWorkflowTaskHandler.java | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/temporal-sdk/src/main/java/io/temporal/internal/replay/ReplayWorkflowTaskHandler.java b/temporal-sdk/src/main/java/io/temporal/internal/replay/ReplayWorkflowTaskHandler.java index 4fb5da8822..d27b77770d 100644 --- a/temporal-sdk/src/main/java/io/temporal/internal/replay/ReplayWorkflowTaskHandler.java +++ b/temporal-sdk/src/main/java/io/temporal/internal/replay/ReplayWorkflowTaskHandler.java @@ -119,18 +119,16 @@ private Result handleWorkflowTaskWithQuery( Result result; if (directQuery) { - // Direct query happens when there is no reason (events) to produce a real persisted - // workflow task. - // But Server needs to notify the workflow about the query and get back the query result. - // Server creates a fake non-persisted a PollWorkflowTaskResponse with just the query. - // This WFT has no new events in the history to process - // and the worker response on such a WFT can't contain any new commands either. + // A direct query is when the server needs to notify the workflow about queries (and get back the query + // results), but there are no new events in history. In this situation the server creates a + // PollWorkflowTaskResponse (i.e. a WFT) with the queries but without new events in the history. The worker + // response to such a WFT may not contain any new commands. QueryResult queryResult = workflowRunTaskHandler.handleDirectQueryWorkflowTask(workflowTask, historyIterator); finalCommand = queryResult.isWorkflowMethodCompleted(); result = createDirectQueryResult(workflowTask, queryResult, null); } else { - // main code path, handle workflow task that can have an embedded query + // Main code path; handle workflow task (with events, and perhaps also queries). WorkflowTaskResult wftResult = workflowRunTaskHandler.handleWorkflowTask(workflowTask, historyIterator); finalCommand = wftResult.isFinalCommand(); From 1000926d100feab7bcadb6665ece4112977ff593 Mon Sep 17 00:00:00 2001 From: Dan Davison Date: Tue, 13 Aug 2024 00:05:02 -0400 Subject: [PATCH 2/6] edit --- .../statemachines/WorkflowStateMachines.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/temporal-sdk/src/main/java/io/temporal/internal/statemachines/WorkflowStateMachines.java b/temporal-sdk/src/main/java/io/temporal/internal/statemachines/WorkflowStateMachines.java index f6463d59fe..b7a0a6ae4f 100644 --- a/temporal-sdk/src/main/java/io/temporal/internal/statemachines/WorkflowStateMachines.java +++ b/temporal-sdk/src/main/java/io/temporal/internal/statemachines/WorkflowStateMachines.java @@ -484,14 +484,14 @@ private void handleSingleEvent(HistoryEvent event, boolean lastTask, boolean has } /** - * Handles command event. Command event is an event which is generated from a command emitted by a - * past decision. Each command has a correspondent event. For example ScheduleActivityTaskCommand - * is recorded to the history as ActivityTaskScheduledEvent. + * Handle a command event. A command event is an event which was generated by a command emitted by + * a past event. Each command has precisely one corresponding event. For example a + * ScheduleActivityTask command gives rise to an ActivityTaskScheduled history event. * - *

Command events always follow WorkflowTaskCompletedEvent. + *

Command events always follow a WorkflowTaskCompleted event. * - *

The handling consists from verifying that the next command in the commands queue matches the - * event, command state machine is notified about the event and the command is removed from the + *

The handling consists of verifying that the next command in the commands queue matches the + * event, the command state machine is notified about the event and the command is removed from the * commands queue. */ private void handleCommandEvent(HistoryEvent event) { From 41c20c0701da490099344bc1b034ae28ea08254c Mon Sep 17 00:00:00 2001 From: Dan Davison Date: Tue, 3 Sep 2024 07:53:13 -0400 Subject: [PATCH 3/6] edits --- .../src/main/java/io/temporal/workflow/ActivityStub.java | 8 ++++---- .../src/main/java/io/temporal/workflow/Async.java | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/temporal-sdk/src/main/java/io/temporal/workflow/ActivityStub.java b/temporal-sdk/src/main/java/io/temporal/workflow/ActivityStub.java index 0c38e2bb0c..4f062ab904 100644 --- a/temporal-sdk/src/main/java/io/temporal/workflow/ActivityStub.java +++ b/temporal-sdk/src/main/java/io/temporal/workflow/ActivityStub.java @@ -23,14 +23,14 @@ import java.lang.reflect.Type; /** - * ActivityStub is used to call an activity without referencing an interface it implements. This is - * useful to call activities when their type is not known at compile time or to execute activities + * ActivityStub is used to call an activity without referencing the interface that it implements. This is + * useful for calling activities when their type is not known at compile time, or for executing activities * implemented in other languages. Created through {@link Workflow#newActivityStub(Class)}. */ public interface ActivityStub { /** - * Executes an activity by its type name and arguments. Blocks until the activity completion. + * Executes an activity by its type name and arguments. Blocks until activity completion. * * @param activityName name of an activity type to execute. * @param resultClass the expected return type of the activity. Use Void.class for activities that @@ -42,7 +42,7 @@ public interface ActivityStub { R execute(String activityName, Class resultClass, Object... args); /** - * Executes an activity by its type name and arguments. Blocks until the activity completion. + * Executes an activity by its type name and arguments. Blocks until activity completion. * * @param activityName name of an activity type to execute. * @param resultClass the expected return class of the activity. Use Void.class for activities diff --git a/temporal-sdk/src/main/java/io/temporal/workflow/Async.java b/temporal-sdk/src/main/java/io/temporal/workflow/Async.java index 007b636458..aab06bc574 100644 --- a/temporal-sdk/src/main/java/io/temporal/workflow/Async.java +++ b/temporal-sdk/src/main/java/io/temporal/workflow/Async.java @@ -29,7 +29,7 @@ public final class Async { /** - * Invokes zero argument function asynchronously. + * Invokes a zero-argument function asynchronously. * * @param function Function to execute asynchronously * @return promise that contains function result or failure @@ -39,7 +39,7 @@ public static Promise function(Functions.Func function) { } /** - * Invokes one argument function asynchronously. + * Invokes a one-argument function asynchronously. * * @param function Function to execute asynchronously * @param arg1 first function argument From 38f675d75ce03cba73d0b91657a4d683fff2a556 Mon Sep 17 00:00:00 2001 From: Dan Davison Date: Fri, 17 Jan 2025 22:58:13 -0500 Subject: [PATCH 4/6] Edit --- .../java/io/temporal/activity/ActivityExecutionContext.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/temporal-sdk/src/main/java/io/temporal/activity/ActivityExecutionContext.java b/temporal-sdk/src/main/java/io/temporal/activity/ActivityExecutionContext.java index 38a4515665..38d77a54ce 100644 --- a/temporal-sdk/src/main/java/io/temporal/activity/ActivityExecutionContext.java +++ b/temporal-sdk/src/main/java/io/temporal/activity/ActivityExecutionContext.java @@ -143,7 +143,7 @@ public interface ActivityExecutionContext { Scope getMetricsScope(); /** - * Get a {@link WorkflowClient} that can be used to start interact with the Temporal service from + * Get a {@link WorkflowClient} that can be used to interact with the Temporal service from * an activity. */ WorkflowClient getWorkflowClient(); From 0e271262d724508446156a71660afb3257f3019e Mon Sep 17 00:00:00 2001 From: Dan Davison Date: Fri, 17 Jan 2025 23:00:25 -0500 Subject: [PATCH 5/6] edit --- .../temporal/internal/statemachines/WorkflowStateMachines.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/temporal-sdk/src/main/java/io/temporal/internal/statemachines/WorkflowStateMachines.java b/temporal-sdk/src/main/java/io/temporal/internal/statemachines/WorkflowStateMachines.java index b7a0a6ae4f..a65c530c58 100644 --- a/temporal-sdk/src/main/java/io/temporal/internal/statemachines/WorkflowStateMachines.java +++ b/temporal-sdk/src/main/java/io/temporal/internal/statemachines/WorkflowStateMachines.java @@ -491,7 +491,7 @@ private void handleSingleEvent(HistoryEvent event, boolean lastTask, boolean has *

Command events always follow a WorkflowTaskCompleted event. * *

The handling consists of verifying that the next command in the commands queue matches the - * event, the command state machine is notified about the event and the command is removed from the + * event. The command state machine is notified about the event and the command is removed from the * commands queue. */ private void handleCommandEvent(HistoryEvent event) { From e9ad3a2935c3795d3fc0d3b216d7f411727f85e7 Mon Sep 17 00:00:00 2001 From: Dan Davison Date: Tue, 21 Jan 2025 10:40:48 -0500 Subject: [PATCH 6/6] suggested change from review --- .../src/main/java/io/temporal/workflow/ActivityStub.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/temporal-sdk/src/main/java/io/temporal/workflow/ActivityStub.java b/temporal-sdk/src/main/java/io/temporal/workflow/ActivityStub.java index 4f062ab904..97d0e814fa 100644 --- a/temporal-sdk/src/main/java/io/temporal/workflow/ActivityStub.java +++ b/temporal-sdk/src/main/java/io/temporal/workflow/ActivityStub.java @@ -23,7 +23,7 @@ import java.lang.reflect.Type; /** - * ActivityStub is used to call an activity without referencing the interface that it implements. This is + * ActivityStub is used to call an activity without referencing an interface that it implements. This is * useful for calling activities when their type is not known at compile time, or for executing activities * implemented in other languages. Created through {@link Workflow#newActivityStub(Class)}. */