@temporalio/core-bridge 1.10.2 → 1.11.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 (126) hide show
  1. package/Cargo.lock +563 -676
  2. package/Cargo.toml +3 -3
  3. package/lib/index.d.ts +16 -5
  4. package/lib/index.js.map +1 -1
  5. package/lib/worker-tuner.d.ts +57 -0
  6. package/lib/worker-tuner.js +3 -0
  7. package/lib/worker-tuner.js.map +1 -0
  8. package/package.json +3 -3
  9. package/releases/aarch64-apple-darwin/index.node +0 -0
  10. package/releases/aarch64-unknown-linux-gnu/index.node +0 -0
  11. package/releases/x86_64-apple-darwin/index.node +0 -0
  12. package/releases/x86_64-pc-windows-msvc/index.node +0 -0
  13. package/releases/x86_64-unknown-linux-gnu/index.node +0 -0
  14. package/sdk-core/.github/workflows/heavy.yml +6 -11
  15. package/sdk-core/.github/workflows/per-pr.yml +23 -41
  16. package/sdk-core/Cargo.toml +5 -5
  17. package/sdk-core/README.md +2 -0
  18. package/sdk-core/client/Cargo.toml +4 -2
  19. package/sdk-core/client/src/lib.rs +60 -17
  20. package/sdk-core/client/src/metrics.rs +1 -1
  21. package/sdk-core/client/src/proxy.rs +17 -12
  22. package/sdk-core/client/src/raw.rs +218 -69
  23. package/sdk-core/client/src/retry.rs +19 -9
  24. package/sdk-core/core/Cargo.toml +12 -12
  25. package/sdk-core/core/src/abstractions.rs +3 -3
  26. package/sdk-core/core/src/core_tests/activity_tasks.rs +2 -1
  27. package/sdk-core/core/src/core_tests/determinism.rs +1 -1
  28. package/sdk-core/core/src/core_tests/local_activities.rs +73 -10
  29. package/sdk-core/core/src/core_tests/queries.rs +2 -1
  30. package/sdk-core/core/src/core_tests/updates.rs +162 -4
  31. package/sdk-core/core/src/core_tests/workers.rs +38 -2
  32. package/sdk-core/core/src/core_tests/workflow_tasks.rs +158 -27
  33. package/sdk-core/core/src/internal_flags.rs +17 -7
  34. package/sdk-core/core/src/lib.rs +9 -3
  35. package/sdk-core/core/src/pollers/poll_buffer.rs +1 -10
  36. package/sdk-core/core/src/protosext/mod.rs +0 -1
  37. package/sdk-core/core/src/protosext/protocol_messages.rs +105 -16
  38. package/sdk-core/core/src/retry_logic.rs +22 -2
  39. package/sdk-core/core/src/telemetry/otel.rs +44 -12
  40. package/sdk-core/core/src/test_help/mod.rs +65 -12
  41. package/sdk-core/core/src/worker/activities/local_activities.rs +1 -4
  42. package/sdk-core/core/src/worker/activities.rs +3 -4
  43. package/sdk-core/core/src/worker/client/mocks.rs +7 -6
  44. package/sdk-core/core/src/worker/client.rs +11 -2
  45. package/sdk-core/core/src/worker/mod.rs +49 -24
  46. package/sdk-core/core/src/worker/tuner/resource_based.rs +48 -48
  47. package/sdk-core/core/src/worker/tuner.rs +124 -4
  48. package/sdk-core/core/src/worker/workflow/driven_workflow.rs +1 -1
  49. package/sdk-core/core/src/worker/workflow/history_update.rs +11 -2
  50. package/sdk-core/core/src/worker/workflow/machines/activity_state_machine.rs +18 -3
  51. package/sdk-core/core/src/worker/workflow/machines/cancel_external_state_machine.rs +1 -0
  52. package/sdk-core/core/src/worker/workflow/machines/cancel_workflow_state_machine.rs +1 -0
  53. package/sdk-core/core/src/worker/workflow/machines/child_workflow_state_machine.rs +1 -0
  54. package/sdk-core/core/src/worker/workflow/machines/complete_workflow_state_machine.rs +1 -0
  55. package/sdk-core/core/src/worker/workflow/machines/continue_as_new_workflow_state_machine.rs +1 -0
  56. package/sdk-core/core/src/worker/workflow/machines/fail_workflow_state_machine.rs +1 -0
  57. package/sdk-core/core/src/worker/workflow/machines/local_activity_state_machine.rs +4 -4
  58. package/sdk-core/core/src/worker/workflow/machines/modify_workflow_properties_state_machine.rs +1 -0
  59. package/sdk-core/core/src/worker/workflow/machines/patch_state_machine.rs +1 -0
  60. package/sdk-core/core/src/worker/workflow/machines/signal_external_state_machine.rs +1 -0
  61. package/sdk-core/core/src/worker/workflow/machines/timer_state_machine.rs +3 -1
  62. package/sdk-core/core/src/worker/workflow/machines/update_state_machine.rs +38 -28
  63. package/sdk-core/core/src/worker/workflow/machines/upsert_search_attributes_state_machine.rs +4 -2
  64. package/sdk-core/core/src/worker/workflow/machines/workflow_machines.rs +95 -71
  65. package/sdk-core/core/src/worker/workflow/machines/workflow_task_state_machine.rs +1 -1
  66. package/sdk-core/core/src/worker/workflow/managed_run.rs +214 -14
  67. package/sdk-core/core/src/worker/workflow/mod.rs +49 -36
  68. package/sdk-core/core/src/worker/workflow/workflow_stream.rs +1 -2
  69. package/sdk-core/core-api/src/errors.rs +13 -7
  70. package/sdk-core/core-api/src/lib.rs +9 -1
  71. package/sdk-core/sdk/Cargo.toml +1 -1
  72. package/sdk-core/sdk/src/activity_context.rs +3 -4
  73. package/sdk-core/sdk/src/lib.rs +96 -49
  74. package/sdk-core/sdk/src/workflow_context/options.rs +8 -4
  75. package/sdk-core/sdk/src/workflow_context.rs +53 -49
  76. package/sdk-core/sdk/src/workflow_future.rs +10 -4
  77. package/sdk-core/sdk-core-protos/Cargo.toml +4 -3
  78. package/sdk-core/sdk-core-protos/build.rs +2 -0
  79. package/sdk-core/sdk-core-protos/protos/api_cloud_upstream/.github/workflows/build.yaml +18 -0
  80. package/sdk-core/sdk-core-protos/protos/api_cloud_upstream/LICENSE +21 -0
  81. package/sdk-core/sdk-core-protos/protos/api_cloud_upstream/Makefile +59 -0
  82. package/sdk-core/sdk-core-protos/protos/api_cloud_upstream/README.md +25 -0
  83. package/sdk-core/sdk-core-protos/protos/api_cloud_upstream/VERSION +1 -0
  84. package/sdk-core/sdk-core-protos/protos/api_cloud_upstream/buf.gen.yaml +14 -0
  85. package/sdk-core/sdk-core-protos/protos/api_cloud_upstream/buf.lock +8 -0
  86. package/sdk-core/sdk-core-protos/protos/api_cloud_upstream/buf.yaml +9 -0
  87. package/sdk-core/sdk-core-protos/protos/api_cloud_upstream/temporal/api/cloud/cloudservice/v1/request_response.proto +520 -0
  88. package/sdk-core/sdk-core-protos/protos/api_cloud_upstream/temporal/api/cloud/cloudservice/v1/service.proto +263 -0
  89. package/sdk-core/sdk-core-protos/protos/api_cloud_upstream/temporal/api/cloud/identity/v1/message.proto +173 -0
  90. package/sdk-core/sdk-core-protos/protos/api_cloud_upstream/temporal/api/cloud/namespace/v1/message.proto +164 -0
  91. package/sdk-core/sdk-core-protos/protos/api_cloud_upstream/temporal/api/cloud/operation/v1/message.proto +36 -0
  92. package/sdk-core/sdk-core-protos/protos/api_cloud_upstream/temporal/api/cloud/region/v1/message.proto +22 -0
  93. package/sdk-core/sdk-core-protos/protos/api_upstream/.github/workflows/trigger-api-go-update.yml +50 -8
  94. package/sdk-core/sdk-core-protos/protos/api_upstream/.gitmodules +3 -0
  95. package/sdk-core/sdk-core-protos/protos/api_upstream/openapi/openapiv2.json +132 -54
  96. package/sdk-core/sdk-core-protos/protos/api_upstream/openapi/openapiv3.yaml +177 -81
  97. package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/command/v1/message.proto +13 -0
  98. package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/enums/v1/failed_cause.proto +2 -0
  99. package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/enums/v1/task_queue.proto +8 -3
  100. package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/history/v1/message.proto +10 -0
  101. package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/nexus/v1/message.proto +3 -3
  102. package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/operatorservice/v1/service.proto +6 -6
  103. package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/sdk/v1/enhanced_stack_trace.proto +96 -0
  104. package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/sdk/v1/user_metadata.proto +49 -0
  105. package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/sdk/v1/workflow_metadata.proto +6 -7
  106. package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/taskqueue/v1/message.proto +55 -24
  107. package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/workflow/v1/message.proto +7 -0
  108. package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/workflowservice/v1/request_response.proto +21 -4
  109. package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/workflowservice/v1/service.proto +64 -45
  110. package/sdk-core/sdk-core-protos/src/history_builder.rs +8 -1
  111. package/sdk-core/sdk-core-protos/src/lib.rs +40 -10
  112. package/sdk-core/test-utils/src/canned_histories.rs +1 -1
  113. package/sdk-core/tests/fuzzy_workflow.rs +4 -2
  114. package/sdk-core/tests/heavy_tests.rs +3 -3
  115. package/sdk-core/tests/integ_tests/activity_functions.rs +2 -2
  116. package/sdk-core/tests/integ_tests/client_tests.rs +234 -6
  117. package/sdk-core/tests/integ_tests/update_tests.rs +180 -47
  118. package/sdk-core/tests/integ_tests/worker_tests.rs +32 -0
  119. package/sdk-core/tests/integ_tests/workflow_tests/activities.rs +47 -3
  120. package/sdk-core/tests/integ_tests/workflow_tests/local_activities.rs +10 -10
  121. package/sdk-core/tests/main.rs +1 -0
  122. package/src/conversions.rs +84 -11
  123. package/src/runtime.rs +5 -17
  124. package/src/worker.rs +27 -6
  125. package/ts/index.ts +24 -5
  126. package/ts/worker-tuner.ts +71 -0
