Skip to content

Commit 47e7e23

Browse files
committed
Polish / code review suggestions
1 parent 53e8c4f commit 47e7e23

File tree

6 files changed

+143
-129
lines changed

6 files changed

+143
-129
lines changed

openapi/openapiv2.json

Lines changed: 27 additions & 37 deletions
Large diffs are not rendered by default.

openapi/openapiv3.yaml

Lines changed: 61 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ paths:
171171
description: |-
172172
RespondActivityTaskFailed is called by workers when processing an activity task fails.
173173

174-
This results in a new `ACTIVITY_TASK_CANCELED` event being written to the workflow history
174+
For workflow activities, this results in a new `ACTIVITY_TASK_CANCELED` event being written to the workflow history
175175
and a new workflow task created for the workflow. Fails with `NotFound` if the task token is
176176
no longer valid due to activity timeout, already being completed, or never having existed.
177177
operationId: RespondActivityTaskCanceled
@@ -245,7 +245,7 @@ paths:
245245
RespondActivityTaskCompleted is called by workers when they successfully complete an activity
246246
task.
247247

248-
This results in a new `ACTIVITY_TASK_COMPLETED` event being written to the workflow history
248+
For workflow activities, this results in a new `ACTIVITY_TASK_COMPLETED` event being written to the workflow history
249249
and a new workflow task created for the workflow. Fails with `NotFound` if the task token is
250250
no longer valid due to activity timeout, already being completed, or never having existed.
251251
operationId: RespondActivityTaskCompleted
@@ -391,10 +391,17 @@ paths:
391391
description: |-
392392
RecordActivityTaskHeartbeat is optionally called by workers while they execute activities.
393393

394-
If worker fails to heartbeat within the `heartbeat_timeout` interval for the activity task,
395-
then it will be marked as timed out and an `ACTIVITY_TASK_TIMED_OUT` event will be written to
396-
the workflow history. Calling `RecordActivityTaskHeartbeat` will fail with `NotFound` in
397-
such situations, in that event, the SDK should request cancellation of the activity.
394+
If a worker fails to heartbeat within the `heartbeat_timeout` interval for the activity task,
395+
then the current attempt times out. Depending on RetryPolicy, this may trigger a retry or
396+
time out the activity.
397+
398+
For workflow activities, an `ACTIVITY_TASK_TIMED_OUT` event will be written to the workflow
399+
history. Calling `RecordActivityTaskHeartbeat` will fail with `NotFound` in such situations,
400+
in that event, the SDK should request cancellation of the activity.
401+
402+
The request may contain response `details` which will be persisted by the server and may be
403+
used by the activity to checkpoint progress. The `cancel_requested` field in the response
404+
indicates whether cancellation has been requested for the activity.
398405
operationId: RecordActivityTaskHeartbeat
399406
parameters:
400407
- name: namespace
@@ -648,7 +655,7 @@ paths:
648655
- WorkflowService
649656
description: |-
650657
DescribeActivityExecution returns information about an activity execution.
651-
Supported use cases include:
658+
It can be used to:
652659
- Get current activity info without waiting
653660
- Long-poll for next state change and return new activity info
654661
Response can optionally include activity input or outcome (if the activity has completed).
@@ -710,7 +717,7 @@ paths:
710717
description: |-
711718
StartActivityExecution starts a new activity execution.
712719

713-
Returns an `ExecutionAlreadyStarted` error if an instance already exists with same activity ID in this namespace
720+
Returns an `ActivityExecutionAlreadyStarted` error if an instance already exists with same activity ID in this namespace
714721
unless permitted by the specified ID conflict policy.
715722
operationId: StartActivityExecution
716723
parameters:
@@ -721,6 +728,10 @@ paths:
721728
type: string
722729
- name: activityId
723730
in: path
731+
description: |-
732+
Identifier for this activity. Required. This identifier should be meaningful in the user's
733+
own system. It must be unique among activities in the same namespace, subject to the rules
734+
imposed by id_reuse_policy and id_conflict_policy.
724735
required: true
725736
schema:
726737
type: string
@@ -750,13 +761,10 @@ paths:
750761
description: |-
751762
RequestCancelActivityExecution requests cancellation of an activity execution.
752763

