Skip to content

Commit 148f618

Browse files
authored
More and better comments (#121)
1 parent 84e4655 commit 148f618

File tree

11 files changed

+561
-150
lines changed

11 files changed

+561
-150
lines changed

temporal/api/command/v1/message.proto

Lines changed: 41 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -48,37 +48,46 @@ message ScheduleActivityTaskCommandAttributes {
4848
temporal.api.taskqueue.v1.TaskQueue task_queue = 4;
4949
temporal.api.common.v1.Header header = 5;
5050
temporal.api.common.v1.Payloads input = 6;
51+
// Indicates how long the caller is willing to wait for activity completion. Limits how long
52+
// retries will be attempted. Either this or `start_to_close_timeout` must be specified. When
53+
// not specified, defaults to the workflow execution timeout.
54+
//
5155
// (-- api-linter: core::0140::prepositions=disabled
5256
// aip.dev/not-precedent: "to" is used to indicate interval. --)
53-
// Indicates how long the caller is willing to wait for an activity completion.
54-
// Limits for how long retries are happening. Either this or start_to_close_timeout_seconds must be specified.
55-
// When not specified defaults to the workflow execution timeout.
5657
google.protobuf.Duration schedule_to_close_timeout = 7 [(gogoproto.stdduration) = true];
58+
// Limits the time an activity task can stay in a task queue before a worker picks it up. This
59+
// timeout is always non retryable, as all a retry would achieve is to put it back into the same
60+
// queue. Defaults to `schedule_to_close_timeout` or workflow execution timeout if that is not
61+
// specified.
62+
//
5763
// (-- api-linter: core::0140::prepositions=disabled
5864
// aip.dev/not-precedent: "to" is used to indicate interval. --)
59-
// Limits time an activity task can stay in a task queue before a worker picks it up.
60-
// This timeout is always non retryable as all a retry would achieve is to put it back into the same queue.
61-
// Defaults to schedule_to_close_timeout_seconds or workflow execution timeout if not specified.
6265
google.protobuf.Duration schedule_to_start_timeout = 8 [(gogoproto.stdduration) = true];
66+
// Maximum time an activity is allowed to execute after being picked up by a worker. This
67+
// timeout is always retryable. Either this or `schedule_to_close_timeout` must be specified.
68+
//
6369
// (-- api-linter: core::0140::prepositions=disabled
6470
// aip.dev/not-precedent: "to" is used to indicate interval. --)
65-
// Maximum time an activity is allowed to execute after a pick up by a worker.
66-
// This timeout is always retryable. Either this or schedule_to_close_timeout_seconds must be specified.
6771
google.protobuf.Duration start_to_close_timeout = 9 [(gogoproto.stdduration) = true];
68-
// Maximum time between successful worker heartbeats.
72+
// Maximum permitted time between successful worker heartbeats.
6973
google.protobuf.Duration heartbeat_timeout = 10 [(gogoproto.stdduration) = true];
70-
// Activities are provided by a default retry policy controlled through the service dynamic configuration.
71-
// Retries are happening up to schedule_to_close_timeout.
72-
// To disable retries set retry_policy.maximum_attempts to 1.
74+
// Activities are provided by a default retry policy which is controlled through the service's
75+
// dynamic configuration. Retries will be attempted until `schedule_to_close_timeout` has
76+
// elapsed. To disable retries set retry_policy.maximum_attempts to 1.
7377
temporal.api.common.v1.RetryPolicy retry_policy = 11;
7478
}
7579

7680
message RequestCancelActivityTaskCommandAttributes {
81+
// The `ACTIVITY_TASK_SCHEDULED` event id for the activity being cancelled.
7782
int64 scheduled_event_id = 1;
7883
}
7984

8085
message StartTimerCommandAttributes {
86+
// An id for the timer, currently live timers must have different ids. Typically autogenerated
87+
// by the SDK.
8188
string timer_id = 1;
89+
// How long until the timer fires, producing a `TIMER_FIRED` event.
90+
//
8291
// (-- api-linter: core::0140::prepositions=disabled
8392
// aip.dev/not-precedent: "to" is used to indicate interval. --)
8493
google.protobuf.Duration start_to_fire_timeout = 2 [(gogoproto.stdduration) = true];
@@ -93,6 +102,7 @@ message FailWorkflowExecutionCommandAttributes {
93102
}
94103

95104
message CancelTimerCommandAttributes {
105+
// The same timer id from the start timer command
96106
string timer_id = 1;
97107
}
98108

@@ -104,16 +114,26 @@ message RequestCancelExternalWorkflowExecutionCommandAttributes {
104114
string namespace = 1;
105115
string workflow_id = 2;
106116
string run_id = 3;
117+
// Deprecated.
107118
string control = 4;
119+
// Set this to true if the workflow being cancelled is a child of the workflow originating this
120+
// command. The request will be rejected if it is set to true and the target workflow is *not*
121+
// a child of the requesting workflow.
108122
bool child_workflow_only = 5;
109123
}
110124

111125
message SignalExternalWorkflowExecutionCommandAttributes {
112126
string namespace = 1;
113127
temporal.api.common.v1.WorkflowExecution execution = 2;
128+
// The workflow author-defined name of the signal to send to the workflow.
114129
string signal_name = 3;
130+
// Serialized value(s) to provide with the signal.
115131
temporal.api.common.v1.Payloads input = 4;
132+
// Deprecated
116133
string control = 5;
134+
// Set this to true if the workflow being cancelled is a child of the workflow originating this
135+
// command. The request will be rejected if it is set to true and the target workflow is *not*
136+
// a child of the requesting workflow.
117137
bool child_workflow_only = 6;
118138
// Headers that are passed by the workflow that is sending a signal to the external
119139
// workflow that is receiving this signal.
@@ -135,20 +155,27 @@ message ContinueAsNewWorkflowExecutionCommandAttributes {
135155
temporal.api.common.v1.WorkflowType workflow_type = 1;
136156
temporal.api.taskqueue.v1.TaskQueue task_queue = 2;
137157
temporal.api.common.v1.Payloads input = 3;
138-
// workflow_execution_timeout is omitted as it shouldn'be overridden from within a workflow.
158+
139159
// Timeout of a single workflow run.
140160
google.protobuf.Duration workflow_run_timeout = 4 [(gogoproto.stdduration) = true];
141161
// Timeout of a single workflow task.
142162
google.protobuf.Duration workflow_task_timeout = 5 [(gogoproto.stdduration) = true];
163+
// How long the workflow start will be delayed - not really a "backoff" in the traditional sense.
143164
google.protobuf.Duration backoff_start_interval = 6 [(gogoproto.stdduration) = true];
144165
temporal.api.common.v1.RetryPolicy retry_policy = 7;
166+
// Should be removed
145167
temporal.api.enums.v1.ContinueAsNewInitiator initiator = 8;
168+
// Should be removed
146169
temporal.api.failure.v1.Failure failure = 9;
170+
// Should be removed
147171
temporal.api.common.v1.Payloads last_completion_result = 10;
172+
// Should be removed. Not necessarily unused but unclear and not exposed by SDKs.
148173
string cron_schedule = 11;
149174
temporal.api.common.v1.Header header = 12;
150175
temporal.api.common.v1.Memo memo = 13;
151176
temporal.api.common.v1.SearchAttributes search_attributes = 14;
177+
178+
// `workflow_execution_timeout` is omitted as it shouldn't be overridden from within a workflow.
152179
}
153180

154181
message StartChildWorkflowExecutionCommandAttributes {
@@ -169,6 +196,7 @@ message StartChildWorkflowExecutionCommandAttributes {
169196
// Default: WORKFLOW_ID_REUSE_POLICY_ALLOW_DUPLICATE.
170197
temporal.api.enums.v1.WorkflowIdReusePolicy workflow_id_reuse_policy = 11;
171198
temporal.api.common.v1.RetryPolicy retry_policy = 12;
199+
// Establish a cron schedule for the child workflow.
172200
string cron_schedule = 13;
173201
temporal.api.common.v1.Header header = 14;
174202
temporal.api.common.v1.Memo memo = 15;

temporal/api/common/v1/message.proto

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,40 +42,57 @@ message DataBlob {
4242
bytes data = 2;
4343
}
4444

45+
// See `Payload`
4546
message Payloads {
4647
repeated Payload payloads = 1;
4748
}
4849

50+
// Represents some binary (byte array) data (ex: activity input parameters or workflow result) with
51+
// metadata which describes this binary data (format, encoding, encryption, etc). Serialization
52+
// of the data may be user-defined.
4953
message Payload {
5054
map<string,bytes> metadata = 1;
5155
bytes data = 2;
5256
}
5357

58+
// A user-defined set of *indexed* fields that are used/exposed when listing/searching workflows.
59+
// The payload is not serialized in a user-defined way.
5460
message SearchAttributes {
5561
map<string, Payload> indexed_fields = 1;
5662
}
5763

64+
// A user-defined set of *unindexed* fields that are exposed when listing/searching workflows
5865
message Memo {
5966
map<string, Payload> fields = 1;
6067
}
6168

69+
// Contains metadata that can be attached to a variety of requests, like starting a workflow, and
70+
// can be propagated between, for example, workflows and activities.
6271
message Header {
6372
map<string, Payload> fields = 1;
6473
}
6574

75+
// Identifies a specific workflow within a namespace. Practically speaking, because run_id is a
76+
// uuid, a workflow execution is globally unique. Note that many commands allow specifying an empty
77+
// run id as a way of saying "target the latest run of the workflow".
6678
message WorkflowExecution {
6779
string workflow_id = 1;
6880
string run_id = 2;
6981
}
7082

83+
// Represents the identifier used by a workflow author to define the workflow. Typically, the
84+
// name of a function. This is sometimes referred to as the workflow's "name"
7185
message WorkflowType {
7286
string name = 1;
7387
}
7488

89+
// Represents the identifier used by a activity author to define the activity. Typically, the
90+
// name of a function. This is sometimes referred to as the activity's "name"
7591
message ActivityType {
7692
string name = 1;
7793
}
7894

95+
// How retries ought to be handled, usable by both workflows and activities
7996
message RetryPolicy {
8097
// Interval of the first retry. If retryBackoffCoefficient is 1.0 then it is used for all retries.
8198
google.protobuf.Duration initial_interval = 1 [(gogoproto.stdduration) = true];
@@ -89,6 +106,7 @@ message RetryPolicy {
89106
// Maximum number of attempts. When exceeded the retries stop even if not expired yet.
90107
// 1 disables retries. 0 means unlimited (up to the timeouts)
91108
int32 maximum_attempts = 4;
92-
// Non-Retryable errors types. Will stop retrying if error type matches this list.
109+
// Non-Retryable errors types. Will stop retrying if the error type matches this list. Note that
110+
// this is not a substring match, the error *type* (not message) must match exactly.
93111
repeated string non_retryable_error_types = 5;
94112
}

temporal/api/enums/v1/failed_cause.proto

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,13 @@ option java_outer_classname = "FailedCauseProto";
3131
option ruby_package = "Temporal::Api::Enums::V1";
3232
option csharp_namespace = "Temporal.Api.Enums.V1";
3333

34+
// Workflow tasks can fail for various reasons. Note that some of these reasons can only originate
35+
// from the server, and some of them can only originate from the SDK/worker.
3436
enum WorkflowTaskFailedCause {
3537
WORKFLOW_TASK_FAILED_CAUSE_UNSPECIFIED = 0;
38+
// Between starting and completing the workflow task (with a workflow completion command), some
39+
// new command (like a signal) was processed into workflow history. The outstanding task will be
40+
// failed with this reason, and a worker must pick up a new task.
3641
WORKFLOW_TASK_FAILED_CAUSE_UNHANDLED_COMMAND = 1;
3742
WORKFLOW_TASK_FAILED_CAUSE_BAD_SCHEDULE_ACTIVITY_ATTRIBUTES = 2;
3843
WORKFLOW_TASK_FAILED_CAUSE_BAD_REQUEST_CANCEL_ACTIVITY_ATTRIBUTES = 3;
@@ -45,6 +50,8 @@ enum WorkflowTaskFailedCause {
4550
WORKFLOW_TASK_FAILED_CAUSE_BAD_REQUEST_CANCEL_EXTERNAL_WORKFLOW_EXECUTION_ATTRIBUTES = 10;
4651
WORKFLOW_TASK_FAILED_CAUSE_BAD_CONTINUE_AS_NEW_ATTRIBUTES = 11;
4752
WORKFLOW_TASK_FAILED_CAUSE_START_TIMER_DUPLICATE_ID = 12;
53+
// The worker wishes to fail the task and have the next one be generated on a normal, not sticky
54+
// queue. Generally workers should prefer to use the explicit `ResetStickyTaskQueue` RPC call.
4855
WORKFLOW_TASK_FAILED_CAUSE_RESET_STICKY_TASK_QUEUE = 13;
4956
WORKFLOW_TASK_FAILED_CAUSE_WORKFLOW_WORKER_UNHANDLED_FAILURE = 14;
5057
WORKFLOW_TASK_FAILED_CAUSE_BAD_SIGNAL_WORKFLOW_EXECUTION_ATTRIBUTES = 15;
@@ -56,6 +63,8 @@ enum WorkflowTaskFailedCause {
5663
WORKFLOW_TASK_FAILED_CAUSE_BAD_BINARY = 21;
5764
WORKFLOW_TASK_FAILED_CAUSE_SCHEDULE_ACTIVITY_DUPLICATE_ID = 22;
5865
WORKFLOW_TASK_FAILED_CAUSE_BAD_SEARCH_ATTRIBUTES = 23;
66+
// The worker encountered a mismatch while replaying history between what was expected, and
67+
// what the workflow code actually did.
5968
WORKFLOW_TASK_FAILED_CAUSE_NON_DETERMINISTIC_ERROR = 24;
6069
}
6170

temporal/api/enums/v1/reset.proto

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ option java_outer_classname = "ResetProto";
3131
option ruby_package = "Temporal::Api::Enums::V1";
3232
option csharp_namespace = "Temporal.Api.Enums.V1";
3333

34+
// TODO: What is this?
3435
enum ResetReapplyType {
3536
RESET_REAPPLY_TYPE_UNSPECIFIED = 0;
3637
RESET_REAPPLY_TYPE_SIGNAL = 1;

temporal/api/enums/v1/task_queue.proto

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,20 @@ option csharp_namespace = "Temporal.Api.Enums.V1";
3333

3434
enum TaskQueueKind {
3535
TASK_QUEUE_KIND_UNSPECIFIED = 0;
36+
// Tasks from a normal workflow task queue always include complete workflow history
37+
//
38+
// The task queue specified by the user is always a normal task queue. There can be as many
39+
// workers as desired for a single normal task queue. All those workers may pick up tasks from
40+
// that queue.
3641
TASK_QUEUE_KIND_NORMAL = 1;
42+
// A sticky queue only includes new history since the last workflow task, and they are
43+
// per-worker.
44+
//
45+
// Sticky queues are created dynamically by each worker during their start up. They only exist
46+
// for the lifetime of the worker process. Tasks in a sticky task queue are only available to
47+
// the worker that created the sticky queue.
48+
//
49+
// Sticky queues are only for workflow tasks. There are no sticky task queues for activities.
3750
TASK_QUEUE_KIND_STICKY = 2;
3851
}
3952

temporal/api/enums/v1/workflow.proto

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,31 +31,38 @@ option java_outer_classname = "WorkflowProto";
3131
option ruby_package = "Temporal::Api::Enums::V1";
3232
option csharp_namespace = "Temporal.Api.Enums.V1";
3333

34+
// Defines how new runs of a workflow with a particular ID may or may not be allowed. Note that
35+
// it is *never* valid to have two actively running instances of the same workflow id.
3436
enum WorkflowIdReusePolicy {
3537
WORKFLOW_ID_REUSE_POLICY_UNSPECIFIED = 0;
36-
// Allow start a workflow execution using the same workflow Id, when workflow not running.
38+
// Allow starting a workflow execution using the same workflow id.
3739
WORKFLOW_ID_REUSE_POLICY_ALLOW_DUPLICATE = 1;
38-
// Allow start a workflow execution using the same workflow Id, when workflow not running, and the last execution close state is in
39-
// [terminated, cancelled, timed out, failed].
40+
// Allow starting a workflow execution using the same workflow id, only when the last
41+
// execution's final state is one of [terminated, cancelled, timed out, failed].
4042
WORKFLOW_ID_REUSE_POLICY_ALLOW_DUPLICATE_FAILED_ONLY = 2;
41-
// Do not allow start a workflow execution using the same workflow Id at all.
43+
// Do not permit re-use of the workflow id for this workflow. Future start workflow requests
44+
// could potentially change the policy, allowing re-use of the workflow id.
4245
WORKFLOW_ID_REUSE_POLICY_REJECT_DUPLICATE = 3;
4346
}
4447

48+
// Defines how child workflows will react to their parent completing
4549
enum ParentClosePolicy {
4650
PARENT_CLOSE_POLICY_UNSPECIFIED = 0;
47-
// Terminate means terminating the child workflow.
51+
// The child workflow will also terminate
4852
PARENT_CLOSE_POLICY_TERMINATE = 1;
49-
// Abandon means not doing anything on the child workflow.
53+
// The child workflow will do nothing
5054
PARENT_CLOSE_POLICY_ABANDON = 2;
51-
// Cancel means requesting cancellation on the child workflow.
55+
// Cancellation will be requested of the child workflow
5256
PARENT_CLOSE_POLICY_REQUEST_CANCEL = 3;
5357
}
5458

5559
enum ContinueAsNewInitiator {
5660
CONTINUE_AS_NEW_INITIATOR_UNSPECIFIED = 0;
61+
// The workflow itself requested to continue as new
5762
CONTINUE_AS_NEW_INITIATOR_WORKFLOW = 1;
63+
// The workflow continued as new because it is retrying
5864
CONTINUE_AS_NEW_INITIATOR_RETRY = 2;
65+
// The workflow continued as new because cron has triggered a new execution
5966
CONTINUE_AS_NEW_INITIATOR_CRON_SCHEDULE = 3;
6067
}
6168

0 commit comments

Comments
 (0)