@temporalio/core-bridge 0.19.2 → 0.20.2

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 (125) 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 +257 -242
  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 +95 -23
  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 +207 -108
  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/concurrency_manager.rs +70 -11
  63. package/sdk-core/core/src/workflow/workflow_tasks/mod.rs +65 -41
  64. package/sdk-core/core-api/Cargo.toml +9 -1
  65. package/sdk-core/core-api/LICENSE.txt +23 -0
  66. package/sdk-core/core-api/src/errors.rs +7 -38
  67. package/sdk-core/core-api/src/lib.rs +44 -52
  68. package/sdk-core/core-api/src/worker.rs +10 -2
  69. package/sdk-core/etc/deps.svg +127 -96
  70. package/sdk-core/protos/api_upstream/temporal/api/command/v1/message.proto +11 -7
  71. package/sdk-core/protos/api_upstream/temporal/api/enums/v1/failed_cause.proto +10 -0
  72. package/sdk-core/protos/api_upstream/temporal/api/enums/v1/namespace.proto +6 -1
  73. package/sdk-core/protos/api_upstream/temporal/api/enums/v1/workflow.proto +6 -0
  74. package/sdk-core/protos/api_upstream/temporal/api/errordetails/v1/message.proto +6 -0
  75. package/sdk-core/protos/api_upstream/temporal/api/history/v1/message.proto +2 -1
  76. package/sdk-core/protos/api_upstream/temporal/api/replication/v1/message.proto +3 -0
  77. package/sdk-core/protos/api_upstream/temporal/api/workflow/v1/message.proto +12 -0
  78. package/sdk-core/protos/api_upstream/temporal/api/workflowservice/v1/request_response.proto +25 -0
  79. package/sdk-core/protos/api_upstream/temporal/api/workflowservice/v1/service.proto +4 -0
  80. package/sdk-core/protos/local/temporal/sdk/core/bridge/bridge.proto +19 -35
  81. package/sdk-core/protos/local/temporal/sdk/core/core_interface.proto +2 -6
  82. package/sdk-core/protos/local/temporal/sdk/core/workflow_activation/workflow_activation.proto +53 -11
  83. package/sdk-core/protos/local/temporal/sdk/core/workflow_commands/workflow_commands.proto +14 -7
  84. package/sdk-core/protos/local/temporal/sdk/core/workflow_completion/workflow_completion.proto +3 -5
  85. package/sdk-core/sdk/Cargo.toml +16 -2
  86. package/sdk-core/sdk/LICENSE.txt +23 -0
  87. package/sdk-core/sdk/src/interceptors.rs +11 -0
  88. package/sdk-core/sdk/src/lib.rs +139 -151
  89. package/sdk-core/sdk/src/workflow_context/options.rs +86 -1
  90. package/sdk-core/sdk/src/workflow_context.rs +36 -17
  91. package/sdk-core/sdk/src/workflow_future.rs +19 -25
  92. package/sdk-core/sdk-core-protos/Cargo.toml +1 -1
  93. package/sdk-core/sdk-core-protos/build.rs +1 -0
  94. package/sdk-core/sdk-core-protos/src/history_info.rs +17 -4
  95. package/sdk-core/sdk-core-protos/src/lib.rs +251 -47
  96. package/sdk-core/test-utils/Cargo.toml +3 -1
  97. package/sdk-core/test-utils/src/canned_histories.rs +27 -0
  98. package/sdk-core/test-utils/src/histfetch.rs +3 -3
  99. package/sdk-core/test-utils/src/lib.rs +223 -68
  100. package/sdk-core/tests/integ_tests/client_tests.rs +27 -4
  101. package/sdk-core/tests/integ_tests/heartbeat_tests.rs +93 -14
  102. package/sdk-core/tests/integ_tests/polling_tests.rs +18 -12
  103. package/sdk-core/tests/integ_tests/queries_tests.rs +50 -53
  104. package/sdk-core/tests/integ_tests/workflow_tests/activities.rs +117 -103
  105. package/sdk-core/tests/integ_tests/workflow_tests/cancel_external.rs +8 -1
  106. package/sdk-core/tests/integ_tests/workflow_tests/cancel_wf.rs +10 -5
  107. package/sdk-core/tests/integ_tests/workflow_tests/child_workflows.rs +7 -1
  108. package/sdk-core/tests/integ_tests/workflow_tests/continue_as_new.rs +32 -9
  109. package/sdk-core/tests/integ_tests/workflow_tests/determinism.rs +7 -1
  110. package/sdk-core/tests/integ_tests/workflow_tests/local_activities.rs +76 -15
  111. package/sdk-core/tests/integ_tests/workflow_tests/patches.rs +19 -3
  112. package/sdk-core/tests/integ_tests/workflow_tests/replay.rs +39 -42
  113. package/sdk-core/tests/integ_tests/workflow_tests/resets.rs +84 -0
  114. package/sdk-core/tests/integ_tests/workflow_tests/signals.rs +30 -8
  115. package/sdk-core/tests/integ_tests/workflow_tests/stickyness.rs +21 -6
  116. package/sdk-core/tests/integ_tests/workflow_tests/timers.rs +26 -16
  117. package/sdk-core/tests/integ_tests/workflow_tests/upsert_search_attrs.rs +66 -0
  118. package/sdk-core/tests/integ_tests/workflow_tests.rs +78 -74
  119. package/sdk-core/tests/load_tests.rs +9 -6
  120. package/sdk-core/tests/main.rs +43 -10
  121. package/src/conversions.rs +7 -12
  122. package/src/lib.rs +322 -357
  123. package/sdk-core/client/src/mocks.rs +0 -167
  124. package/sdk-core/core/src/worker/dispatcher.rs +0 -171
  125. package/sdk-core/protos/local/temporal/sdk/core/bridge/service.proto +0 -61
