@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
@@ -58,8 +58,7 @@ async fn parallel_workflows_same_queue() {
58
58
  let num_workflows = 25usize;
59
59
 
60
60
  let run_ids: Vec<_> = future::join_all(
61
- (0..num_workflows)
62
- .map(|i| starter.start_wf_with_id(format!("wf-id-{}", i), WorkflowOptions::default())),
61
+ (0..num_workflows).map(|i| starter.start_wf_with_id(format!("wf-id-{i}"))),
63
62
  )
64
63
  .await;
65
64
 
@@ -435,8 +434,8 @@ async fn wft_timeout_doesnt_create_unsolvable_autocomplete() {
435
434
  wf_starter
436
435
  // Test needs eviction on and a short timeout
437
436
  .max_cached_workflows(0)
438
- .max_wft(1)
439
- .wft_timeout(Duration::from_secs(1));
437
+ .max_wft(1);
438
+ wf_starter.workflow_options.task_timeout = Some(Duration::from_secs(1));
440
439
  let core = wf_starter.get_worker().await;
441
440
  let client = wf_starter.get_client().await;
442
441
  let task_q = wf_starter.get_task_queue();
@@ -460,7 +459,7 @@ async fn wft_timeout_doesnt_create_unsolvable_autocomplete() {
460
459
  .unwrap();
461
460
  wf_task
462
461
  };
463
- wf_starter.start_wf().await;
462
+ wf_starter.start_wf_with_id(wf_id.to_string()).await;
464
463
 
465
464
  // Poll and schedule the activity
466
465
  let wf_task = poll_sched_act().await;
@@ -572,7 +571,7 @@ async fn slow_completes_with_small_cache() {
572
571
  for i in 0..20 {
573
572
  worker
574
573
  .submit_wf(
575
- format!("{}_{}", wf_name, i),
574
+ format!("{wf_name}_{i}"),
576
575
  wf_name.to_owned(),
577
576
  vec![],
578
577
  WorkflowOptions::default(),
@@ -1,22 +1,12 @@
1
1
  //! Integration tests
2
- //!
3
- //! Note that integ tests which want to use the server (nearly all of them) *need* to use the
4
- //! `#[rstest]` macro and accept the TODO fixture to support auto setup & teardown of ephemeral
5
- //! local servers.
6
2
 
7
3
  #[macro_use]
8
4
  extern crate rstest;
5
+ #[macro_use]
6
+ extern crate temporal_sdk_core_test_utils;
9
7
 
10
8
  #[cfg(test)]
11
9
  mod integ_tests {
12
- #[macro_export]
13
- macro_rules! prost_dur {
14
- ($dur_call:ident $args:tt) => {
15
- std::time::Duration::$dur_call$args
16
- .try_into()
17
- .expect("test duration fits")
18
- };
19
- }
20
10
  mod client_tests;
21
11
  mod ephemeral_server_tests;
22
12
  mod heartbeat_tests;
@@ -1,7 +1,7 @@
1
1
  use anyhow::{anyhow, bail};
2
+ use clap::Parser;
2
3
  use std::{
3
4
  env,
4
- env::args,
5
5
  path::{Path, PathBuf},
6
6
  process::Stdio,
7
7
  };
@@ -12,51 +12,88 @@ use temporal_sdk_core_test_utils::{
12
12
  };
13
13
  use tokio::{self, process::Command};
14
14
 
15
+ #[derive(clap::Parser)]
16
+ #[command(author, version, about, long_about = None)]
17
+ struct Cli {
18
+ /// Test harness to run. Anything defined as a `[[test]]` in core's `Cargo.toml` is valid.
19
+ #[arg(short, long, default_value = "integ_tests")]
20
+ test_name: String,
21
+
22
+ /// What kind of server to auto-launch, if any
23
+ #[arg(short, long, value_enum, default_value = "temporalite")]
24
+ server_kind: ServerKind,
25
+
26
+ /// Arguments to pass through to the `cargo test` command. Ex: `--release`
27
+ #[arg(short, long, allow_hyphen_values(true))]
28
+ cargo_test_args: Vec<String>,
29
+
30
+ /// The rest of the arguments will be passed through to the test harness
31
+ harness_args: Vec<String>,
32
+ }
33
+
34
+ #[derive(Copy, Clone, PartialEq, Eq, clap::ValueEnum)]
35
+ enum ServerKind {
36
+ /// Use Temporalite
37
+ Temporalite,
38
+ /// Use the Java test server
39
+ TestServer,
40
+ /// Do not automatically start any server
41
+ External,
42
+ }
43
+
15
44
  #[tokio::main]
16
45
  async fn main() -> Result<(), anyhow::Error> {
46
+ let Cli {
47
+ test_name,
48
+ server_kind,
49
+ cargo_test_args,
50
+ harness_args,
51
+ } = Cli::parse();
17
52
  let cargo = env::var("CARGO").unwrap_or_else(|_| "cargo".to_string());
18
- let server_type = env::var("INTEG_SERVER_TYPE")
19
- .unwrap_or_else(|_| "temporalite".to_string())
20
- .to_lowercase();
21
53
  // Try building first, so that we error early on build failures & don't start server
54
+ let test_args_preamble = ["test", "--test", &test_name]
55
+ .into_iter()
56
+ .map(ToString::to_string)
57
+ .chain(cargo_test_args)
58
+ .collect::<Vec<_>>();
22
59
  let status = Command::new(&cargo)
23
- .args(["test", "--test", "integ_tests", "--no-run"])
60
+ .args([test_args_preamble.as_slice(), &["--no-run".to_string()]].concat())
24
61
  .status()
25
62
  .await?;
26
63
  if !status.success() {
27
64
  bail!("Building integration tests failed!");
28
65
  }
29
66
 
30
- // Move to clap if we start doing any more complicated input
31
- let (server, envs) = if server_type == "test-server" {
32
- let config = TestServerConfigBuilder::default()
33
- .exe(default_cached_download())
34
- .build()?;
35
- println!("Using java test server");
36
- (
37
- Some(config.start_server_with_output(Stdio::null()).await?),
38
- vec![(INTEG_TEST_SERVER_USED_ENV_VAR, "true")],
39
- )
40
- } else if server_type == "temporalite" {
41
- let config = TemporaliteConfigBuilder::default()
42
- .exe(default_cached_download())
43
- .build()?;
44
- println!("Using temporalite");
45
- (
46
- Some(config.start_server_with_output(Stdio::null()).await?),
47
- vec![(INTEG_TEMPORALITE_USED_ENV_VAR, "true")],
48
- )
49
- } else {
50
- println!("Not starting up a server. One should be running already.");
51
- (None, vec![])
67
+ let (server, envs) = match server_kind {
68
+ ServerKind::Temporalite => {
69
+ let config = TemporaliteConfigBuilder::default()
70
+ .exe(default_cached_download())
71
+ .build()?;
72
+ println!("Using temporalite");
73
+ (
74
+ Some(config.start_server_with_output(Stdio::null()).await?),
75
+ vec![(INTEG_TEMPORALITE_USED_ENV_VAR, "true")],
76
+ )
77
+ }
78
+ ServerKind::TestServer => {
79
+ let config = TestServerConfigBuilder::default()
80
+ .exe(default_cached_download())
81
+ .build()?;
82
+ println!("Using java test server");
83
+ (
84
+ Some(config.start_server_with_output(Stdio::null()).await?),
85
+ vec![(INTEG_TEST_SERVER_USED_ENV_VAR, "true")],
86
+ )
87
+ }
88
+ ServerKind::External => {
89
+ println!("Not starting up a server. One should be running already.");
90
+ (None, vec![])
91
+ }
52
92
  };
53
93
 
54
- // Run the integ tests, passing through arguments
55
- let mut args = args();
56
- // Shift off binary name
57
- args.next();
58
94
  let mut cmd = Command::new(&cargo);
59
95
  if let Some(srv) = server.as_ref() {
96
+ println!("Running on {}", srv.target);
60
97
  cmd.env(
61
98
  INTEG_SERVER_TARGET_ENV_VAR,
62
99
  format!("http://{}", &srv.target),
@@ -66,10 +103,10 @@ async fn main() -> Result<(), anyhow::Error> {
66
103
  .envs(envs)
67
104
  .current_dir(project_root())
68
105
  .args(
69
- ["test", "--test", "integ_tests"]
106
+ test_args_preamble
70
107
  .into_iter()
71
- .map(ToString::to_string)
72
- .chain(args),
108
+ .chain(["--".to_string()])
109
+ .chain(harness_args),
73
110
  )
74
111
  .status()
75
112
  .await?;
@@ -0,0 +1,32 @@
1
+ use anyhow::Context;
2
+ use clap::Parser;
3
+ use futures_util::StreamExt;
4
+ use std::path::PathBuf;
5
+ use temporal_sdk_core::replay_wf_state_inputs;
6
+ use temporal_sdk_core_test_utils::{init_integ_telem, wf_input_saver::read_from_file};
7
+
8
+ #[derive(clap::Parser)]
9
+ #[command(author, version, about, long_about = None)]
10
+ struct Cli {
11
+ /// Path to file containing the saved wf input data
12
+ replay_data: PathBuf,
13
+ }
14
+
15
+ #[tokio::main]
16
+ async fn main() -> Result<(), anyhow::Error> {
17
+ init_integ_telem();
18
+ let Cli { replay_data } = Cli::parse();
19
+ let replay_dat = read_from_file(replay_data)
20
+ .await
21
+ .context("while reading replay data file")?;
22
+
23
+ replay_wf_state_inputs(
24
+ replay_dat.config,
25
+ replay_dat
26
+ .inputs
27
+ .map(|r| r.expect("Reading bytes from file works").to_vec()),
28
+ )
29
+ .await;
30
+
31
+ Ok(())
32
+ }
@@ -1,24 +0,0 @@
1
- [package]
2
- name = "temporal-sdk-core-bridge-ffi"
3
- version = "0.1.0"
4
- edition = "2021"
5
- license-file = "LICENSE.txt"
6
- description = "FFI Bridge for Core"
7
- homepage = "https://temporal.io/"
8
- repository = "https://github.com/temporalio/sdk-core"
9
-
10
- [lib]
11
- crate-type = ["staticlib"]
12
-
13
- [dependencies]
14
- lazy_static = "1.4"
15
- libc = "0.2"
16
- prost = "0.11"
17
- temporal-sdk-core = { version = "0.1", path = "../core" }
18
- temporal-sdk-core-api = { version = "0.1", path = "../core-api" }
19
- temporal-sdk-core-protos = { version = "0.1", path = "../sdk-core-protos" }
20
- tokio = "1"
21
- tracing = "0.1"
22
-
23
- [build-dependencies]
24
- cbindgen = "0.24"
@@ -1,23 +0,0 @@
1
- Temporal Core SDK
2
-
3
- The MIT License
4
-
5
- Copyright (c) 2022 Temporal Technologies, Inc. All Rights Reserved
6
-
7
- Permission is hereby granted, free of charge, to any person obtaining a copy
8
- of this software and associated documentation files (the "Software"), to deal
9
- in the Software without restriction, including without limitation the rights
10
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
- copies of the Software, and to permit persons to whom the Software is
12
- furnished to do so, subject to the following conditions:
13
-
14
- The above copyright notice and this permission notice shall be included in all
15
- copies or substantial portions of the Software.
16
-
17
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
- SOFTWARE.
@@ -1,25 +0,0 @@
1
- extern crate cbindgen;
2
-
3
- use std::env;
4
-
5
- fn main() {
6
- let crate_dir = env::var("CARGO_MANIFEST_DIR").unwrap();
7
-
8
- let changed = cbindgen::Builder::new()
9
- .with_crate(crate_dir)
10
- .with_pragma_once(true)
11
- .with_language(cbindgen::Language::C)
12
- .generate()
13
- .expect("Unable to generate bindings")
14
- .write_to_file("include/sdk-core-bridge.h");
15
-
16
- // If this changed and an env var disallows change, error
17
- if let Ok(env_val) = env::var("TEMPORAL_SDK_CORE_BRIDGE_FFI_DISABLE_HEADER_CHANGE") {
18
- if changed && env_val == "true" {
19
- println!(
20
- "cargo:warning=bridge-ffi's header file changed unexpectedly from what's on disk"
21
- );
22
- std::process::exit(1);
23
- }
24
- }
25
- }
@@ -1,224 +0,0 @@
1
- #pragma once
2
-
3
- #include <stdarg.h>
4
- #include <stdbool.h>
5
- #include <stdint.h>
6
- #include <stdlib.h>
7
-
8
- /**
9
- * A client instance owned by Core. This must be passed to [tmprl_client_free]
10
- * when no longer in use which will free the resources.
11
- */
12
- typedef struct tmprl_client_t tmprl_client_t;
13
-
14
- /**
15
- * A runtime owned by Core. This must be passed to [tmprl_runtime_free] when no longer in use. This
16
- * should not be freed until every call to every [tmprl_worker_t] instance created with this
17
- * runtime has been shutdown. In practice, since the actual runtime is behind an [Arc], it's
18
- * currently OK, but that's an implementation detail.
19
- */
20
- typedef struct tmprl_runtime_t tmprl_runtime_t;
21
-
22
- /**
23
- * A worker instance owned by Core. This must be passed to [tmprl_worker_shutdown]
24
- * when no longer in use which will free the resources.
25
- */
26
- typedef struct tmprl_worker_t tmprl_worker_t;
27
-
28
- /**
29
- * A set of bytes owned by Core. No fields within nor any bytes references must
30
- * ever be mutated outside of Core. This must always be passed to
31
- * tmprl_bytes_free when no longer in use.
32
- */
33
- typedef struct tmprl_bytes_t {
34
- const uint8_t *bytes;
35
- size_t len;
36
- /**
37
- * For internal use only.
38
- */
39
- size_t cap;
40
- /**
41
- * For internal use only.
42
- */
43
- bool disable_free;
44
- } tmprl_bytes_t;
45
-
46
- /**
47
- * Callback called by [tmprl_worker_init] on completion. The first parameter of the
48
- * callback is user data passed into the original function. The second
49
- * parameter is a worker instance if the call is successful or null if not. If
50
- * present, the worker instance must be freed via [tmprl_worker_shutdown] when no
51
- * longer in use. The third parameter of the callback is a byte array for a
52
- * [InitResponse] protobuf message which must be freed via [tmprl_bytes_free].
53
- */
54
- typedef void (*tmprl_worker_init_callback)(void *user_data, struct tmprl_worker_t *worker, const struct tmprl_bytes_t *resp);
55
-
56
- /**
57
- * Callback called on function completion. The first parameter of the callback
58
- * is user data passed into the original function. The second parameter of the
59
- * callback is a never-null byte array for a response protobuf message which
60
- * must be freed via [tmprl_bytes_free].
61
- */
62
- typedef void (*tmprl_callback)(void *user_data, const struct tmprl_bytes_t *core);
63
-
64
- /**
65
- * Callback called by [tmprl_client_init] on completion. The first parameter of the
66
- * callback is user data passed into the original function. The second
67
- * parameter is a client instance if the call is successful or null if not. If
68
- * present, the client instance must be freed via [tmprl_client_free] when no
69
- * longer in use. The third parameter of the callback is a byte array for a
70
- * [InitResponse] protobuf message which must be freed via [tmprl_bytes_free].
71
- */
72
- typedef void (*tmprl_client_init_callback)(void *user_data, struct tmprl_client_t *client, const struct tmprl_bytes_t *resp);
73
-
74
- /**
75
- * Free a set of bytes. The first parameter can be null in cases where a [tmprl_worker_t] instance
76
- * isn't available. If the second parameter is null, this is a no-op.
77
- */
78
- void tmprl_bytes_free(struct tmprl_worker_t *worker, const struct tmprl_bytes_t *bytes);
79
-
80
- /**
81
- * Create a new runtime. The result is never null and must be freed via
82
- * tmprl_runtime_free when no longer in use.
83
- */
84
- struct tmprl_runtime_t *tmprl_runtime_new(void);
85
-
86
- /**
87
- * Free a previously created runtime.
88
- */
89
- void tmprl_runtime_free(struct tmprl_runtime_t *runtime);
90
-
91
- /**
92
- * Create a new worker instance.
93
- *
94
- * `runtime` and `client` are both required and must outlive this instance.
95
- * `req_proto` and `req_proto_len` represent a byte array for a [CreateWorkerRequest] protobuf
96
- * message.
97
- * The callback is invoked on completion.
98
- */
99
- void tmprl_worker_init(struct tmprl_runtime_t *runtime,
100
- struct tmprl_client_t *client,
101
- const uint8_t *req_proto,
102
- size_t req_proto_len,
103
- void *user_data,
104
- tmprl_worker_init_callback callback);
105
-
106
- /**
107
- * Shutdown and free a previously created worker.
108
- *
109
- * The req_proto and req_proto_len represent a byte array for a [bridge::ShutdownWorkerRequest]
110
- * protobuf message, which currently contains nothing and are unused, but the parameters are kept
111
- * for now.
112
- *
113
- * The callback is invoked on completion with a ShutdownWorkerResponse protobuf message.
114
- *
115
- * After the callback has been called, the worker struct will be freed and the pointer will no
116
- * longer be valid.
117
- */
118
- void tmprl_worker_shutdown(struct tmprl_worker_t *worker,
119
- const uint8_t *req_proto,
120
- size_t req_proto_len,
121
- void *user_data,
122
- tmprl_callback callback);
123
-
124
- /**
125
- * Initialize a client connection to the Temporal service.
126
- *
127
- * The runtime is required and must outlive this instance. The `req_proto` and `req_proto_len`
128
- * represent a byte array for a [CreateClientRequest] protobuf message. The callback is invoked on
129
- * completion.
130
- */
131
- void tmprl_client_init(struct tmprl_runtime_t *runtime,
132
- const uint8_t *req_proto,
133
- size_t req_proto_len,
134
- void *user_data,
135
- tmprl_client_init_callback callback);
136
-
137
- /**
138
- * Free a previously created client
139
- */
140
- void tmprl_client_free(struct tmprl_client_t *client);
141
-
142
- /**
143
- * Poll for a workflow activation.
144
- *
145
- * The `req_proto` and `req_proto_len` represent a byte array for a
146
- * [bridge::PollWorkflowActivationRequest] protobuf message, which currently contains nothing and
147
- * is unused, but the parameters are kept for now.
148
- *
149
- * The callback is invoked on completion with a [bridge::PollWorkflowActivationResponse] protobuf
150
- * message.
151
- */
152
- void tmprl_poll_workflow_activation(struct tmprl_worker_t *worker,
153
- const uint8_t *req_proto,
154
- size_t req_proto_len,
155
- void *user_data,
156
- tmprl_callback callback);
157
-
158
- /**
159
- * Poll for an activity task.
160
- *
161
- * The `req_proto` and `req_proto_len` represent a byte array for a
162
- * [bridge::PollActivityTaskRequest] protobuf message, which currently contains nothing and is
163
- * unused, but the parameters are kept for now.
164
- *
165
- * The callback is invoked on completion with a [bridge::PollActivityTaskResponse] protobuf
166
- * message.
167
- */
168
- void tmprl_poll_activity_task(struct tmprl_worker_t *worker,
169
- const uint8_t *req_proto,
170
- size_t req_proto_len,
171
- void *user_data,
172
- tmprl_callback callback);
173
-
174
- /**
175
- * Complete a workflow activation.
176
- *
177
- * The `req_proto` and `req_proto_len` represent a byte array for a
178
- * [bridge::CompleteWorkflowActivationRequest] protobuf message. The callback is invoked on
179
- * completion with a [bridge::CompleteWorkflowActivationResponse] protobuf message.
180
- */
181
- void tmprl_complete_workflow_activation(struct tmprl_worker_t *worker,
182
- const uint8_t *req_proto,
183
- size_t req_proto_len,
184
- void *user_data,
185
- tmprl_callback callback);
186
-
187
- /**
188
- * Complete an activity task.
189
- *
190
- * The `req_proto` and `req_proto_len` represent a byte array for a
191
- * [bridge::CompleteActivityTaskRequest] protobuf message. The callback is invoked on completion
192
- * with a [bridge::CompleteActivityTaskResponse] protobuf message.
193
- */
194
- void tmprl_complete_activity_task(struct tmprl_worker_t *worker,
195
- const uint8_t *req_proto,
196
- size_t req_proto_len,
197
- void *user_data,
198
- tmprl_callback callback);
199
-
200
- /**
201
- * Record an activity heartbeat.
202
- *
203
- * `req_proto` and `req_proto_len` represent a byte array for a
204
- * [bridge::RecordActivityHeartbeatRequest] protobuf message. The callback is invoked on completion
205
- * with a RecordActivityHeartbeatResponse protobuf message.
206
- */
207
- void tmprl_record_activity_heartbeat(struct tmprl_worker_t *worker,
208
- const uint8_t *req_proto,
209
- size_t req_proto_len,
210
- void *user_data,
211
- tmprl_callback callback);
212
-
213
- /**
214
- * Request a workflow eviction.
215
- *
216
- * The `req_proto` and `req_proto_len` represent a byte array for a
217
- * [bridge::RequestWorkflowEvictionRequest] protobuf message. The callback is invoked on completion
218
- * with a [bridge::RequestWorkflowEvictionResponse] protobuf message.
219
- */
220
- void tmprl_request_workflow_eviction(struct tmprl_worker_t *worker,
221
- const uint8_t *req_proto,
222
- size_t req_proto_len,
223
- void *user_data,
224
- tmprl_callback callback);