@temporalio/core-bridge 1.9.2 → 1.10.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 (177) hide show
  1. package/Cargo.lock +754 -473
  2. package/Cargo.toml +3 -3
  3. package/lib/index.d.ts +33 -2
  4. package/lib/index.js.map +1 -1
  5. package/package.json +4 -4
  6. package/releases/aarch64-apple-darwin/index.node +0 -0
  7. package/releases/aarch64-unknown-linux-gnu/index.node +0 -0
  8. package/releases/x86_64-apple-darwin/index.node +0 -0
  9. package/releases/x86_64-pc-windows-msvc/index.node +0 -0
  10. package/releases/x86_64-unknown-linux-gnu/index.node +0 -0
  11. package/scripts/build.js +4 -3
  12. package/sdk-core/.cargo/config.toml +2 -4
  13. package/sdk-core/.github/workflows/heavy.yml +1 -1
  14. package/sdk-core/.github/workflows/per-pr.yml +6 -4
  15. package/sdk-core/Cargo.toml +10 -3
  16. package/sdk-core/README.md +4 -6
  17. package/sdk-core/client/Cargo.toml +13 -5
  18. package/sdk-core/client/src/lib.rs +123 -34
  19. package/sdk-core/client/src/metrics.rs +70 -18
  20. package/sdk-core/client/src/proxy.rs +85 -0
  21. package/sdk-core/client/src/raw.rs +67 -5
  22. package/sdk-core/client/src/worker_registry/mod.rs +5 -3
  23. package/sdk-core/client/src/workflow_handle/mod.rs +3 -1
  24. package/sdk-core/core/Cargo.toml +31 -37
  25. package/sdk-core/core/src/abstractions/take_cell.rs +3 -3
  26. package/sdk-core/core/src/abstractions.rs +176 -108
  27. package/sdk-core/core/src/core_tests/activity_tasks.rs +4 -13
  28. package/sdk-core/core/src/core_tests/determinism.rs +2 -1
  29. package/sdk-core/core/src/core_tests/local_activities.rs +3 -3
  30. package/sdk-core/core/src/core_tests/mod.rs +3 -3
  31. package/sdk-core/core/src/core_tests/queries.rs +42 -5
  32. package/sdk-core/core/src/core_tests/workers.rs +2 -3
  33. package/sdk-core/core/src/core_tests/workflow_tasks.rs +115 -15
  34. package/sdk-core/core/src/ephemeral_server/mod.rs +109 -136
  35. package/sdk-core/core/src/internal_flags.rs +8 -8
  36. package/sdk-core/core/src/lib.rs +16 -11
  37. package/sdk-core/core/src/pollers/mod.rs +11 -5
  38. package/sdk-core/core/src/pollers/poll_buffer.rs +48 -29
  39. package/sdk-core/core/src/protosext/mod.rs +32 -32
  40. package/sdk-core/core/src/protosext/protocol_messages.rs +14 -24
  41. package/sdk-core/core/src/retry_logic.rs +2 -2
  42. package/sdk-core/core/src/telemetry/log_export.rs +10 -9
  43. package/sdk-core/core/src/telemetry/metrics.rs +233 -330
  44. package/sdk-core/core/src/telemetry/mod.rs +11 -38
  45. package/sdk-core/core/src/telemetry/otel.rs +355 -0
  46. package/sdk-core/core/src/telemetry/prometheus_server.rs +36 -23
  47. package/sdk-core/core/src/test_help/mod.rs +80 -59
  48. package/sdk-core/core/src/worker/activities/activity_heartbeat_manager.rs +6 -6
  49. package/sdk-core/core/src/worker/activities/local_activities.rs +46 -43
  50. package/sdk-core/core/src/worker/activities.rs +45 -46
  51. package/sdk-core/core/src/worker/client/mocks.rs +8 -7
  52. package/sdk-core/core/src/worker/client.rs +40 -39
  53. package/sdk-core/core/src/worker/mod.rs +72 -42
  54. package/sdk-core/core/src/worker/slot_provider.rs +28 -28
  55. package/sdk-core/core/src/worker/slot_supplier.rs +1 -0
  56. package/sdk-core/core/src/worker/tuner/fixed_size.rs +52 -0
  57. package/sdk-core/core/src/worker/tuner/resource_based.rs +561 -0
  58. package/sdk-core/core/src/worker/tuner.rs +122 -0
  59. package/sdk-core/core/src/worker/workflow/driven_workflow.rs +6 -6
  60. package/sdk-core/core/src/worker/workflow/history_update.rs +27 -53
  61. package/sdk-core/core/src/worker/workflow/machines/activity_state_machine.rs +4 -17
  62. package/sdk-core/core/src/worker/workflow/machines/cancel_external_state_machine.rs +1 -10
  63. package/sdk-core/core/src/worker/workflow/machines/cancel_workflow_state_machine.rs +4 -11
  64. package/sdk-core/core/src/worker/workflow/machines/child_workflow_state_machine.rs +17 -35
  65. package/sdk-core/core/src/worker/workflow/machines/complete_workflow_state_machine.rs +0 -8
  66. package/sdk-core/core/src/worker/workflow/machines/continue_as_new_workflow_state_machine.rs +1 -5
  67. package/sdk-core/core/src/worker/workflow/machines/fail_workflow_state_machine.rs +0 -5
  68. package/sdk-core/core/src/worker/workflow/machines/local_activity_state_machine.rs +0 -5
  69. package/sdk-core/core/src/worker/workflow/machines/mod.rs +0 -14
  70. package/sdk-core/core/src/worker/workflow/machines/modify_workflow_properties_state_machine.rs +0 -5
  71. package/sdk-core/core/src/worker/workflow/machines/patch_state_machine.rs +0 -5
  72. package/sdk-core/core/src/worker/workflow/machines/signal_external_state_machine.rs +1 -10
  73. package/sdk-core/core/src/worker/workflow/machines/timer_state_machine.rs +3 -10
  74. package/sdk-core/core/src/worker/workflow/machines/transition_coverage.rs +12 -8
  75. package/sdk-core/core/src/worker/workflow/machines/update_state_machine.rs +0 -10
  76. package/sdk-core/core/src/worker/workflow/machines/upsert_search_attributes_state_machine.rs +6 -13
  77. package/sdk-core/core/src/worker/workflow/machines/workflow_machines.rs +27 -37
  78. package/sdk-core/core/src/worker/workflow/machines/workflow_task_state_machine.rs +3 -14
  79. package/sdk-core/core/src/worker/workflow/managed_run.rs +84 -54
  80. package/sdk-core/core/src/worker/workflow/mod.rs +63 -160
  81. package/sdk-core/core/src/worker/workflow/run_cache.rs +22 -13
  82. package/sdk-core/core/src/worker/workflow/wft_extraction.rs +16 -3
  83. package/sdk-core/core/src/worker/workflow/wft_poller.rs +15 -12
  84. package/sdk-core/core/src/worker/workflow/workflow_stream.rs +39 -78
  85. package/sdk-core/core-api/Cargo.toml +6 -5
  86. package/sdk-core/core-api/src/errors.rs +8 -0
  87. package/sdk-core/core-api/src/telemetry/metrics.rs +75 -4
  88. package/sdk-core/core-api/src/telemetry.rs +7 -1
  89. package/sdk-core/core-api/src/worker.rs +212 -56
  90. package/sdk-core/fsm/Cargo.toml +3 -0
  91. package/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/no_handle_conversions_require_into_fail.stderr +1 -1
  92. package/sdk-core/sdk/Cargo.toml +5 -7
  93. package/sdk-core/sdk/src/app_data.rs +3 -3
  94. package/sdk-core/sdk/src/lib.rs +5 -3
  95. package/sdk-core/sdk/src/workflow_context/options.rs +1 -1
  96. package/sdk-core/sdk/src/workflow_context.rs +10 -9
  97. package/sdk-core/sdk/src/workflow_future.rs +1 -1
  98. package/sdk-core/sdk-core-protos/Cargo.toml +8 -6
  99. package/sdk-core/sdk-core-protos/build.rs +1 -10
  100. package/sdk-core/sdk-core-protos/protos/api_upstream/.github/PULL_REQUEST_TEMPLATE.md +3 -0
  101. package/sdk-core/sdk-core-protos/protos/api_upstream/.github/workflows/ci.yml +26 -0
  102. package/sdk-core/sdk-core-protos/protos/api_upstream/Makefile +42 -20
  103. package/sdk-core/sdk-core-protos/protos/api_upstream/README.md +2 -0
  104. package/sdk-core/sdk-core-protos/protos/api_upstream/api-linter.yaml +36 -26
  105. package/sdk-core/sdk-core-protos/protos/api_upstream/buf.lock +2 -0
  106. package/sdk-core/sdk-core-protos/protos/api_upstream/google/protobuf/struct.proto +95 -0
  107. package/sdk-core/sdk-core-protos/protos/api_upstream/openapi/openapiv2.json +9632 -0
  108. package/sdk-core/sdk-core-protos/protos/api_upstream/openapi/openapiv3.yaml +7337 -0
  109. package/sdk-core/sdk-core-protos/protos/api_upstream/openapi/payload_description.txt +2 -0
  110. package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/command/v1/message.proto +45 -11
  111. package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/common/v1/message.proto +22 -4
  112. package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/enums/v1/command_type.proto +2 -0
  113. package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/enums/v1/common.proto +44 -0
  114. package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/enums/v1/event_type.proto +18 -3
  115. package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/enums/v1/failed_cause.proto +20 -0
  116. package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/enums/v1/task_queue.proto +30 -0
  117. package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/enums/v1/update.proto +7 -8
  118. package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/enums/v1/workflow.proto +23 -5
  119. package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/errordetails/v1/message.proto +20 -0
  120. package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/failure/v1/message.proto +25 -0
  121. package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/history/v1/message.proto +141 -15
  122. package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/namespace/v1/message.proto +12 -0
  123. package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/nexus/v1/message.proto +193 -0
  124. package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/operatorservice/v1/request_response.proto +73 -6
  125. package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/operatorservice/v1/service.proto +46 -4
  126. package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/schedule/v1/message.proto +4 -0
  127. package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/sdk/v1/workflow_metadata.proto +2 -2
  128. package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/taskqueue/v1/message.proto +116 -0
  129. package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/workflow/v1/message.proto +134 -0
  130. package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/workflowservice/v1/request_response.proto +274 -29
  131. package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/workflowservice/v1/service.proto +57 -1
  132. package/sdk-core/sdk-core-protos/protos/local/temporal/sdk/core/workflow_activation/workflow_activation.proto +10 -12
  133. package/sdk-core/sdk-core-protos/src/history_builder.rs +1 -1
  134. package/sdk-core/sdk-core-protos/src/lib.rs +54 -51
  135. package/sdk-core/sdk-core-protos/src/task_token.rs +11 -2
  136. package/sdk-core/test-utils/Cargo.toml +7 -4
  137. package/sdk-core/test-utils/src/histfetch.rs +1 -1
  138. package/sdk-core/test-utils/src/lib.rs +44 -62
  139. package/sdk-core/tests/fuzzy_workflow.rs +5 -2
  140. package/sdk-core/tests/heavy_tests.rs +114 -17
  141. package/sdk-core/tests/integ_tests/activity_functions.rs +1 -1
  142. package/sdk-core/tests/integ_tests/client_tests.rs +2 -2
  143. package/sdk-core/tests/integ_tests/ephemeral_server_tests.rs +38 -26
  144. package/sdk-core/tests/integ_tests/metrics_tests.rs +126 -17
  145. package/sdk-core/tests/integ_tests/polling_tests.rs +118 -2
  146. package/sdk-core/tests/integ_tests/update_tests.rs +3 -5
  147. package/sdk-core/tests/integ_tests/visibility_tests.rs +3 -3
  148. package/sdk-core/tests/integ_tests/workflow_tests/activities.rs +1 -1
  149. package/sdk-core/tests/integ_tests/workflow_tests/appdata_propagation.rs +1 -1
  150. package/sdk-core/tests/integ_tests/workflow_tests/cancel_external.rs +1 -1
  151. package/sdk-core/tests/integ_tests/workflow_tests/cancel_wf.rs +1 -1
  152. package/sdk-core/tests/integ_tests/workflow_tests/child_workflows.rs +3 -3
  153. package/sdk-core/tests/integ_tests/workflow_tests/continue_as_new.rs +5 -4
  154. package/sdk-core/tests/integ_tests/workflow_tests/determinism.rs +3 -2
  155. package/sdk-core/tests/integ_tests/workflow_tests/eager.rs +6 -10
  156. package/sdk-core/tests/integ_tests/workflow_tests/local_activities.rs +9 -7
  157. package/sdk-core/tests/integ_tests/workflow_tests/modify_wf_properties.rs +1 -1
  158. package/sdk-core/tests/integ_tests/workflow_tests/patches.rs +14 -9
  159. package/sdk-core/tests/integ_tests/workflow_tests/resets.rs +1 -1
  160. package/sdk-core/tests/integ_tests/workflow_tests/signals.rs +6 -13
  161. package/sdk-core/tests/integ_tests/workflow_tests/stickyness.rs +9 -6
  162. package/sdk-core/tests/integ_tests/workflow_tests/timers.rs +5 -5
  163. package/sdk-core/tests/integ_tests/workflow_tests/upsert_search_attrs.rs +1 -1
  164. package/sdk-core/tests/integ_tests/workflow_tests.rs +115 -11
  165. package/sdk-core/tests/main.rs +2 -2
  166. package/src/conversions.rs +57 -0
  167. package/src/lib.rs +1 -0
  168. package/src/runtime.rs +51 -35
  169. package/ts/index.ts +67 -3
  170. package/sdk-core/core/src/worker/workflow/workflow_stream/saved_wf_inputs.rs +0 -117
  171. package/sdk-core/core/src/worker/workflow/workflow_stream/tonic_status_serde.rs +0 -24
  172. package/sdk-core/sdk/src/payload_converter.rs +0 -11
  173. package/sdk-core/sdk-core-protos/protos/api_upstream/.buildkite/Dockerfile +0 -2
  174. package/sdk-core/sdk-core-protos/protos/api_upstream/.buildkite/docker-compose.yml +0 -15
  175. package/sdk-core/sdk-core-protos/protos/api_upstream/.buildkite/pipeline.yml +0 -10
  176. package/sdk-core/test-utils/src/wf_input_saver.rs +0 -50
  177. package/sdk-core/tests/wf_input_replay.rs +0 -32