package/Cargo.toml CHANGED
@@ -20,10 +20,10 @@ incremental = false
20
20
  futures = { version = "0.3", features = ["executor"] }
21
21
  log = "0.4"
22
22
  neon = { version = "0.10", default-features = false, features = ["napi-6", "event-queue-api"] }
23
- opentelemetry = "0.22"
23
+ opentelemetry = "0.23"
24
24
  parking_lot = "0.12"
25
- prost = "0.12"
26
- prost-types = "0.12"
25
+ prost = "0.13"
26
+ prost-types = "0.13"
27
27
  serde_json = "1.0"
28
28
  tokio = "1.13"
29
29
  once_cell = "1.19"
package/lib/index.d.ts CHANGED
@@ -1,5 +1,7 @@
1
1
  import { LogLevel, Duration } from '@temporalio/common';
2
2
  import type { TLSConfig, ProxyConfig, HttpConnectProxyConfig } from '@temporalio/common/lib/internal-non-workflow';
3
+ import { WorkerTuner } from './worker-tuner';
4
+ export { WorkerTuner, SlotSupplier, ResourceBasedSlotOptions, ResourceBasedTunerOptions, FixedSizeSlotSupplier, } from './worker-tuner';
3
5
  export type { TLSConfig, ProxyConfig, HttpConnectProxyConfig };
