@temporalio/core-bridge 0.22.0 → 1.0.0-rc.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (139) hide show
  1. package/Cargo.lock +120 -15
  2. package/Cargo.toml +3 -1
  3. package/README.md +1 -1
  4. package/index.d.ts +137 -33
  5. package/package.json +6 -6
  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/sdk-core/.buildkite/docker/docker-compose.yaml +4 -2
  12. package/sdk-core/ARCHITECTURE.md +9 -7
  13. package/sdk-core/README.md +5 -1
  14. package/sdk-core/arch_docs/diagrams/workflow_internals.svg +1 -0
  15. package/sdk-core/bridge-ffi/src/lib.rs +1 -1
  16. package/sdk-core/bridge-ffi/src/wrappers.rs +60 -37
  17. package/sdk-core/client/Cargo.toml +1 -0
  18. package/sdk-core/client/src/lib.rs +50 -15
  19. package/sdk-core/client/src/raw.rs +167 -55
  20. package/sdk-core/client/src/retry.rs +9 -4
  21. package/sdk-core/client/src/workflow_handle/mod.rs +4 -2
  22. package/sdk-core/core/Cargo.toml +2 -0
  23. package/sdk-core/core/benches/workflow_replay.rs +1 -7
  24. package/sdk-core/core/src/abstractions.rs +137 -16
  25. package/sdk-core/core/src/core_tests/activity_tasks.rs +258 -63
  26. package/sdk-core/core/src/core_tests/child_workflows.rs +1 -2
  27. package/sdk-core/core/src/core_tests/determinism.rs +2 -2
  28. package/sdk-core/core/src/core_tests/local_activities.rs +8 -7
  29. package/sdk-core/core/src/core_tests/queries.rs +146 -60
  30. package/sdk-core/core/src/core_tests/replay_flag.rs +1 -1
  31. package/sdk-core/core/src/core_tests/workers.rs +39 -23
  32. package/sdk-core/core/src/core_tests/workflow_cancels.rs +1 -1
  33. package/sdk-core/core/src/core_tests/workflow_tasks.rs +387 -280
  34. package/sdk-core/core/src/lib.rs +8 -5
  35. package/sdk-core/core/src/pollers/poll_buffer.rs +16 -10
  36. package/sdk-core/core/src/protosext/mod.rs +7 -9
  37. package/sdk-core/core/src/retry_logic.rs +73 -16
  38. package/sdk-core/core/src/telemetry/metrics.rs +21 -7
  39. package/sdk-core/core/src/telemetry/mod.rs +182 -110
  40. package/sdk-core/core/src/test_help/mod.rs +341 -109
  41. package/sdk-core/core/src/worker/activities/activity_heartbeat_manager.rs +18 -9
  42. package/sdk-core/core/src/worker/activities/local_activities.rs +22 -25
  43. package/sdk-core/core/src/worker/activities.rs +156 -29
  44. package/sdk-core/core/src/worker/client.rs +1 -0
  45. package/sdk-core/core/src/worker/mod.rs +132 -659
  46. package/sdk-core/core/src/{workflow → worker/workflow}/bridge.rs +1 -1
  47. package/sdk-core/core/src/{workflow → worker/workflow}/driven_workflow.rs +1 -1
  48. package/sdk-core/core/src/{workflow → worker/workflow}/history_update.rs +16 -2
  49. package/sdk-core/core/src/{workflow → worker/workflow}/machines/activity_state_machine.rs +39 -4
  50. package/sdk-core/core/src/{workflow → worker/workflow}/machines/cancel_external_state_machine.rs +5 -2
  51. package/sdk-core/core/src/{workflow → worker/workflow}/machines/cancel_workflow_state_machine.rs +1 -1
  52. package/sdk-core/core/src/{workflow → worker/workflow}/machines/child_workflow_state_machine.rs +2 -4
  53. package/sdk-core/core/src/{workflow → worker/workflow}/machines/complete_workflow_state_machine.rs +0 -0
  54. package/sdk-core/core/src/{workflow → worker/workflow}/machines/continue_as_new_workflow_state_machine.rs +1 -1
  55. package/sdk-core/core/src/{workflow → worker/workflow}/machines/fail_workflow_state_machine.rs +0 -0
  56. package/sdk-core/core/src/{workflow → worker/workflow}/machines/local_activity_state_machine.rs +2 -5
  57. package/sdk-core/core/src/{workflow → worker/workflow}/machines/mod.rs +1 -1
  58. package/sdk-core/core/src/{workflow → worker/workflow}/machines/mutable_side_effect_state_machine.rs +0 -0
  59. package/sdk-core/core/src/{workflow → worker/workflow}/machines/patch_state_machine.rs +1 -1
  60. package/sdk-core/core/src/{workflow → worker/workflow}/machines/side_effect_state_machine.rs +0 -0
  61. package/sdk-core/core/src/{workflow → worker/workflow}/machines/signal_external_state_machine.rs +4 -2
  62. package/sdk-core/core/src/{workflow → worker/workflow}/machines/timer_state_machine.rs +1 -2
  63. package/sdk-core/core/src/{workflow → worker/workflow}/machines/transition_coverage.rs +1 -1
  64. package/sdk-core/core/src/{workflow → worker/workflow}/machines/upsert_search_attributes_state_machine.rs +5 -7
  65. package/sdk-core/core/src/{workflow → worker/workflow}/machines/workflow_machines/local_acts.rs +2 -2
  66. package/sdk-core/core/src/{workflow → worker/workflow}/machines/workflow_machines.rs +40 -16
  67. package/sdk-core/core/src/{workflow → worker/workflow}/machines/workflow_task_state_machine.rs +0 -0
  68. package/sdk-core/core/src/worker/workflow/managed_run/managed_wf_test.rs +198 -0
  69. package/sdk-core/core/src/worker/workflow/managed_run.rs +627 -0
  70. package/sdk-core/core/src/worker/workflow/mod.rs +1115 -0
  71. package/sdk-core/core/src/worker/workflow/run_cache.rs +143 -0
  72. package/sdk-core/core/src/worker/workflow/wft_poller.rs +88 -0
  73. package/sdk-core/core/src/worker/workflow/workflow_stream.rs +936 -0
  74. package/sdk-core/core-api/src/errors.rs +3 -10
  75. package/sdk-core/core-api/src/lib.rs +2 -1
  76. package/sdk-core/core-api/src/worker.rs +26 -2
  77. package/sdk-core/etc/dynamic-config.yaml +2 -0
  78. package/sdk-core/integ-with-otel.sh +1 -1
  79. package/sdk-core/protos/api_upstream/Makefile +4 -4
  80. package/sdk-core/protos/api_upstream/api-linter.yaml +2 -0
  81. package/sdk-core/protos/api_upstream/buf.yaml +8 -9
  82. package/sdk-core/protos/api_upstream/temporal/api/cluster/v1/message.proto +83 -0
  83. package/sdk-core/protos/api_upstream/temporal/api/command/v1/message.proto +7 -1
  84. package/sdk-core/protos/api_upstream/temporal/api/enums/v1/cluster.proto +40 -0
  85. package/sdk-core/protos/api_upstream/temporal/api/enums/v1/failed_cause.proto +3 -0
  86. package/sdk-core/protos/api_upstream/temporal/api/enums/v1/reset.proto +3 -1
  87. package/sdk-core/protos/api_upstream/temporal/api/enums/v1/schedule.proto +60 -0
  88. package/sdk-core/protos/api_upstream/temporal/api/enums/v1/workflow.proto +3 -0
  89. package/sdk-core/protos/api_upstream/temporal/api/errordetails/v1/message.proto +32 -4
  90. package/sdk-core/protos/api_upstream/temporal/api/history/v1/message.proto +69 -19
  91. package/sdk-core/protos/api_upstream/temporal/api/namespace/v1/message.proto +13 -0
  92. package/sdk-core/protos/api_upstream/temporal/api/operatorservice/v1/request_response.proto +163 -0
  93. package/sdk-core/protos/api_upstream/temporal/api/operatorservice/v1/service.proto +97 -0
  94. package/sdk-core/protos/api_upstream/temporal/api/schedule/v1/message.proto +300 -0
  95. package/sdk-core/protos/api_upstream/temporal/api/workflow/v1/message.proto +25 -0
  96. package/sdk-core/protos/api_upstream/temporal/api/workflowservice/v1/request_response.proto +180 -3
  97. package/sdk-core/protos/api_upstream/temporal/api/workflowservice/v1/service.proto +53 -3
  98. package/sdk-core/protos/local/temporal/sdk/core/activity_result/activity_result.proto +2 -2
  99. package/sdk-core/protos/local/temporal/sdk/core/activity_task/activity_task.proto +6 -5
  100. package/sdk-core/protos/local/temporal/sdk/core/bridge/bridge.proto +27 -6
  101. package/sdk-core/protos/local/temporal/sdk/core/child_workflow/child_workflow.proto +2 -1
  102. package/sdk-core/protos/local/temporal/sdk/core/common/common.proto +0 -64
  103. package/sdk-core/protos/local/temporal/sdk/core/core_interface.proto +2 -1
  104. package/sdk-core/protos/local/temporal/sdk/core/workflow_activation/workflow_activation.proto +11 -8
  105. package/sdk-core/protos/local/temporal/sdk/core/workflow_commands/workflow_commands.proto +30 -25
  106. package/sdk-core/sdk/src/activity_context.rs +12 -5
  107. package/sdk-core/sdk/src/app_data.rs +37 -0
  108. package/sdk-core/sdk/src/lib.rs +76 -43
  109. package/sdk-core/sdk/src/workflow_context/options.rs +8 -6
  110. package/sdk-core/sdk/src/workflow_context.rs +14 -19
  111. package/sdk-core/sdk/src/workflow_future.rs +11 -6
  112. package/sdk-core/sdk-core-protos/src/history_builder.rs +19 -5
  113. package/sdk-core/sdk-core-protos/src/history_info.rs +11 -6
  114. package/sdk-core/sdk-core-protos/src/lib.rs +87 -176
  115. package/sdk-core/test-utils/src/histfetch.rs +1 -1
  116. package/sdk-core/test-utils/src/lib.rs +93 -77
  117. package/sdk-core/tests/integ_tests/client_tests.rs +2 -2
  118. package/sdk-core/tests/integ_tests/heartbeat_tests.rs +11 -9
  119. package/sdk-core/tests/integ_tests/polling_tests.rs +12 -0
  120. package/sdk-core/tests/integ_tests/queries_tests.rs +39 -22
  121. package/sdk-core/tests/integ_tests/workflow_tests/activities.rs +49 -4
  122. package/sdk-core/tests/integ_tests/workflow_tests/appdata_propagation.rs +61 -0
  123. package/sdk-core/tests/integ_tests/workflow_tests/cancel_wf.rs +1 -1
  124. package/sdk-core/tests/integ_tests/workflow_tests/local_activities.rs +74 -13
  125. package/sdk-core/tests/integ_tests/workflow_tests/replay.rs +19 -0
  126. package/sdk-core/tests/integ_tests/workflow_tests/resets.rs +1 -1
  127. package/sdk-core/tests/integ_tests/workflow_tests/upsert_search_attrs.rs +6 -3
  128. package/sdk-core/tests/integ_tests/workflow_tests.rs +10 -23
  129. package/sdk-core/tests/load_tests.rs +8 -3
  130. package/sdk-core/tests/main.rs +7 -3
  131. package/src/conversions.rs +149 -70
  132. package/src/errors.rs +10 -21
  133. package/src/lib.rs +400 -319
  134. package/sdk-core/core/src/pending_activations.rs +0 -173
  135. package/sdk-core/core/src/worker/wft_delivery.rs +0 -81
  136. package/sdk-core/core/src/workflow/mod.rs +0 -478
  137. package/sdk-core/core/src/workflow/workflow_tasks/cache_manager.rs +0 -194
  138. package/sdk-core/core/src/workflow/workflow_tasks/concurrency_manager.rs +0 -418
  139. package/sdk-core/core/src/workflow/workflow_tasks/mod.rs +0 -989
