@temporalio/core-bridge 1.11.2 → 1.11.4

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 (119) hide show
  1. package/Cargo.lock +396 -489
  2. package/Cargo.toml +3 -2
  3. package/lib/errors.d.ts +2 -0
  4. package/lib/errors.js +7 -3
  5. package/lib/errors.js.map +1 -1
  6. package/lib/index.d.ts +8 -2
  7. package/lib/index.js.map +1 -1
  8. package/lib/worker-tuner.d.ts +111 -1
  9. package/package.json +3 -3
  10. package/releases/aarch64-apple-darwin/index.node +0 -0
  11. package/releases/aarch64-unknown-linux-gnu/index.node +0 -0
  12. package/releases/x86_64-apple-darwin/index.node +0 -0
  13. package/releases/x86_64-pc-windows-msvc/index.node +0 -0
  14. package/releases/x86_64-unknown-linux-gnu/index.node +0 -0
  15. package/sdk-core/.github/workflows/per-pr.yml +3 -3
  16. package/sdk-core/Cargo.toml +0 -1
  17. package/sdk-core/client/Cargo.toml +1 -2
  18. package/sdk-core/client/src/lib.rs +21 -13
  19. package/sdk-core/client/src/metrics.rs +1 -1
  20. package/sdk-core/client/src/raw.rs +46 -1
  21. package/sdk-core/core/Cargo.toml +7 -7
  22. package/sdk-core/core/benches/workflow_replay.rs +1 -1
  23. package/sdk-core/core/src/abstractions/take_cell.rs +1 -1
  24. package/sdk-core/core/src/abstractions.rs +98 -10
  25. package/sdk-core/core/src/core_tests/activity_tasks.rs +8 -2
  26. package/sdk-core/core/src/core_tests/local_activities.rs +1 -1
  27. package/sdk-core/core/src/core_tests/mod.rs +3 -3
  28. package/sdk-core/core/src/core_tests/updates.rs +104 -9
  29. package/sdk-core/core/src/core_tests/workers.rs +72 -3
  30. package/sdk-core/core/src/core_tests/workflow_tasks.rs +6 -7
  31. package/sdk-core/core/src/debug_client.rs +78 -0
  32. package/sdk-core/core/src/ephemeral_server/mod.rs +15 -5
  33. package/sdk-core/core/src/lib.rs +30 -4
  34. package/sdk-core/core/src/pollers/mod.rs +1 -1
  35. package/sdk-core/core/src/pollers/poll_buffer.rs +7 -7
  36. package/sdk-core/core/src/replay/mod.rs +4 -4
  37. package/sdk-core/core/src/telemetry/log_export.rs +2 -2
  38. package/sdk-core/core/src/telemetry/metrics.rs +69 -1
  39. package/sdk-core/core/src/telemetry/otel.rs +2 -2
  40. package/sdk-core/core/src/test_help/mod.rs +3 -3
  41. package/sdk-core/core/src/worker/activities/activity_heartbeat_manager.rs +3 -3
  42. package/sdk-core/core/src/worker/activities/activity_task_poller_stream.rs +1 -1
  43. package/sdk-core/core/src/worker/activities/local_activities.rs +68 -24
  44. package/sdk-core/core/src/worker/activities.rs +26 -15
  45. package/sdk-core/core/src/worker/client/mocks.rs +10 -4
  46. package/sdk-core/core/src/worker/client.rs +17 -0
  47. package/sdk-core/core/src/worker/mod.rs +71 -13
  48. package/sdk-core/core/src/worker/slot_provider.rs +5 -7
  49. package/sdk-core/core/src/worker/tuner/fixed_size.rs +4 -3
  50. package/sdk-core/core/src/worker/tuner/resource_based.rs +171 -32
  51. package/sdk-core/core/src/worker/tuner.rs +18 -6
  52. package/sdk-core/core/src/worker/workflow/history_update.rs +43 -13
  53. package/sdk-core/core/src/worker/workflow/machines/transition_coverage.rs +6 -6
  54. package/sdk-core/core/src/worker/workflow/machines/workflow_machines.rs +6 -5
  55. package/sdk-core/core/src/worker/workflow/managed_run.rs +3 -3
  56. package/sdk-core/core/src/worker/workflow/mod.rs +13 -7
  57. package/sdk-core/core/src/worker/workflow/wft_extraction.rs +7 -7
  58. package/sdk-core/core/src/worker/workflow/wft_poller.rs +2 -2
  59. package/sdk-core/core/src/worker/workflow/workflow_stream.rs +11 -11
  60. package/sdk-core/core-api/Cargo.toml +1 -0
  61. package/sdk-core/core-api/src/worker.rs +84 -30
  62. package/sdk-core/sdk/Cargo.toml +1 -2
  63. package/sdk-core/sdk/src/lib.rs +1 -1
  64. package/sdk-core/sdk/src/workflow_context.rs +9 -8
  65. package/sdk-core/sdk/src/workflow_future.rs +19 -14
  66. package/sdk-core/sdk-core-protos/Cargo.toml +2 -0
  67. package/sdk-core/sdk-core-protos/build.rs +6 -1
  68. package/sdk-core/sdk-core-protos/protos/api_upstream/buf.yaml +1 -0
  69. package/sdk-core/sdk-core-protos/protos/api_upstream/openapi/openapiv2.json +3207 -158
  70. package/sdk-core/sdk-core-protos/protos/api_upstream/openapi/openapiv3.yaml +2934 -118
  71. package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/activity/v1/message.proto +67 -0
  72. package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/common/v1/message.proto +47 -1
  73. package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/enums/v1/event_type.proto +6 -7
  74. package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/enums/v1/failed_cause.proto +2 -0
  75. package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/enums/v1/reset.proto +5 -3
  76. package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/enums/v1/task_queue.proto +3 -3
  77. package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/enums/v1/update.proto +14 -13
  78. package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/failure/v1/message.proto +1 -3
  79. package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/history/v1/message.proto +22 -0
  80. package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/nexus/v1/message.proto +13 -2
  81. package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/operatorservice/v1/service.proto +26 -6
  82. package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/schedule/v1/message.proto +5 -0
  83. package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/sdk/v1/workflow_metadata.proto +6 -0
  84. package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/taskqueue/v1/message.proto +46 -12
  85. package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/update/v1/message.proto +18 -19
  86. package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/workflow/v1/message.proto +27 -0
  87. package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/workflowservice/v1/request_response.proto +192 -19
  88. package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/workflowservice/v1/service.proto +279 -12
  89. package/sdk-core/sdk-core-protos/protos/local/temporal/sdk/core/activity_result/activity_result.proto +1 -1
  90. package/sdk-core/sdk-core-protos/protos/local/temporal/sdk/core/activity_task/activity_task.proto +1 -1
  91. package/sdk-core/sdk-core-protos/protos/local/temporal/sdk/core/child_workflow/child_workflow.proto +1 -1
  92. package/sdk-core/sdk-core-protos/protos/local/temporal/sdk/core/common/common.proto +1 -1
  93. package/sdk-core/sdk-core-protos/protos/local/temporal/sdk/core/core_interface.proto +17 -1
  94. package/sdk-core/sdk-core-protos/protos/local/temporal/sdk/core/external_data/external_data.proto +1 -1
  95. package/sdk-core/sdk-core-protos/protos/local/temporal/sdk/core/workflow_activation/workflow_activation.proto +1 -1
  96. package/sdk-core/sdk-core-protos/protos/local/temporal/sdk/core/workflow_commands/workflow_commands.proto +1 -1
  97. package/sdk-core/sdk-core-protos/protos/local/temporal/sdk/core/workflow_completion/workflow_completion.proto +1 -1
  98. package/sdk-core/sdk-core-protos/src/lib.rs +30 -6
  99. package/sdk-core/test-utils/Cargo.toml +1 -2
  100. package/sdk-core/test-utils/src/lib.rs +2 -2
  101. package/sdk-core/tests/heavy_tests.rs +1 -1
  102. package/sdk-core/tests/integ_tests/ephemeral_server_tests.rs +2 -2
  103. package/sdk-core/tests/integ_tests/metrics_tests.rs +144 -7
  104. package/sdk-core/tests/integ_tests/queries_tests.rs +1 -1
  105. package/sdk-core/tests/integ_tests/update_tests.rs +109 -5
  106. package/sdk-core/tests/integ_tests/worker_tests.rs +44 -8
  107. package/sdk-core/tests/integ_tests/workflow_tests/local_activities.rs +1 -1
  108. package/sdk-core/tests/integ_tests/workflow_tests/resets.rs +1 -1
  109. package/sdk-core/tests/integ_tests/workflow_tests/signals.rs +1 -1
  110. package/sdk-core/tests/integ_tests/workflow_tests.rs +3 -2
  111. package/src/conversions/slot_supplier_bridge.rs +287 -0
  112. package/src/conversions.rs +23 -15
  113. package/src/helpers.rs +35 -1
  114. package/src/runtime.rs +7 -3
  115. package/src/worker.rs +1 -1
  116. package/ts/errors.ts +9 -2
  117. package/ts/index.ts +19 -4
  118. package/ts/worker-tuner.ts +123 -1
  119. package/sdk-core/sdk-core-protos/protos/api_upstream/.gitmodules +0 -3