@@ -364,13 +364,16 @@ pub mod coresdk {
364
364
  #[derive(Serialize, Deserialize)]
365
365
  #[serde(remote = "Timestamp")]
366
366
  struct TimestampDef {
367
- pub seconds: i64,
368
- pub nanos: i32,
367
+ seconds: i64,
368
+ nanos: i32,
369
369
  }
370
370
  mod opt_timestamp {
371
371
  use super::*;
372
372
 
373
- pub fn serialize<S>(value: &Option<Timestamp>, serializer: S) -> Result<S::Ok, S::Error>
373
+ pub(super) fn serialize<S>(
374
+ value: &Option<Timestamp>,
375
+ serializer: S,
376
+ ) -> Result<S::Ok, S::Error>
374
377
  where
375
378
  S: Serializer,
376
379
  {
@@ -380,7 +383,9 @@ pub mod coresdk {
380
383
  value.as_ref().map(Helper).serialize(serializer)
381
384
  }
382
385
 
383
- pub fn deserialize<'de, D>(deserializer: D) -> Result<Option<Timestamp>, D::Error>
386
+ pub(super) fn deserialize<'de, D>(
387
+ deserializer: D,
388
+ ) -> Result<Option<Timestamp>, D::Error>
384
389
  where
385
390
  D: Deserializer<'de>,
386
391
  {
@@ -396,13 +401,16 @@ pub mod coresdk {
396
401
  #[derive(Serialize, Deserialize)]
397
402
  #[serde(remote = "Duration")]
398
403
  struct DurationDef {
399
- pub seconds: i64,
400
- pub nanos: i32,
404
+ seconds: i64,
405
+ nanos: i32,
401
406
  }
402
407
  mod opt_duration {
403
408
  use super::*;
404
409
 
405
- pub fn serialize<S>(value: &Option<Duration>, serializer: S) -> Result<S::Ok, S::Error>
410
+ pub(super) fn serialize<S>(
411
+ value: &Option<Duration>,
412
+ serializer: S,
413
+ ) -> Result<S::Ok, S::Error>
406
414
  where
407
415
  S: Serializer,
408
416
  {
@@ -412,7 +420,7 @@ pub mod coresdk {
412
420
  value.as_ref().map(Helper).serialize(serializer)
413
421
  }
414
422
 
415
- pub fn deserialize<'de, D>(deserializer: D) -> Result<Option<Duration>, D::Error>
423
+ pub(super) fn deserialize<'de, D>(deserializer: D) -> Result<Option<Duration>, D::Error>
416
424
  where
417
425
  D: Deserializer<'de>,
418
426
  {
@@ -483,52 +491,28 @@ pub mod coresdk {
483
491
  }
484
492
 
485
493
  impl WorkflowActivation {
486
- /// Returns the index of the eviction job if this activation contains one. If present
487
- /// it should always be the last job in the list.
488
- pub fn eviction_index(&self) -> Option<usize> {
489
- self.jobs.iter().position(|j| {
490
- matches!(
491
- j,
492
- WorkflowActivationJob {
493
- variant: Some(workflow_activation_job::Variant::RemoveFromCache(_))
494
- }
495
- )
496
- })
497
- }
498
-
499
- /// Returns true if the only job is eviction
494
+ /// Returns true if the only job in the activation is eviction
500
495
  pub fn is_only_eviction(&self) -> bool {
501
- self.jobs.len() == 1 && self.eviction_index().is_some()
496
+ matches!(
497
+ self.jobs.as_slice(),
498
+ [WorkflowActivationJob {
499
+ variant: Some(workflow_activation_job::Variant::RemoveFromCache(_))
500
+ }]
501
+ )
502
502
  }
503
503
 
504
- /// Returns eviction reason if this activation has an evict job
504
+ /// Returns eviction reason if this activation is an eviction
505
505
  pub fn eviction_reason(&self) -> Option<EvictionReason> {
506
506
  self.jobs.iter().find_map(|j| {
507
507
  if let Some(workflow_activation_job::Variant::RemoveFromCache(ref rj)) =
508
508
  j.variant
509
509
  {
510
- EvictionReason::from_i32(rj.reason)
510
+ EvictionReason::try_from(rj.reason).ok()
511
511
  } else {
512
512
  None
513
513
  }
514
514
  })
515
515
  }
516
-
517
- /// Append an eviction job to the joblist
518
- pub fn append_evict_job(&mut self, evict_job: RemoveFromCache) {
519
- if let Some(last_job) = self.jobs.last() {
520
- if matches!(
521
- last_job.variant,
522
- Some(workflow_activation_job::Variant::RemoveFromCache(_))
523
- ) {
524
- return;
525
- }
526
- }
527
- let evict_job = WorkflowActivationJob::from(
528
- workflow_activation_job::Variant::RemoveFromCache(evict_job),
529
- );
530
- self.jobs.push(evict_job);
531
- }
532
516
  }
533
517
 
534
518
  impl Display for EvictionReason {
@@ -1265,6 +1249,13 @@ pub mod coresdk {
1265
1249
  v.started_event_id
1266
1250
  )?;
1267
1251
  }
1252
+ Some(FailureInfo::NexusOperationExecutionFailureInfo(v)) => {
1253
+ write!(
1254
+ f,
1255
+ "Nexus Operation Failure: scheduled_event_id: {}",
1256
+ v.scheduled_event_id
1257
+ )?;
1258
+ }
1268
1259
  }
1269
1260
  write!(f, ")")
1270
1261
  }
@@ -1494,7 +1485,7 @@ pub mod temporal {
1494
1485
 
1495
1486
  impl Display for Command {
1496
1487
  fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
1497
- let ct = CommandType::from_i32(self.command_type)
1488
+ let ct = CommandType::try_from(self.command_type)
1498
1489
  .unwrap_or(CommandType::Unspecified);
1499
1490
  write!(f, "{:?}", ct)
1500
1491
  }
@@ -1539,7 +1530,7 @@ pub mod temporal {
1539
1530
 
1540
1531
  pub fn schedule_activity_cmd_to_api(
1541
1532
  s: workflow_commands::ScheduleActivity,
1542
- use_compatible_version: bool,
1533
+ use_workflow_build_id: bool,
1543
1534
  ) -> command::Attributes {
1544
1535
  command::Attributes::ScheduleActivityTaskCommandAttributes(
1545
1536
  ScheduleActivityTaskCommandAttributes {
@@ -1556,14 +1547,14 @@ pub mod temporal {
1556
1547
  heartbeat_timeout: s.heartbeat_timeout,
1557
1548
  retry_policy: s.retry_policy.map(Into::into),
1558
1549
  request_eager_execution: !s.do_not_eagerly_execute,
1559
- use_compatible_version,
1550
+ use_workflow_build_id,
1560
1551
  },
1561
1552
  )
1562
1553
  }
1563
1554
 
1564
1555
  pub fn start_child_workflow_cmd_to_api(
1565
1556
  s: workflow_commands::StartChildWorkflowExecution,
1566
- use_compatible_version: bool,
1557
+ inherit_build_id: bool,
1567
1558
  ) -> command::Attributes {
1568
1559
  command::Attributes::StartChildWorkflowExecutionCommandAttributes(
1569
1560
  StartChildWorkflowExecutionCommandAttributes {
@@ -1585,7 +1576,7 @@ pub mod temporal {
1585
1576
  retry_policy: s.retry_policy.map(Into::into),
1586
1577
  cron_schedule: s.cron_schedule.clone(),
1587
1578
  parent_close_policy: s.parent_close_policy,
1588
- use_compatible_version,
1579
+ inherit_build_id,
1589
1580
  },
1590
1581
  )
1591
1582
  }
@@ -1612,7 +1603,7 @@ pub mod temporal {
1612
1603
 
1613
1604
  pub fn continue_as_new_cmd_to_api(
1614
1605
  c: workflow_commands::ContinueAsNewWorkflowExecution,
1615
- use_compatible_version: bool,
1606
+ inherit_build_id: bool,
1616
1607
  ) -> command::Attributes {
1617
1608
  command::Attributes::ContinueAsNewWorkflowExecutionCommandAttributes(
1618
1609
  ContinueAsNewWorkflowExecutionCommandAttributes {
@@ -1637,7 +1628,7 @@ pub mod temporal {
1637
1628
  } else {
1638
1629
  Some(c.search_attributes.into())
1639
1630
  },
1640
- use_compatible_version,
1631
+ inherit_build_id,
1641
1632
  ..Default::default()
1642
1633
  },
1643
1634
  )
@@ -1830,7 +1821,7 @@ pub mod temporal {
1830
1821
  impl HistoryEvent {
1831
1822
  /// Returns true if this is an event created to mirror a command
1832
1823
  pub fn is_command_event(&self) -> bool {
1833
- EventType::from_i32(self.event_type).map_or(false, |et| match et {
1824
+ EventType::try_from(self.event_type).map_or(false, |et| match et {
1834
1825
  EventType::ActivityTaskScheduled
1835
1826
  | EventType::ActivityTaskCancelRequested
1836
1827
  | EventType::MarkerRecorded
@@ -1929,7 +1920,7 @@ pub mod temporal {
1929
1920
  f,
1930
1921
  "HistoryEvent(id: {}, {:?})",
1931
1922
  self.event_id,
1932
- EventType::from_i32(self.event_type)
1923
+ EventType::try_from(self.event_type)
1933
1924
  )
1934
1925
  }
1935
1926
  }
@@ -1978,13 +1969,20 @@ pub mod temporal {
1978
1969
  Attributes::SignalExternalWorkflowExecutionFailedEventAttributes(_) => {EventType::SignalExternalWorkflowExecutionFailed}
1979
1970
  Attributes::ExternalWorkflowExecutionSignaledEventAttributes(_) => {EventType::ExternalWorkflowExecutionSignaled}
1980
1971
  Attributes::UpsertWorkflowSearchAttributesEventAttributes(_) => {EventType::UpsertWorkflowSearchAttributes}
1972
+ Attributes::WorkflowExecutionUpdateAdmittedEventAttributes(_) => {EventType::WorkflowExecutionUpdateAdmitted}
1981
1973
  Attributes::WorkflowExecutionUpdateRejectedEventAttributes(_) => {EventType::WorkflowExecutionUpdateRejected}
1982
1974
  Attributes::WorkflowExecutionUpdateAcceptedEventAttributes(_) => {EventType::WorkflowExecutionUpdateAccepted}
1983
1975
  Attributes::WorkflowExecutionUpdateCompletedEventAttributes(_) => {EventType::WorkflowExecutionUpdateCompleted}
1984
- Attributes::WorkflowExecutionUpdateRequestedEventAttributes(_) => {EventType::WorkflowExecutionUpdateRequested}
1985
1976
  Attributes::WorkflowPropertiesModifiedExternallyEventAttributes(_) => {EventType::WorkflowPropertiesModifiedExternally}
1986
1977
  Attributes::ActivityPropertiesModifiedExternallyEventAttributes(_) => {EventType::ActivityPropertiesModifiedExternally}
1987
1978
  Attributes::WorkflowPropertiesModifiedEventAttributes(_) => {EventType::WorkflowPropertiesModified}
1979
+ Attributes::NexusOperationScheduledEventAttributes(_) => {EventType::NexusOperationScheduled}
1980
+ Attributes::NexusOperationStartedEventAttributes(_) => {EventType::NexusOperationStarted}
1981
+ Attributes::NexusOperationCompletedEventAttributes(_) => {EventType::NexusOperationCompleted}
1982
+ Attributes::NexusOperationFailedEventAttributes(_) => {EventType::NexusOperationFailed}
1983
+ Attributes::NexusOperationCanceledEventAttributes(_) => {EventType::NexusOperationCanceled}
1984
+ Attributes::NexusOperationTimedOutEventAttributes(_) => {EventType::NexusOperationTimedOut}
1985
+ Attributes::NexusOperationCancelRequestedEventAttributes(_) => {EventType::NexusOperationCancelRequested}
1988
1986
  }
1989
1987
  }
1990
1988
  }
@@ -2079,6 +2077,11 @@ pub mod temporal {
2079
2077
  tonic::include_proto!("temporal.api.workflow.v1");
2080
2078
  }
2081
2079
  }
2080
+ pub mod nexus {
2081
+ pub mod v1 {
2082
+ tonic::include_proto!("temporal.api.nexus.v1");
2083
+ }
2084
+ }
2082
2085
  pub mod workflowservice {
2083
2086
  pub mod v1 {
2084
2087
  use std::{
@@ -1,5 +1,8 @@
1
1
  use base64::{prelude::BASE64_STANDARD, Engine};
2
- use std::fmt::{Debug, Display, Formatter};
2
+ use std::{
3
+ borrow::Borrow,
4
+ fmt::{Debug, Display, Formatter},
5
+ };
3
6
 
4
7
  static LOCAL_ACT_TASK_TOKEN_PREFIX: &[u8] = b"local_act_";
5
8
 
@@ -43,6 +46,12 @@ impl Debug for TaskToken {
43
46
  }
44
47
  }
45
48
 
46
- pub fn fmt_tt(tt: &[u8]) -> String {
49
+ impl Borrow<[u8]> for TaskToken {
50
+ fn borrow(&self) -> &[u8] {
51
+ self.0.as_slice()
52
+ }
53
+ }
54
+
55
+ pub(crate) fn fmt_tt(tt: &[u8]) -> String {
47
56
  BASE64_STANDARD.encode(tt)
48
57
  }
@@ -16,14 +16,14 @@ ephemeral-server = ["temporal-sdk-core/ephemeral-server"]
16
16
  [dependencies]
17
17
  anyhow = "1.0"
18
18
  async-trait = "0.1"
19
- base64 = "0.21"
19
+ base64 = "0.22"
20
20
  bytes = "1.3"
21
21
  futures = "0.3"
22
22
  log = "0.4"
23
- once_cell = "1.16"
23
+ once_cell = { workspace = true }
24
24
  parking_lot = "0.12"
25
- prost = "0.11"
26
- prost-types = "0.11"
25
+ prost = { workspace = true }
26
+ prost-types = { workspace = true }
27
27
  rand = "0.8"
28
28
  rmp-serde = "1.1"
29
29
  serde_json = "1.0"
@@ -41,3 +41,6 @@ uuid = "1.1"
41
41
  [dependencies.temporal-sdk-core-protos]
42
42
  path = "../sdk-core-protos"
43
43
  version = "0.1"
44
+
45
+ [lints]
46
+ workspace = true
@@ -11,7 +11,7 @@ use temporal_sdk_core_test_utils::get_integ_server_options;
11
11
  #[tokio::main]
12
12
  async fn main() -> Result<(), anyhow::Error> {
13
13
  let gw_opts = get_integ_server_options();
14
- let client = gw_opts.connect("default", None, 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");
@@ -6,16 +6,12 @@ extern crate tracing;
6
6
 
7
7
  pub mod canned_histories;
8
8
  pub mod interceptors;
9
- pub mod wf_input_saver;
10
9
  pub mod workflows;
11
10
 
12
- use anyhow::Context;
13
11
  pub use temporal_sdk_core::replay::HistoryForReplay;
14
12
 
15
- use crate::{
16
- stream::{Stream, TryStreamExt},
17
- wf_input_saver::stream_to_file,
18
- };
13
+ use crate::stream::{Stream, TryStreamExt};
14
+ use anyhow::{Context, Error};
19
15
  use base64::{prelude::BASE64_STANDARD, Engine};
20
16
  use futures::{future, stream, stream::FuturesUnordered, StreamExt};
21
17
  use parking_lot::Mutex;
@@ -51,6 +47,7 @@ use temporal_sdk_core_api::{
51
47
  };
52
48
  use temporal_sdk_core_protos::{
53
49
  coresdk::{
50
+ workflow_activation::WorkflowActivation,
54
51
  workflow_commands::{
55
52
  workflow_command, ActivityCancellationType, CompleteWorkflowExecution, QueryResult,
56
53
  QuerySuccess, ScheduleActivity, ScheduleLocalActivity, StartTimer,
@@ -63,7 +60,7 @@ use temporal_sdk_core_protos::{
63
60
  },
64
61
  DEFAULT_ACTIVITY_TYPE,
65
62
  };
66
- use tokio::sync::{mpsc::unbounded_channel, OnceCell};
63
+ use tokio::sync::OnceCell;
67
64
  use url::Url;
68
65
 
69
66
  pub const NAMESPACE: &str = "default";
@@ -99,6 +96,17 @@ pub async fn init_core_and_create_wf(test_name: &str) -> CoreWfStarter {
99
96
  starter
100
97
  }
101
98
 
99
+ pub fn integ_worker_config(tq: &str) -> WorkerConfigBuilder {
100
+ let mut b = WorkerConfigBuilder::default();
101
+ b.namespace(NAMESPACE)
102
+ .task_queue(tq)
103
+ .max_outstanding_activities(100_usize)
104
+ .max_outstanding_local_activities(100_usize)
105
+ .max_outstanding_workflow_tasks(100_usize)
106
+ .worker_build_id("test_build_id");
107
+ b
108
+ }
109
+
102
110
  /// Create a worker replay instance preloaded with provided histories. Returns the worker impl.
103
111
  pub fn init_core_replay_preloaded<I>(test_name: &str, histories: I) -> Arc<dyn CoreWorker>
104
112
  where
@@ -112,10 +120,7 @@ where
112
120
  I: Stream<Item = HistoryForReplay> + Send + 'static,
113
121
  {
114
122
  init_integ_telem();
115
- let worker_cfg = WorkerConfigBuilder::default()
116
- .namespace(NAMESPACE)
117
- .task_queue(test_name)
118
- .worker_build_id("test_bin_id")
123
+ let worker_cfg = integ_worker_config(test_name)
119
124
  .build()
120
125
  .expect("Configuration options construct properly");
121
126
  let worker = init_replay_worker(ReplayWorkerInput::new(worker_cfg, histories))
@@ -149,7 +154,7 @@ pub async fn history_from_proto_binary(path_from_root: &str) -> Result<History,
149
154
  }
150
155
 
151
156
  static INTEG_TESTS_RT: once_cell::sync::OnceCell<CoreRuntime> = once_cell::sync::OnceCell::new();
152
- pub fn init_integ_telem() {
157
+ pub fn init_integ_telem() -> &'static CoreRuntime {
153
158
  INTEG_TESTS_RT.get_or_init(|| {
154
159
  let telemetry_options = get_integ_telem_options();
155
160
  let rt =
@@ -158,7 +163,7 @@ pub fn init_integ_telem() {
158
163
  let _ = tracing::subscriber::set_global_default(sub);
159
164
  }
160
165
  rt
161
- });
166
+ })
162
167
  }
163
168
 
164
169
  /// Implements a builder pattern to help integ tests initialize core and create workflows
@@ -169,7 +174,7 @@ pub struct CoreWfStarter {
169
174
  /// Options to use when starting workflow(s)
170
175
  pub workflow_options: WorkflowOptions,
171
176
  initted_worker: OnceCell<InitializedWorker>,
172
- runtime_override: Option<CoreRuntime>,
177
+ runtime_override: Option<Arc<CoreRuntime>>,
173
178
  }
174
179
  struct InitializedWorker {
175
180
  worker: Arc<dyn CoreWorker>,
@@ -190,18 +195,16 @@ impl CoreWfStarter {
190
195
  let rand_bytes: Vec<u8> = rand::thread_rng().sample_iter(&Standard).take(6).collect();
191
196
  let task_q_salt = BASE64_STANDARD.encode(rand_bytes);
192
197
  let task_queue = format!("{test_name}_{task_q_salt}");
193
- let mut worker_config = WorkerConfigBuilder::default();
198
+ let mut worker_config = integ_worker_config(&task_queue);
194
199
  worker_config
195
200
  .namespace(env::var(INTEG_NAMESPACE_ENV_VAR).unwrap_or(NAMESPACE.to_string()))
196
- .task_queue(task_queue.clone())
197
- .worker_build_id("test_build_id")
198
201
  .max_cached_workflows(1000_usize);
199
202
  Self {
200
203
  task_queue_name: task_queue,
201
204
  worker_config,
202
205
  initted_worker: OnceCell::new(),
203
206
  workflow_options: Default::default(),
204
- runtime_override,
207
+ runtime_override: runtime_override.map(Arc::new),
205
208
  }
206
209
  }
207
210
 
@@ -212,7 +215,7 @@ impl CoreWfStarter {
212
215
  task_queue_name: self.task_queue_name.clone(),
213
216
  worker_config: self.worker_config.clone(),
214
217
  workflow_options: self.workflow_options.clone(),
215
- runtime_override: None,
218
+ runtime_override: self.runtime_override.clone(),
216
219
  initted_worker: Default::default(),
217
220
  }
218
221
  }
@@ -243,6 +246,7 @@ impl CoreWfStarter {
243
246
  self.start_wf_with_id(self.task_queue_name.clone()).await
244
247
  }
245
248
 
249
+ /// Starts the workflow using the worker, returns run id.
246
250
  pub async fn start_with_worker(
247
251
  &self,
248
252
  wf_name: impl Into<String>,
@@ -328,47 +332,6 @@ impl CoreWfStarter {
328
332
  &self.task_queue_name
329
333
  }
330
334
 
331
- pub fn max_cached_workflows(&mut self, num: usize) -> &mut Self {
332
- self.worker_config.max_cached_workflows(num);
333
- self
334
- }
335
-
336
- pub fn max_wft(&mut self, max: usize) -> &mut Self {
337
- self.worker_config.max_outstanding_workflow_tasks(max);
338
- self
339
- }
340
-
341
- pub fn max_at(&mut self, max: usize) -> &mut Self {
342
- self.worker_config.max_outstanding_activities(max);
343
- self
344
- }
345
-
346
- pub fn max_local_at(&mut self, max: usize) -> &mut Self {
347
- self.worker_config.max_outstanding_local_activities(max);
348
- self
349
- }
350
-
351
- pub fn max_at_polls(&mut self, max: usize) -> &mut Self {
352
- self.worker_config.max_concurrent_at_polls(max);
353
-
354
- self
355
- }
356
-
357
- pub fn no_remote_activities(&mut self) -> &mut Self {
358
- self.worker_config.no_remote_activities(true);
359
- self
360
- }
361
-
362
- pub fn enable_wf_state_input_recording(&mut self) -> &mut Self {
363
- let (ser_tx, ser_rx) = unbounded_channel();
364
- let worker_cfg_clone = self.worker_config.build().unwrap();
365
- tokio::spawn(async move {
366
- stream_to_file(&worker_cfg_clone, ser_rx).await.unwrap();
367
- });
368
- self.worker_config.wf_state_inputs(Some(ser_tx));
369
- self
370
- }
371
-
372
335
  async fn get_or_init(&mut self) -> &InitializedWorker {
373
336
  self.initted_worker
374
337
  .get_or_init(|| async {
@@ -378,7 +341,7 @@ impl CoreWfStarter {
378
341
  .expect("Worker config must be valid");
379
342
  let client = Arc::new(
380
343
  get_integ_server_options()
381
- .connect(cfg.namespace.clone(), None, None)
344
+ .connect(cfg.namespace.clone(), None)
382
345
  .await
383
346
  .expect("Must connect"),
384
347
  );
@@ -510,7 +473,20 @@ impl TestWorker {
510
473
  Ok(res)
511
474
  }
512
475
 
513
- /// Runs until all expected workflows have completed
476
+ pub fn expect_workflow_completion(&self, wf_id: impl Into<String>, run_id: Option<String>) {
477
+ self.started_workflows.lock().push(WorkflowExecutionInfo {
478
+ namespace: self
479
+ .client
480
+ .as_ref()
481
+ .map(|c| c.namespace())
482
+ .unwrap_or(NAMESPACE)
483
+ .to_owned(),
484
+ workflow_id: wf_id.into(),
485
+ run_id,
486
+ });
487
+ }
488
+
489
+ /// Runs until all expected workflows have completed and then shuts down the worker
514
490
  pub async fn run_until_done(&mut self) -> Result<(), anyhow::Error> {
515
491
  self.run_until_done_intercepted(Option::<TestWorkerCompletionIceptor>::None)
516
492
  .await
@@ -604,6 +580,12 @@ impl WorkerInterceptor for TestWorkerCompletionIceptor {
604
580
  n.on_shutdown(sdk_worker);
605
581
  }
606
582
  }
583
+ async fn on_workflow_activation(&self, a: &WorkflowActivation) -> Result<(), Error> {
584
+ if let Some(n) = self.next.as_ref() {
585
+ n.on_workflow_activation(a).await?;
586
+ }
587
+ Ok(())
588
+ }
607
589
  }
608
590
 
609
591
  /// Returns the client options used to connect to the server used for integration tests.
@@ -78,8 +78,11 @@ async fn fuzzy_workflow() {
78
78
  let num_workflows = 200;
79
79
  let wf_name = "fuzzy_wf";
80
80
  let mut starter = CoreWfStarter::new("fuzzy_workflow");
81
- starter.max_wft(25).max_cached_workflows(25).max_at(25);
82
- // .enable_wf_state_input_recording();
81
+ starter
82
+ .worker_config
83
+ .max_outstanding_workflow_tasks(25_usize)
84
+ .max_cached_workflows(25_usize)
85
+ .max_outstanding_activities(25_usize);
83
86
  let mut worker = starter.worker().await;
84
87
  worker.register_wf(wf_name.to_owned(), fuzzy_wf_def);
85
88
  worker.register_activity("echo_activity", echo);