package/src/errors.rs CHANGED
@@ -6,8 +6,6 @@ pub static TRANSPORT_ERROR: OnceCell<Root<JsFunction>> = OnceCell::new();
6
6
  /// Thrown after shutdown was requested as a response to a poll function, JS should stop polling
7
7
  /// once this error is encountered
8
8
  pub static SHUTDOWN_ERROR: OnceCell<Root<JsFunction>> = OnceCell::new();
9
- /// Thrown when using a method for a worker that does not exist (never registered or already shut down)
10
- pub static NO_WORKER_ERROR: OnceCell<Root<JsFunction>> = OnceCell::new();
11
9
  /// Something unexpected happened, considered fatal
12
10
  pub static UNEXPECTED_ERROR: OnceCell<Root<JsFunction>> = OnceCell::new();
13
11
  /// Used in different parts of the project to signal that something unexpected has happened
@@ -22,14 +20,14 @@ pub trait CustomError {
22
20
  where
23
21
  C: Context<'a>;
24
22
 
25
- fn from_string<'a, C>(&self, cx: &mut C, message: String) -> JsResult<'a, JsObject>
23
+ fn from_string<'a, C>(&self, cx: &mut C, message: impl Into<String>) -> JsResult<'a, JsObject>
26
24
  where
27
25
  C: Context<'a>;
28
26
 
29
27
  fn from_error<'a, C, E>(&self, cx: &mut C, err: E) -> JsResult<'a, JsObject>
30
28
  where
31
29
  C: Context<'a>,
32
- E: std::fmt::Display;
30
+ E: std::error::Error;
33
31
  }