package/Cargo.toml CHANGED
@@ -17,10 +17,11 @@ lto = true
17
17
  incremental = false
18
18
 
19
19
  [dependencies]
20
+ async-trait = "0.1.83"
20
21
  futures = { version = "0.3", features = ["executor"] }
21
22
  log = "0.4"
22
- neon = { version = "0.10", default-features = false, features = ["napi-6", "event-queue-api"] }
23
- opentelemetry = "0.23"
23
+ neon = { version = "1.0.0", default-features = false, features = ["napi-6", "futures"] }
24
+ opentelemetry = "0.24"
24
25
  parking_lot = "0.12"
25
26
  prost = "0.13"
26
27
  prost-types = "0.13"
package/lib/errors.d.ts CHANGED
@@ -14,6 +14,8 @@ export declare class TransportError extends Error {
14
14
  * Something unexpected happened, considered fatal
15
15
  */
16
16
  export declare class UnexpectedError extends Error {
17
+ cause?: unknown;
18
+ constructor(message: string, cause?: unknown);
17
19
  }
18
20
  export { IllegalStateError };
19
21
  export declare function convertFromNamedError(e: unknown, keepStackTrace: boolean): unknown;
package/lib/errors.js CHANGED
@@ -6,7 +6,8 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
6
6
  return c > 3 && r && Object.defineProperty(target, key, r), r;
7
7
  };
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.convertFromNamedError = exports.IllegalStateError = exports.UnexpectedError = exports.TransportError = exports.ShutdownError = void 0;
9
+ exports.IllegalStateError = exports.UnexpectedError = exports.TransportError = exports.ShutdownError = void 0;
10
+ exports.convertFromNamedError = convertFromNamedError;
10
11
  const common_1 = require("@temporalio/common");