753-
Requesting to cancel an activity does not automatically transition the activity to canceled status. If the
754-
activity has a currently running attempt, the activity will only transition to canceled status if the current
755-
attempt is unsuccessful.
756-
TODO: Clarify what happens if there are no more allowed retries after the current attempt.
757-
758-
It returns success if the requested activity is already closed.
759-
TODO: This ^^ is copied from RequestCancelWorkflowExecution, do we want to preserve this behavior?
764+
Cancellation is cooperative: this call records the request, but the activity must detect and
765+
acknowledge it for the activity to reach CANCELED status. The cancellation signal is
766+
delivered via `cancel_requested` in the heartbeat response; SDKs surface this via
767+
language-idiomatic mechanisms (context cancellation, exceptions, abort signals).
760768
operationId: RequestCancelActivityExecution
761769
parameters:
762770
- name: namespace
@@ -833,7 +841,7 @@ paths:
833841
TerminateActivityExecution terminates an existing activity execution immediately.
834842

835843
Termination does not reach the worker and the activity code cannot react to it. A terminated activity may have a
836-
running attempt and will be requested to be canceled by the server when it heartbeats.
844+
running attempt.
837845
operationId: TerminateActivityExecution
838846
parameters:
839847
- name: namespace
@@ -869,7 +877,7 @@ paths:
869877
get:
870878
tags:
871879
- WorkflowService
872-
description: CountActivityExecutions is a visibility API to count of activity executions in a specific namespace.
880+
description: CountActivityExecutions is a visibility API to count activity executions in a specific namespace.
873881
operationId: CountActivityExecutions
874882
parameters:
875883
- name: namespace
@@ -3957,7 +3965,7 @@ paths:
39573965
description: |-
39583966
RespondActivityTaskFailed is called by workers when processing an activity task fails.
39593967

3960-
This results in a new `ACTIVITY_TASK_CANCELED` event being written to the workflow history
3968+
For workflow activities, this results in a new `ACTIVITY_TASK_CANCELED` event being written to the workflow history
39613969
and a new workflow task created for the workflow. Fails with `NotFound` if the task token is
39623970
no longer valid due to activity timeout, already being completed, or never having existed.
39633971
operationId: RespondActivityTaskCanceled
@@ -4031,7 +4039,7 @@ paths:
40314039
RespondActivityTaskCompleted is called by workers when they successfully complete an activity
40324040
task.
40334041

4034-
This results in a new `ACTIVITY_TASK_COMPLETED` event being written to the workflow history
4042+
For workflow activities, this results in a new `ACTIVITY_TASK_COMPLETED` event being written to the workflow history
40354043
and a new workflow task created for the workflow. Fails with `NotFound` if the task token is
40364044
no longer valid due to activity timeout, already being completed, or never having existed.
40374045
operationId: RespondActivityTaskCompleted
@@ -4177,10 +4185,17 @@ paths:
41774185
description: |-
41784186
RecordActivityTaskHeartbeat is optionally called by workers while they execute activities.
41794187

