@temporalio/core-bridge 1.9.2 → 1.10.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.
- package/Cargo.lock +754 -473
- package/Cargo.toml +3 -3
- package/lib/index.d.ts +33 -2
- package/lib/index.js.map +1 -1
- package/package.json +4 -4
- package/releases/aarch64-apple-darwin/index.node +0 -0
- package/releases/aarch64-unknown-linux-gnu/index.node +0 -0
- package/releases/x86_64-apple-darwin/index.node +0 -0
- package/releases/x86_64-pc-windows-msvc/index.node +0 -0
- package/releases/x86_64-unknown-linux-gnu/index.node +0 -0
- package/scripts/build.js +4 -3
- package/sdk-core/.cargo/config.toml +2 -4
- package/sdk-core/.github/workflows/heavy.yml +1 -1
- package/sdk-core/.github/workflows/per-pr.yml +6 -4
- package/sdk-core/Cargo.toml +10 -3
- package/sdk-core/README.md +4 -6
- package/sdk-core/client/Cargo.toml +13 -5
- package/sdk-core/client/src/lib.rs +123 -34
- package/sdk-core/client/src/metrics.rs +70 -18
- package/sdk-core/client/src/proxy.rs +85 -0
- package/sdk-core/client/src/raw.rs +67 -5
- package/sdk-core/client/src/worker_registry/mod.rs +5 -3
- package/sdk-core/client/src/workflow_handle/mod.rs +3 -1
- package/sdk-core/core/Cargo.toml +31 -37
- package/sdk-core/core/src/abstractions/take_cell.rs +3 -3
- package/sdk-core/core/src/abstractions.rs +176 -108
- package/sdk-core/core/src/core_tests/activity_tasks.rs +4 -13
- package/sdk-core/core/src/core_tests/determinism.rs +2 -1
- package/sdk-core/core/src/core_tests/local_activities.rs +3 -3
- package/sdk-core/core/src/core_tests/mod.rs +3 -3
- package/sdk-core/core/src/core_tests/queries.rs +42 -5
- package/sdk-core/core/src/core_tests/workers.rs +2 -3
- package/sdk-core/core/src/core_tests/workflow_tasks.rs +115 -15
- package/sdk-core/core/src/ephemeral_server/mod.rs +109 -136
- package/sdk-core/core/src/internal_flags.rs +8 -8
- package/sdk-core/core/src/lib.rs +16 -11
- package/sdk-core/core/src/pollers/mod.rs +11 -5
- package/sdk-core/core/src/pollers/poll_buffer.rs +48 -29
- package/sdk-core/core/src/protosext/mod.rs +32 -32
- package/sdk-core/core/src/protosext/protocol_messages.rs +14 -24
- package/sdk-core/core/src/retry_logic.rs +2 -2
- package/sdk-core/core/src/telemetry/log_export.rs +10 -9
- package/sdk-core/core/src/telemetry/metrics.rs +233 -330
- package/sdk-core/core/src/telemetry/mod.rs +11 -38
- package/sdk-core/core/src/telemetry/otel.rs +355 -0
- package/sdk-core/core/src/telemetry/prometheus_server.rs +36 -23
- package/sdk-core/core/src/test_help/mod.rs +80 -59
- package/sdk-core/core/src/worker/activities/activity_heartbeat_manager.rs +6 -6
- package/sdk-core/core/src/worker/activities/local_activities.rs +46 -43
- package/sdk-core/core/src/worker/activities.rs +45 -46
- package/sdk-core/core/src/worker/client/mocks.rs +8 -7
- package/sdk-core/core/src/worker/client.rs +40 -39
- package/sdk-core/core/src/worker/mod.rs +72 -42
- package/sdk-core/core/src/worker/slot_provider.rs +28 -28
- package/sdk-core/core/src/worker/slot_supplier.rs +1 -0
- package/sdk-core/core/src/worker/tuner/fixed_size.rs +52 -0
- package/sdk-core/core/src/worker/tuner/resource_based.rs +561 -0
- package/sdk-core/core/src/worker/tuner.rs +122 -0
- package/sdk-core/core/src/worker/workflow/driven_workflow.rs +6 -6
- package/sdk-core/core/src/worker/workflow/history_update.rs +27 -53
- package/sdk-core/core/src/worker/workflow/machines/activity_state_machine.rs +4 -17
- package/sdk-core/core/src/worker/workflow/machines/cancel_external_state_machine.rs +1 -10
- package/sdk-core/core/src/worker/workflow/machines/cancel_workflow_state_machine.rs +4 -11
- package/sdk-core/core/src/worker/workflow/machines/child_workflow_state_machine.rs +17 -35
- package/sdk-core/core/src/worker/workflow/machines/complete_workflow_state_machine.rs +0 -8
- package/sdk-core/core/src/worker/workflow/machines/continue_as_new_workflow_state_machine.rs +1 -5
- package/sdk-core/core/src/worker/workflow/machines/fail_workflow_state_machine.rs +0 -5
- package/sdk-core/core/src/worker/workflow/machines/local_activity_state_machine.rs +0 -5
- package/sdk-core/core/src/worker/workflow/machines/mod.rs +0 -14
- package/sdk-core/core/src/worker/workflow/machines/modify_workflow_properties_state_machine.rs +0 -5
- package/sdk-core/core/src/worker/workflow/machines/patch_state_machine.rs +0 -5
- package/sdk-core/core/src/worker/workflow/machines/signal_external_state_machine.rs +1 -10
- package/sdk-core/core/src/worker/workflow/machines/timer_state_machine.rs +3 -10
- package/sdk-core/core/src/worker/workflow/machines/transition_coverage.rs +12 -8
- package/sdk-core/core/src/worker/workflow/machines/update_state_machine.rs +0 -10
- package/sdk-core/core/src/worker/workflow/machines/upsert_search_attributes_state_machine.rs +6 -13
- package/sdk-core/core/src/worker/workflow/machines/workflow_machines.rs +27 -37
- package/sdk-core/core/src/worker/workflow/machines/workflow_task_state_machine.rs +3 -14
- package/sdk-core/core/src/worker/workflow/managed_run.rs +84 -54
- package/sdk-core/core/src/worker/workflow/mod.rs +63 -160
- package/sdk-core/core/src/worker/workflow/run_cache.rs +22 -13
- package/sdk-core/core/src/worker/workflow/wft_extraction.rs +16 -3
- package/sdk-core/core/src/worker/workflow/wft_poller.rs +15 -12
- package/sdk-core/core/src/worker/workflow/workflow_stream.rs +39 -78
- package/sdk-core/core-api/Cargo.toml +6 -5
- package/sdk-core/core-api/src/errors.rs +8 -0
- package/sdk-core/core-api/src/telemetry/metrics.rs +75 -4
- package/sdk-core/core-api/src/telemetry.rs +7 -1
- package/sdk-core/core-api/src/worker.rs +212 -56
- package/sdk-core/fsm/Cargo.toml +3 -0
- package/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/no_handle_conversions_require_into_fail.stderr +1 -1
- package/sdk-core/sdk/Cargo.toml +5 -7
- package/sdk-core/sdk/src/app_data.rs +3 -3
- package/sdk-core/sdk/src/lib.rs +5 -3
- package/sdk-core/sdk/src/workflow_context/options.rs +1 -1
- package/sdk-core/sdk/src/workflow_context.rs +10 -9
- package/sdk-core/sdk/src/workflow_future.rs +1 -1
- package/sdk-core/sdk-core-protos/Cargo.toml +8 -6
- package/sdk-core/sdk-core-protos/build.rs +1 -10
- package/sdk-core/sdk-core-protos/protos/api_upstream/.github/PULL_REQUEST_TEMPLATE.md +3 -0
- package/sdk-core/sdk-core-protos/protos/api_upstream/.github/workflows/ci.yml +26 -0
- package/sdk-core/sdk-core-protos/protos/api_upstream/Makefile +42 -20
- package/sdk-core/sdk-core-protos/protos/api_upstream/README.md +2 -0
- package/sdk-core/sdk-core-protos/protos/api_upstream/api-linter.yaml +36 -26
- package/sdk-core/sdk-core-protos/protos/api_upstream/buf.lock +2 -0
- package/sdk-core/sdk-core-protos/protos/api_upstream/google/protobuf/struct.proto +95 -0
- package/sdk-core/sdk-core-protos/protos/api_upstream/openapi/openapiv2.json +9632 -0
- package/sdk-core/sdk-core-protos/protos/api_upstream/openapi/openapiv3.yaml +7337 -0
- package/sdk-core/sdk-core-protos/protos/api_upstream/openapi/payload_description.txt +2 -0
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/command/v1/message.proto +45 -11
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/common/v1/message.proto +22 -4
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/enums/v1/command_type.proto +2 -0
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/enums/v1/common.proto +44 -0
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/enums/v1/event_type.proto +18 -3
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/enums/v1/failed_cause.proto +20 -0
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/enums/v1/task_queue.proto +30 -0
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/enums/v1/update.proto +7 -8
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/enums/v1/workflow.proto +23 -5
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/errordetails/v1/message.proto +20 -0
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/failure/v1/message.proto +25 -0
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/history/v1/message.proto +141 -15
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/namespace/v1/message.proto +12 -0
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/nexus/v1/message.proto +193 -0
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/operatorservice/v1/request_response.proto +73 -6
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/operatorservice/v1/service.proto +46 -4
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/schedule/v1/message.proto +4 -0
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/sdk/v1/workflow_metadata.proto +2 -2
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/taskqueue/v1/message.proto +116 -0
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/workflow/v1/message.proto +134 -0
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/workflowservice/v1/request_response.proto +274 -29
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/workflowservice/v1/service.proto +57 -1
- package/sdk-core/sdk-core-protos/protos/local/temporal/sdk/core/workflow_activation/workflow_activation.proto +10 -12
- package/sdk-core/sdk-core-protos/src/history_builder.rs +1 -1
- package/sdk-core/sdk-core-protos/src/lib.rs +54 -51
- package/sdk-core/sdk-core-protos/src/task_token.rs +11 -2
- package/sdk-core/test-utils/Cargo.toml +7 -4
- package/sdk-core/test-utils/src/histfetch.rs +1 -1
- package/sdk-core/test-utils/src/lib.rs +44 -62
- package/sdk-core/tests/fuzzy_workflow.rs +5 -2
- package/sdk-core/tests/heavy_tests.rs +114 -17
- package/sdk-core/tests/integ_tests/activity_functions.rs +1 -1
- package/sdk-core/tests/integ_tests/client_tests.rs +2 -2
- package/sdk-core/tests/integ_tests/ephemeral_server_tests.rs +38 -26
- package/sdk-core/tests/integ_tests/metrics_tests.rs +126 -17
- package/sdk-core/tests/integ_tests/polling_tests.rs +118 -2
- package/sdk-core/tests/integ_tests/update_tests.rs +3 -5
- package/sdk-core/tests/integ_tests/visibility_tests.rs +3 -3
- package/sdk-core/tests/integ_tests/workflow_tests/activities.rs +1 -1
- package/sdk-core/tests/integ_tests/workflow_tests/appdata_propagation.rs +1 -1
- package/sdk-core/tests/integ_tests/workflow_tests/cancel_external.rs +1 -1
- package/sdk-core/tests/integ_tests/workflow_tests/cancel_wf.rs +1 -1
- package/sdk-core/tests/integ_tests/workflow_tests/child_workflows.rs +3 -3
- package/sdk-core/tests/integ_tests/workflow_tests/continue_as_new.rs +5 -4
- package/sdk-core/tests/integ_tests/workflow_tests/determinism.rs +3 -2
- package/sdk-core/tests/integ_tests/workflow_tests/eager.rs +6 -10
- package/sdk-core/tests/integ_tests/workflow_tests/local_activities.rs +9 -7
- package/sdk-core/tests/integ_tests/workflow_tests/modify_wf_properties.rs +1 -1
- package/sdk-core/tests/integ_tests/workflow_tests/patches.rs +14 -9
- package/sdk-core/tests/integ_tests/workflow_tests/resets.rs +1 -1
- package/sdk-core/tests/integ_tests/workflow_tests/signals.rs +6 -13
- package/sdk-core/tests/integ_tests/workflow_tests/stickyness.rs +9 -6
- package/sdk-core/tests/integ_tests/workflow_tests/timers.rs +5 -5
- package/sdk-core/tests/integ_tests/workflow_tests/upsert_search_attrs.rs +1 -1
- package/sdk-core/tests/integ_tests/workflow_tests.rs +115 -11
- package/sdk-core/tests/main.rs +2 -2
- package/src/conversions.rs +57 -0
- package/src/lib.rs +1 -0
- package/src/runtime.rs +51 -35
- package/ts/index.ts +67 -3
- package/sdk-core/core/src/worker/workflow/workflow_stream/saved_wf_inputs.rs +0 -117
- package/sdk-core/core/src/worker/workflow/workflow_stream/tonic_status_serde.rs +0 -24
- package/sdk-core/sdk/src/payload_converter.rs +0 -11
- package/sdk-core/sdk-core-protos/protos/api_upstream/.buildkite/Dockerfile +0 -2
- package/sdk-core/sdk-core-protos/protos/api_upstream/.buildkite/docker-compose.yml +0 -15
- package/sdk-core/sdk-core-protos/protos/api_upstream/.buildkite/pipeline.yml +0 -10
- package/sdk-core/test-utils/src/wf_input_saver.rs +0 -50
- package/sdk-core/tests/wf_input_replay.rs +0 -32
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
use crate::{
|
|
2
|
-
abstractions::{dbg_panic,
|
|
2
|
+
abstractions::{dbg_panic, MeteredPermitDealer, OwnedMeteredSemPermit},
|
|
3
3
|
pollers::{self, Poller},
|
|
4
4
|
worker::client::WorkerClient,
|
|
5
5
|
};
|
|
@@ -15,6 +15,7 @@ use std::{
|
|
|
15
15
|
},
|
|
16
16
|
time::Duration,
|
|
17
17
|
};
|
|
18
|
+
use temporal_sdk_core_api::worker::{ActivitySlotKind, SlotKind, WorkflowSlotKind};
|
|
18
19
|
use temporal_sdk_core_protos::temporal::api::{
|
|
19
20
|
taskqueue::v1::TaskQueue,
|
|
20
21
|
workflowservice::v1::{PollActivityTaskQueueResponse, PollWorkflowTaskQueueResponse},
|
|
@@ -29,8 +30,10 @@ use tokio::{
|
|
|
29
30
|
};
|
|
30
31
|
use tokio_util::sync::CancellationToken;
|
|
31
32
|
|
|
32
|
-
|
|
33
|
-
|
|
33
|
+
type PollReceiver<T, SK> =
|
|
34
|
+
Mutex<UnboundedReceiver<pollers::Result<(T, OwnedMeteredSemPermit<SK>)>>>;
|
|
35
|
+
pub(crate) struct LongPollBuffer<T, SK: SlotKind> {
|
|
36
|
+
buffered_polls: PollReceiver<T, SK>,
|
|
34
37
|
shutdown: CancellationToken,
|
|
35
38
|
join_handles: FuturesUnordered<JoinHandle<()>>,
|
|
36
39
|
/// Pollers won't actually start polling until initialized & value is sent
|
|
@@ -63,13 +66,14 @@ where
|
|
|
63
66
|
}
|
|
64
67
|
}
|
|
65
68
|
|
|
66
|
-
impl<T> LongPollBuffer<T>
|
|
69
|
+
impl<T, SK> LongPollBuffer<T, SK>
|
|
67
70
|
where
|
|
68
71
|
T: Send + Debug + 'static,
|
|
72
|
+
SK: SlotKind + 'static,
|
|
69
73
|
{
|
|
70
74
|
pub(crate) fn new<FT, DelayFut>(
|
|
71
75
|
poll_fn: impl Fn() -> FT + Send + Sync + 'static,
|
|
72
|
-
|
|
76
|
+
permit_dealer: Arc<MeteredPermitDealer<SK>>,
|
|
73
77
|
max_pollers: usize,
|
|
74
78
|
shutdown: CancellationToken,
|
|
75
79
|
num_pollers_handler: Option<impl Fn(usize) + Send + Sync + 'static>,
|
|
@@ -91,7 +95,7 @@ where
|
|
|
91
95
|
let pf = pf.clone();
|
|
92
96
|
let shutdown = shutdown.clone();
|
|
93
97
|
let ap = active_pollers.clone();
|
|
94
|
-
let
|
|
98
|
+
let permit_dealer = permit_dealer.clone();
|
|
95
99
|
let nph = nph.clone();
|
|
96
100
|
let pre_permit_delay = pre_permit_delay.clone();
|
|
97
101
|
let mut wait_for_start = wait_for_start.resubscribe();
|
|
@@ -114,7 +118,7 @@ where
|
|
|
114
118
|
}
|
|
115
119
|
}
|
|
116
120
|
let permit = tokio::select! {
|
|
117
|
-
p =
|
|
121
|
+
p = permit_dealer.acquire_owned() => p,
|
|
118
122
|
_ = shutdown.cancelled() => break,
|
|
119
123
|
};
|
|
120
124
|
let permit = if let Ok(p) = permit {
|
|
@@ -143,15 +147,16 @@ where
|
|
|
143
147
|
}
|
|
144
148
|
|
|
145
149
|
#[async_trait::async_trait]
|
|
146
|
-
impl<T> Poller<(T, OwnedMeteredSemPermit)> for LongPollBuffer<T>
|
|
150
|
+
impl<T, SK> Poller<(T, OwnedMeteredSemPermit<SK>)> for LongPollBuffer<T, SK>
|
|
147
151
|
where
|
|
148
152
|
T: Send + Sync + Debug + 'static,
|
|
153
|
+
SK: SlotKind + 'static,
|
|
149
154
|
{
|
|
150
155
|
/// Poll for the next item from this poller
|
|
151
156
|
///
|
|
152
157
|
/// Returns `None` if the poller has been shut down
|
|
153
158
|
#[instrument(name = "long_poll", level = "trace", skip(self))]
|
|
154
|
-
async fn poll(&self) -> Option<pollers::Result<(T, OwnedMeteredSemPermit)>> {
|
|
159
|
+
async fn poll(&self) -> Option<pollers::Result<(T, OwnedMeteredSemPermit<SK>)>> {
|
|
155
160
|
if !self.did_start.fetch_or(true, Ordering::Relaxed) {
|
|
156
161
|
let _ = self.starter.send(());
|
|
157
162
|
}
|
|
@@ -168,8 +173,12 @@ where
|
|
|
168
173
|
self.notify_shutdown();
|
|
169
174
|
while let Some(jh) = self.join_handles.next().await {
|
|
170
175
|
if let Err(e) = jh {
|
|
171
|
-
if
|
|
172
|
-
|
|
176
|
+
if e.is_panic() {
|
|
177
|
+
let as_panic = e.into_panic().downcast::<String>();
|
|
178
|
+
dbg_panic!(
|
|
179
|
+
"Poller task died or did not terminate cleanly: {:?}",
|
|
180
|
+
as_panic
|
|
181
|
+
);
|
|
173
182
|
}
|
|
174
183
|
}
|
|
175
184
|
}
|
|
@@ -183,16 +192,26 @@ where
|
|
|
183
192
|
|
|
184
193
|
/// A poller capable of polling on a sticky and a nonsticky queue simultaneously for workflow tasks.
|
|
185
194
|
#[derive(derive_more::Constructor)]
|
|
186
|
-
pub struct WorkflowTaskPoller {
|
|
195
|
+
pub(crate) struct WorkflowTaskPoller {
|
|
187
196
|
normal_poller: PollWorkflowTaskBuffer,
|
|
188
197
|
sticky_poller: Option<PollWorkflowTaskBuffer>,
|
|
189
198
|
}
|
|
190
199
|
|
|
191
200
|
#[async_trait::async_trait]
|
|
192
|
-
impl
|
|
201
|
+
impl
|
|
202
|
+
Poller<(
|
|
203
|
+
PollWorkflowTaskQueueResponse,
|
|
204
|
+
OwnedMeteredSemPermit<WorkflowSlotKind>,
|
|
205
|
+
)> for WorkflowTaskPoller
|
|
206
|
+
{
|
|
193
207
|
async fn poll(
|
|
194
208
|
&self,
|
|
195
|
-
) -> Option<
|
|
209
|
+
) -> Option<
|
|
210
|
+
pollers::Result<(
|
|
211
|
+
PollWorkflowTaskQueueResponse,
|
|
212
|
+
OwnedMeteredSemPermit<WorkflowSlotKind>,
|
|
213
|
+
)>,
|
|
214
|
+
> {
|
|
196
215
|
if let Some(sq) = self.sticky_poller.as_ref() {
|
|
197
216
|
tokio::select! {
|
|
198
217
|
r = self.normal_poller.poll() => r,
|
|
@@ -223,12 +242,13 @@ impl Poller<(PollWorkflowTaskQueueResponse, OwnedMeteredSemPermit)> for Workflow
|
|
|
223
242
|
}
|
|
224
243
|
}
|
|
225
244
|
|
|
226
|
-
pub type PollWorkflowTaskBuffer =
|
|
245
|
+
pub(crate) type PollWorkflowTaskBuffer =
|
|
246
|
+
LongPollBuffer<PollWorkflowTaskQueueResponse, WorkflowSlotKind>;
|
|
227
247
|
pub(crate) fn new_workflow_task_buffer(
|
|
228
248
|
client: Arc<dyn WorkerClient>,
|
|
229
249
|
task_queue: TaskQueue,
|
|
230
250
|
concurrent_pollers: usize,
|
|
231
|
-
|
|
251
|
+
permit_dealer: Arc<MeteredPermitDealer<WorkflowSlotKind>>,
|
|
232
252
|
shutdown: CancellationToken,
|
|
233
253
|
num_pollers_handler: Option<impl Fn(usize) + Send + Sync + 'static>,
|
|
234
254
|
) -> PollWorkflowTaskBuffer {
|
|
@@ -238,7 +258,7 @@ pub(crate) fn new_workflow_task_buffer(
|
|
|
238
258
|
let task_queue = task_queue.clone();
|
|
239
259
|
async move { client.poll_workflow_task(task_queue).await }
|
|
240
260
|
},
|
|
241
|
-
|
|
261
|
+
permit_dealer,
|
|
242
262
|
concurrent_pollers,
|
|
243
263
|
shutdown,
|
|
244
264
|
num_pollers_handler,
|
|
@@ -246,13 +266,14 @@ pub(crate) fn new_workflow_task_buffer(
|
|
|
246
266
|
)
|
|
247
267
|
}
|
|
248
268
|
|
|
249
|
-
pub type PollActivityTaskBuffer =
|
|
269
|
+
pub(crate) type PollActivityTaskBuffer =
|
|
270
|
+
LongPollBuffer<PollActivityTaskQueueResponse, ActivitySlotKind>;
|
|
250
271
|
#[allow(clippy::too_many_arguments)]
|
|
251
272
|
pub(crate) fn new_activity_task_buffer(
|
|
252
273
|
client: Arc<dyn WorkerClient>,
|
|
253
274
|
task_queue: String,
|
|
254
275
|
concurrent_pollers: usize,
|
|
255
|
-
semaphore: Arc<
|
|
276
|
+
semaphore: Arc<MeteredPermitDealer<ActivitySlotKind>>,
|
|
256
277
|
max_tps: Option<f64>,
|
|
257
278
|
shutdown: CancellationToken,
|
|
258
279
|
num_pollers_handler: Option<impl Fn(usize) + Send + Sync + 'static>,
|
|
@@ -283,19 +304,20 @@ pub(crate) fn new_activity_task_buffer(
|
|
|
283
304
|
|
|
284
305
|
#[cfg(test)]
|
|
285
306
|
#[derive(derive_more::Constructor)]
|
|
286
|
-
pub(crate) struct MockPermittedPollBuffer<PT> {
|
|
287
|
-
sem: Arc<
|
|
307
|
+
pub(crate) struct MockPermittedPollBuffer<PT, SK: SlotKind> {
|
|
308
|
+
sem: Arc<MeteredPermitDealer<SK>>,
|
|
288
309
|
inner: PT,
|
|
289
310
|
}
|
|
290
311
|
|
|
291
312
|
#[cfg(test)]
|
|
292
313
|
#[async_trait::async_trait]
|
|
293
|
-
impl<T, PT> Poller<(T, OwnedMeteredSemPermit)> for MockPermittedPollBuffer<PT>
|
|
314
|
+
impl<T, PT, SK> Poller<(T, OwnedMeteredSemPermit<SK>)> for MockPermittedPollBuffer<PT, SK>
|
|
294
315
|
where
|
|
295
316
|
T: Send + Sync + 'static,
|
|
296
317
|
PT: Poller<T> + Send + Sync + 'static,
|
|
318
|
+
SK: SlotKind + 'static,
|
|
297
319
|
{
|
|
298
|
-
async fn poll(&self) -> Option<pollers::Result<(T, OwnedMeteredSemPermit)>> {
|
|
320
|
+
async fn poll(&self) -> Option<pollers::Result<(T, OwnedMeteredSemPermit<SK>)>> {
|
|
299
321
|
let p = self
|
|
300
322
|
.sem
|
|
301
323
|
.acquire_owned()
|
|
@@ -321,7 +343,8 @@ where
|
|
|
321
343
|
mod tests {
|
|
322
344
|
use super::*;
|
|
323
345
|
use crate::{
|
|
324
|
-
|
|
346
|
+
abstractions::tests::fixed_size_permit_dealer,
|
|
347
|
+
worker::client::mocks::mock_manual_workflow_client,
|
|
325
348
|
};
|
|
326
349
|
use futures::FutureExt;
|
|
327
350
|
use std::time::Duration;
|
|
@@ -350,11 +373,7 @@ mod tests {
|
|
|
350
373
|
normal_name: "".to_string(),
|
|
351
374
|
},
|
|
352
375
|
1,
|
|
353
|
-
Arc::new(
|
|
354
|
-
10,
|
|
355
|
-
MetricsContext::no_op(),
|
|
356
|
-
|_, _| {},
|
|
357
|
-
)),
|
|
376
|
+
Arc::new(fixed_size_permit_dealer(10)),
|
|
358
377
|
CancellationToken::new(),
|
|
359
378
|
None::<fn(usize)>,
|
|
360
379
|
);
|
|
@@ -45,23 +45,23 @@ use temporal_sdk_core_protos::{
|
|
|
45
45
|
/// A validated version of a [PollWorkflowTaskQueueResponse]
|
|
46
46
|
#[derive(Clone, PartialEq)]
|
|
47
47
|
#[allow(clippy::manual_non_exhaustive)] // Clippy doesn't understand it's only for *in* this crate
|
|
48
|
-
pub struct ValidPollWFTQResponse {
|
|
49
|
-
pub task_token: TaskToken,
|
|
50
|
-
pub task_queue: String,
|
|
51
|
-
pub workflow_execution: WorkflowExecution,
|
|
52
|
-
pub workflow_type: String,
|
|
53
|
-
pub history: History,
|
|
54
|
-
pub next_page_token: Vec<u8>,
|
|
55
|
-
pub attempt: u32,
|
|
56
|
-
pub previous_started_event_id: i64,
|
|
57
|
-
pub started_event_id: i64,
|
|
48
|
+
pub(crate) struct ValidPollWFTQResponse {
|
|
49
|
+
pub(crate) task_token: TaskToken,
|
|
50
|
+
pub(crate) task_queue: String,
|
|
51
|
+
pub(crate) workflow_execution: WorkflowExecution,
|
|
52
|
+
pub(crate) workflow_type: String,
|
|
53
|
+
pub(crate) history: History,
|
|
54
|
+
pub(crate) next_page_token: Vec<u8>,
|
|
55
|
+
pub(crate) attempt: u32,
|
|
56
|
+
pub(crate) previous_started_event_id: i64,
|
|
57
|
+
pub(crate) started_event_id: i64,
|
|
58
58
|
/// If this is present, `history` will be empty. This is not a very "tight" design, but it's
|
|
59
59
|
/// enforced at construction time. From the `query` field.
|
|
60
|
-
pub legacy_query: Option<WorkflowQuery>,
|
|
60
|
+
pub(crate) legacy_query: Option<WorkflowQuery>,
|
|
61
61
|
/// Query requests from the `queries` field
|
|
62
|
-
pub query_requests: Vec<QueryWorkflow>,
|
|
62
|
+
pub(crate) query_requests: Vec<QueryWorkflow>,
|
|
63
63
|
/// Protocol messages
|
|
64
|
-
pub messages: Vec<IncomingProtocolMessage>,
|
|
64
|
+
pub(crate) messages: Vec<IncomingProtocolMessage>,
|
|
65
65
|
|
|
66
66
|
/// Zero-size field to prevent explicit construction
|
|
67
67
|
_cant_construct_me: (),
|
|
@@ -253,8 +253,8 @@ impl HistoryEventExt for HistoryEvent {
|
|
|
253
253
|
}
|
|
254
254
|
|
|
255
255
|
pub(crate) struct CompleteLocalActivityData {
|
|
256
|
-
pub marker_dat: LocalActivityMarkerData,
|
|
257
|
-
pub result: Result<Payload, Failure>,
|
|
256
|
+
pub(crate) marker_dat: LocalActivityMarkerData,
|
|
257
|
+
pub(crate) result: Result<Payload, Failure>,
|
|
258
258
|
}
|
|
259
259
|
|
|
260
260
|
pub(crate) fn validate_activity_completion(
|
|
@@ -303,23 +303,23 @@ impl TryFrom<activity_execution_result::Status> for LocalActivityExecutionResult
|
|
|
303
303
|
/// One or both of `schedule_to_close_timeout` and `start_to_close_timeout` are guaranteed to exist.
|
|
304
304
|
#[derive(Debug, Clone)]
|
|
305
305
|
#[cfg_attr(test, derive(Default))]
|
|
306
|
-
pub struct ValidScheduleLA {
|
|
307
|
-
pub seq: u32,
|
|
308
|
-
pub activity_id: String,
|
|
309
|
-
pub activity_type: String,
|
|
310
|
-
pub attempt: u32,
|
|
311
|
-
pub original_schedule_time: Option<SystemTime>,
|
|
312
|
-
pub headers: HashMap<String, Payload>,
|
|
313
|
-
pub arguments: Vec<Payload>,
|
|
314
|
-
pub schedule_to_start_timeout: Option<Duration>,
|
|
315
|
-
pub close_timeouts: LACloseTimeouts,
|
|
316
|
-
pub retry_policy: RetryPolicy,
|
|
317
|
-
pub local_retry_threshold: Duration,
|
|
318
|
-
pub cancellation_type: ActivityCancellationType,
|
|
306
|
+
pub(crate) struct ValidScheduleLA {
|
|
307
|
+
pub(crate) seq: u32,
|
|
308
|
+
pub(crate) activity_id: String,
|
|
309
|
+
pub(crate) activity_type: String,
|
|
310
|
+
pub(crate) attempt: u32,
|
|
311
|
+
pub(crate) original_schedule_time: Option<SystemTime>,
|
|
312
|
+
pub(crate) headers: HashMap<String, Payload>,
|
|
313
|
+
pub(crate) arguments: Vec<Payload>,
|
|
314
|
+
pub(crate) schedule_to_start_timeout: Option<Duration>,
|
|
315
|
+
pub(crate) close_timeouts: LACloseTimeouts,
|
|
316
|
+
pub(crate) retry_policy: RetryPolicy,
|
|
317
|
+
pub(crate) local_retry_threshold: Duration,
|
|
318
|
+
pub(crate) cancellation_type: ActivityCancellationType,
|
|
319
319
|
}
|
|
320
320
|
|
|
321
321
|
#[derive(Debug, Clone, Copy)]
|
|
322
|
-
pub enum LACloseTimeouts {
|
|
322
|
+
pub(crate) enum LACloseTimeouts {
|
|
323
323
|
ScheduleOnly(Duration),
|
|
324
324
|
StartOnly(Duration),
|
|
325
325
|
Both { sched: Duration, start: Duration },
|
|
@@ -328,7 +328,7 @@ pub enum LACloseTimeouts {
|
|
|
328
328
|
impl LACloseTimeouts {
|
|
329
329
|
/// Splits into (schedule_to_close, start_to_close) options, one or both of which is guaranteed
|
|
330
330
|
/// to be populated
|
|
331
|
-
pub fn into_sched_and_start(self) -> (Option<Duration>, Option<Duration>) {
|
|
331
|
+
pub(crate) fn into_sched_and_start(self) -> (Option<Duration>, Option<Duration>) {
|
|
332
332
|
match self {
|
|
333
333
|
LACloseTimeouts::ScheduleOnly(x) => (Some(x), None),
|
|
334
334
|
LACloseTimeouts::StartOnly(x) => (None, Some(x)),
|
|
@@ -345,7 +345,7 @@ impl Default for LACloseTimeouts {
|
|
|
345
345
|
}
|
|
346
346
|
|
|
347
347
|
impl ValidScheduleLA {
|
|
348
|
-
pub fn from_schedule_la(v: ScheduleLocalActivity) -> Result<Self, anyhow::Error> {
|
|
348
|
+
pub(crate) fn from_schedule_la(v: ScheduleLocalActivity) -> Result<Self, anyhow::Error> {
|
|
349
349
|
let original_schedule_time = v
|
|
350
350
|
.original_schedule_time
|
|
351
351
|
.map(|x| {
|
|
@@ -406,7 +406,7 @@ impl ValidScheduleLA {
|
|
|
406
406
|
.clone()
|
|
407
407
|
.try_into_or_none()
|
|
408
408
|
.unwrap_or_else(|| Duration::from_secs(60));
|
|
409
|
-
let cancellation_type = ActivityCancellationType::
|
|
409
|
+
let cancellation_type = ActivityCancellationType::try_from(v.cancellation_type)
|
|
410
410
|
.unwrap_or(ActivityCancellationType::WaitCancellationCompleted);
|
|
411
411
|
Ok(ValidScheduleLA {
|
|
412
412
|
seq: v.seq,
|
|
@@ -8,18 +8,15 @@ use temporal_sdk_core_protos::temporal::api::{
|
|
|
8
8
|
|
|
9
9
|
/// A decoded & verified of a [Message] that came with a WFT.
|
|
10
10
|
#[derive(Debug, Clone, PartialEq)]
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
)
|
|
15
|
-
pub
|
|
16
|
-
pub id: String,
|
|
17
|
-
pub protocol_instance_id: String,
|
|
18
|
-
pub sequencing_id: Option<SequencingId>,
|
|
19
|
-
pub body: IncomingProtocolMessageBody,
|
|
11
|
+
pub(crate) struct IncomingProtocolMessage {
|
|
12
|
+
pub(crate) id: String,
|
|
13
|
+
pub(crate) protocol_instance_id: String,
|
|
14
|
+
pub(crate) sequencing_id: Option<SequencingId>,
|
|
15
|
+
pub(crate) body: IncomingProtocolMessageBody,
|
|
20
16
|
}
|
|
17
|
+
|
|
21
18
|
impl IncomingProtocolMessage {
|
|
22
|
-
pub fn processable_after_event_id(&self) -> Option<i64> {
|
|
19
|
+
pub(crate) fn processable_after_event_id(&self) -> Option<i64> {
|
|
23
20
|
match self.sequencing_id {
|
|
24
21
|
None => Some(0),
|
|
25
22
|
Some(SequencingId::EventId(id)) => Some(id),
|
|
@@ -27,6 +24,7 @@ impl IncomingProtocolMessage {
|
|
|
27
24
|
}
|
|
28
25
|
}
|
|
29
26
|
}
|
|
27
|
+
|
|
30
28
|
impl TryFrom<Message> for IncomingProtocolMessage {
|
|
31
29
|
type Error = anyhow::Error;
|
|
32
30
|
|
|
@@ -44,11 +42,7 @@ impl TryFrom<Message> for IncomingProtocolMessage {
|
|
|
44
42
|
/// All the protocol [Message] bodies Core understands that might come to us when receiving a new
|
|
45
43
|
/// WFT.
|
|
46
44
|
#[derive(Debug, Clone, PartialEq)]
|
|
47
|
-
|
|
48
|
-
feature = "save_wf_inputs",
|
|
49
|
-
derive(serde::Serialize, serde::Deserialize)
|
|
50
|
-
)]
|
|
51
|
-
pub enum IncomingProtocolMessageBody {
|
|
45
|
+
pub(crate) enum IncomingProtocolMessageBody {
|
|
52
46
|
UpdateRequest(UpdateRequest),
|
|
53
47
|
}
|
|
54
48
|
|
|
@@ -71,15 +65,11 @@ impl TryFrom<Option<prost_types::Any>> for IncomingProtocolMessageBody {
|
|
|
71
65
|
}
|
|
72
66
|
|
|
73
67
|
#[derive(Debug, Clone, PartialEq)]
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
)
|
|
78
|
-
pub
|
|
79
|
-
pub name: String,
|
|
80
|
-
pub headers: HashMap<String, Payload>,
|
|
81
|
-
pub input: Vec<Payload>,
|
|
82
|
-
pub meta: update::v1::Meta,
|
|
68
|
+
pub(crate) struct UpdateRequest {
|
|
69
|
+
pub(crate) name: String,
|
|
70
|
+
pub(crate) headers: HashMap<String, Payload>,
|
|
71
|
+
pub(crate) input: Vec<Payload>,
|
|
72
|
+
pub(crate) meta: update::v1::Meta,
|
|
83
73
|
}
|
|
84
74
|
|
|
85
75
|
impl TryFrom<update::v1::Request> for UpdateRequest {
|
|
@@ -173,7 +173,7 @@ mod tests {
|
|
|
173
173
|
Some(&ApplicationFailureInfo {
|
|
174
174
|
r#type: "no retry".to_string(),
|
|
175
175
|
non_retryable: false,
|
|
176
|
-
|
|
176
|
+
..Default::default()
|
|
177
177
|
})
|
|
178
178
|
)
|
|
179
179
|
.is_none());
|
|
@@ -194,7 +194,7 @@ mod tests {
|
|
|
194
194
|
Some(&ApplicationFailureInfo {
|
|
195
195
|
r#type: "".to_string(),
|
|
196
196
|
non_retryable: true,
|
|
197
|
-
|
|
197
|
+
..Default::default()
|
|
198
198
|
})
|
|
199
199
|
)
|
|
200
200
|
.is_none());
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
use futures::channel::mpsc::{channel, Receiver, Sender};
|
|
2
2
|
use parking_lot::Mutex;
|
|
3
|
-
use ringbuf::{Consumer,
|
|
3
|
+
use ringbuf::{consumer::Consumer, producer::Producer, traits::Split, HeapRb};
|
|
4
4
|
use std::{collections::HashMap, fmt, sync::Arc, time::SystemTime};
|
|
5
5
|
use temporal_sdk_core_api::telemetry::{CoreLog, CoreLogConsumer};
|
|
6
6
|
use tracing_subscriber::Layer;
|
|
7
7
|
|
|
8
|
-
type CoreLogsOut = Consumer<CoreLog, Arc<HeapRb<CoreLog>>>;
|
|
9
|
-
|
|
10
8
|
#[derive(Debug)]
|
|
11
9
|
struct CoreLogFieldStorage(HashMap<String, serde_json::Value>);
|
|
12
10
|
|
|
@@ -102,7 +100,7 @@ where
|
|
|
102
100
|
|
|
103
101
|
/// Core log consumer implementation backed by a ring buffer.
|
|
104
102
|
pub struct CoreLogBufferedConsumer {
|
|
105
|
-
logs_in: Mutex<
|
|
103
|
+
logs_in: Mutex<<HeapRb<CoreLog> as Split>::Prod>,
|
|
106
104
|
}
|
|
107
105
|
|
|
108
106
|
impl CoreLogBufferedConsumer {
|
|
@@ -120,7 +118,7 @@ impl CoreLogBufferedConsumer {
|
|
|
120
118
|
|
|
121
119
|
impl CoreLogConsumer for CoreLogBufferedConsumer {
|
|
122
120
|
fn on_log(&self, log: CoreLog) {
|
|
123
|
-
let _ = self.logs_in.lock().
|
|
121
|
+
let _ = self.logs_in.lock().try_push(log);
|
|
124
122
|
}
|
|
125
123
|
}
|
|
126
124
|
|
|
@@ -132,7 +130,7 @@ impl fmt::Debug for CoreLogBufferedConsumer {
|
|
|
132
130
|
|
|
133
131
|
/// Buffer of core logs that can be drained.
|
|
134
132
|
pub struct CoreLogBuffer {
|
|
135
|
-
logs_out:
|
|
133
|
+
logs_out: <HeapRb<CoreLog> as Split>::Cons,
|
|
136
134
|
}
|
|
137
135
|
|
|
138
136
|
impl CoreLogBuffer {
|
|
@@ -218,11 +216,14 @@ impl<'a> tracing::field::Visit for JsonVisitor<'a> {
|
|
|
218
216
|
#[cfg(test)]
|
|
219
217
|
mod tests {
|
|
220
218
|
use crate::{
|
|
221
|
-
telemetry::construct_filter_string,
|
|
219
|
+
telemetry::{construct_filter_string, CoreLogStreamConsumer},
|
|
220
|
+
telemetry_init,
|
|
222
221
|
};
|
|
223
222
|
use futures::stream::StreamExt;
|
|
224
|
-
use std::
|
|
225
|
-
|
|
223
|
+
use std::{
|
|
224
|
+
fmt,
|
|
225
|
+
sync::{Arc, Mutex},
|
|
226
|
+
};
|
|
226
227
|
use temporal_sdk_core_api::telemetry::{
|
|
227
228
|
CoreLog, CoreLogConsumer, CoreTelemetry, Logger, TelemetryOptionsBuilder,
|
|
228
229
|
};
|