@@ -45,6 +45,8 @@ pub mod coresdk {
45
45
 
46
46
  #[allow(clippy::module_inception)]
47
47
  pub mod activity_task {
48
+ use crate::{coresdk::ActivityTaskCompletion, task_token::fmt_tt};
49
+ use std::fmt::{Display, Formatter};
48
50
  tonic::include_proto!("coresdk.activity_task");
49
51
 
50
52
  impl ActivityTask {
@@ -57,6 +59,22 @@ pub mod coresdk {
57
59
  }
58
60
  }
59
61
  }
62
+
63
+ impl Display for ActivityTaskCompletion {
64
+ fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
65
+ write!(
66
+ f,
67
+ "ActivityTaskCompletion(token: {}",
68
+ fmt_tt(&self.task_token),
69
+ )?;
70
+ if let Some(r) = self.result.as_ref() {
71
+ write!(f, ", {}", r)?;
72
+ } else {
73
+ write!(f, ", missing result")?;
74
+ }
75
+ write!(f, ")")
76
+ }
77
+ }
60
78
  }
61
79
  #[allow(clippy::module_inception)]
62
80
  pub mod activity_result {
@@ -70,6 +88,7 @@ pub mod coresdk {
70
88
  };
71
89
  use crate::temporal::api::{enums::v1::TimeoutType, failure::v1::TimeoutFailureInfo};
72
90
  use activity_execution_result as aer;
91
+ use std::fmt::{Display, Formatter};
73
92
 
74
93
  impl ActivityExecutionResult {
75
94
  pub const fn ok(result: Payload) -> Self {
@@ -105,6 +124,57 @@ pub mod coresdk {
105
124
  }
106
125
  }
107
126
 
127
+ impl Display for ActivityExecutionResult {
128
+ fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
129
+ write!(f, "ActivityExecutionResult(")?;
130
+ match self.status.as_ref() {
131
+ None => write!(f, "missing result)"),
132
+ Some(aer::Status::Completed(v)) => {
133
+ write!(f, "{})", v)
134
+ }
135
+ Some(aer::Status::Failed(v)) => {
136
+ write!(f, "{})", v)
137
+ }
138
+ Some(aer::Status::Cancelled(v)) => {
139
+ write!(f, "{})", v)
140
+ }
141
+ Some(aer::Status::WillCompleteAsync(_)) => {
142
+ write!(f, "Will complete async)")
143
+ }
144
+ }
145
+ }
146
+ }
147
+
148
+ impl Display for Success {
149
+ fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
150
+ write!(f, "Success(")?;
151
+ if let Some(ref v) = self.result {
152
+ write!(f, "{}", v)?;
153
+ }
154
+ write!(f, ")")
155
+ }
156
+ }
157
+
158
+ impl Display for Failure {
159
+ fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
160
+ write!(f, "Failure(")?;
161
+ if let Some(ref v) = self.failure {
162
+ write!(f, "{}", v)?;
163
+ }
164
+ write!(f, ")")
165
+ }
166
+ }
167
+
168
+ impl Display for Cancellation {
169
+ fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
170
+ write!(f, "Cancellation(")?;
171
+ if let Some(ref v) = self.failure {
172
+ write!(f, "{}", v)?;
173
+ }
174
+ write!(f, ")")
175
+ }
176
+ }
177
+
108
178
  impl From<Result<APIPayload, APIFailure>> for ActivityExecutionResult {
109
179
  fn from(r: Result<APIPayload, APIFailure>) -> Self {
110
180
  Self {
@@ -190,15 +260,22 @@ pub mod coresdk {
190
260
  coresdk::{AsJsonPayloadExt, IntoPayloadsExt},
191
261
  temporal::api::common::v1::{Payload as ApiPayload, Payloads},
192
262
  };
193
- use std::collections::HashMap;
263
+ use std::{
264
+ collections::HashMap,
265
+ fmt::{Display, Formatter},
266
+ };
194
267
 
195
268
  impl<T> From<T> for Payload
196
269
  where
197
270
  T: AsRef<[u8]>,
198
271
  {
199
272
  fn from(v: T) -> Self {
273
+ // TODO: Set better encodings, whole data converter deal. Setting anything for now
274
+ // at least makes it show up in the web UI.
275
+ let mut metadata = HashMap::new();
276
+ metadata.insert("encoding".to_string(), b"binary/plain".to_vec());
200
277
  Self {
201
- metadata: Default::default(),
278
+ metadata,
202
279
  data: v.as_ref().to_vec(),
203
280
  }
204
281
  }
@@ -211,6 +288,22 @@ pub mod coresdk {
211
288
  }
212
289
  }
213
290
 
291
+ impl Display for Payload {
292
+ fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
293
+ if self.data.len() > 64 {
294
+ let mut windows = self.data.as_slice().windows(32);
295
+ write!(
296
+ f,
297
+ "[{}..{}]",
298
+ base64::encode(windows.next().unwrap_or_default()),
299
+ base64::encode(windows.next_back().unwrap_or_default())
300
+ )
301
+ } else {
302
+ write!(f, "[{}]", base64::encode(&self.data))
303
+ }
304
+ }
305
+ }
306
+
214
307
  pub fn build_has_change_marker_details(
215
308
  patch_id: &str,
216
309
  deprecated: bool,
@@ -344,13 +437,25 @@ pub mod coresdk {
344
437
 
345
438
  pub mod workflow_activation {
346
439
  use crate::{
347
- coresdk::{workflow_activation::remove_from_cache::EvictionReason, FromPayloadsExt},
348
- temporal::api::history::v1::{
349
- WorkflowExecutionCancelRequestedEventAttributes,
350
- WorkflowExecutionSignaledEventAttributes,
440
+ coresdk::{
441
+ common::{NamespacedWorkflowExecution, Payload},
442
+ workflow_activation::remove_from_cache::EvictionReason,
443
+ FromPayloadsExt,
444
+ },
445
+ temporal::api::{
446
+ common::v1::Header,
447
+ history::v1::{
448
+ WorkflowExecutionCancelRequestedEventAttributes,
449
+ WorkflowExecutionSignaledEventAttributes,
450
+ WorkflowExecutionStartedEventAttributes,
451
+ },
452
+ query::v1::WorkflowQuery,
351
453
  },
352
454
  };
353
- use std::fmt::{Display, Formatter};
455
+ use std::{
456
+ collections::HashMap,
457
+ fmt::{Display, Formatter},
458
+ };
354
459
 
355
460
  tonic::include_proto!("coresdk.workflow_activation");
356
461
 
@@ -387,6 +492,15 @@ pub mod coresdk {
387
492
  }
388
493
  }
389
494
 
495
+ pub fn query_to_job(id: String, q: WorkflowQuery) -> QueryWorkflow {
496
+ QueryWorkflow {
497
+ query_id: id,
498
+ query_type: q.query_type,
499
+ arguments: Vec::from_payloads(q.query_args),
500
+ headers: q.header.map(|h| h.into()).unwrap_or_default(),
501
+ }
502
+ }
503
+
390
504
  impl WorkflowActivation {
391
505
  /// Returns the index of the eviction job if this activation contains one. If present
392
506
  /// it should always be the last job in the list.
@@ -515,12 +629,23 @@ pub mod coresdk {
515
629
  }
516
630
  }
517
631
 
632
+ impl Display for QueryWorkflow {
633
+ fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
634
+ write!(
635
+ f,
636
+ "QueryWorkflow(id: {}, type: {})",
637
+ self.query_id, self.query_type
638
+ )
639
+ }
640
+ }
641
+
518
642
  impl From<WorkflowExecutionSignaledEventAttributes> for SignalWorkflow {
519
643
  fn from(a: WorkflowExecutionSignaledEventAttributes) -> Self {
520
644
  Self {
521
645
  signal_name: a.signal_name,
522
646
  input: Vec::from_payloads(a.input),
523
647
  identity: a.identity,
648
+ headers: a.header.map(Into::into).unwrap_or_default(),
524
649
  }
525
650
  }
526
651
  }
@@ -530,6 +655,50 @@ pub mod coresdk {
530
655
  Self { details: vec![] }
531
656
  }
532
657
  }
658
+
659
+ /// Create a [StartWorkflow] job from corresponding event attributes
660
+ pub fn start_workflow_from_attribs(
661
+ attrs: WorkflowExecutionStartedEventAttributes,
662
+ workflow_id: String,
663
+ randomness_seed: u64,
664
+ ) -> StartWorkflow {
665
+ StartWorkflow {
666
+ workflow_type: attrs.workflow_type.map(|wt| wt.name).unwrap_or_default(),
667
+ workflow_id,
668
+ arguments: Vec::from_payloads(attrs.input),
669
+ randomness_seed,
670
+ headers: match attrs.header {
671
+ None => HashMap::new(),
672
+ Some(Header { fields }) => fields
673
+ .into_iter()
674
+ .map(|(k, v)| (k, Payload::from(v)))
675
+ .collect(),
676
+ },
677
+ identity: attrs.identity,
678
+ parent_workflow_info: attrs.parent_workflow_execution.map(|pe| {
679
+ NamespacedWorkflowExecution {
680
+ namespace: attrs.parent_workflow_namespace,
681
+ run_id: pe.run_id,
682
+ workflow_id: pe.workflow_id,
683
+ }
684
+ }),
685
+ workflow_execution_timeout: attrs.workflow_execution_timeout,
686
+ workflow_run_timeout: attrs.workflow_run_timeout,
687
+ workflow_task_timeout: attrs.workflow_task_timeout,
688
+ continued_from_execution_run_id: attrs.continued_execution_run_id,
689
+ continued_initiator: attrs.initiator,
690
+ continued_failure: attrs.continued_failure,
691
+ last_completion_result: attrs.last_completion_result,
692
+ first_execution_run_id: attrs.first_execution_run_id,
693
+ retry_policy: attrs.retry_policy,
694
+ attempt: attrs.attempt,
695
+ cron_schedule: attrs.cron_schedule,
696
+ workflow_execution_expiration_time: attrs.workflow_execution_expiration_time,
697
+ cron_schedule_to_schedule_interval: attrs.first_workflow_task_backoff,
698
+ memo: attrs.memo,
699
+ search_attributes: attrs.search_attributes,
700
+ }
701
+ }
533
702
  }
534
703
 
535
704
  pub mod workflow_completion {
@@ -663,6 +832,12 @@ pub mod coresdk {
663
832
  }
664
833
  }
665
834
 
835
+ impl Display for UpsertWorkflowSearchAttributes {
836
+ fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
837
+ write!(f, "UpsertWorkflowSearchAttributes({})", self.seq) // todo: customize this better
838
+ }
839
+ }
840
+
666
841
  impl Display for SignalExternalWorkflowExecution {
667
842
  fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
668
843
  write!(f, "SignalExternalWorkflowExecution({})", self.seq)
@@ -748,51 +923,35 @@ pub mod coresdk {
748
923
 
749
924
  impl WorkflowActivationCompletion {
750
925
  /// Create a successful activation with no commands in it
751
- pub fn empty(task_queue: impl Into<String>, run_id: impl Into<String>) -> Self {
926
+ pub fn empty(run_id: impl Into<String>) -> Self {
752
927
  let success = workflow_completion::Success::from_variants(vec![]);
753
928
  Self {
754
929
  run_id: run_id.into(),
755
- task_queue: task_queue.into(),
756
930
  status: Some(workflow_activation_completion::Status::Successful(success)),
757
931
  }
758
932
  }
759
933
 
760
934
  /// Create a successful activation from a list of commands
761
- pub fn from_cmds(
762
- task_q: impl Into<String>,
763
- run_id: impl Into<String>,
764
- cmds: Vec<workflow_command::Variant>,
765
- ) -> Self {
935
+ pub fn from_cmds(run_id: impl Into<String>, cmds: Vec<workflow_command::Variant>) -> Self {
766
936
  let success = workflow_completion::Success::from_variants(cmds);
767
937
  Self {
768
938
  run_id: run_id.into(),
769
- task_queue: task_q.into(),
770
939
  status: Some(workflow_activation_completion::Status::Successful(success)),
771
940
  }
772
941
  }
773
942
 
774
943
  /// Create a successful activation from just one command
775
- pub fn from_cmd(
776
- task_q: impl Into<String>,
777
- run_id: impl Into<String>,
778
- cmd: workflow_command::Variant,
779
- ) -> Self {
944
+ pub fn from_cmd(run_id: impl Into<String>, cmd: workflow_command::Variant) -> Self {
780
945
  let success = workflow_completion::Success::from_variants(vec![cmd]);
781
946
  Self {
782
947
  run_id: run_id.into(),
783
- task_queue: task_q.into(),
784
948
  status: Some(workflow_activation_completion::Status::Successful(success)),
785
949
  }
786
950
  }
787
951
 
788
- pub fn fail(
789
- task_q: impl Into<String>,
790
- run_id: impl Into<String>,
791
- failure: Failure,
792
- ) -> Self {
952
+ pub fn fail(run_id: impl Into<String>, failure: Failure) -> Self {
793
953
  Self {
794
954
  run_id: run_id.into(),
795
- task_queue: task_q.into(),
796
955
  status: Some(workflow_activation_completion::Status::Failed(
797
956
  workflow_completion::Failure {
798
957
  failure: Some(failure),
@@ -876,20 +1035,12 @@ pub mod coresdk {
876
1035
  /// Makes converting outgoing lang commands into [WorkflowActivationCompletion]s easier
877
1036
  pub trait IntoCompletion {
878
1037
  /// The conversion function
879
- fn into_completion(
880
- self,
881
- task_queue: String,
882
- run_id: String,
883
- ) -> WorkflowActivationCompletion;
1038
+ fn into_completion(self, run_id: String) -> WorkflowActivationCompletion;
884
1039
  }
885
1040
 
886
1041
  impl IntoCompletion for workflow_command::Variant {
887
- fn into_completion(
888
- self,
889
- task_queue: String,
890
- run_id: String,
891
- ) -> WorkflowActivationCompletion {
892
- WorkflowActivationCompletion::from_cmd(task_queue, run_id, self)
1042
+ fn into_completion(self, run_id: String) -> WorkflowActivationCompletion {
1043
+ WorkflowActivationCompletion::from_cmd(run_id, self)
893
1044
  }
894
1045
  }
895
1046
 
@@ -898,15 +1049,10 @@ pub mod coresdk {
898
1049
  I: IntoIterator<Item = V>,
899
1050
  V: Into<WorkflowCommand>,
900
1051
  {
901
- fn into_completion(
902
- self,
903
- task_queue: String,
904
- run_id: String,
905
- ) -> WorkflowActivationCompletion {
1052
+ fn into_completion(self, run_id: String) -> WorkflowActivationCompletion {
906
1053
  let success = self.into_iter().map(Into::into).collect::<Vec<_>>().into();
907
1054
  WorkflowActivationCompletion {
908
1055
  run_id,
909
- task_queue,
910
1056
  status: Some(workflow_activation_completion::Status::Successful(success)),
911
1057
  }
912
1058
  }
@@ -1028,12 +1174,60 @@ pub mod coresdk {
1028
1174
  }
1029
1175
  }
1030
1176
 
1177
+ impl Display for Failure {
1178
+ fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
1179
+ write!(f, "Failure({}, ", self.message)?;
1180
+ match self.failure_info.as_ref() {
1181
+ None => write!(f, "missing info")?,
1182
+ Some(FailureInfo::TimeoutFailureInfo(v)) => {
1183
+ write!(f, "Timeout: {:?}", v.timeout_type())?;
1184
+ }
1185
+ Some(FailureInfo::ApplicationFailureInfo(v)) => {
1186
+ write!(f, "Application Failure: {}", v.r#type)?;
1187
+ }
1188
+ Some(FailureInfo::CanceledFailureInfo(_)) => {
1189
+ write!(f, "Cancelled")?;
1190
+ }
1191
+ Some(FailureInfo::TerminatedFailureInfo(_)) => {
1192
+ write!(f, "Terminated")?;
1193
+ }
1194
+ Some(FailureInfo::ServerFailureInfo(_)) => {
1195
+ write!(f, "Server Failure")?;
1196
+ }
1197
+ Some(FailureInfo::ResetWorkflowFailureInfo(_)) => {
1198
+ write!(f, "Reset Workflow")?;
1199
+ }
1200
+ Some(FailureInfo::ActivityFailureInfo(v)) => {
1201
+ write!(
1202
+ f,
1203
+ "Activity Failure: scheduled_event_id: {}",
1204
+ v.scheduled_event_id
1205
+ )?;
1206
+ }
1207
+ Some(FailureInfo::ChildWorkflowExecutionFailureInfo(v)) => {
1208
+ write!(
1209
+ f,
1210
+ "Child Workflow: started_event_id: {}",
1211
+ v.started_event_id
1212
+ )?;
1213
+ }
1214
+ }
1215
+ write!(f, ")")
1216
+ }
1217
+ }
1218
+
1031
1219
  impl From<&str> for Failure {
1032
1220
  fn from(v: &str) -> Self {
1033
1221
  Failure::application_failure(v.to_string(), false)
1034
1222
  }
1035
1223
  }
1036
1224
 
1225
+ impl From<String> for Failure {
1226
+ fn from(v: String) -> Self {
1227
+ Failure::application_failure(v, false)
1228
+ }
1229
+ }
1230
+
1037
1231
  impl From<anyhow::Error> for Failure {
1038
1232
  fn from(ae: anyhow::Error) -> Self {
1039
1233
  Failure::application_failure(ae.to_string(), false)
@@ -1284,6 +1478,16 @@ pub mod temporal {
1284
1478
  }
1285
1479
  }
1286
1480
 
1481
+ impl From<workflow_commands::UpsertWorkflowSearchAttributes> for command::Attributes {
1482
+ fn from(s: workflow_commands::UpsertWorkflowSearchAttributes) -> Self {
1483
+ Self::UpsertWorkflowSearchAttributesCommandAttributes(
1484
+ UpsertWorkflowSearchAttributesCommandAttributes {
1485
+ search_attributes: Some(s.search_attributes.into()),
1486
+ },
1487
+ )
1488
+ }
1489
+ }
1490
+
1287
1491
  impl From<workflow_commands::CancelTimer> for command::Attributes {
1288
1492
  fn from(s: workflow_commands::CancelTimer) -> Self {
1289
1493
  Self::CancelTimerCommandAttributes(CancelTimerCommandAttributes {
@@ -1302,7 +1506,7 @@ pub mod temporal {
1302
1506
  }),
1303
1507
  namespace: s.namespace,
1304
1508
  task_queue: Some(s.task_queue.into()),
1305
- header: Some(s.header_fields.into()),
1509
+ header: Some(s.headers.into()),
1306
1510
  input: s.arguments.into_payloads(),
1307
1511
  schedule_to_close_timeout: s.schedule_to_close_timeout,
1308
1512
  schedule_to_start_timeout: s.schedule_to_start_timeout,
@@ -1325,7 +1529,7 @@ pub mod temporal {
1325
1529
  control: "".into(),
1326
1530
  namespace: s.namespace,
1327
1531
  task_queue: Some(s.task_queue.into()),
1328
- header: Some(s.header.into()),
1532
+ header: Some(s.headers.into()),
1329
1533
  memo: Some(s.memo.into()),
1330
1534
  search_attributes: Some(s.search_attributes.into()),
1331
1535
  input: s.input.into_payloads(),
@@ -1371,7 +1575,7 @@ pub mod temporal {
1371
1575
  workflow_run_timeout: c.workflow_run_timeout,
1372
1576
  workflow_task_timeout: c.workflow_task_timeout,
1373
1577
  memo: Some(c.memo.into()),
1374
- header: Some(c.header.into()),
1578
+ header: Some(c.headers.into()),
1375
1579
  search_attributes: Some(c.search_attributes.into()),
1376
1580
  ..Default::default()
1377
1581
  },
@@ -18,12 +18,14 @@ prost = "0.9"
18
18
  prost-types = "0.9"
19
19
  rand = "0.8"
20
20
  serde_json = "1.0"
21
- temporal-client = { path = "../client", features = ["mocks"] }
21
+ temporal-client = { path = "../client" }
22
22
  temporal-sdk = { path = "../sdk" }
23
23
  temporal-sdk-core = { path = "../core" }
24
24
  temporal-sdk-core-api = { path = "../core-api" }
25
25
  thiserror = "1.0"
26
26
  tokio = "1.1"
27
+ tokio-util = { version = "0.7" }
28
+ tracing = "0.1"
27
29
  url = "2.2"
28
30
  uuid = "0.8"
29
31
 
@@ -1,3 +1,4 @@
1
+ use rand::RngCore;
1
2
  use temporal_sdk_core::replay::TestHistoryBuilder;
2
3
  use temporal_sdk_core_protos::{
3
4
  coresdk::common::NamespacedWorkflowExecution,
@@ -855,6 +856,32 @@ pub fn long_sequential_timers(num_tasks: usize) -> TestHistoryBuilder {
855
856
  t
856
857
  }
857
858
 
859
+ /// Sends 5 large signals per workflow task
860
+ pub fn lots_of_big_signals(num_tasks: usize) -> TestHistoryBuilder {
861
+ let mut t = TestHistoryBuilder::default();
862
+ t.add_by_type(EventType::WorkflowExecutionStarted);
863
+ t.add_full_wf_task();
864
+
865
+ let mut rng = rand::thread_rng();
866
+ for _ in 1..=num_tasks {
867
+ let mut dat = [0_u8; 1024 * 1000];
868
+ for _ in 1..=5 {
869
+ rng.fill_bytes(&mut dat);
870
+ t.add_we_signaled(
871
+ "bigsig",
872
+ vec![Payload {
873
+ metadata: Default::default(),
874
+ data: dat.into(),
875
+ }],
876
+ );
877
+ }
878
+ t.add_full_wf_task();
879
+ }
880
+
881
+ t.add_workflow_execution_completed();
882
+ t
883
+ }
884
+
858
885
  /// 1: EVENT_TYPE_WORKFLOW_EXECUTION_STARTED
859
886
  /// 2: EVENT_TYPE_WORKFLOW_TASK_SCHEDULED
860
887
  /// 3: EVENT_TYPE_WORKFLOW_TASK_STARTED
@@ -5,18 +5,18 @@
5
5
  //! We can use `clap` if this needs more arguments / other stuff later on.
6
6
 
7
7
  use prost::Message;
8
- use temporal_client::ServerGatewayApis;
8
+ use temporal_client::WorkflowClientTrait;
9
9
  use temporal_sdk_core_test_utils::get_integ_server_options;
10
10
 
11
11
  #[tokio::main]
12
12
  async fn main() -> Result<(), anyhow::Error> {
13
13
  let gw_opts = get_integ_server_options();
14
- let gateway = gw_opts.connect(None).await?;
14
+ let client = gw_opts.connect("default", None).await?;
15
15
  let wf_id = std::env::args()
16
16
  .nth(1)
17
17
  .expect("must provide workflow id as only argument");
18
18
  let run_id = std::env::args().nth(2);
19
- let hist = gateway
19
+ let hist = client
20
20
  .get_workflow_execution_history(wf_id.clone(), run_id, vec![])
21
21
  .await?
22
22
  .history