4180-
If worker fails to heartbeat within the `heartbeat_timeout` interval for the activity task,
4181-
then it will be marked as timed out and an `ACTIVITY_TASK_TIMED_OUT` event will be written to
4182-
the workflow history. Calling `RecordActivityTaskHeartbeat` will fail with `NotFound` in
4183-
such situations, in that event, the SDK should request cancellation of the activity.
4188+
If a worker fails to heartbeat within the `heartbeat_timeout` interval for the activity task,
4189+
then the current attempt times out. Depending on RetryPolicy, this may trigger a retry or
4190+
time out the activity.
4191+
4192+
For workflow activities, an `ACTIVITY_TASK_TIMED_OUT` event will be written to the workflow
4193+
history. Calling `RecordActivityTaskHeartbeat` will fail with `NotFound` in such situations,
4194+
in that event, the SDK should request cancellation of the activity.
4195+
4196+
The request may contain response `details` which will be persisted by the server and may be
4197+
used by the activity to checkpoint progress. The `cancel_requested` field in the response
4198+
indicates whether cancellation has been requested for the activity.
41844199
operationId: RecordActivityTaskHeartbeat
41854200
parameters:
41864201
- name: namespace
@@ -4434,7 +4449,7 @@ paths:
44344449
- WorkflowService
44354450
description: |-
44364451
DescribeActivityExecution returns information about an activity execution.
4437-
Supported use cases include:
4452+
It can be used to:
44384453
- Get current activity info without waiting
44394454
- Long-poll for next state change and return new activity info
44404455
Response can optionally include activity input or outcome (if the activity has completed).
@@ -4496,7 +4511,7 @@ paths:
44964511
description: |-
44974512
StartActivityExecution starts a new activity execution.
44984513

4499-
Returns an `ExecutionAlreadyStarted` error if an instance already exists with same activity ID in this namespace
4514+
Returns an `ActivityExecutionAlreadyStarted` error if an instance already exists with same activity ID in this namespace
45004515
unless permitted by the specified ID conflict policy.
45014516
operationId: StartActivityExecution
45024517
parameters:
@@ -4507,6 +4522,10 @@ paths:
45074522
type: string
45084523
- name: activityId
45094524
in: path
4525+
description: |-
4526+
Identifier for this activity. Required. This identifier should be meaningful in the user's
4527+
own system. It must be unique among activities in the same namespace, subject to the rules
4528+
imposed by id_reuse_policy and id_conflict_policy.
45104529
required: true
45114530
schema:
45124531
type: string
@@ -4536,13 +4555,10 @@ paths:
45364555
description: |-
45374556
RequestCancelActivityExecution requests cancellation of an activity execution.
45384557

4539-
Requesting to cancel an activity does not automatically transition the activity to canceled status. If the
4540-
activity has a currently running attempt, the activity will only transition to canceled status if the current
4541-
attempt is unsuccessful.
4542-
TODO: Clarify what happens if there are no more allowed retries after the current attempt.
4543-
4544-
It returns success if the requested activity is already closed.
4545-
TODO: This ^^ is copied from RequestCancelWorkflowExecution, do we want to preserve this behavior?
4558+
Cancellation is cooperative: this call records the request, but the activity must detect and
4559+
acknowledge it for the activity to reach CANCELED status. The cancellation signal is
4560+
delivered via `cancel_requested` in the heartbeat response; SDKs surface this via
4561+
language-idiomatic mechanisms (context cancellation, exceptions, abort signals).
45464562
operationId: RequestCancelActivityExecution
45474563
parameters:
45484564
- name: namespace
@@ -4619,7 +4635,7 @@ paths:
46194635
TerminateActivityExecution terminates an existing activity execution immediately.
46204636

