@temporalio/core-bridge 0.19.2 → 0.20.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.
Files changed (124) hide show
  1. package/Cargo.lock +90 -157
  2. package/Cargo.toml +1 -0
  3. package/index.d.ts +11 -27
  4. package/package.json +3 -3
  5. package/releases/aarch64-apple-darwin/index.node +0 -0
  6. package/releases/aarch64-unknown-linux-gnu/index.node +0 -0
  7. package/releases/x86_64-apple-darwin/index.node +0 -0
  8. package/releases/x86_64-pc-windows-msvc/index.node +0 -0
  9. package/releases/x86_64-unknown-linux-gnu/index.node +0 -0
  10. package/sdk-core/.buildkite/docker/Dockerfile +1 -1
  11. package/sdk-core/.buildkite/docker/docker-compose.yaml +1 -1
  12. package/sdk-core/.cargo/config.toml +1 -0
  13. package/sdk-core/CODEOWNERS +1 -1
  14. package/sdk-core/bridge-ffi/include/sdk-core-bridge.h +119 -86
  15. package/sdk-core/bridge-ffi/src/lib.rs +311 -315
  16. package/sdk-core/bridge-ffi/src/wrappers.rs +108 -113
  17. package/sdk-core/client/Cargo.toml +13 -9
  18. package/sdk-core/client/LICENSE.txt +23 -0
  19. package/sdk-core/client/src/lib.rs +286 -174
  20. package/sdk-core/client/src/metrics.rs +86 -12
  21. package/sdk-core/client/src/raw.rs +566 -0
  22. package/sdk-core/client/src/retry.rs +137 -99
  23. package/sdk-core/core/Cargo.toml +15 -10
  24. package/sdk-core/core/LICENSE.txt +23 -0
  25. package/sdk-core/core/benches/workflow_replay.rs +79 -0
  26. package/sdk-core/core/src/abstractions.rs +38 -0
  27. package/sdk-core/core/src/core_tests/activity_tasks.rs +108 -182
  28. package/sdk-core/core/src/core_tests/child_workflows.rs +16 -11
  29. package/sdk-core/core/src/core_tests/determinism.rs +24 -12
  30. package/sdk-core/core/src/core_tests/local_activities.rs +53 -27
  31. package/sdk-core/core/src/core_tests/mod.rs +30 -43
  32. package/sdk-core/core/src/core_tests/queries.rs +82 -81
  33. package/sdk-core/core/src/core_tests/workers.rs +111 -296
  34. package/sdk-core/core/src/core_tests/workflow_cancels.rs +4 -4
  35. package/sdk-core/core/src/core_tests/workflow_tasks.rs +213 -241
  36. package/sdk-core/core/src/lib.rs +73 -318
  37. package/sdk-core/core/src/pollers/mod.rs +4 -6
  38. package/sdk-core/core/src/pollers/poll_buffer.rs +20 -14
  39. package/sdk-core/core/src/protosext/mod.rs +7 -10
  40. package/sdk-core/core/src/replay/mod.rs +11 -150
  41. package/sdk-core/core/src/telemetry/metrics.rs +35 -2
  42. package/sdk-core/core/src/telemetry/mod.rs +49 -16
  43. package/sdk-core/core/src/telemetry/prometheus_server.rs +14 -35
  44. package/sdk-core/core/src/test_help/mod.rs +104 -170
  45. package/sdk-core/core/src/worker/activities/activity_heartbeat_manager.rs +57 -34
  46. package/sdk-core/core/src/worker/activities/local_activities.rs +37 -17
  47. package/sdk-core/core/src/worker/activities.rs +23 -16
  48. package/sdk-core/core/src/worker/client/mocks.rs +86 -0
  49. package/sdk-core/core/src/worker/client.rs +209 -0
  50. package/sdk-core/core/src/worker/mod.rs +193 -105
  51. package/sdk-core/core/src/workflow/driven_workflow.rs +21 -6
  52. package/sdk-core/core/src/workflow/history_update.rs +107 -24
  53. package/sdk-core/core/src/workflow/machines/activity_state_machine.rs +2 -3
  54. package/sdk-core/core/src/workflow/machines/child_workflow_state_machine.rs +2 -3
  55. package/sdk-core/core/src/workflow/machines/mod.rs +20 -17
  56. package/sdk-core/core/src/workflow/machines/signal_external_state_machine.rs +56 -19
  57. package/sdk-core/core/src/workflow/machines/transition_coverage.rs +5 -0
  58. package/sdk-core/core/src/workflow/machines/upsert_search_attributes_state_machine.rs +230 -22
  59. package/sdk-core/core/src/workflow/machines/workflow_machines.rs +81 -115
  60. package/sdk-core/core/src/workflow/machines/workflow_task_state_machine.rs +4 -4
  61. package/sdk-core/core/src/workflow/mod.rs +13 -1
  62. package/sdk-core/core/src/workflow/workflow_tasks/mod.rs +43 -33
  63. package/sdk-core/core-api/Cargo.toml +9 -1
  64. package/sdk-core/core-api/LICENSE.txt +23 -0
  65. package/sdk-core/core-api/src/errors.rs +7 -38
  66. package/sdk-core/core-api/src/lib.rs +44 -52
  67. package/sdk-core/core-api/src/worker.rs +10 -2
  68. package/sdk-core/etc/deps.svg +127 -96
  69. package/sdk-core/protos/api_upstream/temporal/api/command/v1/message.proto +11 -7
  70. package/sdk-core/protos/api_upstream/temporal/api/enums/v1/failed_cause.proto +10 -0
  71. package/sdk-core/protos/api_upstream/temporal/api/enums/v1/namespace.proto +6 -1
  72. package/sdk-core/protos/api_upstream/temporal/api/enums/v1/workflow.proto +6 -0
  73. package/sdk-core/protos/api_upstream/temporal/api/errordetails/v1/message.proto +6 -0
  74. package/sdk-core/protos/api_upstream/temporal/api/history/v1/message.proto +2 -1
  75. package/sdk-core/protos/api_upstream/temporal/api/replication/v1/message.proto +3 -0
  76. package/sdk-core/protos/api_upstream/temporal/api/workflow/v1/message.proto +12 -0
  77. package/sdk-core/protos/api_upstream/temporal/api/workflowservice/v1/request_response.proto +25 -0
  78. package/sdk-core/protos/api_upstream/temporal/api/workflowservice/v1/service.proto +4 -0
  79. package/sdk-core/protos/local/temporal/sdk/core/bridge/bridge.proto +19 -35
  80. package/sdk-core/protos/local/temporal/sdk/core/core_interface.proto +2 -6
  81. package/sdk-core/protos/local/temporal/sdk/core/workflow_activation/workflow_activation.proto +53 -11
  82. package/sdk-core/protos/local/temporal/sdk/core/workflow_commands/workflow_commands.proto +14 -7
  83. package/sdk-core/protos/local/temporal/sdk/core/workflow_completion/workflow_completion.proto +3 -5
  84. package/sdk-core/sdk/Cargo.toml +16 -2
  85. package/sdk-core/sdk/LICENSE.txt +23 -0
  86. package/sdk-core/sdk/src/interceptors.rs +11 -0
  87. package/sdk-core/sdk/src/lib.rs +138 -150
  88. package/sdk-core/sdk/src/workflow_context/options.rs +86 -1
  89. package/sdk-core/sdk/src/workflow_context.rs +36 -17
  90. package/sdk-core/sdk/src/workflow_future.rs +19 -25
  91. package/sdk-core/sdk-core-protos/Cargo.toml +1 -1
  92. package/sdk-core/sdk-core-protos/build.rs +1 -0
  93. package/sdk-core/sdk-core-protos/src/history_info.rs +17 -4
  94. package/sdk-core/sdk-core-protos/src/lib.rs +251 -47
  95. package/sdk-core/test-utils/Cargo.toml +3 -1
  96. package/sdk-core/test-utils/src/canned_histories.rs +27 -0
  97. package/sdk-core/test-utils/src/histfetch.rs +3 -3
  98. package/sdk-core/test-utils/src/lib.rs +223 -68
  99. package/sdk-core/tests/integ_tests/client_tests.rs +27 -4
  100. package/sdk-core/tests/integ_tests/heartbeat_tests.rs +93 -14
  101. package/sdk-core/tests/integ_tests/polling_tests.rs +18 -12
  102. package/sdk-core/tests/integ_tests/queries_tests.rs +50 -53
  103. package/sdk-core/tests/integ_tests/workflow_tests/activities.rs +117 -103
  104. package/sdk-core/tests/integ_tests/workflow_tests/cancel_external.rs +8 -1
  105. package/sdk-core/tests/integ_tests/workflow_tests/cancel_wf.rs +10 -5
  106. package/sdk-core/tests/integ_tests/workflow_tests/child_workflows.rs +7 -1
  107. package/sdk-core/tests/integ_tests/workflow_tests/continue_as_new.rs +8 -3
  108. package/sdk-core/tests/integ_tests/workflow_tests/determinism.rs +7 -1
  109. package/sdk-core/tests/integ_tests/workflow_tests/local_activities.rs +76 -15
  110. package/sdk-core/tests/integ_tests/workflow_tests/patches.rs +19 -3
  111. package/sdk-core/tests/integ_tests/workflow_tests/replay.rs +39 -42
  112. package/sdk-core/tests/integ_tests/workflow_tests/resets.rs +84 -0
  113. package/sdk-core/tests/integ_tests/workflow_tests/signals.rs +30 -8
  114. package/sdk-core/tests/integ_tests/workflow_tests/stickyness.rs +21 -6
  115. package/sdk-core/tests/integ_tests/workflow_tests/timers.rs +26 -16
  116. package/sdk-core/tests/integ_tests/workflow_tests/upsert_search_attrs.rs +66 -0
  117. package/sdk-core/tests/integ_tests/workflow_tests.rs +78 -74
  118. package/sdk-core/tests/load_tests.rs +9 -6
  119. package/sdk-core/tests/main.rs +43 -10
  120. package/src/conversions.rs +7 -12
  121. package/src/lib.rs +322 -357
  122. package/sdk-core/client/src/mocks.rs +0 -167
  123. package/sdk-core/core/src/worker/dispatcher.rs +0 -171
  124. package/sdk-core/protos/local/temporal/sdk/core/bridge/service.proto +0 -61
