@temporalio/core-bridge 0.17.2 → 0.18.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 (170) hide show
  1. package/Cargo.lock +339 -226
  2. package/Cargo.toml +7 -3
  3. package/common.js +50 -0
  4. package/index.d.ts +7 -0
  5. package/index.js +12 -0
  6. package/package.json +7 -4
  7. package/releases/aarch64-apple-darwin/index.node +0 -0
  8. package/releases/aarch64-unknown-linux-gnu/index.node +0 -0
  9. package/{index.node → releases/index.node} +0 -0
  10. package/releases/x86_64-apple-darwin/index.node +0 -0
  11. package/releases/x86_64-pc-windows-msvc/index.node +0 -0
  12. package/releases/x86_64-unknown-linux-gnu/index.node +0 -0
  13. package/scripts/build.js +10 -50
  14. package/sdk-core/.buildkite/docker/Dockerfile +1 -1
  15. package/sdk-core/.buildkite/docker/docker-compose.yaml +2 -2
  16. package/sdk-core/.buildkite/pipeline.yml +2 -0
  17. package/sdk-core/Cargo.toml +1 -88
  18. package/sdk-core/README.md +30 -6
  19. package/sdk-core/bridge-ffi/Cargo.toml +24 -0
  20. package/sdk-core/bridge-ffi/LICENSE.txt +23 -0
  21. package/sdk-core/bridge-ffi/build.rs +25 -0
  22. package/sdk-core/bridge-ffi/include/sdk-core-bridge.h +216 -0
  23. package/sdk-core/bridge-ffi/src/lib.rs +829 -0
  24. package/sdk-core/bridge-ffi/src/wrappers.rs +193 -0
  25. package/sdk-core/client/Cargo.toml +32 -0
  26. package/sdk-core/{src/pollers/gateway.rs → client/src/lib.rs} +101 -195
  27. package/sdk-core/client/src/metrics.rs +89 -0
  28. package/sdk-core/client/src/mocks.rs +167 -0
  29. package/sdk-core/{src/pollers → client/src}/retry.rs +172 -14
  30. package/sdk-core/core/Cargo.toml +96 -0
  31. package/sdk-core/{src → core/src}/core_tests/activity_tasks.rs +193 -37
  32. package/sdk-core/{src → core/src}/core_tests/child_workflows.rs +14 -14
  33. package/sdk-core/{src → core/src}/core_tests/determinism.rs +8 -8
  34. package/sdk-core/core/src/core_tests/local_activities.rs +328 -0
  35. package/sdk-core/{src → core/src}/core_tests/mod.rs +6 -9
  36. package/sdk-core/{src → core/src}/core_tests/queries.rs +45 -52
  37. package/sdk-core/{src → core/src}/core_tests/replay_flag.rs +8 -12
  38. package/sdk-core/{src → core/src}/core_tests/workers.rs +120 -33
  39. package/sdk-core/{src → core/src}/core_tests/workflow_cancels.rs +16 -26
  40. package/sdk-core/{src → core/src}/core_tests/workflow_tasks.rs +264 -286
  41. package/sdk-core/core/src/lib.rs +374 -0
  42. package/sdk-core/{src → core/src}/log_export.rs +3 -27
  43. package/sdk-core/core/src/pending_activations.rs +162 -0
  44. package/sdk-core/{src → core/src}/pollers/mod.rs +4 -22
  45. package/sdk-core/{src → core/src}/pollers/poll_buffer.rs +1 -1
  46. package/sdk-core/core/src/protosext/mod.rs +396 -0
  47. package/sdk-core/core/src/replay/mod.rs +210 -0
  48. package/sdk-core/core/src/retry_logic.rs +144 -0
  49. package/sdk-core/{src → core/src}/telemetry/metrics.rs +3 -58
  50. package/sdk-core/{src → core/src}/telemetry/mod.rs +8 -8
  51. package/sdk-core/{src → core/src}/telemetry/prometheus_server.rs +0 -0
  52. package/sdk-core/{src → core/src}/test_help/mod.rs +34 -73
  53. package/sdk-core/{src → core/src}/worker/activities/activity_heartbeat_manager.rs +95 -42
  54. package/sdk-core/core/src/worker/activities/local_activities.rs +973 -0
  55. package/sdk-core/{src → core/src}/worker/activities.rs +52 -33
  56. package/sdk-core/{src → core/src}/worker/dispatcher.rs +8 -6
  57. package/sdk-core/{src → core/src}/worker/mod.rs +305 -195
  58. package/sdk-core/core/src/worker/wft_delivery.rs +81 -0
  59. package/sdk-core/{src → core/src}/workflow/bridge.rs +5 -2
  60. package/sdk-core/{src → core/src}/workflow/driven_workflow.rs +17 -7
  61. package/sdk-core/{src → core/src}/workflow/history_update.rs +33 -7
  62. package/sdk-core/{src → core/src/workflow}/machines/activity_state_machine.rs +26 -26
  63. package/sdk-core/{src → core/src/workflow}/machines/cancel_external_state_machine.rs +8 -11
  64. package/sdk-core/{src → core/src/workflow}/machines/cancel_workflow_state_machine.rs +19 -21
  65. package/sdk-core/{src → core/src/workflow}/machines/child_workflow_state_machine.rs +19 -21
  66. package/sdk-core/{src → core/src/workflow}/machines/complete_workflow_state_machine.rs +3 -5
  67. package/sdk-core/{src → core/src/workflow}/machines/continue_as_new_workflow_state_machine.rs +18 -18
  68. package/sdk-core/{src → core/src/workflow}/machines/fail_workflow_state_machine.rs +5 -6
  69. package/sdk-core/core/src/workflow/machines/local_activity_state_machine.rs +1451 -0
  70. package/sdk-core/{src → core/src/workflow}/machines/mod.rs +54 -107
  71. package/sdk-core/{src → core/src/workflow}/machines/mutable_side_effect_state_machine.rs +0 -0
  72. package/sdk-core/{src → core/src/workflow}/machines/patch_state_machine.rs +29 -30
  73. package/sdk-core/{src → core/src/workflow}/machines/side_effect_state_machine.rs +0 -0
  74. package/sdk-core/{src → core/src/workflow}/machines/signal_external_state_machine.rs +17 -19
  75. package/sdk-core/{src → core/src/workflow}/machines/timer_state_machine.rs +20 -21
  76. package/sdk-core/{src → core/src/workflow}/machines/transition_coverage.rs +5 -2
  77. package/sdk-core/{src → core/src/workflow}/machines/upsert_search_attributes_state_machine.rs +0 -0
  78. package/sdk-core/core/src/workflow/machines/workflow_machines/local_acts.rs +96 -0
  79. package/sdk-core/{src → core/src/workflow}/machines/workflow_machines.rs +344 -160
  80. package/sdk-core/{src → core/src/workflow}/machines/workflow_task_state_machine.rs +1 -1
  81. package/sdk-core/{src → core/src}/workflow/mod.rs +200 -39
  82. package/sdk-core/{src → core/src}/workflow/workflow_tasks/cache_manager.rs +0 -0
  83. package/sdk-core/{src → core/src}/workflow/workflow_tasks/concurrency_manager.rs +38 -5
  84. package/sdk-core/{src → core/src}/workflow/workflow_tasks/mod.rs +297 -81
  85. package/sdk-core/{test_utils → core-api}/Cargo.toml +10 -7
  86. package/sdk-core/{src → core-api/src}/errors.rs +42 -90
  87. package/sdk-core/core-api/src/lib.rs +158 -0
  88. package/sdk-core/{src/worker/config.rs → core-api/src/worker.rs} +18 -23
  89. package/sdk-core/etc/deps.svg +156 -0
  90. package/sdk-core/fsm/rustfsm_procmacro/src/lib.rs +5 -5
  91. package/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/no_handle_conversions_require_into_fail.stderr +3 -5
  92. package/sdk-core/fsm/rustfsm_trait/src/lib.rs +7 -1
  93. package/sdk-core/histories/fail_wf_task.bin +0 -0
  94. package/sdk-core/histories/timer_workflow_history.bin +0 -0
  95. package/sdk-core/protos/api_upstream/temporal/api/command/v1/message.proto +44 -13
  96. package/sdk-core/protos/api_upstream/temporal/api/common/v1/message.proto +19 -1
  97. package/sdk-core/protos/api_upstream/temporal/api/enums/v1/common.proto +1 -1
  98. package/sdk-core/protos/api_upstream/temporal/api/enums/v1/failed_cause.proto +9 -0
  99. package/sdk-core/protos/api_upstream/temporal/api/enums/v1/namespace.proto +1 -0
  100. package/sdk-core/protos/api_upstream/temporal/api/enums/v1/reset.proto +1 -0
  101. package/sdk-core/protos/api_upstream/temporal/api/enums/v1/task_queue.proto +13 -0
  102. package/sdk-core/protos/api_upstream/temporal/api/enums/v1/workflow.proto +14 -7
  103. package/sdk-core/protos/api_upstream/temporal/api/history/v1/message.proto +176 -18
  104. package/sdk-core/protos/api_upstream/temporal/api/namespace/v1/message.proto +6 -0
  105. package/sdk-core/protos/api_upstream/temporal/api/query/v1/message.proto +11 -0
  106. package/sdk-core/protos/api_upstream/temporal/api/taskqueue/v1/message.proto +3 -0
  107. package/sdk-core/protos/api_upstream/temporal/api/workflowservice/v1/request_response.proto +156 -7
  108. package/sdk-core/protos/api_upstream/temporal/api/workflowservice/v1/service.proto +135 -104
  109. package/sdk-core/protos/local/temporal/sdk/core/activity_result/activity_result.proto +78 -0
  110. package/sdk-core/protos/local/temporal/sdk/core/activity_task/activity_task.proto +78 -0
  111. package/sdk-core/protos/local/temporal/sdk/core/bridge/bridge.proto +205 -0
  112. package/sdk-core/protos/local/temporal/sdk/core/bridge/service.proto +61 -0
  113. package/sdk-core/protos/local/{child_workflow.proto → temporal/sdk/core/child_workflow/child_workflow.proto} +1 -1
  114. package/sdk-core/protos/local/{common.proto → temporal/sdk/core/common/common.proto} +5 -3
  115. package/sdk-core/protos/local/{core_interface.proto → temporal/sdk/core/core_interface.proto} +10 -10
  116. package/sdk-core/protos/local/temporal/sdk/core/external_data/external_data.proto +30 -0
  117. package/sdk-core/protos/local/{workflow_activation.proto → temporal/sdk/core/workflow_activation/workflow_activation.proto} +35 -11
  118. package/sdk-core/protos/local/{workflow_commands.proto → temporal/sdk/core/workflow_commands/workflow_commands.proto} +55 -4
  119. package/sdk-core/protos/local/{workflow_completion.proto → temporal/sdk/core/workflow_completion/workflow_completion.proto} +3 -3
  120. package/sdk-core/sdk/Cargo.toml +32 -0
  121. package/sdk-core/{src/prototype_rust_sdk → sdk/src}/conversions.rs +0 -0
  122. package/sdk-core/sdk/src/lib.rs +699 -0
  123. package/sdk-core/sdk/src/payload_converter.rs +11 -0
  124. package/sdk-core/sdk/src/workflow_context/options.rs +180 -0
  125. package/sdk-core/{src/prototype_rust_sdk → sdk/src}/workflow_context.rs +201 -124
  126. package/sdk-core/{src/prototype_rust_sdk → sdk/src}/workflow_future.rs +63 -30
  127. package/sdk-core/sdk-core-protos/Cargo.toml +10 -0
  128. package/sdk-core/sdk-core-protos/build.rs +28 -6
  129. package/sdk-core/sdk-core-protos/src/constants.rs +7 -0
  130. package/sdk-core/{src/test_help → sdk-core-protos/src}/history_builder.rs +134 -49
  131. package/sdk-core/sdk-core-protos/src/history_info.rs +216 -0
  132. package/sdk-core/sdk-core-protos/src/lib.rs +594 -168
  133. package/sdk-core/sdk-core-protos/src/task_token.rs +38 -0
  134. package/sdk-core/sdk-core-protos/src/utilities.rs +14 -0
  135. package/sdk-core/test-utils/Cargo.toml +32 -0
  136. package/sdk-core/{src/test_help → test-utils/src}/canned_histories.rs +59 -78
  137. package/sdk-core/test-utils/src/histfetch.rs +28 -0
  138. package/sdk-core/{test_utils → test-utils}/src/lib.rs +131 -68
  139. package/sdk-core/tests/integ_tests/client_tests.rs +1 -1
  140. package/sdk-core/tests/integ_tests/heartbeat_tests.rs +11 -7
  141. package/sdk-core/tests/integ_tests/polling_tests.rs +12 -11
  142. package/sdk-core/tests/integ_tests/queries_tests.rs +82 -78
  143. package/sdk-core/tests/integ_tests/workflow_tests/activities.rs +91 -71
  144. package/sdk-core/tests/integ_tests/workflow_tests/cancel_external.rs +3 -4
  145. package/sdk-core/tests/integ_tests/workflow_tests/cancel_wf.rs +2 -4
  146. package/sdk-core/tests/integ_tests/workflow_tests/child_workflows.rs +4 -6
  147. package/sdk-core/tests/integ_tests/workflow_tests/continue_as_new.rs +4 -6
  148. package/sdk-core/tests/integ_tests/workflow_tests/determinism.rs +3 -4
  149. package/sdk-core/tests/integ_tests/workflow_tests/local_activities.rs +496 -0
  150. package/sdk-core/tests/integ_tests/workflow_tests/patches.rs +5 -8
  151. package/sdk-core/tests/integ_tests/workflow_tests/replay.rs +125 -0
  152. package/sdk-core/tests/integ_tests/workflow_tests/signals.rs +7 -13
  153. package/sdk-core/tests/integ_tests/workflow_tests/stickyness.rs +33 -5
  154. package/sdk-core/tests/integ_tests/workflow_tests/timers.rs +12 -16
  155. package/sdk-core/tests/integ_tests/workflow_tests.rs +85 -82
  156. package/sdk-core/tests/load_tests.rs +6 -6
  157. package/sdk-core/tests/main.rs +2 -2
  158. package/src/conversions.rs +24 -21
  159. package/src/errors.rs +8 -0
  160. package/src/lib.rs +323 -211
  161. package/sdk-core/protos/local/activity_result.proto +0 -46
  162. package/sdk-core/protos/local/activity_task.proto +0 -66
  163. package/sdk-core/src/core_tests/retry.rs +0 -147
  164. package/sdk-core/src/lib.rs +0 -403
  165. package/sdk-core/src/machines/local_activity_state_machine.rs +0 -117
  166. package/sdk-core/src/pending_activations.rs +0 -249
  167. package/sdk-core/src/protosext/mod.rs +0 -160
  168. package/sdk-core/src/prototype_rust_sdk.rs +0 -412
  169. package/sdk-core/src/task_token.rs +0 -20
  170. package/sdk-core/src/test_help/history_info.rs +0 -158