46214637
Termination does not reach the worker and the activity code cannot react to it. A terminated activity may have a
4622-
running attempt and will be requested to be canceled by the server when it heartbeats.
4638+
running attempt.
46234639
operationId: TerminateActivityExecution
46244640
parameters:
46254641
- name: namespace
@@ -4655,7 +4671,7 @@ paths:
46554671
get:
46564672
tags:
46574673
- WorkflowService
4658-
description: CountActivityExecutions is a visibility API to count of activity executions in a specific namespace.
4674+
description: CountActivityExecutions is a visibility API to count activity executions in a specific namespace.
46594675
operationId: CountActivityExecutions
46604676
parameters:
46614677
- name: namespace
@@ -7308,10 +7324,7 @@ components:
73087324
format: date-time
73097325
attempt:
73107326
type: integer
7311-
description: |-
7312-
The attempt this activity is currently on.
7313-
Incremented each time a new attempt is started.
7314-
TODO(dandavison): Confirm if this is on scheduled or started.
7327+
description: The attempt this activity is currently on. Incremented each time a new attempt is scheduled.
73157328
format: int32
73167329
executionDuration:
73177330
pattern: ^-?(?:0|[1-9][0-9]{0,11})(?:\.[0-9]{1,9})?s$
@@ -7368,6 +7381,9 @@ components:
73687381
stateTransitionCount:
73697382
type: string
73707383
description: Incremented each time the activity's state is mutated in persistence.
7384+
stateSizeBytes:
7385+
type: string
7386+
description: Updated once on scheduled and once on terminal status.
73717387
searchAttributes:
73727388
$ref: '#/components/schemas/SearchAttributes'
73737389
header:
@@ -9867,23 +9883,11 @@ components:
98679883
$ref: '#/components/schemas/Link_WorkflowEvent'
98689884
batchJob:
98699885
$ref: '#/components/schemas/Link_BatchJob'
9870-
activity:
9871-
$ref: '#/components/schemas/Link_Activity'
98729886
description: |-
98739887
Link can be associated with history events. It might contain information about an external entity
98749888
related to the history event. For example, workflow A makes a Nexus call that starts workflow B:
98759889
in this case, a history event in workflow A could contain a Link to the workflow started event in
98769890
workflow B, and vice-versa.
9877-
Link_Activity:
9878-
type: object
9879-
properties:
9880-
namespace:
9881-
type: string
9882-
activityId:
9883-
type: string
9884-
runId:
9885-
type: string
9886-
description: A link to an activity.
98879891
Link_BatchJob:
98889892
type: object
98899893
properties:
@@ -13048,8 +13052,14 @@ components:
1304813052
description: A unique identifier for this start request. Typically UUIDv4.
1304913053
activityId:
1305013054
type: string
13055+
description: |-
13056+
Identifier for this activity. Required. This identifier should be meaningful in the user's
13057+
own system. It must be unique among activities in the same namespace, subject to the rules
13058+
imposed by id_reuse_policy and id_conflict_policy.
1305113059
activityType:
13052-
$ref: '#/components/schemas/ActivityType'
13060+
allOf:
13061+
- $ref: '#/components/schemas/ActivityType'
13062+
description: The type of the activity, a string that corresponds to a registered activity on a worker.
1305313063
taskQueue:
1305413064
allOf:
1305513065
- $ref: '#/components/schemas/TaskQueue'

temporal/api/common/v1/message.proto

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -240,17 +240,9 @@ message Link {
240240
string job_id = 1;
241241
}
242242

243-
// A link to an activity.
244-
message Activity {
245-
string namespace = 1;
246-
string activity_id = 2;
247-
string run_id = 3;
248-
}
249-
250243
oneof variant {
251244
WorkflowEvent workflow_event = 1;
252245
BatchJob batch_job = 2;
253-
Activity activity = 3;
254246
}
255247
}
256248

temporal/api/enums/v1/activity.proto