@@ -7,7 +7,10 @@ syntax = "proto3";
7
7
  package coresdk.workflow_activation;
8
8
 
9
9
  import "google/protobuf/timestamp.proto";
10
+ import "google/protobuf/duration.proto";
10
11
  import "temporal/api/failure/v1/message.proto";
12
+ import "temporal/api/common/v1/message.proto";
13
+ import "temporal/api/enums/v1/workflow.proto";
11
14
  import "temporal/sdk/core/activity_result/activity_result.proto";
12
15
  import "temporal/sdk/core/child_workflow/child_workflow.proto";
13
16
  import "temporal/sdk/core/common/common.proto";
@@ -63,22 +66,56 @@ message WorkflowActivationJob {
63
66
  }
64
67
  }
65
68
 
66
- /// Start a new workflow
69
+ // Start a new workflow
67
70
  message StartWorkflow {
68
- /// The identifier the lang-specific sdk uses to execute workflow code
71
+ // The identifier the lang-specific sdk uses to execute workflow code
69
72
  string workflow_type = 1;
70
- /// The workflow id used on the temporal server
73
+ // The workflow id used on the temporal server
71
74
  string workflow_id = 2;
72
- /// Inputs to the workflow code
75
+ // Inputs to the workflow code
73
76
  repeated common.Payload arguments = 3;
74
- /// The seed must be used to initialize the random generator used by SDK.
75
- /// RandomSeedUpdatedAttributes are used to deliver seed updates.
77
+ // The seed must be used to initialize the random generator used by SDK.
78
+ // RandomSeedUpdatedAttributes are used to deliver seed updates.
76
79
  uint64 randomness_seed = 4;
77
- /// Used to add metadata e.g. for tracing and auth, meant to be read and written to by interceptors.
80
+ // Used to add metadata e.g. for tracing and auth, meant to be read and written to by interceptors.
78
81
  map<string, common.Payload> headers = 5;
79
-
80
- // TODO: Do we need namespace here, or should that just be fetchable easily?
81
- // will be others - workflow exe started attrs, etc
82
+ // Identity of the client who requested this execution
83
+ string identity = 6;
84
+ // If this workflow is a child, information about the parent
85
+ common.NamespacedWorkflowExecution parent_workflow_info = 7;
86
+ // Total workflow execution timeout including retries and continue as new.
87
+ google.protobuf.Duration workflow_execution_timeout = 8;
88
+ // Timeout of a single workflow run.
89
+ google.protobuf.Duration workflow_run_timeout = 9;
90
+ // Timeout of a single workflow task.
91
+ google.protobuf.Duration workflow_task_timeout = 10;
92
+ // Run id of the previous workflow which continued-as-new or retired or cron executed into this
93
+ // workflow, if any.
94
+ string continued_from_execution_run_id = 11;
95
+ // If this workflow was a continuation, indicates the type of continuation.
96
+ temporal.api.enums.v1.ContinueAsNewInitiator continued_initiator = 12;
97
+ // If this workflow was a continuation and that continuation failed, the details of that.
98
+ temporal.api.failure.v1.Failure continued_failure = 13;
99
+ // If this workflow was a continuation and that continuation completed, the details of that.
100
+ temporal.api.common.v1.Payloads last_completion_result = 14;
101
+ // This is the very first run id the workflow ever had, following continuation chains.
102
+ string first_execution_run_id = 15;
103
+ // This workflow's retry policy
104
+ temporal.api.common.v1.RetryPolicy retry_policy = 16;
105
+ // Starting at 1, the number of times we have tried to execute this workflow
106
+ int32 attempt = 17;
107
+ // If this workflow runs on a cron schedule, it will appear here
108
+ string cron_schedule = 18;
109
+ // The absolute time at which the workflow will be timed out.
110
+ // This is passed without change to the next run/retry of a workflow.
111
+ google.protobuf.Timestamp workflow_execution_expiration_time = 19;
112
+ // For a cron workflow, this contains the amount of time between when this iteration of
113
+ // the cron workflow was scheduled and when it should run next per its cron_schedule.
114
+ google.protobuf.Duration cron_schedule_to_schedule_interval = 20;
115
+ // User-defined memo
116
+ temporal.api.common.v1.Memo memo = 21;
117
+ // Search attributes created/updated when this workflow was started
118
+ temporal.api.common.v1.SearchAttributes search_attributes = 22;
82
119
  }