package/Cargo.toml CHANGED
@@ -10,6 +10,12 @@ exclude = ["index.node", "sdk-core"]
10
10
  name = "temporal_sdk_typescript_bridge"
11
11
  crate-type = ["cdylib"]
12
12
 
13
+ [profile.release]
14
+ opt-level = 3
15
+ debug = false
16
+ lto = true
17
+ incremental = false
18
+
13
19
  [dependencies]
14
20
  futures = { version = "0.3", features = ["executor"] }
15
21
  log = "0.4"
@@ -19,6 +25,4 @@ prost = "0.9"
19
25
  prost-types = "0.9"
20
26
  tokio = "1.13"
21
27
  once_cell = "1.7.2"
22
- # TODO: revert back to version *, can't now because of this error: prerelease package needs to be specified explicitly
23
- temporal-sdk-core = { version = "0.1.0-alpha.1", path = "./sdk-core" }
24
- temporal-sdk-core-protos = { version = "0.1.0", path = "./sdk-core/sdk-core-protos" }
28
+ temporal-sdk-core = { version = "*", path = "./sdk-core/core" }
package/common.js ADDED
@@ -0,0 +1,50 @@
1
+ /**
2
+ * Shared code for scripts/build.js and index.js
3
+ *
4
+ * @module
5
+ */
6
+
7
+ const os = require('os');
8
+ const path = require('path');
9
+ const fs = require('fs');
10
+
11
+ // List of tested compile targets
12
+ const targets = [
13
+ 'x86_64-apple-darwin',
14
+ 'aarch64-apple-darwin',
15
+ 'x86_64-unknown-linux-gnu',
16
+ 'aarch64-unknown-linux-gnu',
17
+ // TODO: this is not supported on macos
18
+ 'x86_64-pc-windows-msvc',
19
+ 'x86_64-pc-windows-gnu',
20
+ ];
21
+
22
+ const archAlias = { x64: 'x86_64', arm64: 'aarch64' };
23
+ const platformMapping = { darwin: 'apple-darwin', linux: 'unknown-linux-gnu', win32: 'pc-windows-msvc' };
24
+
25
+ class PrebuildError extends Error {
26
+ constructor(message) {
27
+ super(message);
28
+ this.name = 'PrebuildError';
29
+ }
30
+ }
31
+
32
+ function getPrebuiltPath() {
33
+ const arch = archAlias[os.arch()];
34
+ if (arch === undefined) {
35
+ throw new PrebuildError(`No prebuilt module for arch ${os.arch()}`);
36
+ }
37
+ const platform = platformMapping[os.platform()];
38
+ if (platform === undefined) {
39
+ throw new PrebuildError(`No prebuilt module for platform ${os.platform()}`);
40
+ }
41
+ const binary = path.resolve(__dirname, 'releases', `${arch}-${platform}`, 'index.node');
42
+ if (fs.existsSync(binary)) {
43
+ console.log('Found prebuilt bridge module', { binary });
44
+ return binary;
45
+ } else {
46
+ throw new PrebuildError(`No prebuilt module found at ${binary}`);
47
+ }
48
+ }
49
+
50
+ module.exports = { targets, archAlias, platformMapping, PrebuildError, getPrebuiltPath };
package/index.d.ts CHANGED
@@ -169,7 +169,14 @@ export declare type LogsCallback = (err: Error, result: LogEntry[]) => void;
169
169
  // TODO: improve type, for some reason Error is not accepted here