4
6
  /** @deprecated Import from @temporalio/common instead */
5
7
  export { LogLevel };
@@ -250,9 +252,10 @@ export interface WorkerOptions {
250
252
  * The task queue the worker will pull from
251
253
  */
252
254
  taskQueue: string;
253
- maxConcurrentActivityTaskExecutions: number;
254
- maxConcurrentWorkflowTaskExecutions: number;
255
- maxConcurrentLocalActivityExecutions: number;
255
+ /**
256
+ * The tuner the worker will use
257
+ */
258
+ tuner: WorkerTuner;
256
259
  nonStickyToStickyPollRatio: number;
257
260
  /**
258
261
  * Maximum number of Workflow tasks to poll concurrently.
@@ -356,11 +359,15 @@ export interface TimeSkippingServerConfig {
356
359
  port?: number;
357
360
  /**
358
361
  * Extra args to pass to the executable command.
362
+ *
363
+ * Note that the Test Server implementation may be changed to another one in the future. Therefore, there is
364
+ * no guarantee that server options, and particularly those provided through the `extraArgs` array, will continue to
365
+ * be supported in the future.
359
366
  */
360
367
  extraArgs?: string[];
361
368
  }
362
369
  /**
363
- * Configuration for the Temporal CLI dev server.
370
+ * Configuration for the Temporal CLI Dev Server.
364
371
  */