83
120
 
84
121
  /// Notify a workflow that a timer has fired
@@ -147,6 +184,8 @@ message QueryWorkflow {
147
184
  /// The query's function/method/etc name
148
185
  string query_type = 2;
149
186
  repeated common.Payload arguments = 3;
187
+ /// Headers attached to the query
188
+ map<string, common.Payload> headers = 5;
150
189
  }
151
190
 
152
191
  /// Cancel a running workflow
@@ -155,11 +194,14 @@ message CancelWorkflow {
155
194
  repeated common.Payload details = 1;
156
195
  }
157
196
 
158
- /// Send a signal to a workflow
197
+ // Send a signal to a workflow
159
198
  message SignalWorkflow {
160
199
  string signal_name = 1;
161
200
  repeated common.Payload input = 2;
201
+ // Identity of the sender of the signal
162
202
  string identity = 3;
203
+ // Headers attached to the signal
204
+ map<string, common.Payload> headers = 5;
163
205
  }
164
206
 
165
207
  // Inform lang what the result of a call to `patched` or similar API should be -- this is always
@@ -32,9 +32,7 @@ message WorkflowCommand {
32
32
  CancelSignalWorkflow cancel_signal_workflow = 15;
33
33
  ScheduleLocalActivity schedule_local_activity = 16;
34
34
  RequestCancelLocalActivity request_cancel_local_activity = 17;
35
-
36
- // To be added as/if needed:
37
- // UpsertWorkflowSearchAttributes upsert_workflow_search_attributes_command_attributes = 14;
35
+ UpsertWorkflowSearchAttributes upsert_workflow_search_attributes_command_attributes = 18;
38
36
  }
