@temporalio/core-bridge 1.5.2 → 1.6.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 (153) hide show
  1. package/Cargo.lock +255 -48
  2. package/package.json +4 -4
  3. package/releases/aarch64-apple-darwin/index.node +0 -0
  4. package/releases/aarch64-unknown-linux-gnu/index.node +0 -0
  5. package/releases/x86_64-apple-darwin/index.node +0 -0
  6. package/releases/x86_64-pc-windows-msvc/index.node +0 -0
  7. package/releases/x86_64-unknown-linux-gnu/index.node +0 -0
  8. package/sdk-core/.buildkite/pipeline.yml +1 -3
  9. package/sdk-core/.cargo/config.toml +5 -2
  10. package/sdk-core/.github/workflows/heavy.yml +28 -0
  11. package/sdk-core/Cargo.toml +1 -1
  12. package/sdk-core/README.md +9 -5
  13. package/sdk-core/client/src/lib.rs +211 -36
  14. package/sdk-core/client/src/raw.rs +1 -1
  15. package/sdk-core/client/src/retry.rs +32 -20
  16. package/sdk-core/core/Cargo.toml +23 -9
  17. package/sdk-core/core/src/abstractions.rs +11 -0
  18. package/sdk-core/core/src/core_tests/activity_tasks.rs +6 -5
  19. package/sdk-core/core/src/core_tests/local_activities.rs +263 -22
  20. package/sdk-core/core/src/core_tests/queries.rs +2 -2
  21. package/sdk-core/core/src/core_tests/workflow_tasks.rs +249 -5
  22. package/sdk-core/core/src/ephemeral_server/mod.rs +5 -6
  23. package/sdk-core/core/src/lib.rs +2 -0
  24. package/sdk-core/core/src/protosext/mod.rs +1 -1
  25. package/sdk-core/core/src/telemetry/log_export.rs +1 -1
  26. package/sdk-core/core/src/telemetry/mod.rs +23 -8
  27. package/sdk-core/core/src/test_help/mod.rs +8 -1
  28. package/sdk-core/core/src/worker/activities/local_activities.rs +259 -125
  29. package/sdk-core/core/src/worker/activities.rs +3 -2
  30. package/sdk-core/core/src/worker/mod.rs +53 -26
  31. package/sdk-core/core/src/worker/workflow/bridge.rs +1 -3
  32. package/sdk-core/core/src/worker/workflow/driven_workflow.rs +3 -5
  33. package/sdk-core/core/src/worker/workflow/history_update.rs +835 -277
  34. package/sdk-core/core/src/worker/workflow/machines/activity_state_machine.rs +9 -17
  35. package/sdk-core/core/src/worker/workflow/machines/cancel_external_state_machine.rs +3 -5
  36. package/sdk-core/core/src/worker/workflow/machines/cancel_workflow_state_machine.rs +1 -2
  37. package/sdk-core/core/src/worker/workflow/machines/child_workflow_state_machine.rs +3 -5
  38. package/sdk-core/core/src/worker/workflow/machines/complete_workflow_state_machine.rs +1 -2
  39. package/sdk-core/core/src/worker/workflow/machines/continue_as_new_workflow_state_machine.rs +1 -2
  40. package/sdk-core/core/src/worker/workflow/machines/fail_workflow_state_machine.rs +1 -2
  41. package/sdk-core/core/src/worker/workflow/machines/local_activity_state_machine.rs +73 -51
  42. package/sdk-core/core/src/worker/workflow/machines/mod.rs +3 -3
  43. package/sdk-core/core/src/worker/workflow/machines/modify_workflow_properties_state_machine.rs +4 -4
  44. package/sdk-core/core/src/worker/workflow/machines/patch_state_machine.rs +1 -2
  45. package/sdk-core/core/src/worker/workflow/machines/signal_external_state_machine.rs +3 -5
  46. package/sdk-core/core/src/worker/workflow/machines/timer_state_machine.rs +6 -7
  47. package/sdk-core/core/src/worker/workflow/machines/transition_coverage.rs +2 -2
  48. package/sdk-core/core/src/worker/workflow/machines/upsert_search_attributes_state_machine.rs +4 -4
  49. package/sdk-core/core/src/worker/workflow/machines/workflow_machines/local_acts.rs +6 -17
  50. package/sdk-core/core/src/worker/workflow/machines/workflow_machines.rs +89 -58
  51. package/sdk-core/core/src/worker/workflow/machines/workflow_task_state_machine.rs +4 -7
  52. package/sdk-core/core/src/worker/workflow/managed_run/managed_wf_test.rs +21 -9
  53. package/sdk-core/core/src/worker/workflow/managed_run.rs +1021 -360
  54. package/sdk-core/core/src/worker/workflow/mod.rs +306 -346
  55. package/sdk-core/core/src/worker/workflow/run_cache.rs +29 -53
  56. package/sdk-core/core/src/worker/workflow/wft_extraction.rs +125 -0
  57. package/sdk-core/core/src/worker/workflow/wft_poller.rs +1 -4
  58. package/sdk-core/core/src/worker/workflow/workflow_stream/saved_wf_inputs.rs +115 -0
  59. package/sdk-core/core/src/worker/workflow/workflow_stream/tonic_status_serde.rs +24 -0
  60. package/sdk-core/core/src/worker/workflow/workflow_stream.rs +444 -714
  61. package/sdk-core/core-api/Cargo.toml +2 -0
  62. package/sdk-core/core-api/src/errors.rs +1 -34
  63. package/sdk-core/core-api/src/lib.rs +6 -2
  64. package/sdk-core/core-api/src/worker.rs +14 -1
  65. package/sdk-core/etc/deps.svg +115 -140
  66. package/sdk-core/etc/regen-depgraph.sh +5 -0
  67. package/sdk-core/fsm/rustfsm_procmacro/src/lib.rs +6 -6
  68. package/sdk-core/fsm/rustfsm_trait/src/lib.rs +7 -3
  69. package/sdk-core/histories/evict_while_la_running_no_interference-16_history.bin +0 -0
  70. package/sdk-core/protos/api_upstream/Makefile +5 -5
  71. package/sdk-core/protos/api_upstream/build/go.mod +7 -0
  72. package/sdk-core/protos/api_upstream/build/go.sum +5 -0
  73. package/sdk-core/protos/api_upstream/build/tools.go +29 -0
  74. package/sdk-core/protos/api_upstream/go.mod +6 -0
  75. package/sdk-core/protos/api_upstream/temporal/api/batch/v1/message.proto +9 -2
  76. package/sdk-core/protos/api_upstream/temporal/api/command/v1/message.proto +12 -19
  77. package/sdk-core/protos/api_upstream/temporal/api/common/v1/message.proto +2 -2
  78. package/sdk-core/protos/api_upstream/temporal/api/enums/v1/batch_operation.proto +3 -2
  79. package/sdk-core/protos/api_upstream/temporal/api/enums/v1/command_type.proto +3 -2
  80. package/sdk-core/protos/api_upstream/temporal/api/enums/v1/common.proto +3 -2
  81. package/sdk-core/protos/api_upstream/temporal/api/enums/v1/event_type.proto +3 -3
  82. package/sdk-core/protos/api_upstream/temporal/api/enums/v1/failed_cause.proto +20 -2
  83. package/sdk-core/protos/api_upstream/temporal/api/{update/v1/message.proto → enums/v1/interaction_type.proto} +11 -18
  84. package/sdk-core/protos/api_upstream/temporal/api/enums/v1/namespace.proto +2 -2
  85. package/sdk-core/protos/api_upstream/temporal/api/enums/v1/query.proto +2 -2
  86. package/sdk-core/protos/api_upstream/temporal/api/enums/v1/reset.proto +2 -2
  87. package/sdk-core/protos/api_upstream/temporal/api/enums/v1/schedule.proto +2 -2
  88. package/sdk-core/protos/api_upstream/temporal/api/enums/v1/task_queue.proto +2 -2
  89. package/sdk-core/protos/api_upstream/temporal/api/enums/v1/update.proto +2 -13
  90. package/sdk-core/protos/api_upstream/temporal/api/enums/v1/workflow.proto +2 -2
  91. package/sdk-core/protos/api_upstream/temporal/api/errordetails/v1/message.proto +2 -2
  92. package/sdk-core/protos/api_upstream/temporal/api/failure/v1/message.proto +2 -2
  93. package/sdk-core/protos/api_upstream/temporal/api/filter/v1/message.proto +2 -2
  94. package/sdk-core/protos/api_upstream/temporal/api/history/v1/message.proto +13 -19
  95. package/sdk-core/protos/api_upstream/temporal/api/interaction/v1/message.proto +87 -0
  96. package/sdk-core/protos/api_upstream/temporal/api/namespace/v1/message.proto +2 -2
  97. package/sdk-core/protos/api_upstream/temporal/api/operatorservice/v1/request_response.proto +2 -2
  98. package/sdk-core/protos/api_upstream/temporal/api/operatorservice/v1/service.proto +2 -2
  99. package/sdk-core/protos/api_upstream/temporal/api/query/v1/message.proto +2 -2
  100. package/sdk-core/protos/api_upstream/temporal/api/replication/v1/message.proto +2 -2
  101. package/sdk-core/protos/api_upstream/temporal/api/schedule/v1/message.proto +2 -2
  102. package/sdk-core/protos/api_upstream/temporal/api/taskqueue/v1/message.proto +2 -2
  103. package/sdk-core/protos/api_upstream/temporal/api/version/v1/message.proto +2 -2
  104. package/sdk-core/protos/api_upstream/temporal/api/workflow/v1/message.proto +2 -2
  105. package/sdk-core/protos/api_upstream/temporal/api/workflowservice/v1/request_response.proto +13 -8
  106. package/sdk-core/protos/api_upstream/temporal/api/workflowservice/v1/service.proto +2 -2
  107. package/sdk-core/protos/local/temporal/sdk/core/workflow_activation/workflow_activation.proto +2 -0
  108. package/sdk-core/protos/testsrv_upstream/temporal/api/testservice/v1/request_response.proto +2 -2
  109. package/sdk-core/protos/testsrv_upstream/temporal/api/testservice/v1/service.proto +2 -2
  110. package/sdk-core/sdk/Cargo.toml +4 -3
  111. package/sdk-core/sdk/src/lib.rs +87 -21
  112. package/sdk-core/sdk/src/workflow_future.rs +7 -12
  113. package/sdk-core/sdk-core-protos/Cargo.toml +5 -2
  114. package/sdk-core/sdk-core-protos/build.rs +36 -2
  115. package/sdk-core/sdk-core-protos/src/history_builder.rs +26 -19
  116. package/sdk-core/sdk-core-protos/src/history_info.rs +4 -0
  117. package/sdk-core/sdk-core-protos/src/lib.rs +78 -34
  118. package/sdk-core/sdk-core-protos/src/task_token.rs +12 -2
  119. package/sdk-core/test-utils/Cargo.toml +3 -1
  120. package/sdk-core/test-utils/src/histfetch.rs +1 -1
  121. package/sdk-core/test-utils/src/lib.rs +50 -18
  122. package/sdk-core/test-utils/src/wf_input_saver.rs +50 -0
  123. package/sdk-core/test-utils/src/workflows.rs +29 -0
  124. package/sdk-core/tests/fuzzy_workflow.rs +130 -0
  125. package/sdk-core/tests/{load_tests.rs → heavy_tests.rs} +114 -7
  126. package/sdk-core/tests/integ_tests/heartbeat_tests.rs +5 -2
  127. package/sdk-core/tests/integ_tests/metrics_tests.rs +1 -1
  128. package/sdk-core/tests/integ_tests/polling_tests.rs +1 -39
  129. package/sdk-core/tests/integ_tests/queries_tests.rs +2 -127
  130. package/sdk-core/tests/integ_tests/visibility_tests.rs +52 -5
  131. package/sdk-core/tests/integ_tests/workflow_tests/activities.rs +74 -1
  132. package/sdk-core/tests/integ_tests/workflow_tests/cancel_wf.rs +5 -13
  133. package/sdk-core/tests/integ_tests/workflow_tests/continue_as_new.rs +1 -1
  134. package/sdk-core/tests/integ_tests/workflow_tests/determinism.rs +2 -10
  135. package/sdk-core/tests/integ_tests/workflow_tests/local_activities.rs +69 -197
  136. package/sdk-core/tests/integ_tests/workflow_tests/patches.rs +4 -28
  137. package/sdk-core/tests/integ_tests/workflow_tests/replay.rs +12 -7
  138. package/sdk-core/tests/integ_tests/workflow_tests/signals.rs +14 -14
  139. package/sdk-core/tests/integ_tests/workflow_tests/stickyness.rs +3 -19
  140. package/sdk-core/tests/integ_tests/workflow_tests/timers.rs +3 -19
  141. package/sdk-core/tests/integ_tests/workflow_tests/upsert_search_attrs.rs +1 -1
  142. package/sdk-core/tests/integ_tests/workflow_tests.rs +5 -6
  143. package/sdk-core/tests/main.rs +2 -12
  144. package/sdk-core/tests/runner.rs +71 -34
  145. package/sdk-core/tests/wf_input_replay.rs +32 -0
  146. package/sdk-core/bridge-ffi/Cargo.toml +0 -24
  147. package/sdk-core/bridge-ffi/LICENSE.txt +0 -23
  148. package/sdk-core/bridge-ffi/build.rs +0 -25
  149. package/sdk-core/bridge-ffi/include/sdk-core-bridge.h +0 -224
  150. package/sdk-core/bridge-ffi/src/lib.rs +0 -746
  151. package/sdk-core/bridge-ffi/src/wrappers.rs +0 -221
  152. package/sdk-core/protos/local/temporal/sdk/core/bridge/bridge.proto +0 -210
  153. package/sdk-core/sdk/src/conversions.rs +0 -8