365
372
  export interface DevServerConfig {
366
373
  type: 'dev-server';
@@ -401,13 +408,17 @@ export interface DevServerConfig {
401
408
  port?: number;
402
409
  /**
403
410
  * Extra args to pass to the executable command.
411
+ *
412
+ * Note that the Dev Server implementation may be changed to another one in the future. Therefore, there is no
413
+ * guarantee that Dev Server options, and particularly those provided through the `extraArgs` array, will continue to
414
+ * be supported in the future.
404
415
  */
405
416
  extraArgs?: string[];
406
417
  }
407
418
  /**
408
419
  * Configuration for spawning an ephemeral Temporal server.
409
420
  *
410
- * Both the time-skipping test server and Temporal CLI dev server are supported.
421
+ * Both the time-skipping Test Server and Temporal CLI dev server are supported.
411
422
  */
412
423
  export type EphemeralServerConfig = TimeSkippingServerConfig | DevServerConfig;
413
424
  export interface Worker {
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../ts/index.ts"],"names":[],"mappings":";;;AAsjBA,mCAA0E;AAAjE,uGAAA,aAAa,OAAA;AAAE,wGAAA,cAAc,OAAA;AAAE,yGAAA,eAAe,OAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../ts/index.ts"],"names":[],"mappings":";;;AAykBA,mCAA0E;AAAjE,uGAAA,aAAa,OAAA;AAAE,wGAAA,cAAc,OAAA;AAAE,yGAAA,eAAe,OAAA"}
@@ -0,0 +1,57 @@
1
+ /**
2
+ * A worker tuner allows the customization of the performance characteristics of workers by
3
+ * controlling how "slots" are handed out for different task types. In order to poll for and then
4
+ * run tasks, a slot must first be reserved by the {@link SlotSupplier} returned by the tuner.
5
+ *
6
+ * @experimental
7
+ */
8
+ export interface WorkerTuner {
9
+ workflowTaskSlotSupplier: SlotSupplier;
10
+ activityTaskSlotSupplier: SlotSupplier;
11
+ localActivityTaskSlotSupplier: SlotSupplier;
12
+ }
13
+ /**
14
+ * Controls how slots are handed out for a specific task type.
15
+ *
16
+ * For now, only {@link ResourceBasedSlotOptions} and {@link FixedSizeSlotSupplier} are supported,
17
+ * but we may add support for custom tuners in the future.
18
+ *
19
+ * @experimental
20
+ */
21
+ export type SlotSupplier = ResourceBasedSlotsForType | FixedSizeSlotSupplier;
22
+ /**
23
+ * Options for a specific slot type within a {@link ResourceBasedSlotsForType}
24
+ *
25
+ * @experimental
26
+ */
27
+ export interface ResourceBasedSlotOptions {
28
+ minimumSlots: number;
29
+ maximumSlots: number;
30
+ rampThrottleMs: number;
31
+ }
32
+ /**
33
+ * @experimental
34
+ */
35
+ type ResourceBasedSlotsForType = ResourceBasedSlotOptions & {
36
+ type: 'resource-based';
37
+ tunerOptions: ResourceBasedTunerOptions;
38
+ };
39
+ /**
40
+ * Options for a {@link ResourceBasedTuner} to control target resource usage
41
+ *
42
+ * @experimental
43
+ */
44
+ export interface ResourceBasedTunerOptions {
45
+ targetMemoryUsage: number;
46
+ targetCpuUsage: number;
47
+ }
48
+ /**
49
+ * A fixed-size slot supplier that will never issue more than a fixed number of slots.
50
+ *
51
+ * @experimental
52
+ */
53
+ export interface FixedSizeSlotSupplier {
54
+ type: 'fixed-size';
55
+ numSlots: number;
56
+ }
57
+ export {};
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=worker-tuner.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"worker-tuner.js","sourceRoot":"","sources":["../ts/worker-tuner.ts"],"names":[],"mappings":""}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@temporalio/core-bridge",
3
- "version": "1.10.2",
3
+ "version": "1.11.0",
4
4
  "description": "Temporal.io SDK Core<>Node bridge",
5
5
  "main": "index.js",
6
6
  "types": "lib/index.d.ts",
@@ -22,7 +22,7 @@
22
22
  "author": "Temporal Technologies Inc. <sdk@temporal.io>",
23
23
  "license": "MIT",
24
24
  "dependencies": {
25
- "@temporalio/common": "1.10.2",
25
+ "@temporalio/common": "1.11.0",
26
26
  "arg": "^5.0.2",
27
27
  "cargo-cp-artifact": "^0.1.8",
28
28
  "which": "^4.0.0"
@@ -52,5 +52,5 @@
52
52
  "publishConfig": {
53
53
  "access": "public"
54
54
  },
55
- "gitHead": "a44bdfa780c1247fe7ed82b4b73c7b1577ee94af"
55
+ "gitHead": "3d7dd521cadc2ebcc4989360eeb0bedacd4533ab"
56
56
  }
@@ -15,19 +15,14 @@ jobs:
15
15
  timeout-minutes: 20
16
16
  runs-on: ubuntu-latest-16-cores
17
17
  steps:
18
- - uses: actions/checkout@v2
18
+ - uses: actions/checkout@v4
19
19
  with:
20
20
  submodules: recursive
21
- - uses: actions-rs/toolchain@v1
22
- with:
23
- toolchain: stable
21
+ - uses: dtolnay/rust-toolchain@stable
24
22
  - name: Install protoc
25
- uses: arduino/setup-protoc@v1
23
+ uses: arduino/setup-protoc@v3
26
24
  with:
27
- version: '3.x'
25
+ # TODO: Upgrade proto once https://github.com/arduino/setup-protoc/issues/99 is fixed
26
+ version: '23.x'
28
27
  repo-token: ${{ secrets.GITHUB_TOKEN }}
29
-
30
- - uses: actions-rs/cargo@v1
31
- with:
32
- command: integ-test
33
- args: -c "--release" -t heavy_tests -- --test-threads 1
28
+ - run: cargo integ-test -c "--release" -t heavy_tests -- --test-threads 1
@@ -16,62 +16,47 @@ jobs:
16
16
  timeout-minutes: 10
17
17
  runs-on: ubuntu-latest
18
18
  steps:
19
- - uses: actions/checkout@v2
19
+ - uses: actions/checkout@v4
20
20
  with:
21
21
  submodules: recursive
22
- - uses: actions-rs/toolchain@v1
22
+ - uses: dtolnay/rust-toolchain@stable
23
23
  with:
24
- profile: minimal
25
24
  toolchain: 1.77.0
26
- override: true
27
25
  - name: Install protoc
28
- uses: arduino/setup-protoc@v1
26
+ uses: arduino/setup-protoc@v3
29
27
  with:
30
- version: '3.x'
28
+ # TODO: Upgrade proto once https://github.com/arduino/setup-protoc/issues/99 is fixed
29
+ version: '23.x'
31
30
  repo-token: ${{ secrets.GITHUB_TOKEN }}
32
31
  - run: rustup component add rustfmt clippy
33
32
  - uses: Swatinem/rust-cache@v2
34
- - uses: actions-rs/cargo@v1
35
- with:
36
- command: fmt
37
- args: --all -- --check
38
- - uses: actions-rs/cargo@v1
39
- with:
40
- command: doc
41
- args: --workspace --all-features --no-deps
42
- - uses: actions-rs/cargo@v1
43
- with:
44
- command: lint
45
- - uses: actions-rs/cargo@v1
46
- with:
47
- command: test-lint
33
+ - run: cargo fmt --all --check
34
+ - run: cargo doc --workspace --all-features --no-deps
35
+ - run: cargo lint
36
+ - run: cargo test-lint
48
37
 
49
38
  test:
50
39
  name: Unit Tests
51
40
  timeout-minutes: 10
52
41
  runs-on: ubuntu-latest
53
42
  steps:
54
- - uses: actions/checkout@v2
55
- - uses: actions-rs/toolchain@v1
43
+ - uses: actions/checkout@v4
44
+ - uses: dtolnay/rust-toolchain@stable
56
45
  with:
57
- profile: minimal
58
46
  toolchain: 1.77.0
59
- override: true
60
47
  - name: Install protoc
61
- uses: arduino/setup-protoc@v1
48
+ uses: arduino/setup-protoc@v3
62
49
  with:
63
- version: '3.x'
50
+ # TODO: Upgrade proto once https://github.com/arduino/setup-protoc/issues/99 is fixed
51
+ version: '23.x'
64
52
  repo-token: ${{ secrets.GITHUB_TOKEN }}
65
53
  - uses: Swatinem/rust-cache@v2
66
- - uses: actions-rs/cargo@v1
67
- with:
68
- command: test
69
- args: -- --include-ignored --nocapture
70
- - uses: actions/upload-artifact@v3
54
+ - run: cargo test -- --include-ignored --nocapture
55
+ - uses: actions/upload-artifact@v4
71
56
  with:
72
57
  name: coverage-report
73
58
  path: tarpaulin-report.html
74
- - uses: actions/upload-artifact@v3
59
+ - uses: actions/upload-artifact@v4
75
60
  with:
76
61
  name: state-machine-coverage
77
62
  path: machine_coverage/
@@ -81,18 +66,15 @@ jobs:
81
66
  timeout-minutes: 20
82
67
  runs-on: ubuntu-latest
83
68
  steps:
84
- - uses: actions/checkout@v2
85
- - uses: actions-rs/toolchain@v1
69
+ - uses: actions/checkout@v4
70
+ - uses: dtolnay/rust-toolchain@stable
86
71
  with:
87
- profile: minimal
88
72
  toolchain: 1.77.0
89
- override: true
90
73
  - name: Install protoc
91
- uses: arduino/setup-protoc@v1
74
+ uses: arduino/setup-protoc@v3
92
75
  with:
93
- version: '3.x'
76
+ # TODO: Upgrade proto once https://github.com/arduino/setup-protoc/issues/99 is fixed
77
+ version: '23.x'
94
78
  repo-token: ${{ secrets.GITHUB_TOKEN }}
95
79
  - uses: Swatinem/rust-cache@v2
96
- - uses: actions-rs/cargo@v1
97
- with:
98
- command: integ-test
80
+ - run: cargo integ-test
@@ -10,11 +10,11 @@ license-file = "LICENSE.txt"
10
10
  derive_builder = "0.20"
11
11
  derive_more = { version = "0.99", default-features = false, features = ["constructor", "display", "from", "into"] }
12
12
  once_cell = "1.16"
13
- tonic = "0.11"
14
- tonic-build = "0.11"
15
- opentelemetry = "0.22"
16
- prost = "0.12"
17
- prost-types = "0.12"
13
+ tonic = "0.12"
14
+ tonic-build = "0.12"
15
+ opentelemetry = { version = "0.24", features = ["metrics"] }
16
+ prost = "0.13"
17
+ prost-types = "0.13"
18
18
 
19
19
  [workspace.lints.rust]
20
20
  unreachable_pub = "warn"
@@ -90,6 +90,8 @@ is a subtree. To update it, use:
90
90
  `git pull --squash --rebase=false -s subtree ssh://git@github.com/temporalio/api.git master --allow-unrelated-histories`
91
91
 
92
92
  Do not question why this git command is the way it is. It is not our place to interpret git's ways.
93
+ This same approach can be taken for updating `sdk-core-protos/protos/api_cloud_upstream` from the
94
+ `api-cloud` repo.
93
95
 
94
96
  The java testserver protos are also pulled from the sdk-java repo, but since we only need a
95
97
  subdirectory of that repo, we just copy the files with read-tree:
@@ -22,8 +22,10 @@ derive_builder = { workspace = true }
22
22
  derive_more = "0.99"
23
23
  futures = "0.3"
24
24
  futures-retry = "0.6.0"
25
- http = "0.2"
26
- hyper = { version = "0.14" }
25
+ http = "1.1.0"
26
+ http-body-util = "0.1"
27
+ hyper = { version = "1.4.1" }
28
+ hyper-util = "0.1.6"
27
29
  once_cell = { workspace = true }
28
30
  opentelemetry = { workspace = true, features = ["metrics"], optional = true }
29
31
  parking_lot = "0.12"
@@ -18,7 +18,7 @@ pub use crate::{
18
18
  proxy::HttpConnectProxyOptions,
19
19
  retry::{CallType, RetryClient, RETRYABLE_ERROR_CODES},
20
20
  };
21
- pub use raw::{HealthService, OperatorService, TestService, WorkflowService};
21
+ pub use raw::{CloudService, HealthService, OperatorService, TestService, WorkflowService};
22
22
  pub use temporal_sdk_core_protos::temporal::api::{
23
23
  enums::v1::ArchivalState,
24
24
  filter::v1::{StartTimeFilter, StatusFilter, WorkflowExecutionFilter, WorkflowTypeFilter},
@@ -56,6 +56,7 @@ use temporal_sdk_core_protos::{
56
56
  coresdk::{workflow_commands::QueryResult, IntoPayloadsExt},
57
57
  grpc::health::v1::health_client::HealthClient,
58
58
  temporal::api::{
59
+ cloud::cloudservice::v1::cloud_service_client::CloudServiceClient,
59
60
  common::v1::{Header, Payload, Payloads, RetryPolicy, WorkflowExecution, WorkflowType},
60
61
  enums::v1::{TaskQueueKind, WorkflowIdReusePolicy},
61
62
  failure::v1::Failure,
@@ -84,6 +85,7 @@ use uuid::Uuid;
84
85
 
85
86
  static CLIENT_NAME_HEADER_KEY: &str = "client-name";
86
87
  static CLIENT_VERSION_HEADER_KEY: &str = "client-version";
88
+ static TEMPORAL_NAMESPACE_HEADER_KEY: &str = "temporal-namespace";
87
89
  /// These must match the gRPC method names, not the snake case versions that exist in the Rust code.
88
90
  static LONG_POLL_METHOD_NAMES: [&str; 3] = [
89
91
  "PollWorkflowTaskQueue",
@@ -156,6 +158,10 @@ pub struct ClientOptions {
156
158
  /// If set true, error code labels will not be included on request failure metrics.
157
159
  #[builder(default)]
158
160
  pub disable_error_code_metric_tags: bool,
161
+
162
+ /// If set true, get_system_info will not be called upon connection
163
+ #[builder(default)]
164
+ pub skip_get_system_info: bool,
159
165
  }
160
166
 
161
167
  /// Configuration options for TLS
@@ -447,18 +453,20 @@ impl ClientOptions {
447
453
  capabilities: None,
448
454
  workers: Arc::new(SlotManager::new()),
449
455
  };
450
- match client
451
- .get_system_info(GetSystemInfoRequest::default())
452
- .await
453
- {
454
- Ok(sysinfo) => {
455
- client.capabilities = sysinfo.into_inner().capabilities;
456
- }
457
- Err(status) => match status.code() {
458
- Code::Unimplemented => {}
459
- _ => return Err(ClientInitError::SystemInfoCallError(status)),
460
- },
461
- };
456
+ if !self.skip_get_system_info {
457
+ match client
458
+ .get_system_info(GetSystemInfoRequest::default())
459
+ .await
460
+ {
461
+ Ok(sysinfo) => {
462
+ client.capabilities = sysinfo.into_inner().capabilities;
463
+ }
464
+ Err(status) => match status.code() {
465
+ Code::Unimplemented => {}
466
+ _ => return Err(ClientInitError::SystemInfoCallError(status)),
467
+ },
468
+ };
469
+ }
462
470
  Ok(RetryClient::new(client, self.retry_config.clone()))
463
471
  }
464
472
 
@@ -466,7 +474,7 @@ impl ClientOptions {
466
474
  /// Passes it through if TLS options not set.
467
475
  async fn add_tls_to_channel(&self, mut channel: Endpoint) -> Result<Endpoint, ClientInitError> {
468
476
  if let Some(tls_cfg) = &self.tls_cfg {
469
- let mut tls = tonic::transport::ClientTlsConfig::new();
477
+ let mut tls = tonic::transport::ClientTlsConfig::new().with_native_roots();
470
478
 
471
479
  if let Some(root_cert) = &tls_cfg.server_root_ca_cert {
472
480
  let server_root_ca_cert = Certificate::from_pem(root_cert);
@@ -528,9 +536,7 @@ impl Interceptor for ServiceCallInterceptor {
528
536
  );
529
537
  }
530
538
  self.headers.read().apply_to_metadata(metadata);
531
- if !metadata.contains_key("grpc-timeout") {
532
- request.set_timeout(OTHER_CALL_TIMEOUT);
533
- }
539
+ request.set_default_timeout(OTHER_CALL_TIMEOUT);
534
540
 
535
541
  Ok(request)
536
542
  }
@@ -542,6 +548,7 @@ pub struct TemporalServiceClient<T> {
542
548
  svc: T,
543
549
  workflow_svc_client: OnceCell<WorkflowServiceClient<T>>,
544
550
  operator_svc_client: OnceCell<OperatorServiceClient<T>>,
551
+ cloud_svc_client: OnceCell<CloudServiceClient<T>>,
545
552
  test_svc_client: OnceCell<TestServiceClient<T>>,
546
553
  health_svc_client: OnceCell<HealthClient<T>>,
547
554
  }
@@ -571,6 +578,7 @@ where
571
578
  svc,
572
579
  workflow_svc_client: OnceCell::new(),
573
580
  operator_svc_client: OnceCell::new(),
581
+ cloud_svc_client: OnceCell::new(),
574
582
  test_svc_client: OnceCell::new(),
575
583
  health_svc_client: OnceCell::new(),
576
584
  }
@@ -589,6 +597,13 @@ where
589
597
  .max_decoding_message_size(get_decode_max_size())
590
598
  })
591
599
  }
600
+ /// Get the underlying cloud service client
601
+ pub fn cloud_svc(&self) -> &CloudServiceClient<T> {
602
+ self.cloud_svc_client.get_or_init(|| {
603
+ CloudServiceClient::new(self.svc.clone())
604
+ .max_decoding_message_size(get_decode_max_size())
605
+ })
606
+ }
592
607
  /// Get the underlying test service client
593
608
  pub fn test_svc(&self) -> &TestServiceClient<T> {
594
609
  self.test_svc_client.get_or_init(|| {
@@ -612,6 +627,11 @@ where
612
627
  let _ = self.operator_svc();
613
628
  self.operator_svc_client.get_mut().unwrap()
614
629
  }
630
+ /// Get the underlying cloud service client mutably
631
+ pub fn cloud_svc_mut(&mut self) -> &mut CloudServiceClient<T> {
632
+ let _ = self.cloud_svc();
633
+ self.cloud_svc_client.get_mut().unwrap()
634
+ }
615
635
  /// Get the underlying test service client mutably
616
636
  pub fn test_svc_mut(&mut self) -> &mut TestServiceClient<T> {
617
637
  let _ = self.test_svc();
@@ -1604,9 +1624,22 @@ pub trait WfClientExt: WfHandleClient + Sized + Clone {
1604
1624
 
1605
1625
  impl<T> WfClientExt for T where T: WfHandleClient + Clone + Sized {}
1606
1626
 
1627
+ trait RequestExt {
1628
+ /// Set a timeout for a request if one is not already specified in the metadata
1629
+ fn set_default_timeout(&mut self, duration: Duration);
1630
+ }
1631
+ impl<T> RequestExt for tonic::Request<T> {
1632
+ fn set_default_timeout(&mut self, duration: Duration) {
1633
+ if !self.metadata().contains_key("grpc-timeout") {
1634
+ self.set_timeout(duration)
1635
+ }
1636
+ }
1637
+ }
1638
+
1607
1639
  #[cfg(test)]
1608
1640
  mod tests {
1609
1641
  use super::*;
1642
+ use tonic::metadata::Ascii;
1610
1643
 
1611
1644
  #[test]
1612
1645
  fn applies_headers() {
@@ -1667,6 +1700,16 @@ mod tests {
1667
1700
  let req = interceptor.call(tonic::Request::new(())).unwrap();
1668
1701
  assert!(!req.metadata().contains_key("my-meta-key"));
1669
1702
  assert!(!req.metadata().contains_key("authorization"));
1703
+
1704
+ // Timeout header not overriden
1705
+ let mut req = tonic::Request::new(());
1706
+ req.metadata_mut()
1707
+ .insert("grpc-timeout", "1S".parse().unwrap());
1708
+ let req = interceptor.call(req).unwrap();
1709
+ assert_eq!(
1710
+ req.metadata().get("grpc-timeout").unwrap(),
1711
+ "1S".parse::<MetadataValue<Ascii>>().unwrap()
1712
+ );
1670
1713
  }
1671
1714
 
1672
1715
  #[test]
@@ -173,7 +173,7 @@ pub struct GrpcMetricSvc {
173
173
  }
174
174
 
175
175
  impl Service<http::Request<BoxBody>> for GrpcMetricSvc {
176
- type Response = http::Response<tonic::transport::Body>;
176
+ type Response = http::Response<BoxBody>;
177
177
  type Error = tonic::transport::Error;
178
178
  type Future = BoxFuture<'static, Result<Self::Response, Self::Error>>;
179
179
 
@@ -1,12 +1,17 @@
1
1
  use base64::prelude::*;
2
- use hyper::header;
3
- use std::future::Future;
4
- use std::pin::Pin;
5
- use std::task::Context;
6
- use std::task::Poll;
2
+ use http_body_util::Empty;
3
+ use hyper::{body::Bytes, header};
4
+ use hyper_util::{
5
+ client::legacy::Client,
6
+ rt::{TokioExecutor, TokioIo},
7
+ };
8
+ use std::{
9
+ future::Future,
10
+ pin::Pin,
11
+ task::{Context, Poll},
12
+ };
7
13
  use tokio::net::TcpStream;
8
- use tonic::transport::Channel;
9
- use tonic::transport::Endpoint;
14
+ use tonic::transport::{Channel, Endpoint};
10
15
  use tower::{service_fn, Service};
11
16
 
12
17
  /// Options for HTTP CONNECT proxy.
@@ -43,12 +48,12 @@ impl HttpConnectProxyOptions {
43
48
  let creds = BASE64_STANDARD.encode(format!("{}:{}", user, pass));
44
49
  req_build = req_build.header(header::PROXY_AUTHORIZATION, format!("Basic {}", creds));
45
50
  }
46
- let req = req_build.body(hyper::Body::empty())?;
51
+ let req = req_build.body(Empty::<Bytes>::new())?;
47
52
 
48
53
  // We have to create a client with a specific connector because Hyper is
49
54
  // not letting us change the HTTP/2 authority
50
- let client =
51
- hyper::Client::builder().build(OverrideAddrConnector(self.target_addr.clone()));
55
+ let client = Client::builder(TokioExecutor::new())
56
+ .build(OverrideAddrConnector(self.target_addr.clone()));
52
57
 
53
58
  // Send request
54
59
  let res = client.request(req).await?;
@@ -67,7 +72,7 @@ impl HttpConnectProxyOptions {
67
72
  struct OverrideAddrConnector(String);
68
73
 
69
74
  impl Service<hyper::Uri> for OverrideAddrConnector {
70
- type Response = TcpStream;
75
+ type Response = TokioIo<TcpStream>;
71
76
 
72
77
  type Error = anyhow::Error;
73
78
 
@@ -79,7 +84,7 @@ impl Service<hyper::Uri> for OverrideAddrConnector {
79
84
 
80
85
  fn call(&mut self, _uri: hyper::Uri) -> Self::Future {
81
86
  let target_addr = self.0.clone();
82
- let fut = async move { Ok(TcpStream::connect(target_addr).await?) };
87
+ let fut = async move { Ok(TokioIo::new(TcpStream::connect(target_addr).await?)) };
83
88
  Box::pin(fut)
84
89
  }
85
90
  }