39
37
  }
40
38
 
@@ -57,7 +55,7 @@ message ScheduleActivity {
57
55
  string namespace = 4;
58
56
  // The name of the task queue to place this activity request in
59
57
  string task_queue = 5;
60
- map<string, common.Payload> header_fields = 6;
58
+ map<string, common.Payload> headers = 6;
61
59
  /// Arguments/input to the activity. Called "input" upstream.
62
60
  repeated common.Payload arguments = 7;
63
61
  /// Indicates how long the caller is willing to wait for an activity completion. Limits how long
@@ -93,7 +91,7 @@ message ScheduleLocalActivity {
93
91
  /// If this local activity is a retry (as per the attempt field) this needs to be the original
94
92
  /// scheduling time (as provided in `DoBackoff`)
95
93
  google.protobuf.Timestamp original_schedule_time = 5;
96
- map<string, common.Payload> header_fields = 6;
94
+ map<string, common.Payload> headers = 6;
97
95
  /// Arguments/input to the activity.
98
96
  repeated common.Payload arguments = 7;
99
97
  /// Indicates how long the caller is willing to wait for local activity completion. Limits how
@@ -187,7 +185,7 @@ message ContinueAsNewWorkflowExecution {
187
185
  /// Memo fields
188
186
  map<string, common.Payload> memo = 6;
189
187
  /// Header fields
190
- map<string, common.Payload> header = 7;
188
+ map<string, common.Payload> headers = 7;
191
189
  /// Search attributes
192
190
  map<string, common.Payload> search_attributes = 8;
193
191
  }
@@ -230,7 +228,7 @@ message StartChildWorkflowExecution {
230
228
  common.RetryPolicy retry_policy = 13;
231
229
  string cron_schedule = 14;
232
230
  /// Header fields
233
- map<string, common.Payload> header = 15;
231
+ map<string, common.Payload> headers = 15;
234
232
  /// Memo fields
235
233
  map<string, common.Payload> memo = 16;
236
234
  /// Search attributes
@@ -273,6 +271,8 @@ message SignalExternalWorkflowExecution {
273
271
  string signal_name = 4;
274
272
  /// Arguments for the handler
275
273
  repeated common.Payload args = 5;
274
+ /// Headers to attach to the signal
275
+ map<string, common.Payload> headers = 6;
276
276
  }
277
277
 
278
278
  /// Can be used to cancel not-already-sent `SignalExternalWorkflowExecution` commands
@@ -280,3 +280,10 @@ message CancelSignalWorkflow {
280
280
  /// Lang's incremental sequence number as passed to `SignalExternalWorkflowExecution`
281
281
  uint32 seq = 1;
282
282
  }
283
+
284
+ message UpsertWorkflowSearchAttributes {
285
+ /// Lang's incremental sequence number as passed to `UpsertWorkflowSearchAttributes`
286
+ uint32 seq = 1;
287
+ /// SearchAttributes fields - equivalent to indexed_fields on api. Key = search index, Value = value?
288
+ map<string, common.Payload> search_attributes = 2;
289
+ }
@@ -8,13 +8,11 @@ import "temporal/sdk/core/workflow_commands/workflow_commands.proto";
8
8
 
9
9
  /// Result of a single workflow activation, reported from lang to core
10
10
  message WorkflowActivationCompletion {
11
- // The task queue the workflow activation you are completing originated from
12
- string task_queue = 1;
13
11
  // The run id from the workflow activation you are completing
14
- string run_id = 2;
12
+ string run_id = 1;
15
13
  oneof status {
16
- Success successful = 3;
17
- Failure failed = 4;
14
+ Success successful = 2;
15
+ Failure failed = 3;
18
16
  }
19
17
  }
20
18
 
@@ -2,19 +2,29 @@
2
2
  name = "temporal-sdk"
3
3
  version = "0.1.0-alpha.1"
4
4
  edition = "2021"
5
+ authors = ["Spencer Judge <spencer@temporal.io>"]
6
+ license-file = "LICENSE.txt"
7
+ description = "Temporal Rust SDK"
8
+ homepage = "https://temporal.io/"
9
+ repository = "https://github.com/temporalio/sdk-core"
10
+ keywords = ["temporal", "workflow"]
11
+ categories = ["development-tools"]
5
12
 
6
13
  # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
7
14
 
8
15
  [dependencies]
9
16
  anyhow = "1.0"
17
+ base64 = "0.13"
10
18
  crossbeam = "0.8"
11
19
  derive_more = "0.99"
12
20
  futures = "0.3"
13
- parking_lot = { version = "0.11", features = ["send_guard"] }
21
+ once_cell = "1.10"
22
+ parking_lot = { version = "0.12", features = ["send_guard"] }
14
23
  prost-types = "0.9"
24
+ sha2 = "0.10"
15
25
  serde = "1.0"
16
26
  tokio = { version = "1.1", features = ["rt", "rt-multi-thread", "parking_lot", "time", "fs"] }
17
- tokio-util = { version = "0.6.9" }
27
+ tokio-util = { version = "0.7" }
18
28
  tokio-stream = "0.1"
19
29
  tonic = "0.6"
20
30
  tracing = { version = "0.1", features = ["log-always"] }
@@ -30,3 +40,7 @@ version = "0.1"
30
40
  [dependencies.temporal-sdk-core-api]
31
41
  path = "../core-api"
32
42
  version = "0.1"
43
+
44
+ [dependencies.temporal-client]
45
+ path = "../client"
46
+ version = "0.1"
@@ -0,0 +1,23 @@
1
+ Temporal Core SDK
2
+
3
+ The MIT License
4
+
5
+ Copyright (c) 2021 Temporal Technologies, Inc. All Rights Reserved
6
+
7
+ Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ of this software and associated documentation files (the "Software"), to deal
9
+ in the Software without restriction, including without limitation the rights
10
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ copies of the Software, and to permit persons to whom the Software is
12
+ furnished to do so, subject to the following conditions:
13
+
14
+ The above copyright notice and this permission notice shall be included in all
15
+ copies or substantial portions of the Software.
16
+
17
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
+ SOFTWARE.
@@ -0,0 +1,11 @@
1
+ //! User-definable interceptors are defined in this module
2
+
3
+ use temporal_sdk_core_protos::coresdk::workflow_completion::WorkflowActivationCompletion;
4
+
5
+ /// Implementors can intercept certain actions that happen within the Worker.
6
+ ///
7
+ /// Advanced usage only.
8
+ pub trait WorkerInterceptor {
9
+ /// Called every time a workflow activation completes
10
+ fn on_workflow_activation_completion(&self, completion: &WorkflowActivationCompletion);
11
+ }