@@ -0,0 +1,28 @@
1
+ name: Heavy Tests
2
+
3
+ on: # rebuild any PRs and main branch changes
4
+ pull_request:
5
+ push:
6
+ branches:
7
+ - master
8
+
9
+ jobs:
10
+ build-and-test:
11
+ runs-on: ubuntu-latest-16-cores
12
+ steps:
13
+ - uses: actions/checkout@v2
14
+ with:
15
+ submodules: recursive
16
+ - uses: actions-rs/toolchain@v1
17
+ with:
18
+ toolchain: stable
19
+ - name: Install protoc
20
+ uses: arduino/setup-protoc@v1
21
+ with:
22
+ version: '3.x'
23
+ repo-token: ${{ secrets.GITHUB_TOKEN }}
24
+
25
+ - uses: actions-rs/cargo@v1
26
+ with:
27
+ command: integ-test
28
+ args: -c "--release" -c "--all-features" -t heavy_tests -- --test-threads 1
@@ -1,2 +1,2 @@
1
1
  [workspace]
2
- members = ["bridge-ffi", "core", "client", "core-api", "fsm", "test-utils", "sdk-core-protos", "sdk"]
2
+ members = ["core", "client", "core-api", "fsm", "test-utils", "sdk-core-protos", "sdk"]
@@ -1,6 +1,13 @@
1
1
  [![Build status](https://badge.buildkite.com/c23f47f4a827f04daece909963bd3a248496f0cdbabfbecee4.svg?branch=master)](https://buildkite.com/temporal/core-sdk?branch=master)
2
2
 
3
- Core SDK that can be used as a base for all other Temporal SDKs.
3
+ Core SDK that can be used as a base for other Temporal SDKs. It is currently used as the base of:
4
+
5
+ - [TypeScript SDK](https://github.com/temporalio/sdk-typescript/)
6
+ - [Python SDK](https://github.com/temporalio/sdk-python/)
7
+
8
+ For the reasoning behind the Core SDK, see:
9
+
10
+ - [Why Rust powers Temporal’s new Core SDK](https://temporal.io/blog/why-rust-powers-core-sdk).
4
11
 
5
12
  # Getting started
6
13
 
@@ -17,7 +24,6 @@ This repo is composed of multiple crates:
17
24
  * temporal-sdk-core-api `./core-api` - Defines the API surface exposed by Core
18
25
  * temporal-sdk-core `./core` - The Core implementation
19
26
  * temporal-sdk `./sdk` - A (currently prototype) Rust SDK built on top of Core. Used for testing.
20
- * temporal-sdk-core-bridge-ffi `./bridge-ffi` - C API wrapper for Core
21
27
  * rustfsm `./fsm` - Implements a procedural macro used by core for defining state machines
22
28
  (contains subcrates). It is temporal agnostic.
23
29
 
@@ -52,9 +58,7 @@ it for a test, insert the below snippet at the start of the test. By default, tr
52
58
  to stdout in a (reasonably) pretty manner.
53
59
 
54
60
  ```rust
55
- crate::telemetry::telemetry_init(Default::default());
56
- let s = info_span!("Test start");
57
- let _enter = s.enter();
61
+ crate::telemetry::test_telem_console();
58
62
  ```
59
63
 
60
64
  The passed in options to initialization can be customized to export to an OTel collector, etc.
@@ -15,12 +15,14 @@ mod workflow_handle;
15
15
  pub use crate::retry::{CallType, RetryClient, RETRYABLE_ERROR_CODES};
16
16
  pub use raw::{HealthService, OperatorService, TestService, WorkflowService};
17
17
  pub use temporal_sdk_core_protos::temporal::api::{
18
+ enums::v1::ArchivalState,
18
19
  filter::v1::{StartTimeFilter, StatusFilter, WorkflowExecutionFilter, WorkflowTypeFilter},
19
20
  workflowservice::v1::{
20
21
  list_closed_workflow_executions_request::Filters as ListClosedFilters,
21
22
  list_open_workflow_executions_request::Filters as ListOpenFilters,
22
23
  },
23
24
  };
25
+ pub use tonic;
24
26
  pub use workflow_handle::{WorkflowExecutionInfo, WorkflowExecutionResult};
25
27
 
26
28
  use crate::{
@@ -51,6 +53,7 @@ use temporal_sdk_core_protos::{
51
53
  failure::v1::Failure,
52
54
  operatorservice::v1::operator_service_client::OperatorServiceClient,
53
55
  query::v1::WorkflowQuery,
56
+ replication::v1::ClusterReplicationConfig,
54
57
  taskqueue::v1::TaskQueue,
55
58
  testservice::v1::test_service_client::TestServiceClient,
56
59
  workflowservice::v1::{workflow_service_client::WorkflowServiceClient, *},
@@ -592,6 +595,133 @@ impl Namespace {
592
595
  }
593
596
  }
594
597
 
598
+ /// Default workflow execution retention for a Namespace is 3 days
599
+ pub const DEFAULT_WORKFLOW_EXECUTION_RETENTION_PERIOD: Duration =
600
+ Duration::from_secs(60 * 60 * 24 * 3);
601
+
602
+ /// Helper struct for `register_namespace`.
603
+ #[derive(Clone, derive_builder::Builder)]
604
+ pub struct RegisterNamespaceOptions {
605
+ /// Name (required)
606
+ #[builder(setter(into))]
607
+ pub namespace: String,
608
+ /// Description (required)
609
+ #[builder(setter(into))]
610
+ pub description: String,
611
+ /// Owner's email
612
+ #[builder(setter(into), default)]
613
+ pub owner_email: String,
614
+ /// Workflow execution retention period
615
+ #[builder(default = "DEFAULT_WORKFLOW_EXECUTION_RETENTION_PERIOD")]
616
+ pub workflow_execution_retention_period: Duration,
617
+ /// Cluster settings
618
+ #[builder(setter(strip_option, custom), default)]
619
+ pub clusters: Vec<ClusterReplicationConfig>,
620
+ /// Active cluster name
621
+ #[builder(setter(into), default)]
622
+ pub active_cluster_name: String,
623
+ /// Custom Data
624
+ #[builder(default)]
625
+ pub data: HashMap<String, String>,
626
+ /// Security Token
627
+ #[builder(setter(into), default)]
628
+ pub security_token: String,
629
+ /// Global namespace
630
+ #[builder(default)]
631
+ pub is_global_namespace: bool,
632
+ /// History Archival setting
633
+ #[builder(setter(into), default = "ArchivalState::Unspecified")]
634
+ pub history_archival_state: ArchivalState,
635
+ /// History Archival uri
636
+ #[builder(setter(into), default)]
637
+ pub history_archival_uri: String,
638
+ /// Visibility Archival setting
639
+ #[builder(setter(into), default = "ArchivalState::Unspecified")]
640
+ pub visibility_archival_state: ArchivalState,
641
+ /// Visibility Archival uri
642
+ #[builder(setter(into), default)]
643
+ pub visibility_archival_uri: String,
644
+ }
645
+
646
+ impl RegisterNamespaceOptions {
647
+ /// Builder convenience. Less `use` imports
648
+ pub fn builder() -> RegisterNamespaceOptionsBuilder {
649
+ Default::default()
650
+ }
651
+ }
652
+
653
+ impl From<RegisterNamespaceOptions> for RegisterNamespaceRequest {
654
+ fn from(val: RegisterNamespaceOptions) -> Self {
655
+ RegisterNamespaceRequest {
656
+ namespace: val.namespace,
657
+ description: val.description,
658
+ owner_email: val.owner_email,
659
+ workflow_execution_retention_period: val
660
+ .workflow_execution_retention_period
661
+ .try_into()
662
+ .ok(),
663
+ clusters: val.clusters,
664
+ active_cluster_name: val.active_cluster_name,
665
+ data: val.data,
666
+ security_token: val.security_token,
667
+ is_global_namespace: val.is_global_namespace,
668
+ history_archival_state: val.history_archival_state as i32,
669
+ history_archival_uri: val.history_archival_uri,
670
+ visibility_archival_state: val.visibility_archival_state as i32,
671
+ visibility_archival_uri: val.visibility_archival_uri,
672
+ }
673
+ }
674
+ }
675
+
676
+ impl RegisterNamespaceOptionsBuilder {
677
+ /// Custum builder function for convenience
678
+ /// Warning: setting cluster_names could blow away any previously set cluster configs
679
+ pub fn cluster_names(&mut self, clusters: Vec<String>) {
680
+ self.clusters = Some(
681
+ clusters
682
+ .into_iter()
683
+ .map(|s| ClusterReplicationConfig { cluster_name: s })
684
+ .collect(),
685
+ );
686
+ }
687
+ }
688
+
689
+ /// Helper struct for `signal_with_start_workflow_execution`.
690
+ #[derive(Clone, derive_builder::Builder)]
691
+ pub struct SignalWithStartOptions {
692
+ /// Input payload for the workflow run
693
+ #[builder(setter(strip_option), default)]
694
+ pub input: Option<Payloads>,
695
+ /// Task Queue to target (required)
696
+ #[builder(setter(into))]
697
+ pub task_queue: String,
698
+ /// Workflow id for the workflow run
699
+ #[builder(setter(into))]
700
+ pub workflow_id: String,
701
+ /// Workflow type for the workflow run
702
+ #[builder(setter(into))]
703
+ pub workflow_type: String,
704
+ #[builder(setter(strip_option), default)]
705
+ /// Request id for idempotency/deduplication
706
+ pub request_id: Option<String>,
707
+ /// The signal name to send (required)
708
+ #[builder(setter(into))]
709
+ pub signal_name: String,
710
+ /// Payloads for the signal
711
+ #[builder(default)]
712
+ pub signal_input: Option<Payloads>,
713
+ #[builder(setter(strip_option), default)]
714
+ /// Headers for the signal
715
+ pub signal_header: Option<Header>,
716
+ }
717
+
718
+ impl SignalWithStartOptions {
719
+ /// Builder convenience. Less `use` imports
720
+ pub fn builder() -> SignalWithStartOptionsBuilder {
721
+ Default::default()
722
+ }
723
+ }
724
+
595
725
  /// This trait provides higher-level friendlier interaction with the server.
596
726
  /// See the [WorkflowService] trait for a lower-level client.
597
727
  #[cfg_attr(test, mockall::automock)]
@@ -677,15 +807,8 @@ pub trait WorkflowClientTrait {
677
807
  #[allow(clippy::too_many_arguments)]
678
808
  async fn signal_with_start_workflow_execution(
679
809
  &self,
680
- input: Option<Payloads>,
681
- task_queue: String,
682
- workflow_id: String,
683
- workflow_type: String,
684
- request_id: Option<String>,
685
- options: WorkflowOptions,
686
- signal_name: String,
687
- signal_input: Option<Payloads>,
688
- signal_header: Option<Header>,
810
+ options: SignalWithStartOptions,
811
+ workflow_options: WorkflowOptions,
689
812
  ) -> Result<SignalWithStartWorkflowExecutionResponse>;
690
813
 
691
814
  /// Request a query of a certain workflow instance
@@ -734,13 +857,19 @@ pub trait WorkflowClientTrait {
734
857
  run_id: Option<String>,
735
858
  ) -> Result<TerminateWorkflowExecutionResponse>;
736
859
 
860
+ /// Register a new namespace
861
+ async fn register_namespace(
862
+ &self,
863
+ options: RegisterNamespaceOptions,
864
+ ) -> Result<RegisterNamespaceResponse>;
865
+
737
866
  /// Lists all available namespaces
738
867
  async fn list_namespaces(&self) -> Result<ListNamespacesResponse>;
739
868
 
740
869
  /// Query namespace details
741
870
  async fn describe_namespace(&self, namespace: Namespace) -> Result<DescribeNamespaceResponse>;
742
871
 
743
- /// List open workflows with Standard Visibility filtering
872
+ /// List open workflow executions with Standard Visibility filtering
744
873
  async fn list_open_workflow_executions(
745
874
  &self,
746
875
  max_page_size: i32,
@@ -749,7 +878,7 @@ pub trait WorkflowClientTrait {
749
878
  filters: Option<ListOpenFilters>,
750
879
  ) -> Result<ListOpenWorkflowExecutionsResponse>;
751
880
 
752
- /// List closed workflows Standard Visibility filtering
881
+ /// List closed workflow executions Standard Visibility filtering
753
882
  async fn list_closed_workflow_executions(
754
883
  &self,
755
884
  max_page_size: i32,
@@ -758,14 +887,25 @@ pub trait WorkflowClientTrait {
758
887
  filters: Option<ListClosedFilters>,
759
888
  ) -> Result<ListClosedWorkflowExecutionsResponse>;
760
889
 
761
- /// List workflows with Advanced Visibility filtering
890
+ /// List workflow executions with Advanced Visibility filtering
762
891
  async fn list_workflow_executions(
763
892
  &self,
764
- max_page_size: i32,
893
+ page_size: i32,
765
894
  next_page_token: Vec<u8>,
766
895
  query: String,
767
896
  ) -> Result<ListWorkflowExecutionsResponse>;
768
897
 
898
+ /// List archived workflow executions
899
+ async fn list_archived_workflow_executions(
900
+ &self,
901
+ page_size: i32,
902
+ next_page_token: Vec<u8>,
903
+ query: String,
904
+ ) -> Result<ListArchivedWorkflowExecutionsResponse>;
905
+
906
+ /// Get Cluster Search Attributes
907
+ async fn get_search_attributes(&self) -> Result<GetSearchAttributesResponse>;
908
+
769
909
  /// Returns options that were used to initialize the client
770
910
  fn get_options(&self) -> &ClientOptions;
771
911
 
@@ -973,42 +1113,43 @@ impl WorkflowClientTrait for Client {
973
1113
 
974
1114
  async fn signal_with_start_workflow_execution(
975
1115
  &self,
976
- input: Option<Payloads>,
977
- task_queue: String,
978
- workflow_id: String,
979
- workflow_type: String,
980
- request_id: Option<String>,
981
- options: WorkflowOptions,
982
- signal_name: String,
983
- signal_input: Option<Payloads>,
984
- signal_header: Option<Header>,
1116
+ options: SignalWithStartOptions,
1117
+ workflow_options: WorkflowOptions,
985
1118
  ) -> Result<SignalWithStartWorkflowExecutionResponse> {
986
1119
  Ok(self
987
1120
  .wf_svc()
988
1121
  .signal_with_start_workflow_execution(SignalWithStartWorkflowExecutionRequest {
989
1122
  namespace: self.namespace.clone(),
990
- workflow_id,
1123
+ workflow_id: options.workflow_id,
991
1124
  workflow_type: Some(WorkflowType {
992
- name: workflow_type,
1125
+ name: options.workflow_type,
993
1126
  }),
994
1127
  task_queue: Some(TaskQueue {
995
- name: task_queue,
1128
+ name: options.task_queue,
996
1129
  kind: TaskQueueKind::Normal as i32,
997
1130
  }),
998
- input,
999
- signal_name,
1000
- signal_input,
1131
+ input: options.input,
1132
+ signal_name: options.signal_name,
1133
+ signal_input: options.signal_input,
1001
1134
  identity: self.inner.options.identity.clone(),
1002
- request_id: request_id.unwrap_or_else(|| Uuid::new_v4().to_string()),
1003
- workflow_id_reuse_policy: options.id_reuse_policy as i32,
1004
- workflow_execution_timeout: options
1135
+ request_id: options
1136
+ .request_id
1137
+ .unwrap_or_else(|| Uuid::new_v4().to_string()),
1138
+ workflow_id_reuse_policy: workflow_options.id_reuse_policy as i32,
1139
+ workflow_execution_timeout: workflow_options
1005
1140
  .execution_timeout
1006
1141
  .and_then(|d| d.try_into().ok()),
1007
- workflow_run_timeout: options.execution_timeout.and_then(|d| d.try_into().ok()),
1008
- workflow_task_timeout: options.task_timeout.and_then(|d| d.try_into().ok()),
1009
- search_attributes: options.search_attributes.and_then(|d| d.try_into().ok()),
1010
- cron_schedule: options.cron_schedule.unwrap_or_default(),
1011
- header: signal_header,
1142
+ workflow_run_timeout: workflow_options
1143
+ .execution_timeout
1144
+ .and_then(|d| d.try_into().ok()),
1145
+ workflow_task_timeout: workflow_options
1146
+ .task_timeout
1147
+ .and_then(|d| d.try_into().ok()),
1148
+ search_attributes: workflow_options
1149
+ .search_attributes
1150
+ .and_then(|d| d.try_into().ok()),
1151
+ cron_schedule: workflow_options.cron_schedule.unwrap_or_default(),
1152
+ header: options.signal_header,
1012
1153
  ..Default::default()
1013
1154
  })
1014
1155
  .await?
@@ -1140,6 +1281,14 @@ impl WorkflowClientTrait for Client {
1140
1281
  .into_inner())
1141
1282
  }
1142
1283
 
1284
+ async fn register_namespace(
1285
+ &self,
1286
+ options: RegisterNamespaceOptions,
1287
+ ) -> Result<RegisterNamespaceResponse> {
1288
+ let req = Into::<RegisterNamespaceRequest>::into(options);
1289
+ Ok(self.wf_svc().register_namespace(req).await?.into_inner())
1290
+ }
1291
+
1143
1292
  async fn list_namespaces(&self) -> Result<ListNamespacesResponse> {
1144
1293
  Ok(self
1145
1294
  .wf_svc()
@@ -1214,6 +1363,32 @@ impl WorkflowClientTrait for Client {
1214
1363
  .into_inner())
1215
1364
  }
1216
1365
 
1366
+ async fn list_archived_workflow_executions(
1367
+ &self,
1368
+ page_size: i32,
1369
+ next_page_token: Vec<u8>,
1370
+ query: String,
1371
+ ) -> Result<ListArchivedWorkflowExecutionsResponse> {
1372
+ Ok(self
1373
+ .wf_svc()
1374
+ .list_archived_workflow_executions(ListArchivedWorkflowExecutionsRequest {
1375
+ namespace: self.namespace.clone(),
1376
+ page_size,
1377
+ next_page_token,
1378
+ query,
1379
+ })
1380
+ .await?
1381
+ .into_inner())
1382
+ }
1383
+
1384
+ async fn get_search_attributes(&self) -> Result<GetSearchAttributesResponse> {
1385
+ Ok(self
1386
+ .wf_svc()
1387
+ .get_search_attributes(GetSearchAttributesRequest {})
1388
+ .await?
1389
+ .into_inner())
1390
+ }
1391
+
1217
1392
  fn get_options(&self) -> &ClientOptions {
1218
1393
  &self.inner.options
1219
1394
  }
@@ -898,7 +898,7 @@ mod tests {
898
898
  let no_underscores: HashSet<_> = impl_list.iter().map(|x| x.replace('_', "")).collect();
899
899
  for method in methods {
900
900
  if !no_underscores.contains(&method.to_lowercase()) {
901
- panic!("RPC method {} is not implemented by raw client", method)
901
+ panic!("RPC method {method} is not implemented by raw client")
902
902
  }
903
903
  }
904
904
  }
@@ -1,6 +1,6 @@
1
1
  use crate::{
2
- ClientOptions, ListClosedFilters, ListOpenFilters, Namespace, Result, RetryConfig,
3
- StartTimeFilter, WorkflowClientTrait, WorkflowOptions,
2
+ ClientOptions, ListClosedFilters, ListOpenFilters, Namespace, RegisterNamespaceOptions, Result,
3
+ RetryConfig, SignalWithStartOptions, StartTimeFilter, WorkflowClientTrait, WorkflowOptions,
4
4
  };
5
5
  use backoff::{backoff::Backoff, exponential::ExponentialBackoff, Clock, SystemClock};
6
6
  use futures_retry::{ErrorHandler, FutureRetry, RetryPolicy};
@@ -8,7 +8,7 @@ use std::{fmt::Debug, future::Future, sync::Arc, time::Duration};
8
8
  use temporal_sdk_core_protos::{
9
9
  coresdk::workflow_commands::QueryResult,
10
10
  temporal::api::{
11
- common::v1::{Header, Payload, Payloads},
11
+ common::v1::{Payload, Payloads},
12
12
  enums::v1::WorkflowTaskFailedCause,
13
13
  failure::v1::Failure,
14
14
  query::v1::WorkflowQuery,
@@ -362,28 +362,14 @@ where
362
362
 
363
363
  async fn signal_with_start_workflow_execution(
364
364
  &self,
365
- input: Option<Payloads>,
366
- task_queue: String,
367
- workflow_id: String,
368
- workflow_type: String,
369
- request_id: Option<String>,
370
- options: WorkflowOptions,
371
- signal_name: String,
372
- signal_input: Option<Payloads>,
373
- signal_header: Option<Header>,
365
+ options: SignalWithStartOptions,
366
+ workflow_options: WorkflowOptions,
374
367
  ) -> Result<SignalWithStartWorkflowExecutionResponse> {
375
368
  retry_call!(
376
369
  self,
377
370
  signal_with_start_workflow_execution,
378
- input.clone(),
379
- task_queue.clone(),
380
- workflow_id.clone(),
381
- workflow_type.clone(),
382
- request_id.clone(),
383
371
  options.clone(),
384
- signal_name.clone(),
385
- signal_input.clone(),
386
- signal_header.clone()
372
+ workflow_options.clone()
387
373
  )
388
374
  }
389
375
 
@@ -473,6 +459,13 @@ where
473
459
  )
474
460
  }
475
461
 
462
+ async fn register_namespace(
463
+ &self,
464
+ options: RegisterNamespaceOptions,
465
+ ) -> Result<RegisterNamespaceResponse> {
466
+ retry_call!(self, register_namespace, options.clone())
467
+ }
468
+
476
469
  async fn list_namespaces(&self) -> Result<ListNamespacesResponse> {
477
470
  retry_call!(self, list_namespaces,)
478
471
  }
@@ -530,6 +523,25 @@ where
530
523
  )
531
524
  }
532
525
 
526
+ async fn list_archived_workflow_executions(
527
+ &self,
528
+ page_size: i32,
529
+ next_page_token: Vec<u8>,
530
+ query: String,
531
+ ) -> Result<ListArchivedWorkflowExecutionsResponse> {
532
+ retry_call!(
533
+ self,
534
+ list_archived_workflow_executions,
535
+ page_size,
536
+ next_page_token.clone(),
537
+ query.clone()
538
+ )
539
+ }
540
+
541
+ async fn get_search_attributes(&self) -> Result<GetSearchAttributesResponse> {
542
+ retry_call!(self, get_search_attributes)
543
+ }
544
+
533
545
  fn get_options(&self) -> &ClientOptions {
534
546
  self.client.get_options()
535
547
  }
@@ -12,12 +12,18 @@ categories = ["development-tools"]
12
12
 
13
13
  [lib]
14
14
 
15
+ [features]
16
+ # Do not enable this feature when building production SDKs. If we ever want a user in the field to
17
+ # record WF input data, we can build them a custom SDK or they can build - it adds significant extra
18
+ # code size in the form of [de]serializers.
19
+ save_wf_inputs = ["rmp-serde", "temporal-sdk-core-protos/serde_serialize"]
20
+
15
21
  [dependencies]
16
22
  anyhow = "1.0"
17
23
  arc-swap = "1.3"
18
24
  async-channel = "1.6"
19
25
  async-trait = "0.1"
20
- base64 = "0.13"
26
+ base64 = "0.21"
21
27
  crossbeam = "0.8"
22
28
  dashmap = "5.0"
23
29
  derive_builder = "0.12"
@@ -31,8 +37,7 @@ http = "0.2"
31
37
  hyper = "0.14"
32
38
  itertools = "0.10"
33
39
  lazy_static = "1.4"
34
- log = "0.4"
35
- lru = "0.8"
40
+ lru = "0.9"
36
41
  mockall = "0.11"
37
42
  nix = "0.26"
38
43
  once_cell = "1.5"
@@ -40,12 +45,14 @@ opentelemetry = { version = "0.18", features = ["rt-tokio"] }
40
45
  opentelemetry-otlp = { version = "0.11", features = ["tokio", "metrics"] }
41
46
  opentelemetry-prometheus = "0.11"
42
47
  parking_lot = { version = "0.12", features = ["send_guard"] }
48
+ pin-project = "1.0"
43
49
  prometheus = "0.13"
44
50
  prost = "0.11"
45
- prost-types = "0.11"
51
+ prost-types = { version = "0.4", package = "prost-wkt-types" }
46
52
  rand = "0.8.3"
47
53
  reqwest = { version = "0.11", features = ["json", "stream", "rustls-tls", "tokio-rustls"], default-features = false }
48
54
  ringbuf = "0.3"
55
+ rmp-serde = { version = "1.1", optional = true }
49
56
  serde = "1.0"
50
57
  serde_json = "1.0"
51
58
  siphasher = "0.3"
@@ -56,13 +63,13 @@ tokio = { version = "1.1", features = ["rt", "rt-multi-thread", "parking_lot", "
56
63
  tokio-util = { version = "0.7", features = ["io", "io-util"] }
57
64
  tokio-stream = "0.1"
58
65
  tonic = { version = "0.8", features = ["tls", "tls-roots"] }
59
- tracing = { version = "0.1", features = ["log-always"] }
66
+ tracing = "0.1"
60
67
  tracing-futures = "0.2"
61
68
  tracing-opentelemetry = "0.18"
62
69
  tracing-subscriber = { version = "0.3", features = ["parking_lot", "env-filter", "registry"] }
63
70
  url = "2.2"
64
71
  uuid = { version = "1.1", features = ["v4"] }
65
- zip = "0.6"
72
+ zip = "0.6.3"
66
73
 
67
74
  # 1st party local deps
68
75
  [dependencies.temporal-sdk-core-api]
@@ -85,6 +92,7 @@ version = "0.1"
85
92
  [dev-dependencies]
86
93
  assert_matches = "1.4"
87
94
  bimap = "0.6.1"
95
+ clap = { version = "4.0", features = ["derive"] }
88
96
  criterion = "0.4"
89
97
  rstest = "0.16"
90
98
  temporal-sdk-core-test-utils = { path = "../test-utils" }
@@ -101,9 +109,10 @@ path = "../tests/main.rs"
101
109
  test = false
102
110
 
103
111
  [[test]]
104
- name = "load_tests"
105
- path = "../tests/load_tests.rs"
112
+ name = "heavy_tests"
113
+ path = "../tests/heavy_tests.rs"
106
114
  test = false
115
+ required-features = ["save_wf_inputs"]
107
116
 
108
117
  [[bench]]
109
118
  name = "workflow_replay"
@@ -113,4 +122,9 @@ harness = false
113
122
  # the dev-dependencies, which we want.
114
123
  [[example]]
115
124
  name = "integ_runner"
116
- path = "../tests/runner.rs"
125
+ path = "../tests/runner.rs"
126
+
127
+ [[example]]
128
+ name = "wf_input_replay"
129
+ path = "../tests/wf_input_replay.rs"
130
+ required-features = ["save_wf_inputs"]
@@ -79,6 +79,17 @@ impl Debug for OwnedMeteredSemPermit {
79
79
  self.inner.fmt(f)
80
80
  }
81
81
  }
82
+ #[cfg(feature = "save_wf_inputs")]
83
+ impl OwnedMeteredSemPermit {
84
+ pub(crate) fn fake_deserialized() -> Self {
85
+ let sem = Arc::new(Semaphore::new(1));
86
+ let inner = sem.try_acquire_owned().unwrap();
87
+ Self {
88
+ inner,
89
+ record_fn: Box::new(|| {}),
90
+ }
91
+ }
92
+ }
82
93
 
83
94
  /// From the input stream, create a new stream which only pulls from the input stream when allowed.
84
95
  /// When allowed is determined by the passed in `proceeder` emitting an item. The input stream is
@@ -24,7 +24,6 @@ use std::{
24
24
  use temporal_client::WorkflowOptions;
25
25
  use temporal_sdk::{ActivityOptions, WfContext};
26
26
  use temporal_sdk_core_api::{errors::CompleteActivityError, Worker as WorkerTrait};
27
- use temporal_sdk_core_protos::temporal::api::command::v1::ScheduleActivityTaskCommandAttributes;
28
27
  use temporal_sdk_core_protos::{
29
28
  coresdk::{
30
29
  activity_result::{
@@ -41,7 +40,7 @@ use temporal_sdk_core_protos::{
41
40
  ActivityTaskCompletion,
42
41
  },
43
42
  temporal::api::{
44
- command::v1::command::Attributes,
43
+ command::v1::{command::Attributes, ScheduleActivityTaskCommandAttributes},
45
44
  enums::v1::EventType,
46
45
  workflowservice::v1::{
47
46
  PollActivityTaskQueueResponse, RecordActivityTaskHeartbeatResponse,
@@ -654,6 +653,7 @@ async fn no_eager_activities_requested_when_worker_options_disable_remote_activi
654
653
  Ok(RespondWorkflowTaskCompletedResponse {
655
654
  workflow_task: None,
656
655
  activity_tasks: vec![],
656
+ reset_history_event_id: 0,
657
657
  })
658
658
  });
659
659
  let mut mock = single_hist_mock_sg(wfid, t, [1], mock, true);
@@ -703,7 +703,7 @@ async fn activity_tasks_from_completion_are_delivered() {
703
703
  t.add_by_type(EventType::WorkflowExecutionStarted);
704
704
  t.add_full_wf_task();
705
705
  let act_same_queue_scheduled_ids = (1..4)
706
- .map(|i| t.add_activity_task_scheduled(format!("act_id_{}_same_queue", i)))
706
+ .map(|i| t.add_activity_task_scheduled(format!("act_id_{i}_same_queue")))
707
707
  .collect_vec();
708
708
  t.add_activity_task_scheduled("act_id_same_queue_not_eager");
709
709
  t.add_activity_task_scheduled("act_id_different_queue");
@@ -742,10 +742,11 @@ async fn activity_tasks_from_completion_are_delivered() {
742
742
  activity_tasks: (1..4)
743
743
  .map(|i| PollActivityTaskQueueResponse {
744
744
  task_token: vec![i],
745
- activity_id: format!("act_id_{}_same_queue", i),
745
+ activity_id: format!("act_id_{i}_same_queue"),
746
746
  ..Default::default()
747
747
  })
748
748
  .collect_vec(),
749
+ reset_history_event_id: 0,
749
750
  })
750
751
  });
751
752
  mock.expect_complete_activity_task()
@@ -766,7 +767,7 @@ async fn activity_tasks_from_completion_are_delivered() {
766
767
  .map(|seq| {
767
768
  ScheduleActivity {
768
769
  seq,
769
- activity_id: format!("act_id_{}_same_queue", seq),
770
+ activity_id: format!("act_id_{seq}_same_queue"),
770
771
  task_queue: TEST_Q.to_string(),
771
772
  cancellation_type: ActivityCancellationType::TryCancel as i32,
772
773
  ..Default::default()