@temporalio/core-bridge 0.22.0 → 1.0.0-rc.1
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 +120 -15
- package/Cargo.toml +3 -1
- package/README.md +1 -1
- package/index.d.ts +137 -33
- package/package.json +6 -6
- 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/lib.rs +1 -1
- package/sdk-core/bridge-ffi/src/wrappers.rs +60 -37
- package/sdk-core/client/Cargo.toml +1 -0
- package/sdk-core/client/src/lib.rs +50 -15
- package/sdk-core/client/src/raw.rs +167 -55
- 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/benches/workflow_replay.rs +1 -7
- 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 +8 -5
- package/sdk-core/core/src/pollers/poll_buffer.rs +16 -10
- package/sdk-core/core/src/protosext/mod.rs +7 -9
- package/sdk-core/core/src/retry_logic.rs +73 -16
- package/sdk-core/core/src/telemetry/metrics.rs +21 -7
- package/sdk-core/core/src/telemetry/mod.rs +182 -110
- 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 +22 -25
- 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 +27 -6
- 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 +87 -176
- package/sdk-core/test-utils/src/histfetch.rs +1 -1
- package/sdk-core/test-utils/src/lib.rs +93 -77
- package/sdk-core/tests/integ_tests/client_tests.rs +2 -2
- 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 +7 -3
- package/src/conversions.rs +149 -70
- package/src/errors.rs +10 -21
- package/src/lib.rs +400 -319
- 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
|
@@ -25,6 +25,7 @@ use crate::{
|
|
|
25
25
|
use backoff::{ExponentialBackoff, SystemClock};
|
|
26
26
|
use http::uri::InvalidUri;
|
|
27
27
|
use opentelemetry::metrics::Meter;
|
|
28
|
+
use parking_lot::RwLock;
|
|
28
29
|
use std::{
|
|
29
30
|
collections::HashMap,
|
|
30
31
|
fmt::{Debug, Formatter},
|
|
@@ -34,10 +35,10 @@ use std::{
|
|
|
34
35
|
time::{Duration, Instant},
|
|
35
36
|
};
|
|
36
37
|
use temporal_sdk_core_protos::{
|
|
37
|
-
coresdk::{
|
|
38
|
+
coresdk::{workflow_commands::QueryResult, IntoPayloadsExt},
|
|
38
39
|
temporal::api::{
|
|
39
40
|
command::v1::Command,
|
|
40
|
-
common::v1::{Payloads, WorkflowExecution, WorkflowType},
|
|
41
|
+
common::v1::{Payload, Payloads, WorkflowExecution, WorkflowType},
|
|
41
42
|
enums::v1::{TaskQueueKind, WorkflowTaskFailedCause},
|
|
42
43
|
failure::v1::Failure,
|
|
43
44
|
query::v1::{WorkflowQuery, WorkflowQueryResult},
|
|
@@ -74,23 +75,18 @@ pub struct ClientOptions {
|
|
|
74
75
|
|
|
75
76
|
/// The name of the SDK being implemented on top of core. Is set as `client-name` header in
|
|
76
77
|
/// all RPC calls
|
|
78
|
+
#[builder(setter(into))]
|
|
77
79
|
pub client_name: String,
|
|
78
80
|
|
|
79
81
|
/// The version of the SDK being implemented on top of core. Is set as `client-version` header
|
|
80
82
|
/// in all RPC calls. The server decides if the client is supported based on this.
|
|
83
|
+
#[builder(setter(into))]
|
|
81
84
|
pub client_version: String,
|
|
82
85
|
|
|
83
|
-
/// Other non-required static headers which should be attached to every request
|
|
84
|
-
#[builder(default)]
|
|
85
|
-
pub static_headers: HashMap<String, String>,
|
|
86
|
-
|
|
87
86
|
/// A human-readable string that can identify this process. Defaults to empty string.
|
|
88
87
|
#[builder(default)]
|
|
89
88
|
pub identity: String,
|
|
90
89
|
|
|
91
|
-
/// A string that should be unique to this process' binary
|
|
92
|
-
pub worker_binary_id: String,
|
|
93
|
-
|
|
94
90
|
/// If specified, use TLS as configured by the [TlsConfig] struct. If this is set core will
|
|
95
91
|
/// attempt to use TLS when connecting to the Temporal server. Lang SDK is expected to pass any
|
|
96
92
|
/// certs or keys as bytes, loading them from disk itself if needed.
|
|
@@ -252,11 +248,18 @@ impl From<ConfiguredClient<WorkflowServiceClientWithMetrics>> for AnyClient {
|
|
|
252
248
|
pub struct ConfiguredClient<C> {
|
|
253
249
|
client: C,
|
|
254
250
|
options: ClientOptions,
|
|
251
|
+
headers: Arc<RwLock<HashMap<String, String>>>,
|
|
255
252
|
/// Capabilities as read from the `get_system_info` RPC call made on client connection
|
|
256
253
|
capabilities: Option<get_system_info_response::Capabilities>,
|
|
257
254
|
}
|
|
258
255
|
|
|
259
256
|
impl<C> ConfiguredClient<C> {
|
|
257
|
+
/// Set HTTP request headers overwriting previous headers
|
|
258
|
+
pub fn set_headers(&self, headers: HashMap<String, String>) {
|
|
259
|
+
let mut guard = self.headers.write();
|
|
260
|
+
*guard = headers;
|
|
261
|
+
}
|
|
262
|
+
|
|
260
263
|
/// Returns the options the client is configured with
|
|
261
264
|
pub fn options(&self) -> &ClientOptions {
|
|
262
265
|
&self.options
|
|
@@ -295,8 +298,12 @@ impl ClientOptions {
|
|
|
295
298
|
&self,
|
|
296
299
|
namespace: impl Into<String>,
|
|
297
300
|
metrics_meter: Option<&Meter>,
|
|
301
|
+
headers: Option<Arc<RwLock<HashMap<String, String>>>>,
|
|
298
302
|
) -> Result<RetryClient<Client>, ClientInitError> {
|
|
299
|
-
let client = self
|
|
303
|
+
let client = self
|
|
304
|
+
.connect_no_namespace(metrics_meter, headers)
|
|
305
|
+
.await?
|
|
306
|
+
.into_inner();
|
|
300
307
|
let client = Client::new(client, namespace.into());
|
|
301
308
|
let retry_client = RetryClient::new(client, self.retry_config.clone());
|
|
302
309
|
Ok(retry_client)
|
|
@@ -309,6 +316,7 @@ impl ClientOptions {
|
|
|
309
316
|
pub async fn connect_no_namespace(
|
|
310
317
|
&self,
|
|
311
318
|
metrics_meter: Option<&Meter>,
|
|
319
|
+
headers: Option<Arc<RwLock<HashMap<String, String>>>>,
|
|
312
320
|
) -> Result<RetryClient<ConfiguredClient<WorkflowServiceClientWithMetrics>>, ClientInitError>
|
|
313
321
|
{
|
|
314
322
|
let channel = Channel::from_shared(self.target_url.to_string())?;
|
|
@@ -320,9 +328,14 @@ impl ClientOptions {
|
|
|
320
328
|
metrics: metrics_meter.map(|mm| MetricsContext::new(vec![], mm)),
|
|
321
329
|
})
|
|
322
330
|
.service(channel);
|
|
323
|
-
let
|
|
331
|
+
let headers = headers.unwrap_or_default();
|
|
332
|
+
let interceptor = ServiceCallInterceptor {
|
|
333
|
+
opts: self.clone(),
|
|
334
|
+
headers: headers.clone(),
|
|
335
|
+
};
|
|
324
336
|
|
|
325
337
|
let mut client = ConfiguredClient {
|
|
338
|
+
headers,
|
|
326
339
|
client: WorkflowServiceClient::with_interceptor(service, interceptor),
|
|
327
340
|
options: self.clone(),
|
|
328
341
|
capabilities: None,
|
|
@@ -394,6 +407,8 @@ pub struct WorkflowTaskCompletion {
|
|
|
394
407
|
#[derive(Clone)]
|
|
395
408
|
pub struct ServiceCallInterceptor {
|
|
396
409
|
opts: ClientOptions,
|
|
410
|
+
/// Only accessed as a reader
|
|
411
|
+
headers: Arc<RwLock<HashMap<String, String>>>,
|
|
397
412
|
}
|
|
398
413
|
|
|
399
414
|
impl Interceptor for ServiceCallInterceptor {
|
|
@@ -415,7 +430,8 @@ impl Interceptor for ServiceCallInterceptor {
|
|
|
415
430
|
.parse()
|
|
416
431
|
.unwrap_or_else(|_| MetadataValue::from_static("")),
|
|
417
432
|
);
|
|
418
|
-
|
|
433
|
+
let headers = &*self.headers.read();
|
|
434
|
+
for (k, v) in headers {
|
|
419
435
|
if let (Ok(k), Ok(v)) = (MetadataKey::from_str(k), MetadataValue::from_str(v)) {
|
|
420
436
|
metadata.insert(k, v);
|
|
421
437
|
}
|
|
@@ -439,6 +455,8 @@ pub struct Client {
|
|
|
439
455
|
inner: ConfiguredClient<WorkflowServiceClientWithMetrics>,
|
|
440
456
|
/// The namespace this client interacts with
|
|
441
457
|
namespace: String,
|
|
458
|
+
/// If set, attach as the worker build id to relevant calls
|
|
459
|
+
bound_worker_build_id: Option<String>,
|
|
442
460
|
}
|
|
443
461
|
|
|
444
462
|
impl Client {
|
|
@@ -450,6 +468,7 @@ impl Client {
|
|
|
450
468
|
Client {
|
|
451
469
|
inner: client,
|
|
452
470
|
namespace,
|
|
471
|
+
bound_worker_build_id: None,
|
|
453
472
|
}
|
|
454
473
|
}
|
|
455
474
|
|
|
@@ -477,6 +496,17 @@ impl Client {
|
|
|
477
496
|
pub fn options(&self) -> &ClientOptions {
|
|
478
497
|
&self.inner.options
|
|
479
498
|
}
|
|
499
|
+
|
|
500
|
+
/// Return the options this client was initialized with mutably
|
|
501
|
+
pub fn options_mut(&mut self) -> &mut ClientOptions {
|
|
502
|
+
&mut self.inner.options
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
/// Set a worker build id to be attached to relevant requests. Unlikely to be useful outside
|
|
506
|
+
/// of core.
|
|
507
|
+
pub fn set_worker_build_id(&mut self, id: String) {
|
|
508
|
+
self.bound_worker_build_id = Some(id)
|
|
509
|
+
}
|
|
480
510
|
}
|
|
481
511
|
|
|
482
512
|
/// This trait provides higher-level friendlier interaction with the server.
|
|
@@ -614,6 +644,7 @@ pub trait WorkflowClientTrait {
|
|
|
614
644
|
&self,
|
|
615
645
|
workflow_id: String,
|
|
616
646
|
run_id: Option<String>,
|
|
647
|
+
reason: String,
|
|
617
648
|
) -> Result<RequestCancelWorkflowExecutionResponse>;
|
|
618
649
|
|
|
619
650
|
/// Terminate a currently executing workflow
|
|
@@ -693,7 +724,7 @@ impl WorkflowClientTrait for Client {
|
|
|
693
724
|
} as i32,
|
|
694
725
|
}),
|
|
695
726
|
identity: self.inner.options.identity.clone(),
|
|
696
|
-
binary_checksum: self.
|
|
727
|
+
binary_checksum: self.bound_worker_build_id.clone().unwrap_or_default(),
|
|
697
728
|
};
|
|
698
729
|
|
|
699
730
|
Ok(self
|
|
@@ -757,7 +788,7 @@ impl WorkflowClientTrait for Client {
|
|
|
757
788
|
sticky_attributes: request.sticky_attributes,
|
|
758
789
|
return_new_workflow_task: request.return_new_workflow_task,
|
|
759
790
|
force_create_new_workflow_task: request.force_create_new_workflow_task,
|
|
760
|
-
binary_checksum: self.
|
|
791
|
+
binary_checksum: self.bound_worker_build_id.clone().unwrap_or_default(),
|
|
761
792
|
query_results: request
|
|
762
793
|
.query_responses
|
|
763
794
|
.into_iter()
|
|
@@ -845,6 +876,8 @@ impl WorkflowClientTrait for Client {
|
|
|
845
876
|
failure,
|
|
846
877
|
identity: self.inner.options.identity.clone(),
|
|
847
878
|
namespace: self.namespace.clone(),
|
|
879
|
+
// TODO: Implement - https://github.com/temporalio/sdk-core/issues/293
|
|
880
|
+
last_heartbeat_details: None,
|
|
848
881
|
})
|
|
849
882
|
.await?
|
|
850
883
|
.into_inner())
|
|
@@ -861,7 +894,7 @@ impl WorkflowClientTrait for Client {
|
|
|
861
894
|
cause: cause as i32,
|
|
862
895
|
failure,
|
|
863
896
|
identity: self.inner.options.identity.clone(),
|
|
864
|
-
binary_checksum: self.
|
|
897
|
+
binary_checksum: self.bound_worker_build_id.clone().unwrap_or_default(),
|
|
865
898
|
namespace: self.namespace.clone(),
|
|
866
899
|
};
|
|
867
900
|
Ok(self
|
|
@@ -978,6 +1011,7 @@ impl WorkflowClientTrait for Client {
|
|
|
978
1011
|
&self,
|
|
979
1012
|
workflow_id: String,
|
|
980
1013
|
run_id: Option<String>,
|
|
1014
|
+
reason: String,
|
|
981
1015
|
) -> Result<RequestCancelWorkflowExecutionResponse> {
|
|
982
1016
|
Ok(self
|
|
983
1017
|
.wf_svc()
|
|
@@ -990,6 +1024,7 @@ impl WorkflowClientTrait for Client {
|
|
|
990
1024
|
identity: self.inner.options.identity.clone(),
|
|
991
1025
|
request_id: "".to_string(),
|
|
992
1026
|
first_execution_run_id: "".to_string(),
|
|
1027
|
+
reason,
|
|
993
1028
|
})
|
|
994
1029
|
.await?
|
|
995
1030
|
.into_inner())
|