@temporalio/core-bridge 0.23.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Cargo.lock +118 -15
- package/Cargo.toml +2 -1
- package/LICENSE.md +1 -1
- package/README.md +1 -1
- package/index.d.ts +47 -18
- package/package.json +7 -7
- package/releases/aarch64-apple-darwin/index.node +0 -0
- package/releases/aarch64-unknown-linux-gnu/index.node +0 -0
- package/releases/x86_64-apple-darwin/index.node +0 -0
- package/releases/x86_64-pc-windows-msvc/index.node +0 -0
- package/releases/x86_64-unknown-linux-gnu/index.node +0 -0
- package/sdk-core/.buildkite/docker/docker-compose.yaml +4 -2
- package/sdk-core/ARCHITECTURE.md +9 -7
- package/sdk-core/README.md +5 -1
- package/sdk-core/arch_docs/diagrams/workflow_internals.svg +1 -0
- package/sdk-core/bridge-ffi/src/wrappers.rs +0 -3
- package/sdk-core/client/src/lib.rs +26 -8
- package/sdk-core/client/src/raw.rs +166 -54
- package/sdk-core/client/src/retry.rs +9 -4
- package/sdk-core/client/src/workflow_handle/mod.rs +4 -2
- package/sdk-core/core/Cargo.toml +2 -0
- package/sdk-core/core/src/abstractions.rs +137 -16
- package/sdk-core/core/src/core_tests/activity_tasks.rs +258 -63
- package/sdk-core/core/src/core_tests/child_workflows.rs +1 -2
- package/sdk-core/core/src/core_tests/determinism.rs +2 -2
- package/sdk-core/core/src/core_tests/local_activities.rs +8 -7
- package/sdk-core/core/src/core_tests/queries.rs +146 -60
- package/sdk-core/core/src/core_tests/replay_flag.rs +1 -1
- package/sdk-core/core/src/core_tests/workers.rs +39 -23
- package/sdk-core/core/src/core_tests/workflow_cancels.rs +1 -1
- package/sdk-core/core/src/core_tests/workflow_tasks.rs +387 -280
- package/sdk-core/core/src/lib.rs +6 -4
- package/sdk-core/core/src/pollers/poll_buffer.rs +16 -10
- package/sdk-core/core/src/protosext/mod.rs +6 -6
- package/sdk-core/core/src/retry_logic.rs +1 -1
- package/sdk-core/core/src/telemetry/metrics.rs +21 -7
- package/sdk-core/core/src/telemetry/mod.rs +18 -4
- package/sdk-core/core/src/test_help/mod.rs +341 -109
- package/sdk-core/core/src/worker/activities/activity_heartbeat_manager.rs +18 -9
- package/sdk-core/core/src/worker/activities/local_activities.rs +19 -16
- package/sdk-core/core/src/worker/activities.rs +156 -29
- package/sdk-core/core/src/worker/client.rs +1 -0
- package/sdk-core/core/src/worker/mod.rs +132 -659
- package/sdk-core/core/src/{workflow → worker/workflow}/bridge.rs +1 -1
- package/sdk-core/core/src/{workflow → worker/workflow}/driven_workflow.rs +1 -1
- package/sdk-core/core/src/{workflow → worker/workflow}/history_update.rs +16 -2
- package/sdk-core/core/src/{workflow → worker/workflow}/machines/activity_state_machine.rs +39 -4
- package/sdk-core/core/src/{workflow → worker/workflow}/machines/cancel_external_state_machine.rs +5 -2
- package/sdk-core/core/src/{workflow → worker/workflow}/machines/cancel_workflow_state_machine.rs +1 -1
- package/sdk-core/core/src/{workflow → worker/workflow}/machines/child_workflow_state_machine.rs +2 -4
- package/sdk-core/core/src/{workflow → worker/workflow}/machines/complete_workflow_state_machine.rs +0 -0
- package/sdk-core/core/src/{workflow → worker/workflow}/machines/continue_as_new_workflow_state_machine.rs +1 -1
- package/sdk-core/core/src/{workflow → worker/workflow}/machines/fail_workflow_state_machine.rs +0 -0
- package/sdk-core/core/src/{workflow → worker/workflow}/machines/local_activity_state_machine.rs +2 -5
- package/sdk-core/core/src/{workflow → worker/workflow}/machines/mod.rs +1 -1
- package/sdk-core/core/src/{workflow → worker/workflow}/machines/mutable_side_effect_state_machine.rs +0 -0
- package/sdk-core/core/src/{workflow → worker/workflow}/machines/patch_state_machine.rs +1 -1
- package/sdk-core/core/src/{workflow → worker/workflow}/machines/side_effect_state_machine.rs +0 -0
- package/sdk-core/core/src/{workflow → worker/workflow}/machines/signal_external_state_machine.rs +4 -2
- package/sdk-core/core/src/{workflow → worker/workflow}/machines/timer_state_machine.rs +1 -2
- package/sdk-core/core/src/{workflow → worker/workflow}/machines/transition_coverage.rs +1 -1
- package/sdk-core/core/src/{workflow → worker/workflow}/machines/upsert_search_attributes_state_machine.rs +5 -7
- package/sdk-core/core/src/{workflow → worker/workflow}/machines/workflow_machines/local_acts.rs +2 -2
- package/sdk-core/core/src/{workflow → worker/workflow}/machines/workflow_machines.rs +40 -16
- package/sdk-core/core/src/{workflow → worker/workflow}/machines/workflow_task_state_machine.rs +0 -0
- package/sdk-core/core/src/worker/workflow/managed_run/managed_wf_test.rs +198 -0
- package/sdk-core/core/src/worker/workflow/managed_run.rs +627 -0
- package/sdk-core/core/src/worker/workflow/mod.rs +1115 -0
- package/sdk-core/core/src/worker/workflow/run_cache.rs +143 -0
- package/sdk-core/core/src/worker/workflow/wft_poller.rs +88 -0
- package/sdk-core/core/src/worker/workflow/workflow_stream.rs +936 -0
- package/sdk-core/core-api/src/errors.rs +3 -10
- package/sdk-core/core-api/src/lib.rs +2 -1
- package/sdk-core/core-api/src/worker.rs +26 -2
- package/sdk-core/etc/dynamic-config.yaml +2 -0
- package/sdk-core/integ-with-otel.sh +1 -1
- package/sdk-core/protos/api_upstream/Makefile +4 -4
- package/sdk-core/protos/api_upstream/api-linter.yaml +2 -0
- package/sdk-core/protos/api_upstream/buf.yaml +8 -9
- package/sdk-core/protos/api_upstream/temporal/api/cluster/v1/message.proto +83 -0
- package/sdk-core/protos/api_upstream/temporal/api/command/v1/message.proto +7 -1
- package/sdk-core/protos/api_upstream/temporal/api/enums/v1/cluster.proto +40 -0
- package/sdk-core/protos/api_upstream/temporal/api/enums/v1/failed_cause.proto +3 -0
- package/sdk-core/protos/api_upstream/temporal/api/enums/v1/reset.proto +3 -1
- package/sdk-core/protos/api_upstream/temporal/api/enums/v1/schedule.proto +60 -0
- package/sdk-core/protos/api_upstream/temporal/api/enums/v1/workflow.proto +3 -0
- package/sdk-core/protos/api_upstream/temporal/api/errordetails/v1/message.proto +32 -4
- package/sdk-core/protos/api_upstream/temporal/api/history/v1/message.proto +69 -19
- package/sdk-core/protos/api_upstream/temporal/api/namespace/v1/message.proto +13 -0
- package/sdk-core/protos/api_upstream/temporal/api/operatorservice/v1/request_response.proto +163 -0
- package/sdk-core/protos/api_upstream/temporal/api/operatorservice/v1/service.proto +97 -0
- package/sdk-core/protos/api_upstream/temporal/api/schedule/v1/message.proto +300 -0
- package/sdk-core/protos/api_upstream/temporal/api/workflow/v1/message.proto +25 -0
- package/sdk-core/protos/api_upstream/temporal/api/workflowservice/v1/request_response.proto +180 -3
- package/sdk-core/protos/api_upstream/temporal/api/workflowservice/v1/service.proto +53 -3
- package/sdk-core/protos/local/temporal/sdk/core/activity_result/activity_result.proto +2 -2
- package/sdk-core/protos/local/temporal/sdk/core/activity_task/activity_task.proto +6 -5
- package/sdk-core/protos/local/temporal/sdk/core/bridge/bridge.proto +0 -1
- package/sdk-core/protos/local/temporal/sdk/core/child_workflow/child_workflow.proto +2 -1
- package/sdk-core/protos/local/temporal/sdk/core/common/common.proto +0 -64
- package/sdk-core/protos/local/temporal/sdk/core/core_interface.proto +2 -1
- package/sdk-core/protos/local/temporal/sdk/core/workflow_activation/workflow_activation.proto +11 -8
- package/sdk-core/protos/local/temporal/sdk/core/workflow_commands/workflow_commands.proto +30 -25
- package/sdk-core/sdk/src/activity_context.rs +12 -5
- package/sdk-core/sdk/src/app_data.rs +37 -0
- package/sdk-core/sdk/src/lib.rs +76 -43
- package/sdk-core/sdk/src/workflow_context/options.rs +8 -6
- package/sdk-core/sdk/src/workflow_context.rs +14 -19
- package/sdk-core/sdk/src/workflow_future.rs +11 -6
- package/sdk-core/sdk-core-protos/src/history_builder.rs +19 -5
- package/sdk-core/sdk-core-protos/src/history_info.rs +11 -6
- package/sdk-core/sdk-core-protos/src/lib.rs +74 -176
- package/sdk-core/test-utils/src/lib.rs +85 -72
- package/sdk-core/tests/integ_tests/heartbeat_tests.rs +11 -9
- package/sdk-core/tests/integ_tests/polling_tests.rs +12 -0
- package/sdk-core/tests/integ_tests/queries_tests.rs +39 -22
- package/sdk-core/tests/integ_tests/workflow_tests/activities.rs +49 -4
- package/sdk-core/tests/integ_tests/workflow_tests/appdata_propagation.rs +61 -0
- package/sdk-core/tests/integ_tests/workflow_tests/cancel_wf.rs +1 -1
- package/sdk-core/tests/integ_tests/workflow_tests/local_activities.rs +74 -13
- package/sdk-core/tests/integ_tests/workflow_tests/replay.rs +19 -0
- package/sdk-core/tests/integ_tests/workflow_tests/resets.rs +1 -1
- package/sdk-core/tests/integ_tests/workflow_tests/upsert_search_attrs.rs +6 -3
- package/sdk-core/tests/integ_tests/workflow_tests.rs +10 -23
- package/sdk-core/tests/load_tests.rs +8 -3
- package/sdk-core/tests/main.rs +2 -1
- package/src/conversions.rs +47 -39
- package/src/errors.rs +10 -21
- package/src/lib.rs +342 -325
- package/sdk-core/core/src/pending_activations.rs +0 -173
- package/sdk-core/core/src/worker/wft_delivery.rs +0 -81
- package/sdk-core/core/src/workflow/mod.rs +0 -478
- package/sdk-core/core/src/workflow/workflow_tasks/cache_manager.rs +0 -194
- package/sdk-core/core/src/workflow/workflow_tasks/concurrency_manager.rs +0 -418
- package/sdk-core/core/src/workflow/workflow_tasks/mod.rs +0 -989
|
@@ -4,8 +4,8 @@ package coresdk.activity_result;
|
|
|
4
4
|
|
|
5
5
|
import "google/protobuf/duration.proto";
|
|
6
6
|
import "google/protobuf/timestamp.proto";
|
|
7
|
+
import "temporal/api/common/v1/message.proto";
|
|
7
8
|
import "temporal/api/failure/v1/message.proto";
|
|
8
|
-
import "temporal/sdk/core/common/common.proto";
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* Used to report activity completions to core
|
|
@@ -32,7 +32,7 @@ message ActivityResolution {
|
|
|
32
32
|
|
|
33
33
|
/** Used to report successful completion either when executing or resolving */
|
|
34
34
|
message Success {
|
|
35
|
-
common.Payload result = 1;
|
|
35
|
+
temporal.api.common.v1.Payload result = 1;
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
/** Used to report activity failure either when executing or resolving */
|
|
@@ -7,6 +7,7 @@ package coresdk.activity_task;
|
|
|
7
7
|
|
|
8
8
|
import "google/protobuf/duration.proto";
|
|
9
9
|
import "google/protobuf/timestamp.proto";
|
|
10
|
+
import "temporal/api/common/v1/message.proto";
|
|
10
11
|
import "temporal/sdk/core/common/common.proto";
|
|
11
12
|
|
|
12
13
|
message ActivityTask {
|
|
@@ -27,16 +28,16 @@ message Start {
|
|
|
27
28
|
// The workflow's type name or function identifier
|
|
28
29
|
string workflow_type = 2;
|
|
29
30
|
// The workflow execution which requested this activity
|
|
30
|
-
common.WorkflowExecution workflow_execution = 3;
|
|
31
|
+
temporal.api.common.v1.WorkflowExecution workflow_execution = 3;
|
|
31
32
|
// The activity's ID
|
|
32
33
|
string activity_id = 4;
|
|
33
34
|
// The activity's type name or function identifier
|
|
34
35
|
string activity_type = 5;
|
|
35
|
-
map<string, common.Payload> header_fields = 6;
|
|
36
|
+
map<string, temporal.api.common.v1.Payload> header_fields = 6;
|
|
36
37
|
// Arguments to the activity
|
|
37
|
-
repeated common.Payload input = 7;
|
|
38
|
+
repeated temporal.api.common.v1.Payload input = 7;
|
|
38
39
|
// The last details that were recorded by a heartbeat when this task was generated
|
|
39
|
-
repeated common.Payload heartbeat_details = 8;
|
|
40
|
+
repeated temporal.api.common.v1.Payload heartbeat_details = 8;
|
|
40
41
|
// When the task was *first* scheduled
|
|
41
42
|
google.protobuf.Timestamp scheduled_time = 9;
|
|
42
43
|
// When this current attempt at the task was scheduled
|
|
@@ -54,7 +55,7 @@ message Start {
|
|
|
54
55
|
// This is an actual retry policy the service uses. It can be different from the one provided
|
|
55
56
|
// (or not) during activity scheduling as the service can override the provided one in case its
|
|
56
57
|
// values are not specified or exceed configured system limits.
|
|
57
|
-
common.RetryPolicy retry_policy = 16;
|
|
58
|
+
temporal.api.common.v1.RetryPolicy retry_policy = 16;
|
|
58
59
|
|
|
59
60
|
// Set to true if this is a local activity. Note that heartbeating does not apply to local
|
|
60
61
|
// activities.
|
|
@@ -2,6 +2,7 @@ syntax = "proto3";
|
|
|
2
2
|
|
|
3
3
|
package coresdk.child_workflow;
|
|
4
4
|
|
|
5
|
+
import "temporal/api/common/v1/message.proto";
|
|
5
6
|
import "temporal/api/failure/v1/message.proto";
|
|
6
7
|
import "temporal/sdk/core/common/common.proto";
|
|
7
8
|
|
|
@@ -20,7 +21,7 @@ message ChildWorkflowResult {
|
|
|
20
21
|
* Used in ChildWorkflowResult to report successful completion.
|
|
21
22
|
*/
|
|
22
23
|
message Success {
|
|
23
|
-
common.Payload result = 1;
|
|
24
|
+
temporal.api.common.v1.Payload result = 1;
|
|
24
25
|
}
|
|
25
26
|
|
|
26
27
|
/**
|
|
@@ -4,26 +4,6 @@ package coresdk.common;
|
|
|
4
4
|
|
|
5
5
|
import "google/protobuf/duration.proto";
|
|
6
6
|
|
|
7
|
-
// Many of the messages in here are exact or near duplicates of the protobufs defined by the
|
|
8
|
-
// Temporal API. We dupe them here to introduce better ergonomics wherever possible, and to
|
|
9
|
-
// decouple ourselves from upstream changes. Additionally, we have no need for wire compatibility
|
|
10
|
-
// between core and lang sdks, since the lang SDK chooses which version of core it wants to use.
|
|
11
|
-
|
|
12
|
-
// Used as arguments to activities, signals, queries, etc.
|
|
13
|
-
message Payload {
|
|
14
|
-
map<string,bytes> metadata = 1;
|
|
15
|
-
bytes data = 2;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
// Identifying information about a particular workflow execution. Namespace is expected to be
|
|
19
|
-
// assumed or included in whatever message is wrapping this one.
|
|
20
|
-
message WorkflowExecution {
|
|
21
|
-
// Can never be empty
|
|
22
|
-
string workflow_id = 1;
|
|
23
|
-
// May be empty if the most recent run of the workflow with the given ID is being targeted
|
|
24
|
-
string run_id = 2;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
7
|
// Identifying information about a particular workflow execution, including namespace
|
|
28
8
|
message NamespacedWorkflowExecution {
|
|
29
9
|
// Namespace the workflow run is located in
|
|
@@ -33,47 +13,3 @@ message NamespacedWorkflowExecution {
|
|
|
33
13
|
// May be empty if the most recent run of the workflow with the given ID is being targeted
|
|
34
14
|
string run_id = 3;
|
|
35
15
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
// Defines how an activity or workflow should be retried in the event of failure, timeout, etc.
|
|
39
|
-
// Defaults may differ depending on what this is being used for. See containing messages.
|
|
40
|
-
message RetryPolicy {
|
|
41
|
-
// Interval of the first retry. If backoff_coefficient is 1.0 then it is used for all
|
|
42
|
-
// retries. If this is not specified, there will be *no retrying*. Lang SDKs should require
|
|
43
|
-
// this to be set.
|
|
44
|
-
google.protobuf.Duration initial_interval = 1;
|
|
45
|
-
// Coefficient used to calculate the next retry interval. The next retry interval is previous
|
|
46
|
-
// interval multiplied by the coefficient. Must be 1 or larger.
|
|
47
|
-
double backoff_coefficient = 2;
|
|
48
|
-
// Maximum interval between retries. Exponential backoff leads to interval increase. This value
|
|
49
|
-
// caps that interval.
|
|
50
|
-
google.protobuf.Duration maximum_interval = 3;
|
|
51
|
-
// Maximum number of attempts. When exceeded, retrying will stop. 1 disables retries. 0 means
|
|
52
|
-
// unlimited retries (until the activity or workflow's total timeout is reached).
|
|
53
|
-
int32 maximum_attempts = 4;
|
|
54
|
-
// If a stringified error type matches something in this list, retries will cease.
|
|
55
|
-
repeated string non_retryable_error_types = 5;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
enum WorkflowIdReusePolicy {
|
|
59
|
-
WORKFLOW_ID_REUSE_POLICY_UNSPECIFIED = 0;
|
|
60
|
-
// Allow start a workflow execution using the same workflow Id, when workflow not running.
|
|
61
|
-
WORKFLOW_ID_REUSE_POLICY_ALLOW_DUPLICATE = 1;
|
|
62
|
-
// Allow start a workflow execution using the same workflow Id, when workflow not running, and the last execution close state is in
|
|
63
|
-
// [terminated, cancelled, timed out, failed].
|
|
64
|
-
WORKFLOW_ID_REUSE_POLICY_ALLOW_DUPLICATE_FAILED_ONLY = 2;
|
|
65
|
-
// Do not allow start a workflow execution using the same workflow Id at all.
|
|
66
|
-
WORKFLOW_ID_REUSE_POLICY_REJECT_DUPLICATE = 3;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
/** Possible causes of failure to cancel an external workflow */
|
|
70
|
-
enum CancelExternalWorkflowExecutionFailedCause {
|
|
71
|
-
CANCEL_EXTERNAL_WORKFLOW_EXECUTION_FAILED_CAUSE_UNSPECIFIED = 0;
|
|
72
|
-
CANCEL_EXTERNAL_WORKFLOW_EXECUTION_FAILED_CAUSE_EXTERNAL_WORKFLOW_EXECUTION_NOT_FOUND = 1;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
/** Possible causes of failure to signal an external workflow */
|
|
76
|
-
enum SignalExternalWorkflowExecutionFailedCause {
|
|
77
|
-
SIGNAL_EXTERNAL_WORKFLOW_EXECUTION_FAILED_CAUSE_UNSPECIFIED = 0;
|
|
78
|
-
SIGNAL_EXTERNAL_WORKFLOW_EXECUTION_FAILED_CAUSE_EXTERNAL_WORKFLOW_EXECUTION_NOT_FOUND = 1;
|
|
79
|
-
}
|
|
@@ -8,6 +8,7 @@ package coresdk;
|
|
|
8
8
|
import "google/protobuf/duration.proto";
|
|
9
9
|
import "google/protobuf/empty.proto";
|
|
10
10
|
import "google/protobuf/timestamp.proto";
|
|
11
|
+
import "temporal/api/common/v1/message.proto";
|
|
11
12
|
import "temporal/sdk/core/activity_result/activity_result.proto";
|
|
12
13
|
import "temporal/sdk/core/activity_task/activity_task.proto";
|
|
13
14
|
import "temporal/sdk/core/common/common.proto";
|
|
@@ -19,7 +20,7 @@ import "temporal/sdk/core/workflow_completion/workflow_completion.proto";
|
|
|
19
20
|
// A request as given to `record_activity_heartbeat`
|
|
20
21
|
message ActivityHeartbeat {
|
|
21
22
|
bytes task_token = 1;
|
|
22
|
-
repeated common.Payload details = 2;
|
|
23
|
+
repeated temporal.api.common.v1.Payload details = 2;
|
|
23
24
|
}
|
|
24
25
|
|
|
25
26
|
// A request as given to `complete_activity_task`
|
package/sdk-core/protos/local/temporal/sdk/core/workflow_activation/workflow_activation.proto
CHANGED
|
@@ -25,8 +25,11 @@ message WorkflowActivation {
|
|
|
25
25
|
google.protobuf.Timestamp timestamp = 2;
|
|
26
26
|
/// Whether or not the activation is replaying past events
|
|
27
27
|
bool is_replaying = 3;
|
|
28
|
+
/// Current history length as determined by the event id of the most recently processed event.
|
|
29
|
+
/// This ensures that the number is always deterministic
|
|
30
|
+
uint32 history_length = 4;
|
|
28
31
|
/// The things to do upon activating the workflow
|
|
29
|
-
repeated WorkflowActivationJob jobs =
|
|
32
|
+
repeated WorkflowActivationJob jobs = 5;
|
|
30
33
|
}
|
|
31
34
|
|
|
32
35
|
message WorkflowActivationJob {
|
|
@@ -73,12 +76,12 @@ message StartWorkflow {
|
|
|
73
76
|
// The workflow id used on the temporal server
|
|
74
77
|
string workflow_id = 2;
|
|
75
78
|
// Inputs to the workflow code
|
|
76
|
-
repeated common.Payload arguments = 3;
|
|
79
|
+
repeated temporal.api.common.v1.Payload arguments = 3;
|
|
77
80
|
// The seed must be used to initialize the random generator used by SDK.
|
|
78
81
|
// RandomSeedUpdatedAttributes are used to deliver seed updates.
|
|
79
82
|
uint64 randomness_seed = 4;
|
|
80
83
|
// Used to add metadata e.g. for tracing and auth, meant to be read and written to by interceptors.
|
|
81
|
-
map<string, common.Payload> headers = 5;
|
|
84
|
+
map<string, temporal.api.common.v1.Payload> headers = 5;
|
|
82
85
|
// Identity of the client who requested this execution
|
|
83
86
|
string identity = 6;
|
|
84
87
|
// If this workflow is a child, information about the parent
|
|
@@ -183,25 +186,25 @@ message QueryWorkflow {
|
|
|
183
186
|
string query_id = 1;
|
|
184
187
|
/// The query's function/method/etc name
|
|
185
188
|
string query_type = 2;
|
|
186
|
-
repeated common.Payload arguments = 3;
|
|
189
|
+
repeated temporal.api.common.v1.Payload arguments = 3;
|
|
187
190
|
/// Headers attached to the query
|
|
188
|
-
map<string, common.Payload> headers = 5;
|
|
191
|
+
map<string, temporal.api.common.v1.Payload> headers = 5;
|
|
189
192
|
}
|
|
190
193
|
|
|
191
194
|
/// Cancel a running workflow
|
|
192
195
|
message CancelWorkflow {
|
|
193
196
|
/// Information from the cancellation request
|
|
194
|
-
repeated common.Payload details = 1;
|
|
197
|
+
repeated temporal.api.common.v1.Payload details = 1;
|
|
195
198
|
}
|
|
196
199
|
|
|
197
200
|
// Send a signal to a workflow
|
|
198
201
|
message SignalWorkflow {
|
|
199
202
|
string signal_name = 1;
|
|
200
|
-
repeated common.Payload input = 2;
|
|
203
|
+
repeated temporal.api.common.v1.Payload input = 2;
|
|
201
204
|
// Identity of the sender of the signal
|
|
202
205
|
string identity = 3;
|
|
203
206
|
// Headers attached to the signal
|
|
204
|
-
map<string, common.Payload> headers = 5;
|
|
207
|
+
map<string, temporal.api.common.v1.Payload> headers = 5;
|
|
205
208
|
}
|
|
206
209
|
|
|
207
210
|
// Inform lang what the result of a call to `patched` or similar API should be -- this is always
|
|
@@ -9,6 +9,8 @@ package coresdk.workflow_commands;
|
|
|
9
9
|
|
|
10
10
|
import "google/protobuf/duration.proto";
|
|
11
11
|
import "google/protobuf/timestamp.proto";
|
|
12
|
+
import "temporal/api/common/v1/message.proto";
|
|
13
|
+
import "temporal/api/enums/v1/workflow.proto";
|
|
12
14
|
import "temporal/api/failure/v1/message.proto";
|
|
13
15
|
import "temporal/sdk/core/child_workflow/child_workflow.proto";
|
|
14
16
|
import "temporal/sdk/core/common/common.proto";
|
|
@@ -32,7 +34,7 @@ message WorkflowCommand {
|
|
|
32
34
|
CancelSignalWorkflow cancel_signal_workflow = 15;
|
|
33
35
|
ScheduleLocalActivity schedule_local_activity = 16;
|
|
34
36
|
RequestCancelLocalActivity request_cancel_local_activity = 17;
|
|
35
|
-
UpsertWorkflowSearchAttributes
|
|
37
|
+
UpsertWorkflowSearchAttributes upsert_workflow_search_attributes = 18;
|
|
36
38
|
}
|
|
37
39
|
}
|
|
38
40
|
|
|
@@ -55,9 +57,9 @@ message ScheduleActivity {
|
|
|
55
57
|
string namespace = 4;
|
|
56
58
|
// The name of the task queue to place this activity request in
|
|
57
59
|
string task_queue = 5;
|
|
58
|
-
map<string, common.Payload> headers = 6;
|
|
60
|
+
map<string, temporal.api.common.v1.Payload> headers = 6;
|
|
59
61
|
/// Arguments/input to the activity. Called "input" upstream.
|
|
60
|
-
repeated common.Payload arguments = 7;
|
|
62
|
+
repeated temporal.api.common.v1.Payload arguments = 7;
|
|
61
63
|
/// Indicates how long the caller is willing to wait for an activity completion. Limits how long
|
|
62
64
|
/// retries will be attempted. Either this or start_to_close_timeout_seconds must be specified.
|
|
63
65
|
/// When not specified defaults to the workflow execution timeout.
|
|
@@ -74,9 +76,13 @@ message ScheduleActivity {
|
|
|
74
76
|
/// Activities are provided by a default retry policy controlled through the service dynamic
|
|
75
77
|
/// configuration. Retries are happening up to schedule_to_close_timeout. To disable retries set
|
|
76
78
|
/// retry_policy.maximum_attempts to 1.
|
|
77
|
-
common.RetryPolicy retry_policy = 12;
|
|
79
|
+
temporal.api.common.v1.RetryPolicy retry_policy = 12;
|
|
78
80
|
/// Defines how the workflow will wait (or not) for cancellation of the activity to be confirmed
|
|
79
81
|
ActivityCancellationType cancellation_type = 13;
|
|
82
|
+
/// If set, the worker will not tell the service that it can immediately start executing this
|
|
83
|
+
/// activity. When unset/default, workers will always attempt to do so if activity execution
|
|
84
|
+
/// slots are available.
|
|
85
|
+
bool do_not_eagerly_execute = 14;
|
|
80
86
|
}
|
|
81
87
|
|
|
82
88
|
message ScheduleLocalActivity {
|
|
@@ -91,9 +97,9 @@ message ScheduleLocalActivity {
|
|
|
91
97
|
/// If this local activity is a retry (as per the attempt field) this needs to be the original
|
|
92
98
|
/// scheduling time (as provided in `DoBackoff`)
|
|
93
99
|
google.protobuf.Timestamp original_schedule_time = 5;
|
|
94
|
-
map<string, common.Payload> headers = 6;
|
|
100
|
+
map<string, temporal.api.common.v1.Payload> headers = 6;
|
|
95
101
|
/// Arguments/input to the activity.
|
|
96
|
-
repeated common.Payload arguments = 7;
|
|
102
|
+
repeated temporal.api.common.v1.Payload arguments = 7;
|
|
97
103
|
/// Indicates how long the caller is willing to wait for local activity completion. Limits how
|
|
98
104
|
/// long retries will be attempted. When not specified defaults to the workflow execution
|
|
99
105
|
/// timeout (which may be unset).
|
|
@@ -111,7 +117,7 @@ message ScheduleLocalActivity {
|
|
|
111
117
|
google.protobuf.Duration start_to_close_timeout = 10;
|
|
112
118
|
/// Specify a retry policy for the local activity. By default local activities will be retried
|
|
113
119
|
/// indefinitely.
|
|
114
|
-
common.RetryPolicy retry_policy = 11;
|
|
120
|
+
temporal.api.common.v1.RetryPolicy retry_policy = 11;
|
|
115
121
|
/// If the activity is retrying and backoff would exceed this value, lang will be told to
|
|
116
122
|
/// schedule a timer and retry the activity after. Otherwise, backoff will happen internally in
|
|
117
123
|
/// core. Defaults to 1 minute.
|
|
@@ -154,12 +160,12 @@ message QueryResult {
|
|
|
154
160
|
}
|
|
155
161
|
|
|
156
162
|
message QuerySuccess {
|
|
157
|
-
common.Payload response = 1;
|
|
163
|
+
temporal.api.common.v1.Payload response = 1;
|
|
158
164
|
}
|
|
159
165
|
|
|
160
166
|
/// Issued when the workflow completes successfully
|
|
161
167
|
message CompleteWorkflowExecution {
|
|
162
|
-
common.Payload result = 1;
|
|
168
|
+
temporal.api.common.v1.Payload result = 1;
|
|
163
169
|
}
|
|
164
170
|
|
|
165
171
|
/// Issued when the workflow errors out
|
|
@@ -177,17 +183,17 @@ message ContinueAsNewWorkflowExecution {
|
|
|
177
183
|
string task_queue = 2;
|
|
178
184
|
/// Inputs to the workflow code. Should be specified. Will not re-use old arguments, as that
|
|
179
185
|
/// typically wouldn't make any sense.
|
|
180
|
-
repeated common.Payload arguments = 3;
|
|
186
|
+
repeated temporal.api.common.v1.Payload arguments = 3;
|
|
181
187
|
/// Timeout for a single run of the new workflow.
|
|
182
188
|
google.protobuf.Duration workflow_run_timeout = 4;
|
|
183
189
|
/// Timeout of a single workflow task.
|
|
184
190
|
google.protobuf.Duration workflow_task_timeout = 5;
|
|
185
191
|
/// Memo fields
|
|
186
|
-
map<string, common.Payload> memo = 6;
|
|
192
|
+
map<string, temporal.api.common.v1.Payload> memo = 6;
|
|
187
193
|
/// Header fields
|
|
188
|
-
map<string, common.Payload> headers = 7;
|
|
194
|
+
map<string, temporal.api.common.v1.Payload> headers = 7;
|
|
189
195
|
/// Search attributes
|
|
190
|
-
map<string, common.Payload> search_attributes = 8;
|
|
196
|
+
map<string, temporal.api.common.v1.Payload> search_attributes = 8;
|
|
191
197
|
}
|
|
192
198
|
|
|
193
199
|
/// Indicate a workflow has completed as cancelled. Generally sent as a response to an activation
|
|
@@ -213,7 +219,7 @@ message StartChildWorkflowExecution {
|
|
|
213
219
|
string workflow_id = 3;
|
|
214
220
|
string workflow_type = 4;
|
|
215
221
|
string task_queue = 5;
|
|
216
|
-
repeated common.Payload input = 6;
|
|
222
|
+
repeated temporal.api.common.v1.Payload input = 6;
|
|
217
223
|
/// Total workflow execution timeout including retries and continue as new.
|
|
218
224
|
google.protobuf.Duration workflow_execution_timeout = 7;
|
|
219
225
|
/// Timeout of a single workflow run.
|
|
@@ -224,15 +230,15 @@ message StartChildWorkflowExecution {
|
|
|
224
230
|
child_workflow.ParentClosePolicy parent_close_policy = 10;
|
|
225
231
|
// string control = 11; (unused from StartChildWorkflowExecutionCommandAttributes)
|
|
226
232
|
// Default: WORKFLOW_ID_REUSE_POLICY_ALLOW_DUPLICATE.
|
|
227
|
-
|
|
228
|
-
common.RetryPolicy retry_policy = 13;
|
|
233
|
+
temporal.api.enums.v1.WorkflowIdReusePolicy workflow_id_reuse_policy = 12;
|
|
234
|
+
temporal.api.common.v1.RetryPolicy retry_policy = 13;
|
|
229
235
|
string cron_schedule = 14;
|
|
230
236
|
/// Header fields
|
|
231
|
-
map<string, common.Payload> headers = 15;
|
|
237
|
+
map<string, temporal.api.common.v1.Payload> headers = 15;
|
|
232
238
|
/// Memo fields
|
|
233
|
-
map<string, common.Payload> memo = 16;
|
|
239
|
+
map<string, temporal.api.common.v1.Payload> memo = 16;
|
|
234
240
|
/// Search attributes
|
|
235
|
-
map<string, common.Payload> search_attributes = 17;
|
|
241
|
+
map<string, temporal.api.common.v1.Payload> search_attributes = 17;
|
|
236
242
|
/// Defines behaviour of the underlying workflow when child workflow cancellation has been requested.
|
|
237
243
|
child_workflow.ChildWorkflowCancellationType cancellation_type = 18;
|
|
238
244
|
}
|
|
@@ -270,9 +276,9 @@ message SignalExternalWorkflowExecution {
|
|
|
270
276
|
/// Name of the signal handler
|
|
271
277
|
string signal_name = 4;
|
|
272
278
|
/// Arguments for the handler
|
|
273
|
-
repeated common.Payload args = 5;
|
|
279
|
+
repeated temporal.api.common.v1.Payload args = 5;
|
|
274
280
|
/// Headers to attach to the signal
|
|
275
|
-
map<string, common.Payload> headers = 6;
|
|
281
|
+
map<string, temporal.api.common.v1.Payload> headers = 6;
|
|
276
282
|
}
|
|
277
283
|
|
|
278
284
|
/// Can be used to cancel not-already-sent `SignalExternalWorkflowExecution` commands
|
|
@@ -282,8 +288,7 @@ message CancelSignalWorkflow {
|
|
|
282
288
|
}
|
|
283
289
|
|
|
284
290
|
message UpsertWorkflowSearchAttributes {
|
|
285
|
-
///
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
map<string, common.Payload> search_attributes = 2;
|
|
291
|
+
/// SearchAttributes fields - equivalent to indexed_fields on api. Key = search index, Value =
|
|
292
|
+
/// value?
|
|
293
|
+
map<string, temporal.api.common.v1.Payload> search_attributes = 1;
|
|
289
294
|
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
use crate::app_data::AppData;
|
|
2
|
+
|
|
1
3
|
use prost_types::{Duration, Timestamp};
|
|
2
4
|
use std::{
|
|
3
5
|
collections::HashMap,
|
|
@@ -6,11 +8,8 @@ use std::{
|
|
|
6
8
|
};
|
|
7
9
|
use temporal_sdk_core_api::Worker;
|
|
8
10
|
use temporal_sdk_core_protos::{
|
|
9
|
-
coresdk::{
|
|
10
|
-
|
|
11
|
-
common::{Payload, RetryPolicy, WorkflowExecution},
|
|
12
|
-
ActivityHeartbeat,
|
|
13
|
-
},
|
|
11
|
+
coresdk::{activity_task, ActivityHeartbeat},
|
|
12
|
+
temporal::api::common::v1::{Payload, RetryPolicy, WorkflowExecution},
|
|
14
13
|
utilities::TryIntoOrNone,
|
|
15
14
|
};
|
|
16
15
|
use tokio_util::sync::CancellationToken;
|
|
@@ -19,6 +18,7 @@ use tokio_util::sync::CancellationToken;
|
|
|
19
18
|
#[derive(Clone)]
|
|
20
19
|
pub struct ActContext {
|
|
21
20
|
worker: Arc<dyn Worker>,
|
|
21
|
+
app_data: Arc<AppData>,
|
|
22
22
|
cancellation_token: CancellationToken,
|
|
23
23
|
input: Vec<Payload>,
|
|
24
24
|
heartbeat_details: Vec<Payload>,
|
|
@@ -55,6 +55,7 @@ impl ActContext {
|
|
|
55
55
|
/// (which may be a default [Payload]).
|
|
56
56
|
pub(crate) fn new(
|
|
57
57
|
worker: Arc<dyn Worker>,
|
|
58
|
+
app_data: Arc<AppData>,
|
|
58
59
|
cancellation_token: CancellationToken,
|
|
59
60
|
task_queue: String,
|
|
60
61
|
task_token: Vec<u8>,
|
|
@@ -90,6 +91,7 @@ impl ActContext {
|
|
|
90
91
|
(
|
|
91
92
|
ActContext {
|
|
92
93
|
worker,
|
|
94
|
+
app_data,
|
|
93
95
|
cancellation_token,
|
|
94
96
|
input,
|
|
95
97
|
heartbeat_details,
|
|
@@ -157,6 +159,11 @@ impl ActContext {
|
|
|
157
159
|
pub fn headers(&self) -> &HashMap<String, Payload> {
|
|
158
160
|
&self.header_fields
|
|
159
161
|
}
|
|
162
|
+
|
|
163
|
+
/// Get custom Application Data
|
|
164
|
+
pub fn app_data<T: Send + Sync + 'static>(&self) -> Option<&T> {
|
|
165
|
+
self.app_data.get::<T>()
|
|
166
|
+
}
|
|
160
167
|
}
|
|
161
168
|
|
|
162
169
|
/// Deadline calculation. This is a port of
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
use std::{
|
|
2
|
+
any::{Any, TypeId},
|
|
3
|
+
collections::HashMap,
|
|
4
|
+
fmt,
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
/// A Wrapper Type for workflow and activity app data
|
|
8
|
+
#[derive(Default)]
|
|
9
|
+
pub struct AppData {
|
|
10
|
+
map: HashMap<TypeId, Box<dyn Any + Send + Sync>>,
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
impl AppData {
|
|
14
|
+
/// Insert an item, overwritting duplicates
|
|
15
|
+
pub fn insert<T: Send + Sync + 'static>(&mut self, val: T) -> Option<T> {
|
|
16
|
+
self.map
|
|
17
|
+
.insert(TypeId::of::<T>(), Box::new(val))
|
|
18
|
+
.and_then(downcast_owned)
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/// Get a reference to a type in the map
|
|
22
|
+
pub fn get<T: 'static>(&self) -> Option<&T> {
|
|
23
|
+
self.map
|
|
24
|
+
.get(&TypeId::of::<T>())
|
|
25
|
+
.and_then(|boxed| boxed.downcast_ref())
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
impl fmt::Debug for AppData {
|
|
30
|
+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
31
|
+
f.debug_struct("AppData").finish()
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
fn downcast_owned<T: Send + Sync + 'static>(boxed: Box<dyn Any + Send + Sync>) -> Option<T> {
|
|
36
|
+
boxed.downcast().ok().map(|boxed| *boxed)
|
|
37
|
+
}
|