34
32
 
35
33
  // Implement `CustomError` for ALL errors in a `OnceCell`. This only needs to be
@@ -48,20 +46,20 @@ impl CustomError for OnceCell<Root<JsFunction>> {
48
46
  error.construct(cx, args)
49
47
  }
50
48
 
51
- fn from_string<'a, C>(&self, cx: &mut C, message: String) -> JsResult<'a, JsObject>
49
+ fn from_string<'a, C>(&self, cx: &mut C, message: impl Into<String>) -> JsResult<'a, JsObject>
52
50
  where
53
51
  C: Context<'a>,
54
52
  {
55
- let args = vec![cx.string(message).upcast()];
53
+ let args = vec![cx.string(message.into()).upcast()];
56
54
  self.construct(cx, args)
57
55
  }
58
56
 
59
57
  fn from_error<'a, C, E>(&self, cx: &mut C, err: E) -> JsResult<'a, JsObject>
60
58
  where
61
59
  C: Context<'a>,
62
- E: std::fmt::Display,
60
+ E: std::error::Error,
63
61
  {
64
- self.from_string(cx, format!("{}", err))
62
+ self.from_string(cx, format!("{:?}", err))
65
63
  }
66
64
  }
67
65
 
@@ -77,29 +75,20 @@ pub fn register_errors(mut cx: FunctionContext) -> JsResult<JsUndefined> {
77
75
 
78
76
  let mapping = cx.argument::<JsObject>(0)?;
79
77
  let shutdown_error = mapping
80
- .get(&mut cx, "ShutdownError")?
81
- .downcast_or_throw::<JsFunction, FunctionContext>(&mut cx)?
82
- .root(&mut cx);
83
- let no_worker_error = mapping
84
- .get(&mut cx, "NoWorkerRegisteredError")?
85
- .downcast_or_throw::<JsFunction, FunctionContext>(&mut cx)?
78
+ .get::<JsFunction, _, _>(&mut cx, "ShutdownError")?
86
79
  .root(&mut cx);
87
80
  let transport_error = mapping
88
- .get(&mut cx, "TransportError")?
89
- .downcast_or_throw::<JsFunction, FunctionContext>(&mut cx)?
81
+ .get::<JsFunction, _, _>(&mut cx, "TransportError")?
90
82
  .root(&mut cx);
91
83
  let unexpected_error = mapping
92
- .get(&mut cx, "UnexpectedError")?
93
- .downcast_or_throw::<JsFunction, FunctionContext>(&mut cx)?
84
+ .get::<JsFunction, _, _>(&mut cx, "UnexpectedError")?
94
85
  .root(&mut cx);
95
86
  let illegal_state_error = mapping
96
- .get(&mut cx, "IllegalStateError")?
97
- .downcast_or_throw::<JsFunction, FunctionContext>(&mut cx)?
87
+ .get::<JsFunction, _, _>(&mut cx, "IllegalStateError")?
98
88
  .root(&mut cx);
99
89
 
100
90
  TRANSPORT_ERROR.get_or_try_init(|| Ok(transport_error))?;
101
91
  SHUTDOWN_ERROR.get_or_try_init(|| Ok(shutdown_error))?;
102
- NO_WORKER_ERROR.get_or_try_init(|| Ok(no_worker_error))?;
103
92
  UNEXPECTED_ERROR.get_or_try_init(|| Ok(unexpected_error))?;
104
93
  ILLEGAL_STATE_ERROR.get_or_try_init(|| Ok(illegal_state_error))?;
105
94