@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.
- package/Cargo.lock +90 -157
- package/Cargo.toml +1 -0
- package/index.d.ts +11 -27
- package/package.json +3 -3
- 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/Dockerfile +1 -1
- package/sdk-core/.buildkite/docker/docker-compose.yaml +1 -1
- package/sdk-core/.cargo/config.toml +1 -0
- package/sdk-core/CODEOWNERS +1 -1
- package/sdk-core/bridge-ffi/include/sdk-core-bridge.h +119 -86
- package/sdk-core/bridge-ffi/src/lib.rs +311 -315
- package/sdk-core/bridge-ffi/src/wrappers.rs +108 -113
- package/sdk-core/client/Cargo.toml +13 -9
- package/sdk-core/client/LICENSE.txt +23 -0
- package/sdk-core/client/src/lib.rs +286 -174
- package/sdk-core/client/src/metrics.rs +86 -12
- package/sdk-core/client/src/raw.rs +566 -0
- package/sdk-core/client/src/retry.rs +137 -99
- package/sdk-core/core/Cargo.toml +15 -10
- package/sdk-core/core/LICENSE.txt +23 -0
- package/sdk-core/core/benches/workflow_replay.rs +79 -0
- package/sdk-core/core/src/abstractions.rs +38 -0
- package/sdk-core/core/src/core_tests/activity_tasks.rs +108 -182
- package/sdk-core/core/src/core_tests/child_workflows.rs +16 -11
- package/sdk-core/core/src/core_tests/determinism.rs +24 -12
- package/sdk-core/core/src/core_tests/local_activities.rs +53 -27
- package/sdk-core/core/src/core_tests/mod.rs +30 -43
- package/sdk-core/core/src/core_tests/queries.rs +82 -81
- package/sdk-core/core/src/core_tests/workers.rs +111 -296
- package/sdk-core/core/src/core_tests/workflow_cancels.rs +4 -4
- package/sdk-core/core/src/core_tests/workflow_tasks.rs +213 -241
- package/sdk-core/core/src/lib.rs +73 -318
- package/sdk-core/core/src/pollers/mod.rs +4 -6
- package/sdk-core/core/src/pollers/poll_buffer.rs +20 -14
- package/sdk-core/core/src/protosext/mod.rs +7 -10
- package/sdk-core/core/src/replay/mod.rs +11 -150
- package/sdk-core/core/src/telemetry/metrics.rs +35 -2
- package/sdk-core/core/src/telemetry/mod.rs +49 -16
- package/sdk-core/core/src/telemetry/prometheus_server.rs +14 -35
- package/sdk-core/core/src/test_help/mod.rs +104 -170
- package/sdk-core/core/src/worker/activities/activity_heartbeat_manager.rs +57 -34
- package/sdk-core/core/src/worker/activities/local_activities.rs +37 -17
- package/sdk-core/core/src/worker/activities.rs +23 -16
- package/sdk-core/core/src/worker/client/mocks.rs +86 -0
- package/sdk-core/core/src/worker/client.rs +209 -0
- package/sdk-core/core/src/worker/mod.rs +193 -105
- package/sdk-core/core/src/workflow/driven_workflow.rs +21 -6
- package/sdk-core/core/src/workflow/history_update.rs +107 -24
- package/sdk-core/core/src/workflow/machines/activity_state_machine.rs +2 -3
- package/sdk-core/core/src/workflow/machines/child_workflow_state_machine.rs +2 -3
- package/sdk-core/core/src/workflow/machines/mod.rs +20 -17
- package/sdk-core/core/src/workflow/machines/signal_external_state_machine.rs +56 -19
- package/sdk-core/core/src/workflow/machines/transition_coverage.rs +5 -0
- package/sdk-core/core/src/workflow/machines/upsert_search_attributes_state_machine.rs +230 -22
- package/sdk-core/core/src/workflow/machines/workflow_machines.rs +81 -115
- package/sdk-core/core/src/workflow/machines/workflow_task_state_machine.rs +4 -4
- package/sdk-core/core/src/workflow/mod.rs +13 -1
- package/sdk-core/core/src/workflow/workflow_tasks/mod.rs +43 -33
- package/sdk-core/core-api/Cargo.toml +9 -1
- package/sdk-core/core-api/LICENSE.txt +23 -0
- package/sdk-core/core-api/src/errors.rs +7 -38
- package/sdk-core/core-api/src/lib.rs +44 -52
- package/sdk-core/core-api/src/worker.rs +10 -2
- package/sdk-core/etc/deps.svg +127 -96
- package/sdk-core/protos/api_upstream/temporal/api/command/v1/message.proto +11 -7
- package/sdk-core/protos/api_upstream/temporal/api/enums/v1/failed_cause.proto +10 -0
- package/sdk-core/protos/api_upstream/temporal/api/enums/v1/namespace.proto +6 -1
- package/sdk-core/protos/api_upstream/temporal/api/enums/v1/workflow.proto +6 -0
- package/sdk-core/protos/api_upstream/temporal/api/errordetails/v1/message.proto +6 -0
- package/sdk-core/protos/api_upstream/temporal/api/history/v1/message.proto +2 -1
- package/sdk-core/protos/api_upstream/temporal/api/replication/v1/message.proto +3 -0
- package/sdk-core/protos/api_upstream/temporal/api/workflow/v1/message.proto +12 -0
- package/sdk-core/protos/api_upstream/temporal/api/workflowservice/v1/request_response.proto +25 -0
- package/sdk-core/protos/api_upstream/temporal/api/workflowservice/v1/service.proto +4 -0
- package/sdk-core/protos/local/temporal/sdk/core/bridge/bridge.proto +19 -35
- package/sdk-core/protos/local/temporal/sdk/core/core_interface.proto +2 -6
- package/sdk-core/protos/local/temporal/sdk/core/workflow_activation/workflow_activation.proto +53 -11
- package/sdk-core/protos/local/temporal/sdk/core/workflow_commands/workflow_commands.proto +14 -7
- package/sdk-core/protos/local/temporal/sdk/core/workflow_completion/workflow_completion.proto +3 -5
- package/sdk-core/sdk/Cargo.toml +16 -2
- package/sdk-core/sdk/LICENSE.txt +23 -0
- package/sdk-core/sdk/src/interceptors.rs +11 -0
- package/sdk-core/sdk/src/lib.rs +138 -150
- package/sdk-core/sdk/src/workflow_context/options.rs +86 -1
- package/sdk-core/sdk/src/workflow_context.rs +36 -17
- package/sdk-core/sdk/src/workflow_future.rs +19 -25
- package/sdk-core/sdk-core-protos/Cargo.toml +1 -1
- package/sdk-core/sdk-core-protos/build.rs +1 -0
- package/sdk-core/sdk-core-protos/src/history_info.rs +17 -4
- package/sdk-core/sdk-core-protos/src/lib.rs +251 -47
- package/sdk-core/test-utils/Cargo.toml +3 -1
- package/sdk-core/test-utils/src/canned_histories.rs +27 -0
- package/sdk-core/test-utils/src/histfetch.rs +3 -3
- package/sdk-core/test-utils/src/lib.rs +223 -68
- package/sdk-core/tests/integ_tests/client_tests.rs +27 -4
- package/sdk-core/tests/integ_tests/heartbeat_tests.rs +93 -14
- package/sdk-core/tests/integ_tests/polling_tests.rs +18 -12
- package/sdk-core/tests/integ_tests/queries_tests.rs +50 -53
- package/sdk-core/tests/integ_tests/workflow_tests/activities.rs +117 -103
- package/sdk-core/tests/integ_tests/workflow_tests/cancel_external.rs +8 -1
- package/sdk-core/tests/integ_tests/workflow_tests/cancel_wf.rs +10 -5
- package/sdk-core/tests/integ_tests/workflow_tests/child_workflows.rs +7 -1
- package/sdk-core/tests/integ_tests/workflow_tests/continue_as_new.rs +8 -3
- package/sdk-core/tests/integ_tests/workflow_tests/determinism.rs +7 -1
- package/sdk-core/tests/integ_tests/workflow_tests/local_activities.rs +76 -15
- package/sdk-core/tests/integ_tests/workflow_tests/patches.rs +19 -3
- package/sdk-core/tests/integ_tests/workflow_tests/replay.rs +39 -42
- package/sdk-core/tests/integ_tests/workflow_tests/resets.rs +84 -0
- package/sdk-core/tests/integ_tests/workflow_tests/signals.rs +30 -8
- package/sdk-core/tests/integ_tests/workflow_tests/stickyness.rs +21 -6
- package/sdk-core/tests/integ_tests/workflow_tests/timers.rs +26 -16
- package/sdk-core/tests/integ_tests/workflow_tests/upsert_search_attrs.rs +66 -0
- package/sdk-core/tests/integ_tests/workflow_tests.rs +78 -74
- package/sdk-core/tests/load_tests.rs +9 -6
- package/sdk-core/tests/main.rs +43 -10
- package/src/conversions.rs +7 -12
- package/src/lib.rs +322 -357
- package/sdk-core/client/src/mocks.rs +0 -167
- package/sdk-core/core/src/worker/dispatcher.rs +0 -171
- package/sdk-core/protos/local/temporal/sdk/core/bridge/service.proto +0 -61
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
use assert_matches::assert_matches;
|
|
2
2
|
use futures::future::join_all;
|
|
3
3
|
use std::time::{Duration, Instant};
|
|
4
|
+
use temporal_client::WorkflowOptions;
|
|
4
5
|
use temporal_sdk::{ActivityOptions, WfContext};
|
|
5
6
|
use temporal_sdk_core_protos::coresdk::{
|
|
6
7
|
activity_result::ActivityExecutionResult, activity_task::activity_task as act_task,
|
|
@@ -19,7 +20,6 @@ async fn activity_load() {
|
|
|
19
20
|
.max_at_polls(10)
|
|
20
21
|
.max_at(CONCURRENCY);
|
|
21
22
|
let mut worker = starter.worker().await;
|
|
22
|
-
let task_q = starter.get_task_queue().to_owned();
|
|
23
23
|
|
|
24
24
|
let activity_id = "act-1";
|
|
25
25
|
let activity_timeout = Duration::from_secs(8);
|
|
@@ -57,7 +57,12 @@ async fn activity_load() {
|
|
|
57
57
|
let wf_id = format!("activity_load_{}", i);
|
|
58
58
|
async move {
|
|
59
59
|
worker
|
|
60
|
-
.submit_wf(
|
|
60
|
+
.submit_wf(
|
|
61
|
+
wf_id,
|
|
62
|
+
wf_type.to_owned(),
|
|
63
|
+
vec![],
|
|
64
|
+
WorkflowOptions::default(),
|
|
65
|
+
)
|
|
61
66
|
.await
|
|
62
67
|
.unwrap();
|
|
63
68
|
}
|
|
@@ -66,15 +71,14 @@ async fn activity_load() {
|
|
|
66
71
|
dbg!(starting.elapsed());
|
|
67
72
|
|
|
68
73
|
let running = Instant::now();
|
|
69
|
-
let core = starter.
|
|
74
|
+
let core = starter.get_worker().await;
|
|
70
75
|
|
|
71
76
|
// Poll for and complete all activities
|
|
72
77
|
let c2 = core.clone();
|
|
73
78
|
let all_acts = async move {
|
|
74
79
|
let mut act_complete_futs = vec![];
|
|
75
80
|
for _ in 0..CONCURRENCY {
|
|
76
|
-
let
|
|
77
|
-
let task = c2.poll_activity_task(&task_q).await.unwrap();
|
|
81
|
+
let task = c2.poll_activity_task().await.unwrap();
|
|
78
82
|
assert_matches!(
|
|
79
83
|
task.variant,
|
|
80
84
|
Some(act_task::Variant::Start(ref start_activity)) => {
|
|
@@ -86,7 +90,6 @@ async fn activity_load() {
|
|
|
86
90
|
act_complete_futs.push(tokio::spawn(async move {
|
|
87
91
|
core.complete_activity_task(ActivityTaskCompletion {
|
|
88
92
|
task_token: task.task_token,
|
|
89
|
-
task_queue: task_q,
|
|
90
93
|
result: Some(ActivityExecutionResult::ok(pd.into())),
|
|
91
94
|
})
|
|
92
95
|
.await
|
package/sdk-core/tests/main.rs
CHANGED
|
@@ -2,19 +2,53 @@
|
|
|
2
2
|
|
|
3
3
|
#[cfg(test)]
|
|
4
4
|
mod integ_tests {
|
|
5
|
-
use std::str::FromStr;
|
|
6
|
-
use temporal_sdk_core::{
|
|
7
|
-
ClientTlsConfig, ServerGatewayApis, ServerGatewayOptionsBuilder, TlsConfig,
|
|
8
|
-
};
|
|
9
|
-
use temporal_sdk_core_test_utils::NAMESPACE;
|
|
10
|
-
use url::Url;
|
|
11
|
-
|
|
12
5
|
mod client_tests;
|
|
13
6
|
mod heartbeat_tests;
|
|
14
7
|
mod polling_tests;
|
|
15
8
|
mod queries_tests;
|
|
16
9
|
mod workflow_tests;
|
|
17
10
|
|
|
11
|
+
use std::str::FromStr;
|
|
12
|
+
use temporal_client::WorkflowService;
|
|
13
|
+
use temporal_sdk_core::{
|
|
14
|
+
init_worker, telemetry_init, ClientOptionsBuilder, ClientTlsConfig, TlsConfig,
|
|
15
|
+
WorkflowClientTrait,
|
|
16
|
+
};
|
|
17
|
+
use temporal_sdk_core_api::{worker::WorkerConfigBuilder, CoreTelemetry};
|
|
18
|
+
use temporal_sdk_core_protos::temporal::api::workflowservice::v1::ListNamespacesRequest;
|
|
19
|
+
use temporal_sdk_core_test_utils::{
|
|
20
|
+
get_integ_server_options, get_integ_telem_options, NAMESPACE,
|
|
21
|
+
};
|
|
22
|
+
use url::Url;
|
|
23
|
+
|
|
24
|
+
// Create a worker like a bridge would (unwraps aside)
|
|
25
|
+
#[tokio::test]
|
|
26
|
+
#[ignore] // Really a compile time check more than anything
|
|
27
|
+
async fn lang_bridge_example() {
|
|
28
|
+
let opts = get_integ_server_options();
|
|
29
|
+
let telem_d = telemetry_init(&get_integ_telem_options()).unwrap();
|
|
30
|
+
let mut retrying_client = opts
|
|
31
|
+
.connect_no_namespace(telem_d.get_metric_meter())
|
|
32
|
+
.await
|
|
33
|
+
.unwrap();
|
|
34
|
+
|
|
35
|
+
let _worker = init_worker(
|
|
36
|
+
WorkerConfigBuilder::default()
|
|
37
|
+
.namespace("default")
|
|
38
|
+
.task_queue("Wheee!")
|
|
39
|
+
.build()
|
|
40
|
+
.unwrap(),
|
|
41
|
+
// clone the client if you intend to use it later. Strip off the retry wrapper since
|
|
42
|
+
// worker will assert its own
|
|
43
|
+
retrying_client.clone(),
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
// Do things with worker or client
|
|
47
|
+
let _ = retrying_client
|
|
48
|
+
.list_namespaces(ListNamespacesRequest::default())
|
|
49
|
+
.await;
|
|
50
|
+
}
|
|
51
|
+
|
|
18
52
|
// TODO: Currently ignored because starting up the docker image with TLS requires some hoop
|
|
19
53
|
// jumping. We should upgrade CI to be able to do that but this was manually run against
|
|
20
54
|
// https://github.com/temporalio/customization-samples/tree/master/tls/tls-simple
|
|
@@ -37,9 +71,8 @@ mod integ_tests {
|
|
|
37
71
|
)
|
|
38
72
|
.await
|
|
39
73
|
.unwrap();
|
|
40
|
-
let sgo =
|
|
74
|
+
let sgo = ClientOptionsBuilder::default()
|
|
41
75
|
.target_url(Url::from_str("https://localhost:7233").unwrap())
|
|
42
|
-
.namespace(NAMESPACE.to_string())
|
|
43
76
|
.worker_binary_id("binident".to_string())
|
|
44
77
|
.tls_cfg(TlsConfig {
|
|
45
78
|
server_root_ca_cert: Some(root),
|
|
@@ -51,7 +84,7 @@ mod integ_tests {
|
|
|
51
84
|
})
|
|
52
85
|
.build()
|
|
53
86
|
.unwrap();
|
|
54
|
-
let con = sgo.connect(None).await.unwrap();
|
|
87
|
+
let con = sgo.connect(NAMESPACE.to_string(), None).await.unwrap();
|
|
55
88
|
con.list_namespaces().await.unwrap();
|
|
56
89
|
}
|
|
57
90
|
}
|
package/src/conversions.rs
CHANGED
|
@@ -9,8 +9,8 @@ use opentelemetry::trace::{SpanContext, SpanId, TraceFlags, TraceId, TraceState}
|
|
|
9
9
|
use std::{fmt::Display, net::SocketAddr, str::FromStr, time::Duration};
|
|
10
10
|
use temporal_sdk_core::{
|
|
11
11
|
api::worker::{WorkerConfig, WorkerConfigBuilder},
|
|
12
|
-
ClientTlsConfig, RetryConfig,
|
|
13
|
-
|
|
12
|
+
ClientOptions, ClientOptionsBuilder, ClientTlsConfig, RetryConfig, TelemetryOptions,
|
|
13
|
+
TelemetryOptionsBuilder, TlsConfig, Url,
|
|
14
14
|
};
|
|
15
15
|
|
|
16
16
|
macro_rules! js_value_getter {
|
|
@@ -105,10 +105,7 @@ where
|
|
|
105
105
|
|
|
106
106
|
pub(crate) trait ObjectHandleConversionsExt {
|
|
107
107
|
fn as_otel_span_context(&self, ctx: &mut FunctionContext) -> NeonResult<SpanContext>;
|
|
108
|
-
fn
|
|
109
|
-
&self,
|
|
110
|
-
ctx: &mut FunctionContext,
|
|
111
|
-
) -> NeonResult<ServerGatewayOptions>;
|
|
108
|
+
fn as_client_options(&self, ctx: &mut FunctionContext) -> NeonResult<ClientOptions>;
|
|
112
109
|
fn as_telemetry_options(&self, cx: &mut FunctionContext) -> NeonResult<TelemetryOptions>;
|
|
113
110
|
fn as_worker_config(&self, cx: &mut FunctionContext) -> NeonResult<WorkerConfig>;
|
|
114
111
|
}
|
|
@@ -127,10 +124,7 @@ impl ObjectHandleConversionsExt for Handle<'_, JsObject> {
|
|
|
127
124
|
))
|
|
128
125
|
}
|
|
129
126
|
|
|
130
|
-
fn
|
|
131
|
-
&self,
|
|
132
|
-
cx: &mut FunctionContext,
|
|
133
|
-
) -> NeonResult<ServerGatewayOptions> {
|
|
127
|
+
fn as_client_options(&self, cx: &mut FunctionContext) -> NeonResult<ClientOptions> {
|
|
134
128
|
let url = match Url::parse(&js_value_getter!(cx, self, "url", JsString)) {
|
|
135
129
|
Ok(url) => url,
|
|
136
130
|
// Note that address is what's used in the Node side.
|
|
@@ -204,7 +198,7 @@ impl ObjectHandleConversionsExt for Handle<'_, JsObject> {
|
|
|
204
198
|
},
|
|
205
199
|
};
|
|
206
200
|
|
|
207
|
-
let mut gateway_opts =
|
|
201
|
+
let mut gateway_opts = ClientOptionsBuilder::default();
|
|
208
202
|
if let Some(tls_cfg) = tls_cfg {
|
|
209
203
|
gateway_opts.tls_cfg(tls_cfg);
|
|
210
204
|
}
|
|
@@ -212,7 +206,6 @@ impl ObjectHandleConversionsExt for Handle<'_, JsObject> {
|
|
|
212
206
|
.client_name("temporal-typescript".to_string())
|
|
213
207
|
.client_version(js_value_getter!(cx, self, "sdkVersion", JsString))
|
|
214
208
|
.target_url(url)
|
|
215
|
-
.namespace(js_value_getter!(cx, self, "namespace", JsString))
|
|
216
209
|
.identity(js_value_getter!(cx, self, "identity", JsString))
|
|
217
210
|
.worker_binary_id(js_value_getter!(cx, self, "workerBinaryId", JsString))
|
|
218
211
|
.retry_config(retry_config)
|
|
@@ -255,6 +248,7 @@ impl ObjectHandleConversionsExt for Handle<'_, JsObject> {
|
|
|
255
248
|
}
|
|
256
249
|
|
|
257
250
|
fn as_worker_config(&self, cx: &mut FunctionContext) -> NeonResult<WorkerConfig> {
|
|
251
|
+
let namespace = js_value_getter!(cx, self, "namespace", JsString);
|
|
258
252
|
let task_queue = js_value_getter!(cx, self, "taskQueue", JsString);
|
|
259
253
|
let max_outstanding_activities =
|
|
260
254
|
js_value_getter!(cx, self, "maxConcurrentActivityTaskExecutions", JsNumber) as usize;
|
|
@@ -298,6 +292,7 @@ impl ObjectHandleConversionsExt for Handle<'_, JsObject> {
|
|
|
298
292
|
.max_cached_workflows(max_cached_workflows)
|
|
299
293
|
.nonsticky_to_sticky_poll_ratio(nonsticky_to_sticky_poll_ratio)
|
|
300
294
|
.sticky_queue_schedule_to_start_timeout(sticky_queue_schedule_to_start_timeout)
|
|
295
|
+
.namespace(namespace)
|
|
301
296
|
.task_queue(task_queue)
|
|
302
297
|
.max_heartbeat_throttle_interval(max_heartbeat_throttle_interval)
|
|
303
298
|
.default_heartbeat_throttle_interval(default_heartbeat_throttle_interval)
|