11
12
  Object.defineProperty(exports, "IllegalStateError", { enumerable: true, get: function () { return common_1.IllegalStateError; } });
12
13
  const type_helpers_1 = require("@temporalio/common/lib/type-helpers");
@@ -33,6 +34,10 @@ exports.TransportError = TransportError = __decorate([
33
34
  * Something unexpected happened, considered fatal
34
35
  */
35
36
  let UnexpectedError = class UnexpectedError extends Error {
37
+ constructor(message, cause) {
38
+ super(message);
39
+ this.cause = cause;
40
+ }
36
41
  };
37
42
  exports.UnexpectedError = UnexpectedError;
38
43
  exports.UnexpectedError = UnexpectedError = __decorate([
@@ -59,12 +64,11 @@ function convertFromNamedError(e, keepStackTrace) {
59
64
  newerr.stack = keepStackTrace ? e.stack : undefined;
60
65
  return newerr;
61
66
  case 'UnexpectedError':
62
- newerr = new UnexpectedError(e.message);
67
+ newerr = new UnexpectedError(e.message, e);
63
68
  newerr.stack = keepStackTrace ? e.stack : undefined;
64
69
  return newerr;
65
70
  }
66
71
  }
67
72
  return e;
68
73
  }
69
- exports.convertFromNamedError = convertFromNamedError;
70
74
  //# sourceMappingURL=errors.js.map
package/lib/errors.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"errors.js","sourceRoot":"","sources":["../ts/errors.ts"],"names":[],"mappings":";;;;;;;;;AAAA,+CAAuD;AAsB9C,kGAtBA,0BAAiB,OAsBA;AArB1B,sEAA0F;AAE1F;;GAEG;AAEI,IAAM,aAAa,GAAnB,MAAM,aAAc,SAAQ,KAAK;CAAG,CAAA;AAA9B,sCAAa;wBAAb,aAAa;IADzB,IAAA,yCAA0B,EAAC,eAAe,CAAC;GAC/B,aAAa,CAAiB;AAE3C;;;GAGG;AAEI,IAAM,cAAc,GAApB,MAAM,cAAe,SAAQ,KAAK;CAAG,CAAA;AAA/B,wCAAc;yBAAd,cAAc;IAD1B,IAAA,yCAA0B,EAAC,gBAAgB,CAAC;GAChC,cAAc,CAAiB;AAE5C;;GAEG;AAEI,IAAM,eAAe,GAArB,MAAM,eAAgB,SAAQ,KAAK;CAAG,CAAA;AAAhC,0CAAe;0BAAf,eAAe;IAD3B,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,IAAI,cAAc,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;gBACvC,MAAM,CAAC,KAAK,GAAG,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;gBACpD,OAAO,MAAM,CAAC;YAEhB,KAAK,mBAAmB;gBACtB,MAAM,GAAG,IAAI,0BAAiB,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;gBAC1C,MAAM,CAAC,KAAK,GAAG,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;gBACpD,OAAO,MAAM,CAAC;YAEhB,KAAK,eAAe;gBAClB,MAAM,GAAG,IAAI,aAAa,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;gBACtC,MAAM,CAAC,KAAK,GAAG,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;gBACpD,OAAO,MAAM,CAAC;YAEhB,KAAK,iBAAiB;gBACpB,MAAM,GAAG,IAAI,eAAe,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;gBAC3C,MAAM,CAAC,KAAK,GAAG,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;gBACpD,OAAO,MAAM,CAAC;QAClB,CAAC;IACH,CAAC;IACD,OAAO,CAAC,CAAC;AACX,CAAC"}
package/lib/index.d.ts CHANGED
@@ -1,7 +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
3
  import { WorkerTuner } from './worker-tuner';
4
- export { WorkerTuner, SlotSupplier, ResourceBasedSlotOptions, ResourceBasedTunerOptions, FixedSizeSlotSupplier, } from './worker-tuner';
4
+ export { WorkerTuner, SlotSupplier, ResourceBasedSlotOptions, ResourceBasedTunerOptions, FixedSizeSlotSupplier, CustomSlotSupplier, SlotInfo, WorkflowSlotInfo, ActivitySlotInfo, LocalActivitySlotInfo, SlotMarkUsedContext, SlotPermit, SlotReserveContext, SlotReleaseContext, } from './worker-tuner';
5
5
  export type { TLSConfig, ProxyConfig, HttpConnectProxyConfig };
6
6
  /** @deprecated Import from @temporalio/common instead */
7
7
  export { LogLevel };
@@ -102,7 +102,13 @@ export interface OtelCollectorExporter {
102
102
  /**
103
103
  * URL of a gRPC OpenTelemetry collector.
104
104
  *
105
- * @format Starts with "grpc://" or "http://" for an unsecured connection (typical), or "grpcs://" or "https://" for a TLS connection.
105
+ * Syntax should generally look like `http://server:4317` (the `grpc://` is also fine). Core's OTLP
106
+ * metric exporter does not support the 'OTLP/HTTP' protocol (e.g. `http://server:4318/v1/metrics`).
107
+ * For greater flexibility, you may setup an OTel collector running as a sidecar (e.g. to proxy
108
+ * OTLP/gRPC requests to a remote OTLP/HTTP endpoint).
109
+ *
110
+ * @format Starts with "grpc://" or "http://" for an unsecured connection (typical),
111
+ * or "grpcs://" or "https://" for a TLS connection.
106
112
  * @note The `OTEL_EXPORTER_OTLP_ENDPOINT` environment variable, if set, will override this property.
107
113
  */
108
114
  url: string;
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../ts/index.ts"],"names":[],"mappings":";;;AA4kBA,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":";;;AA2lBA,mCAA0E;AAAjE,uGAAA,aAAa,OAAA;AAAE,wGAAA,cAAc,OAAA;AAAE,yGAAA,eAAe,OAAA"}
@@ -10,6 +10,20 @@ export interface WorkerTuner {
10
10
  activityTaskSlotSupplier: SlotSupplier;
11
11
  localActivityTaskSlotSupplier: SlotSupplier;
12
12
  }
13
+ export type SlotInfo = WorkflowSlotInfo | ActivitySlotInfo | LocalActivitySlotInfo;
14
+ export interface WorkflowSlotInfo {
15
+ type: 'workflow';
16
+ workflowId: string;
17
+ runId: string;
18
+ }
19
+ export interface ActivitySlotInfo {
20
+ type: 'activity';
21
+ activityId: string;
22
+ }
23
+ export interface LocalActivitySlotInfo {
24
+ type: 'local-activity';
25
+ activityId: string;
26
+ }
13
27
  /**
14
28
  * Controls how slots are handed out for a specific task type.
15
29
  *
@@ -18,7 +32,7 @@ export interface WorkerTuner {
18
32
  *
19
33
  * @experimental
20
34
  */
21
- export type SlotSupplier = ResourceBasedSlotsForType | FixedSizeSlotSupplier;
35
+ export type SlotSupplier = ResourceBasedSlotsForType | FixedSizeSlotSupplier | CustomSlotSupplier<any>;
22
36
  /**
23
37
  * Options for a specific slot type within a {@link ResourceBasedSlotsForType}
24
38
  *
@@ -54,4 +68,100 @@ export interface FixedSizeSlotSupplier {
54
68
  type: 'fixed-size';
55
69
  numSlots: number;
56
70
  }
71
+ /**
72
+ * The interface can be implemented to provide custom slot supplier behavior.
73
+ */
74
+ export interface CustomSlotSupplier<SI extends SlotInfo> {
75
+ type: 'custom';
76
+ /**
77
+ * This function is called before polling for new tasks. Your implementation should block until a
78
+ * slot is available then return a permit to use that slot.
79
+ *
80
+ * The only acceptable exception to throw is AbortError, any other exceptions thrown will be
81
+ * logged and ignored.
82
+ *
83
+ * The value inside the returned promise should be an object, however other types will still count
84
+ * as having issued a permit. Including undefined or null. Returning undefined or null does *not*
85
+ * mean you have not issued a permit. Implementations are expected to block until a meaningful
86
+ * permit can be issued.
87
+ *
88
+ * @param ctx The context for slot reservation.
89
+ * @param abortSignal The SDK may decide to abort the reservation request if it's no longer
90
+ * needed. Implementations may clean up and then must reject the promise with AbortError.
91
+ * @returns A permit to use the slot which may be populated with your own data.
92
+ */
93
+ reserveSlot(ctx: SlotReserveContext, abortSignal: AbortSignal): Promise<SlotPermit>;
94
+ /**
95
+ * This function is called when trying to reserve slots for "eager" workflow and activity tasks.
96
+ * Eager tasks are those which are returned as a result of completing a workflow task, rather than
97
+ * from polling. Your implementation must not block, and if a slot is available, return a permit
98
+ * to use that slot.
99
+ *
100
+ * @param ctx The context for slot reservation.
101
+ * @returns Maybe a permit to use the slot which may be populated with your own data.
102
+ */
103
+ tryReserveSlot(ctx: SlotReserveContext): SlotPermit | null;
104
+ /**
105
+ * This function is called once a slot is actually being used to process some task, which may be
106
+ * some time after the slot was reserved originally. For example, if there is no work for a
107
+ * worker, a number of slots equal to the number of active pollers may already be reserved, but
108
+ * none of them are being used yet. This call should be non-blocking.
109
+ *
110
+ * @param ctx The context for marking a slot as used.
111
+ */
112
+ markSlotUsed(slot: SlotMarkUsedContext<SI>): void;
113
+ /**
114
+ * This function is called once a permit is no longer needed. This could be because the task has
115
+ * finished, whether successfully or not, or because the slot was no longer needed (ex: the number
116
+ * of active pollers decreased). This call should be non-blocking.
117
+ *
118
+ * @param ctx The context for releasing a slot.
119
+ */
120
+ releaseSlot(slot: SlotReleaseContext<SI>): void;
121
+ }
122
+ export interface SlotPermit {
123
+ }
124
+ export interface SlotReserveContext {
125
+ /**
126
+ * The type of slot trying to be reserved
127
+ */
128
+ slotType: SlotInfo['type'];
129
+ /**
130
+ * The name of the task queue for which this reservation request is associated
131
+ */
132
+ taskQueue: string;
133
+ /**
134
+ * The identity of the worker that is requesting the reservation
135
+ */
136
+ workerIdentity: string;
137
+ /**
138
+ * The build id of the worker that is requesting the reservation
139
+ */
140
+ workerBuildId: string;
141
+ /**
142
+ * True iff this is a reservation for a sticky poll for a workflow task
143
+ */
144
+ isSticky: boolean;
145
+ }
146
+ export interface SlotMarkUsedContext<SI extends SlotInfo> {
147
+ /**
148
+ * Info about the task that will be using the slot
149
+ */
150
+ slotInfo: SI;
151
+ /**
152
+ * The permit that was issued when the slot was reserved
153
+ */
154
+ permit: SlotPermit;
155
+ }
156
+ export interface SlotReleaseContext<SI extends SlotInfo> {
157
+ /**
158
+ * Info about the task that used this slot, if any. A slot may be released without being used in
159
+ * the event a poll times out.
160
+ */
161
+ slotInfo?: SI;
162
+ /**
163
+ * The permit that was issued when the slot was reserved
164
+ */
165
+ permit: SlotPermit;
166
+ }
57
167
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@temporalio/core-bridge",
3
- "version": "1.11.2",
3
+ "version": "1.11.4",
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.11.2",
25
+ "@temporalio/common": "^1.11.4",
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": "e78b4f71236ccd3227e674bad68439e961fec639"
55
+ "gitHead": "6a7e2d527c9f7078ee78abd9d59ca0d318bb70dd"
56
56
  }
@@ -21,7 +21,7 @@ jobs:
21
21
  submodules: recursive
22
22
  - uses: dtolnay/rust-toolchain@stable
23
23
  with:
24
- toolchain: 1.77.0
24
+ toolchain: 1.80.0
25
25
  - name: Install protoc
26
26
  uses: arduino/setup-protoc@v3
27
27
  with:
@@ -43,7 +43,7 @@ jobs:
43
43
  - uses: actions/checkout@v4
44
44
  - uses: dtolnay/rust-toolchain@stable
45
45
  with:
46
- toolchain: 1.77.0
46
+ toolchain: 1.80.0
47
47
  - name: Install protoc
48
48
  uses: arduino/setup-protoc@v3
49
49
  with:
@@ -74,7 +74,7 @@ jobs:
74
74
  - uses: actions/checkout@v4
75
75
  - uses: dtolnay/rust-toolchain@stable
76
76
  with:
77
- toolchain: 1.77.0
77
+ toolchain: 1.80.0
78
78
  - name: Install protoc
79
79
  uses: arduino/setup-protoc@v3
80
80
  with:
@@ -9,7 +9,6 @@ license-file = "LICENSE.txt"
9
9
  [workspace.dependencies]
10
10
  derive_builder = "0.20"
11
11
  derive_more = { version = "1.0", features = ["constructor", "display", "from", "into", "debug"] }
12
- once_cell = "1.16"
13
12
  tonic = "0.12"
14
13
  tonic-build = "0.12"
15
14
  opentelemetry = { version = "0.24", features = ["metrics"] }
@@ -20,13 +20,12 @@ backoff = "0.4"
20
20
  base64 = "0.22"
21
21
  derive_builder = { workspace = true }
22
22
  derive_more = { workspace = true }
23
- futures = "0.3"
23
+ futures-util = { version = "0.3", default-features = false }
24
24
  futures-retry = "0.6.0"
25
25
  http = "1.1.0"
26
26
  http-body-util = "0.1"
27
27
  hyper = { version = "1.4.1" }
28
28
  hyper-util = "0.1.6"
29
- once_cell = { workspace = true }
30
29
  opentelemetry = { workspace = true, features = ["metrics"], optional = true }
31
30
  parking_lot = "0.12"
32
31
  prost-types = { workspace = true }
@@ -41,8 +41,8 @@ use crate::{
41
41
  };
42
42
  use backoff::{exponential, ExponentialBackoff, SystemClock};
43
43
  use http::{uri::InvalidUri, Uri};
44
- use once_cell::sync::OnceCell;
45
44
  use parking_lot::RwLock;
45
+ use std::sync::OnceLock;
46
46
  use std::{
47
47
  collections::HashMap,
48
48
  fmt::{Debug, Formatter},
@@ -58,7 +58,7 @@ use temporal_sdk_core_protos::{
58
58
  temporal::api::{
59
59
  cloud::cloudservice::v1::cloud_service_client::CloudServiceClient,
60
60
  common::v1::{Header, Payload, Payloads, RetryPolicy, WorkflowExecution, WorkflowType},
61
- enums::v1::{TaskQueueKind, WorkflowIdReusePolicy},
61
+ enums::v1::{TaskQueueKind, WorkflowIdConflictPolicy, WorkflowIdReusePolicy},
62
62
  failure::v1::Failure,
63
63
  operatorservice::v1::operator_service_client::OperatorServiceClient,
64
64
  query::v1::WorkflowQuery,
@@ -546,17 +546,17 @@ impl Interceptor for ServiceCallInterceptor {
546
546
  #[derive(Debug, Clone)]
547
547
  pub struct TemporalServiceClient<T> {
548
548
  svc: T,
549
- workflow_svc_client: OnceCell<WorkflowServiceClient<T>>,
550
- operator_svc_client: OnceCell<OperatorServiceClient<T>>,
551
- cloud_svc_client: OnceCell<CloudServiceClient<T>>,
552
- test_svc_client: OnceCell<TestServiceClient<T>>,
553
- health_svc_client: OnceCell<HealthClient<T>>,
549
+ workflow_svc_client: OnceLock<WorkflowServiceClient<T>>,
550
+ operator_svc_client: OnceLock<OperatorServiceClient<T>>,
551
+ cloud_svc_client: OnceLock<CloudServiceClient<T>>,
552
+ test_svc_client: OnceLock<TestServiceClient<T>>,
553
+ health_svc_client: OnceLock<HealthClient<T>>,
554
554
  }
555
555
 
556
556
  /// We up the limit on incoming messages from server from the 4Mb default to 128Mb. If for
557
557
  /// whatever reason this needs to be changed by the user, we support overriding it via env var.
558
558
  fn get_decode_max_size() -> usize {
559
- static _DECODE_MAX_SIZE: OnceCell<usize> = OnceCell::new();
559
+ static _DECODE_MAX_SIZE: OnceLock<usize> = OnceLock::new();
560
560
  *_DECODE_MAX_SIZE.get_or_init(|| {
561
561
  std::env::var("TEMPORAL_MAX_INCOMING_GRPC_BYTES")
562
562
  .ok()
@@ -576,11 +576,11 @@ where
576
576
  fn new(svc: T) -> Self {
577
577
  Self {
578
578
  svc,
579
- workflow_svc_client: OnceCell::new(),
580
- operator_svc_client: OnceCell::new(),
581
- cloud_svc_client: OnceCell::new(),
582
- test_svc_client: OnceCell::new(),
583
- health_svc_client: OnceCell::new(),
579
+ workflow_svc_client: OnceLock::new(),
580
+ operator_svc_client: OnceLock::new(),
581
+ cloud_svc_client: OnceLock::new(),
582
+ test_svc_client: OnceLock::new(),
583
+ health_svc_client: OnceLock::new(),
584
584
  }
585
585
  }
586
586
  /// Get the underlying workflow service client
@@ -1060,6 +1060,10 @@ pub struct WorkflowOptions {
1060
1060
  /// Set the policy for reusing the workflow id
1061
1061
  pub id_reuse_policy: WorkflowIdReusePolicy,
1062
1062
 
1063
+ /// Set the policy for how to resolve conflicts with running policies.
1064
+ /// NOTE: This is ignored for child workflows.
1065
+ pub id_conflict_policy: WorkflowIdConflictPolicy,
1066
+
1063
1067
  /// Optionally set the execution timeout for the workflow
1064
1068
  /// <https://docs.temporal.io/workflows/#workflow-execution-timeout>
1065
1069
  pub execution_timeout: Option<Duration>,
@@ -1111,6 +1115,7 @@ impl WorkflowClientTrait for Client {
1111
1115
  }),
1112
1116
  request_id: request_id.unwrap_or_else(|| Uuid::new_v4().to_string()),
1113
1117
  workflow_id_reuse_policy: options.id_reuse_policy as i32,
1118
+ workflow_id_conflict_policy: options.id_conflict_policy as i32,
1114
1119
  workflow_execution_timeout: options
1115
1120
  .execution_timeout
1116
1121
  .and_then(|d| d.try_into().ok()),
@@ -1276,6 +1281,7 @@ impl WorkflowClientTrait for Client {
1276
1281
  .request_id
1277
1282
  .unwrap_or_else(|| Uuid::new_v4().to_string()),
1278
1283
  workflow_id_reuse_policy: workflow_options.id_reuse_policy as i32,
1284
+ workflow_id_conflict_policy: workflow_options.id_conflict_policy as i32,
1279
1285
  workflow_execution_timeout: workflow_options
1280
1286
  .execution_timeout
1281
1287
  .and_then(|d| d.try_into().ok()),
@@ -1395,6 +1401,7 @@ impl WorkflowClientTrait for Client {
1395
1401
  request_id: request_id.unwrap_or_else(|| Uuid::new_v4().to_string()),
1396
1402
  first_execution_run_id: "".to_string(),
1397
1403
  reason,
1404
+ links: vec![],
1398
1405
  },
1399
1406
  )
1400
1407
  .await?
@@ -1418,6 +1425,7 @@ impl WorkflowClientTrait for Client {
1418
1425
  details: None,
1419
1426
  identity: self.inner.options.identity.clone(),
1420
1427
  first_execution_run_id: "".to_string(),
1428
+ links: vec![],
1421
1429
  },
1422
1430
  )
1423
1431
  .await?
@@ -1,5 +1,5 @@
1
1
  use crate::{AttachMetricLabels, LONG_POLL_METHOD_NAMES};
2
- use futures::{future::BoxFuture, FutureExt};
2
+ use futures_util::{future::BoxFuture, FutureExt};
3
3
  use std::{
4
4
  sync::Arc,
5
5
  task::{Context, Poll},
@@ -9,7 +9,7 @@ use crate::{
9
9
  Client, ConfiguredClient, InterceptedMetricsSvc, RequestExt, RetryClient,
10
10
  TemporalServiceClient, LONG_POLL_TIMEOUT, TEMPORAL_NAMESPACE_HEADER_KEY,
11
11
  };
12
- use futures::{future::BoxFuture, FutureExt, TryFutureExt};
12
+ use futures_util::{future::BoxFuture, FutureExt, TryFutureExt};
13
13
  use std::sync::Arc;
14
14
  use temporal_sdk_core_api::telemetry::metrics::MetricKeyValue;
15
15
  use temporal_sdk_core_protos::{
@@ -1124,6 +1124,51 @@ proxier! {
1124
1124
  r.extensions_mut().insert(labels);
1125
1125
  }
1126
1126
  );
1127
+ (
1128
+ shutdown_worker,
1129
+ ShutdownWorkerRequest,
1130
+ ShutdownWorkerResponse,
1131
+ |r| {
1132
+ let labels = namespaced_request!(r);
1133
+ r.extensions_mut().insert(labels);
1134
+ }
1135
+ );
1136
+ (
1137
+ update_activity_options_by_id,
1138
+ UpdateActivityOptionsByIdRequest,
1139
+ UpdateActivityOptionsByIdResponse,
1140
+ |r| {
1141
+ let labels = namespaced_request!(r);
1142
+ r.extensions_mut().insert(labels);
1143
+ }
1144
+ );
1145
+ (
1146
+ pause_activity_by_id,
1147
+ PauseActivityByIdRequest,
1148
+ PauseActivityByIdResponse,
1149
+ |r| {
1150
+ let labels = namespaced_request!(r);
1151
+ r.extensions_mut().insert(labels);
1152
+ }
1153
+ );
1154
+ (
1155
+ unpause_activity_by_id,
1156
+ UnpauseActivityByIdRequest,
1157
+ UnpauseActivityByIdResponse,
1158
+ |r| {
1159
+ let labels = namespaced_request!(r);
1160
+ r.extensions_mut().insert(labels);
1161
+ }
1162
+ );
1163
+ (
1164
+ reset_activity_by_id,
1165
+ ResetActivityByIdRequest,
1166
+ ResetActivityByIdResponse,
1167
+ |r| {
1168
+ let labels = namespaced_request!(r);
1169
+ r.extensions_mut().insert(labels);
1170
+ }
1171
+ );
1127
1172
  }
1128
1173
 
1129
1174
  proxier! {
@@ -18,6 +18,7 @@ otel = ["dep:opentelemetry", "dep:opentelemetry_sdk", "dep:opentelemetry-otlp",
18
18
  "dep:opentelemetry-prometheus", "dep:hyper", "dep:hyper-util", "dep:http-body-util"]
19
19
  tokio-console = ["console-subscriber"]
20
20
  ephemeral-server = ["dep:flate2", "dep:reqwest", "dep:tar", "dep:zip"]
21
+ debug-plugin = ["dep:reqwest"]
21
22
 
22
23
  [dependencies]
23
24
  anyhow = "1.0"
@@ -32,16 +33,15 @@ derive_more = { workspace = true }
32
33
  enum_dispatch = "0.3"
33
34
  enum-iterator = "2"
34
35
  flate2 = { version = "1.0", optional = true }
35
- futures = "0.3"
36
- futures-util = "0.3"
37
- governor = "0.6"
36
+ futures-util = { version = "0.3", default-features = false }
37
+ futures-channel = { version = "0.3", default-features = false, features = ["std"] }
38
+ governor = "0.7"
38
39
  http-body-util = { version = "0.1", optional = true }
39
40
  hyper = { version = "1.2", optional = true }
40
41
  hyper-util = { version = "0.1", features = ["server", "http1", "http2", "tokio"], optional = true }
41
42
  itertools = "0.13"
42
43
  lru = "0.12"
43
44
  mockall = "0.13"
44
- once_cell = { workspace = true }
45
45
  opentelemetry = { workspace = true, features = ["metrics"], optional = true }
46
46
  opentelemetry_sdk = { version = "0.24", features = ["rt-tokio", "metrics"], optional = true }
47
47
  opentelemetry-otlp = { version = "0.17", features = ["tokio", "metrics", "tls"], optional = true }
@@ -53,13 +53,13 @@ prometheus = "0.13"
53
53
  prost = { workspace = true }
54
54
  prost-types = { version = "0.6", package = "prost-wkt-types" }
55
55
  rand = "0.8.3"
56
- reqwest = { version = "0.12", features = ["json", "stream", "rustls-tls"], default-features = false, optional = true }
56
+ reqwest = { version = "0.12", features = ["json", "stream", "rustls-tls-native-roots"], default-features = false, optional = true }
57
57
  ringbuf = "0.4"
58
58
  serde = "1.0"
59
59
  serde_json = "1.0"
60
60
  siphasher = "1.0"
61
61
  slotmap = "1.0"
62
- sysinfo = { version = "0.31", default-features = false, features = ["system"] }
62
+ sysinfo = { version = "0.32", default-features = false, features = ["system"] }
63
63
  tar = { version = "0.4", optional = true }
64
64
  thiserror = "1.0"
65
65
  tokio = { version = "1.37", features = ["rt", "rt-multi-thread", "parking_lot", "time", "fs", "process"] }
@@ -92,7 +92,7 @@ assert_matches = "1.4"
92
92
  bimap = "0.6.1"
93
93
  clap = { version = "4.0", features = ["derive"] }
94
94
  criterion = "0.5"
95
- rstest = "0.22"
95
+ rstest = "0.23"
96
96
  temporal-sdk-core-test-utils = { path = "../test-utils" }
97
97
  temporal-sdk = { path = "../sdk" }
98
98
  tokio-stream = { version = "0.1", features = ["net"] }
@@ -1,5 +1,5 @@
1
1
  use criterion::{criterion_group, criterion_main, Criterion};
2
- use futures::StreamExt;
2
+ use futures_util::StreamExt;
3
3
  use std::time::Duration;
4
4
  use temporal_sdk::{WfContext, WorkflowFunction};
5
5
  use temporal_sdk_core::replay::HistoryForReplay;
@@ -1,7 +1,7 @@
1
1
  use parking_lot::Mutex;
2
2
  use std::sync::atomic::{AtomicBool, Ordering};
3
3
 
4
- /// Implements something a bit like a `OnceCell`, but starts already initialized and allows you
4
+ /// Implements something a bit like a `OnceLock`, but starts already initialized and allows you
5
5
  /// to take everything out of it only once in a thread-safe way. This isn't optimized for super
6
6
  /// fast-path usage.
7
7
  pub(crate) struct TakeCell<T> {