170
170
  export declare function registerErrors(errors: Record<string, any>): void;
171
171
  export declare function newCore(coreOptions: CoreOptions, callback: CoreCallback): void;
172
+ export declare function newReplayCore(telemOptions: TelemetryOptions, callback: CoreCallback): void;
172
173
  export declare function newWorker(core: Core, workerOptions: WorkerOptions, callback: WorkerCallback): void;
174
+ export declare function newReplayWorker(
175
+ core: Core,
176
+ workerOptions: WorkerOptions,
177
+ history: ArrayBuffer,
178
+ callback: WorkerCallback
179
+ ): void;
173
180
  export declare function workerShutdown(worker: Worker, callback: VoidCallback): void;
174
181
  export declare function coreShutdown(core: Core, callback: VoidCallback): void;
175
182
  export declare function corePollLogs(core: Core, callback: LogsCallback): void;
package/index.js ADDED
@@ -0,0 +1,12 @@
1
+ const { getPrebuiltPath, PrebuildError } = require('./common');
2
+
3
+ try {
4
+ const prebuiltPath = getPrebuiltPath();
5
+ module.exports = require(prebuiltPath);
6
+ } catch (err) {
7
+ if (err instanceof PrebuildError) {
8
+ module.exports = require('./default-build/index.node');
9
+ } else {
10
+ throw err;
11
+ }
12
+ }
package/package.json CHANGED
@@ -1,12 +1,13 @@
1
1
  {
2
2
  "name": "@temporalio/core-bridge",
3
- "version": "0.17.2",
3
+ "version": "0.18.0",
4
4
  "description": "Temporal.io SDK Core<>Node bridge",
5
- "main": "index.node",
5
+ "main": "index.js",
6
6
  "types": "index.d.ts",
7
7
  "scripts": {
8
8
  "build-rust": "node ./scripts/build.js --force",
9
9
  "build": "npm run build-rust",
10
+ "build-rust-release": "npm run build-rust -- --release",
10
11
  "install": "node ./scripts/build.js"
11
12
  },
12
13
  "keywords": [
@@ -19,7 +20,7 @@
19
20
  "license": "MIT",
20
21
  "dependencies": {
21
22
  "@opentelemetry/api": "^1.0.3",
22
- "@temporalio/common": "^0.17.2",
23
+ "@temporalio/common": "^0.18.0",
23
24
  "arg": "^5.0.1",
24
25
  "cargo-cp-artifact": "^0.1.4",
25
26
  "which": "^2.0.2"
@@ -35,10 +36,12 @@
35
36
  "sdk-core",
36
37
  "Cargo.toml",
37
38
  "Cargo.lock",
39
+ "index.js",
40
+ "common.js",
38
41
  "index.d.ts"
39
42
  ],
40
43
  "publishConfig": {
41
44
  "access": "public"
42
45
  },
43
- "gitHead": "2232465a4f9b0cade28f0c21c2d7856053678728"
46
+ "gitHead": "1f8030e0e003fac70969bee9bb816d9520910d02"
44
47
  }
package/scripts/build.js CHANGED
@@ -1,32 +1,19 @@
1
1
  const path = require('path');
2
2
  const arg = require('arg');
3
- const os = require('os');
4
3
  const fs = require('fs');
5
4
  const which = require('which');
6
5
  const { spawnSync } = require('child_process');
7
6
  const { version } = require('../package.json');
7
+ const { targets, getPrebuiltPath, PrebuildError } = require('../common');
8
8
 
9
9
  process.chdir(path.resolve(__dirname, '..'));
10
10
 
11
- // List of tested compile targets
12
- const targets = [
13
- 'x86_64-apple-darwin',
14
- 'aarch64-apple-darwin',
15
- 'x86_64-unknown-linux-gnu',
16
- 'aarch64-unknown-linux-gnu',
17
- // TODO: this is not supported on macos
18
- 'x86_64-pc-windows-msvc',
19
- 'x86_64-pc-windows-gnu',
20
- ];
21
-
22
- const archAlias = { x64: 'x86_64', arm64: 'aarch64' };
23
- const platformMapping = { darwin: 'apple-darwin', linux: 'unknown-linux-gnu', win32: 'pc-windows-gnu' };
24
-
25
11
  const args = arg({
26
12
  '--help': Boolean,
27
13
  '-h': '--help',
28
14
  '--version': Boolean,
29
15
  '-v': '--version',
16
+ '--release': Boolean,
30
17
  '--target': [String],
31
18
  '--force': Boolean,
32
19
  '-f': '--force',
@@ -41,7 +28,8 @@ Options:
41
28
  -h, --help Show this help message and exit
42
29
  -v, --version Show program's version number and exit
43
30
  -f, --force Forces a build instead of using a prebuilt binary
44
- -t, --target Compilation targets, choose any of:
31
+ --release Build in release mode (or set BUILD_CORE_RELEASE env var)
32
+ --target Compilation targets, choose any of:
45
33
  ${targets.concat('all').join('\n ')}
46
34
 
47
35
  Happy compiling!`;
@@ -54,7 +42,6 @@ if (args['--version']) {
54
42
  console.log(version);
55
43
  process.exit();
56
44
  }
57
- // });
58
45
 
59
46
  // prepare recompile options
60
47
  const targetsArg = args['--target'] || [];
@@ -65,11 +52,12 @@ if (unsupportedTargets.length) {
65
52
  process.exit(1);
66
53
  }
67
54
  const forceBuild = args['--force'];
55
+ const buildRelease = args['--release'] || process.env.BUILD_CORE_RELEASE !== undefined;
68
56
 
69
57
  function compile(target) {
70
- console.log('Compiling bridge', { target });
58
+ console.log('Compiling bridge', { target, buildRelease });
71
59
 
72
- const out = target ? `releases/${target}/index.node` : 'index.node';
60
+ const out = target ? `releases/${target}/index.node` : 'default-build/index.node';
73
61
  try {
74
62
  fs.unlinkSync(out);
75
63
  } catch (err) {
@@ -87,7 +75,7 @@ function compile(target) {
87
75
  'cargo',
88
76
  'build',
89
77
  '--message-format=json-render-diagnostics',
90
- '--release',
78
+ ...(buildRelease ? ['--release'] : []),
91
79
  ...(target ? ['--target', target] : []),
92
80
  ];
93
81
  const cmd = which.sync('cargo-cp-artifact');
@@ -101,35 +89,6 @@ function compile(target) {
101
89
  }
102
90
  }
103
91
 
104
- class PrebuildError extends Error {
105
- constructor(message) {
106
- super(message);
107
- this.name = 'PrebuildError';
108
- }
109
- }
110
-
111
- function usePrebuilt() {
112
- const arch = archAlias[os.arch()];
113
- if (arch === undefined) {
114
- throw new PrebuildError(`No prebuilt module for arch ${os.arch()}`);
115
- }
116
- const platform = platformMapping[os.platform()];
117
- if (arch === undefined) {
118
- throw new PrebuildError(`No prebuilt module for platform ${os.platform()}`);
119
- }
120
- const source = path.resolve(__dirname, '../releases', `${arch}-${platform}`, 'index.node');
121
- const target = path.resolve(__dirname, '..', 'index.node');
122
- try {
123
- fs.copyFileSync(source, target);
124
- console.log('Copied prebuilt bridge module', { source, target });
125
- } catch (err) {
126
- if (err.code === 'ENOENT') {
127
- throw new PrebuildError(`No prebuilt module found at ${source}`);
128
- }
129
- throw err;
130
- }
131
- }
132
-
133
92
  if (requestedTargets.length > 0) {
134
93
  // NOTE: no forceBuild
135
94
  for (const target of requestedTargets) {
@@ -138,9 +97,10 @@ if (requestedTargets.length > 0) {
138
97
  } else {
139
98
  if (!forceBuild) {
140
99
  try {
141
- usePrebuilt();
100
+ getPrebuiltPath();
142
101
  } catch (err) {
143
102
  if (err instanceof PrebuildError) {
103
+ console.warn(err.message);
144
104
  compile();
145
105
  } else {
146
106
  throw err;
@@ -1,4 +1,4 @@
1
- FROM rust:1.56
1
+ FROM rust:1.58
2
2
 
3
3
  RUN rustup component add rustfmt && \
4
4
  rustup component add clippy
@@ -9,7 +9,7 @@ services:
9
9
  # - '9042:9042'
10
10
 
11
11
  temporal:
12
- image: temporalio/auto-setup:1.12.3
12
+ image: temporalio/auto-setup:1.13.0
13
13
  ports:
14
14
  - "7233:7233"
15
15
  - "7234:7234"
@@ -26,7 +26,7 @@ services:
26
26
  - cassandra
27
27
 
28
28
  temporal-web:
29
- image: temporalio/web:1.12.0
29
+ image: temporalio/web:1.13.0
30
30
  logging:
31
31
  driver: none
32
32
  ports:
@@ -25,6 +25,8 @@ steps:
25
25
  config:
26
26
  - .buildkite/docker/docker-compose.yaml
27
27
  - .buildkite/docker/docker-compose-ci.yaml
28
+ env:
29
+ - TEMPORAL_SDK_CORE_BRIDGE_FFI_DISABLE_HEADER_CHANGE=true
28
30
  - label: "test"
29
31
  agents:
30
32
  queue: "default"
@@ -1,89 +1,2 @@
1
- [package]
2
- name = "temporal-sdk-core"
3
- version = "0.1.0-alpha.1"
4
- authors = ["Spencer Judge <spencer@temporal.io>", "Vitaly Arbuzov <vitaly@temporal.io>"]
5
- edition = "2021"
6
- license-file = "LICENSE.txt"
7
- description = "Library for building new Temporal SDKs"
8
- homepage = "https://temporal.io/"
9
- repository = "https://github.com/temporalio/sdk-core"
10
- keywords = ["temporal", "workflow"]
11
- categories = ["development-tools"]
12
-
13
- [lib]
14
-
15
- [dependencies]
16
- anyhow = "1.0"
17
- arc-swap = "1.3"
18
- async-trait = "0.1"
19
- backoff = "0.3.0"
20
- base64 = "0.13"
21
- crossbeam = "0.8"
22
- dashmap = "4.0"
23
- derive_builder = "0.10"
24
- derive_more = "0.99"
25
- futures = "0.3"
26
- futures-retry = "0.6.0"
27
- http = "0.2"
28
- hyper = "0.14"
29
- itertools = "0.10"
30
- lazy_static = "1.4"
31
- log = "0.4"
32
- lru = "0.7"
33
- once_cell = "1.5"
34
- opentelemetry = { version = "0.16", features = ["rt-tokio"] }
35
- opentelemetry-otlp = { version = "0.9.0", features = ["tokio", "metrics"] }
36
- opentelemetry-prometheus = "0.9.0"
37
- parking_lot = { version = "0.11", features = ["send_guard"] }
38
- prometheus = "0.12"
39
- prost = "0.9"
40
- prost-types = "0.9"
41
- rand = "0.8.3"
42
- ringbuf = "0.2"
43
- slotmap = "1.0"
44
- thiserror = "1.0"
45
- tokio = { version = "1.1", features = ["rt", "rt-multi-thread", "parking_lot", "time", "fs"] }
46
- tokio-util = { version = "0.6.9" }
47
- tokio-stream = "0.1"
48
- tonic = { version = "0.6", features = ["tls", "tls-roots"] }
49
- tower = "0.4"
50
- tracing = { version = "0.1", features = ["log-always"] }
51
- tracing-futures = "0.2"
52
- tracing-opentelemetry = "0.15"
53
- tracing-subscriber = { version = "0.2", features = ["parking_lot"] }
54
- url = "2.2"
55
- uuid = { version = "0.8.2", features = ["v4"] }
56
-
57
- # 1st party local deps
58
- [dependencies.temporal-sdk-core-protos]
59
- path = "sdk-core-protos"
60
- version = "0.1"
61
-
62
- [dependencies.rustfsm]
63
- path = "fsm"
64
- version = "0.1"
65
-
66
- [dev-dependencies]
67
- assert_matches = "1.4"
68
- bimap = "0.6.1"
69
- mockall = "0.10"
70
- rstest = "0.10"
71
- test_utils = { path = "test_utils" }
72
-
73
- [build-dependencies]
74
- tonic-build = "0.6"
75
-
76
1
  [workspace]
77
- members = [".", "fsm", "test_utils", "sdk-core-protos"]
78
-
79
- [[test]]
80
- name = "integ_tests"
81
- path = "tests/main.rs"
82
- # Prevents autodiscovery, and hence these getting run with `cargo test`. Run with
83
- # `cargo test --test integ_tests`
84
- test = false
85
-
86
- [[test]]
87
- name = "load_tests"
88
- path = "tests/load_tests.rs"
89
- test = false
2
+ members = ["bridge-ffi", "core", "client", "core-api", "fsm", "test-utils", "sdk-core-protos", "sdk"]
@@ -6,16 +6,27 @@ Core SDK that can be used as a base for all other Temporal SDKs.
6
6
 
7
7
  See the [Architecture](ARCHITECTURE.md) doc for some high-level information.
8
8
 
9
- This repo uses a subtree for upstream protobuf files. The path `protos/api_upstream` is a
10
- subtree. To update it, use:
11
- `git subtree pull --prefix protos/api_upstream/ git://github.com/temporalio/api.git master --squash`
12
-
13
9
  ## Dependencies
14
10
  * Protobuf compiler
15
11
 
16
12
  # Development
17
13
 
18
- All of the following commands are enforced for each pull request.
14
+ This repo is composed of multiple crates:
15
+ * temporal-sdk-core-protos `./sdk-core-protos` - Holds the generated proto code and extensions
16
+ * temporal-client `./client` - Defines client(s) for interacting with the Temporal gRPC service
17
+ * temporal-sdk-core-api `./core-api` - Defines the API surface exposed by Core
18
+ * temporal-sdk-core `./core` - The Core implementation
19
+ * temporal-sdk `./sdk` - A (currently prototype) Rust SDK built on top of Core. Used for testing.
20
+ * temporal-sdk-core-bridge-ffi `./bridge-ffi` - C API wrapper for Core
21
+ * rustfsm `./fsm` - Implements a procedural macro used by core for defining state machines
22
+ (contains subcrates). It is temporal agnostic.
23
+
24
+ Visualized (dev dependencies are in blue):
25
+
26
+ ![Crate dependency graph](./etc/deps.svg)
27
+
28
+
29
+ All the following commands are enforced for each pull request:
19
30
 
20
31
  ## Building and testing
21
32
 
@@ -52,10 +63,23 @@ To run integ tests with OTel collection on, you can use `integ-with-otel.sh`. Yo
52
63
  sure you are running the collector via docker, which can be done like so:
53
64
  `docker-compose -f .buildkite/docker/docker-compose.yaml -f .buildkite/docker/docker-compose-telem.yaml up`
54
65
 
55
-
56
66
  If you are working on a language SDK, you are expected to initialize tracing early in your `main`
57
67
  equivalent.
58
68
 
69
+ ## Proto files
70
+
71
+ This repo uses a subtree for upstream protobuf files. The path `protos/api_upstream` is a
72
+ subtree. To update it, use:
73
+ `git subtree pull --prefix protos/api_upstream/ git://github.com/temporalio/api.git master --squash`
74
+
75
+ ## Fetching Histories
76
+ Tests which would like to replay stored histories rely on that history being made available in
77
+ binary format. You can fetch histories in that format like so (from a local docker server):
78
+
79
+ `cargo run --bin histfetch {workflow_id} [{run_id}]`
80
+
81
+ You can change the `TEMPORAL_SERVICE_ADDRESS` env var to fetch from a different address.
82
+
59
83
  ## Style Guidelines
60
84
 
61
85
  ### Error handling
@@ -0,0 +1,24 @@
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
+ log = "0.4"
17
+ prost = "0.9"
18
+ temporal-sdk-core = { version = "0.1", path = "../core" }
19
+ temporal-sdk-core-api = { version = "0.1", path = "../core-api" }
20
+ temporal-sdk-core-protos = { version = "0.1", path = "../sdk-core-protos" }
21
+ tokio = "1"
22
+
23
+ [build-dependencies]
24
+ cbindgen = "0.20.0"
@@ -0,0 +1,23 @@
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.
@@ -0,0 +1,25 @@
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
+ }