Lines changed: 28 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,30 +12,43 @@ option csharp_namespace = "Temporalio.Api.Enums.V1";
1212
// Status of a standalone activity.
1313
// The status is updated once, when the activity is originally scheduled, and again when the activity reaches a terminal
1414
// status.
15-
// TODO: Should this be a common execution status? Seems like the other archetypes will share this status.
1615
// (-- api-linter: core::0216::synonyms=disabled
1716
// aip.dev/not-precedent: Named consistently with WorkflowExecutionStatus. --)
1817
enum ActivityExecutionStatus {
1918
ACTIVITY_EXECUTION_STATUS_UNSPECIFIED = 0;
20-
// The activity is not in a terminal status. This does not necessarily mean that there is a currently running
21-
// attempt. The activity may be backing off between attempts or waiting for a worker to pick it up.
19+
20+
// The activity has not reached a terminal status. See PendingActivityState for the run state
21+
// (SCHEDULED, STARTED, or CANCEL_REQUESTED).
2222
ACTIVITY_EXECUTION_STATUS_RUNNING = 1;
23-
// The activity completed successfully.
23+
24+
// The activity completed successfully. An activity can complete even after cancellation is
25+
// requested if the worker calls RespondActivityTaskCompleted before acknowledging cancellation.
2426
ACTIVITY_EXECUTION_STATUS_COMPLETED = 2;
25-
// The activity completed with failure.
27+
28+
// The activity failed. Causes:
29+
// - Worker returned a non-retryable failure
30+
// - RetryPolicy.maximum_attempts exhausted
31+
// - Attempt failed after cancellation was requested (retries blocked)
2632
ACTIVITY_EXECUTION_STATUS_FAILED = 3;
27-
// The activity completed as canceled.
28-
// Requesting to cancel an activity does not automatically transition the activity to canceled status. If the
29-
// activity has a currently running attempt, the activity will only transition to canceled status if the current
30-
// attempt is unsuccessful.
31-
// TODO: Clarify what happens if there are no more allowed retries after the current attempt.
33+
34+
// The activity was canceled. Reached when:
35+
// - Cancellation requested while SCHEDULED (immediate), or
36+
// - Cancellation requested while STARTED and worker called RespondActivityTaskCanceled.
37+
//
38+
// Workers discover cancellation requests via heartbeat responses (cancel_requested=true).
39+
// Activities that do not heartbeat will not learn of cancellation and may complete, fail, or
40+
// time out normally. CANCELED requires explicit worker acknowledgment or immediate cancellation
41+
// of a SCHEDULED activity.
3242
ACTIVITY_EXECUTION_STATUS_CANCELED = 4;
33-
// The activity was terminated. Termination does not reach the worker and the activity code cannot react to it.
34-
// A terminated activity may have a running attempt and will be requested to be canceled by the server when it
35-
// heartbeats.
43+
44+
// The activity was terminated. Immediate; does not wait for worker acknowledgment.
3645
ACTIVITY_EXECUTION_STATUS_TERMINATED = 5;
37-
// The activity has timed out by reaching the specified shedule-to-start or schedule-to-close timeouts.
38-
// TODO: Clarify if there are other conditions where the activity can end up in timed out status.
46+
47+
// The activity timed out. See TimeoutType for the specific timeout.
48+
// - SCHEDULE_TO_START and SCHEDULE_TO_CLOSE timeouts always result in TIMED_OUT.
49+
// - START_TO_CLOSE and HEARTBEAT may retry if RetryPolicy permits; TIMED_OUT is
50+
// reached when retry is blocked (RetryPolicy.maximum_attempts exhausted,
51+
// SCHEDULE_TO_CLOSE would be exceeded, or cancellation has been requested).
3952
ACTIVITY_EXECUTION_STATUS_TIMED_OUT = 6;
4053
}
4154

temporal/api/workflowservice/v1/request_response.proto

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2665,7 +2665,12 @@ message StartActivityExecutionRequest {
26652665
// A unique identifier for this start request. Typically UUIDv4.
26662666
string request_id = 3;
26672667

2668+
// Identifier for this activity. Required. This identifier should be meaningful in the user's
2669+
// own system. It must be unique among activities in the same namespace, subject to the rules
2670+
// imposed by id_reuse_policy and id_conflict_policy.
26682671
string activity_id = 4;
2672+
2673+
// The type of the activity, a string that corresponds to a registered activity on a worker.
26692674
temporal.api.common.v1.ActivityType activity_type = 5;
26702675

26712676
// Task queue to schedule this activity on.

0 commit comments

Comments
 (0)