@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,11 +1,3 @@
|
|
|
1
|
-
#[cfg(feature = "save_wf_inputs")]
|
|
2
|
-
mod saved_wf_inputs;
|
|
3
|
-
#[cfg(feature = "save_wf_inputs")]
|
|
4
|
-
mod tonic_status_serde;
|
|
5
|
-
|
|
6
|
-
#[cfg(feature = "save_wf_inputs")]
|
|
7
|
-
pub use saved_wf_inputs::replay_wf_state_inputs;
|
|
8
|
-
|
|
9
1
|
use crate::{
|
|
10
2
|
abstractions::dbg_panic,
|
|
11
3
|
worker::workflow::{
|
|
@@ -30,8 +22,10 @@ use tracing::{Level, Span};
|
|
|
30
22
|
/// See [WFStream::build] for more
|
|
31
23
|
pub(super) struct WFStream {
|
|
32
24
|
runs: RunCache,
|
|
33
|
-
/// Buffered polls for new runs which need a cache slot to open up before we can handle them
|
|
34
|
-
|
|
25
|
+
/// Buffered polls for new runs which need a cache slot to open up before we can handle them.
|
|
26
|
+
/// The inner list is possibly multiple buffered tasks for one run, which can happen if there
|
|
27
|
+
/// is a backlog of queries.
|
|
28
|
+
buffered_polls_need_cache_slot: VecDeque<Vec<PermittedWFT>>,
|
|
35
29
|
/// Is filled with runs that we decided need to have their history fetched during state
|
|
36
30
|
/// manipulation. Must be drained after handling each input.
|
|
37
31
|
runs_needing_fetching: VecDeque<HistoryFetchReq>,
|
|
@@ -41,9 +35,6 @@ pub(super) struct WFStream {
|
|
|
41
35
|
ignore_evicts_on_shutdown: bool,
|
|
42
36
|
|
|
43
37
|
metrics: MetricsContext,
|
|
44
|
-
|
|
45
|
-
#[cfg(feature = "save_wf_inputs")]
|
|
46
|
-
wf_state_inputs: Option<UnboundedSender<Vec<u8>>>,
|
|
47
38
|
}
|
|
48
39
|
impl WFStream {
|
|
49
40
|
/// Constructs workflow state management and returns a stream which outputs activations.
|
|
@@ -105,18 +96,12 @@ impl WFStream {
|
|
|
105
96
|
metrics: basics.metrics,
|
|
106
97
|
runs_needing_fetching: Default::default(),
|
|
107
98
|
history_fetch_refcounter: Arc::new(HistfetchRC {}),
|
|
108
|
-
|
|
109
|
-
#[cfg(feature = "save_wf_inputs")]
|
|
110
|
-
wf_state_inputs: basics.worker_config.wf_state_inputs.clone(),
|
|
111
99
|
};
|
|
112
100
|
all_inputs
|
|
113
101
|
.map(move |action: WFStreamInput| {
|
|
114
102
|
let span = span!(Level::DEBUG, "new_stream_input", action=?action);
|
|
115
103
|
let _span_g = span.enter();
|
|
116
104
|
|
|
117
|
-
#[cfg(feature = "save_wf_inputs")]
|
|
118
|
-
let maybe_write = state.prep_input(&action);
|
|
119
|
-
|
|
120
105
|
let mut activations = vec![];
|
|
121
106
|
let maybe_act = match action {
|
|
122
107
|
WFStreamInput::NewWft(pwft) => {
|
|
@@ -188,14 +173,6 @@ impl WFStream {
|
|
|
188
173
|
activations.extend(maybe_act);
|
|
189
174
|
activations.extend(state.reconcile_buffered());
|
|
190
175
|
|
|
191
|
-
// Always flush *after* actually handling the input, as this allows LA sink
|
|
192
|
-
// responses to be recorded before the input, so they can be read and buffered to be
|
|
193
|
-
// replayed during the handling of the input itself.
|
|
194
|
-
#[cfg(feature = "save_wf_inputs")]
|
|
195
|
-
if let Some(write) = maybe_write {
|
|
196
|
-
state.flush_write(write);
|
|
197
|
-
}
|
|
198
|
-
|
|
199
176
|
if state.shutdown_done() {
|
|
200
177
|
info!("Workflow shutdown is done");
|
|
201
178
|
return Err(PollWfError::ShutDown);
|
|
@@ -366,27 +343,36 @@ impl WFStream {
|
|
|
366
343
|
debug!(run_id=%run_id, "Evicting run");
|
|
367
344
|
self.runs.remove(run_id);
|
|
368
345
|
}
|
|
369
|
-
let maybe_ready_wft =
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
346
|
+
let maybe_ready_wft = maybe_buffered
|
|
347
|
+
.get_next_wft()
|
|
348
|
+
.or(wft_from_complete)
|
|
349
|
+
.map(|x| vec![x])
|
|
350
|
+
.or_else(|| {
|
|
351
|
+
// Attempt to apply a buffered poll for some *other* run, if we didn't have a
|
|
352
|
+
// wft from complete or a buffered poll for *this* run and we evicted
|
|
353
|
+
if should_evict {
|
|
354
|
+
self.buffered_polls_need_cache_slot.pop_front()
|
|
355
|
+
} else {
|
|
356
|
+
None
|
|
357
|
+
}
|
|
358
|
+
});
|
|
359
|
+
let mut maybe_wfts = maybe_ready_wft.unwrap_or_default();
|
|
360
|
+
if let Some(first_wft) = maybe_wfts.pop() {
|
|
361
|
+
res = self.instantiate_or_update(first_wft);
|
|
384
362
|
// We accept that there might be query tasks remaining in the buffer if we evicted
|
|
385
363
|
// and re-instantiated here. It's likely those tasks are now invalidated anyway.
|
|
386
364
|
if maybe_buffered.has_tasks() && should_evict {
|
|
387
365
|
warn!("There were leftover buffered tasks when evicting run");
|
|
388
366
|
}
|
|
389
367
|
}
|
|
368
|
+
// If there happened to be more than one buffered WFT for this run, move them into the
|
|
369
|
+
// now-instantiated run's buffer.
|
|
370
|
+
for wft in maybe_wfts {
|
|
371
|
+
let should_be_nothing = self.instantiate_or_update(wft);
|
|
372
|
+
if should_be_nothing.is_some() {
|
|
373
|
+
dbg_panic!("Extra buffered run should not have produced an activation");
|
|
374
|
+
}
|
|
375
|
+
}
|
|
390
376
|
}
|
|
391
377
|
|
|
392
378
|
if res.is_none() {
|
|
@@ -484,16 +470,15 @@ impl WFStream {
|
|
|
484
470
|
|
|
485
471
|
fn buffer_resp_on_full_cache(&mut self, work: PermittedWFT) {
|
|
486
472
|
debug!(run_id=%work.work.execution.run_id, "Buffering WFT because cache is full");
|
|
487
|
-
// If there's already a buffered poll for the run,
|
|
488
|
-
if let Some(rh) = self
|
|
489
|
-
.
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
*rh = work;
|
|
473
|
+
// If there's already a buffered poll for the run, add to it.
|
|
474
|
+
if let Some(rh) = self.buffered_polls_need_cache_slot.iter_mut().find(|w| {
|
|
475
|
+
w.first()
|
|
476
|
+
.is_some_and(|ww| ww.work.execution.run_id == work.work.execution.run_id)
|
|
477
|
+
}) {
|
|
478
|
+
rh.push(work);
|
|
494
479
|
} else {
|
|
495
|
-
//
|
|
496
|
-
self.buffered_polls_need_cache_slot.push_back(work);
|
|
480
|
+
// Otherwise push it to the back
|
|
481
|
+
self.buffered_polls_need_cache_slot.push_back(vec![work]);
|
|
497
482
|
}
|
|
498
483
|
}
|
|
499
484
|
|
|
@@ -571,10 +556,6 @@ impl WFStream {
|
|
|
571
556
|
|
|
572
557
|
/// All possible inputs to the [WFStream]
|
|
573
558
|
#[derive(derive_more::From, Debug)]
|
|
574
|
-
#[cfg_attr(
|
|
575
|
-
feature = "save_wf_inputs",
|
|
576
|
-
derive(serde::Serialize, serde::Deserialize)
|
|
577
|
-
)]
|
|
578
559
|
enum WFStreamInput {
|
|
579
560
|
NewWft(PermittedWFT),
|
|
580
561
|
Local(LocalInput),
|
|
@@ -582,19 +563,9 @@ enum WFStreamInput {
|
|
|
582
563
|
PollerDead,
|
|
583
564
|
/// The stream given to us which represents the poller (or a mock) encountered a non-retryable
|
|
584
565
|
/// error while polling
|
|
585
|
-
PollerError(
|
|
586
|
-
#[cfg_attr(
|
|
587
|
-
feature = "save_wf_inputs",
|
|
588
|
-
serde(with = "tonic_status_serde::SerdeStatus")
|
|
589
|
-
)]
|
|
590
|
-
tonic::Status,
|
|
591
|
-
),
|
|
566
|
+
PollerError(tonic::Status),
|
|
592
567
|
FailedFetch {
|
|
593
568
|
run_id: String,
|
|
594
|
-
#[cfg_attr(
|
|
595
|
-
feature = "save_wf_inputs",
|
|
596
|
-
serde(with = "tonic_status_serde::SerdeStatus")
|
|
597
|
-
)]
|
|
598
569
|
err: tonic::Status,
|
|
599
570
|
auto_reply_fail_tt: Option<TaskToken>,
|
|
600
571
|
},
|
|
@@ -602,15 +573,10 @@ enum WFStreamInput {
|
|
|
602
573
|
|
|
603
574
|
/// A non-poller-received input to the [WFStream]
|
|
604
575
|
#[derive(derive_more::DebugCustom)]
|
|
605
|
-
#[cfg_attr(
|
|
606
|
-
feature = "save_wf_inputs",
|
|
607
|
-
derive(serde::Serialize, serde::Deserialize)
|
|
608
|
-
)]
|
|
609
576
|
#[debug(fmt = "LocalInput {{ {input:?} }}")]
|
|
610
577
|
pub(super) struct LocalInput {
|
|
611
|
-
pub input: LocalInputs,
|
|
612
|
-
|
|
613
|
-
pub span: Span,
|
|
578
|
+
pub(super) input: LocalInputs,
|
|
579
|
+
pub(super) span: Span,
|
|
614
580
|
}
|
|
615
581
|
impl From<HeartbeatTimeoutMsg> for LocalInput {
|
|
616
582
|
fn from(hb: HeartbeatTimeoutMsg) -> Self {
|
|
@@ -623,10 +589,6 @@ impl From<HeartbeatTimeoutMsg> for LocalInput {
|
|
|
623
589
|
/// Everything that _isn't_ a poll which may affect workflow state. Always higher priority than
|
|
624
590
|
/// new polls.
|
|
625
591
|
#[derive(Debug, derive_more::From)]
|
|
626
|
-
#[cfg_attr(
|
|
627
|
-
feature = "save_wf_inputs",
|
|
628
|
-
derive(serde::Serialize, serde::Deserialize)
|
|
629
|
-
)]
|
|
630
592
|
pub(super) enum LocalInputs {
|
|
631
593
|
Completion(WFActCompleteMsg),
|
|
632
594
|
FetchedPageCompletion {
|
|
@@ -637,7 +599,6 @@ pub(super) enum LocalInputs {
|
|
|
637
599
|
PostActivation(PostActivationMsg),
|
|
638
600
|
RequestEviction(RequestEvictMsg),
|
|
639
601
|
HeartbeatTimeout(String),
|
|
640
|
-
#[cfg_attr(feature = "save_wf_inputs", serde(skip))]
|
|
641
602
|
GetStateInfo(GetStateInfoMsg),
|
|
642
603
|
}
|
|
643
604
|
impl LocalInputs {
|
|
@@ -13,18 +13,16 @@ categories = ["development-tools"]
|
|
|
13
13
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
|
14
14
|
|
|
15
15
|
[features]
|
|
16
|
-
otel_impls = ["opentelemetry"]
|
|
16
|
+
otel_impls = ["dep:opentelemetry"]
|
|
17
17
|
|
|
18
18
|
[dependencies]
|
|
19
19
|
async-trait = "0.1"
|
|
20
|
-
derive_builder =
|
|
20
|
+
derive_builder = { workspace = true }
|
|
21
21
|
derive_more = { workspace = true }
|
|
22
22
|
opentelemetry = { workspace = true, optional = true }
|
|
23
|
-
prost-types =
|
|
24
|
-
serde = { version = "1.0", default_features = false, features = ["derive"] }
|
|
23
|
+
prost-types = { workspace = true }
|
|
25
24
|
serde_json = "1.0"
|
|
26
25
|
thiserror = "1.0"
|
|
27
|
-
tokio = "1.24"
|
|
28
26
|
tonic = { workspace = true }
|
|
29
27
|
tracing-core = "0.1"
|
|
30
28
|
url = "2.3"
|
|
@@ -32,3 +30,6 @@ url = "2.3"
|
|
|
32
30
|
[dependencies.temporal-sdk-core-protos]
|
|
33
31
|
path = "../sdk-core-protos"
|
|
34
32
|
version = "0.1"
|
|
33
|
+
|
|
34
|
+
[lints]
|
|
35
|
+
workspace = true
|
|
@@ -60,3 +60,11 @@ pub enum CompleteActivityError {
|
|
|
60
60
|
completion: Option<ActivityExecutionResult>,
|
|
61
61
|
},
|
|
62
62
|
}
|
|
63
|
+
|
|
64
|
+
/// Errors we can encounter during workflow processing which we may treat as either WFT failures
|
|
65
|
+
/// or whole-workflow failures depending on user preference.
|
|
66
|
+
#[derive(Clone, Debug, Eq, PartialEq, Hash)]
|
|
67
|
+
pub enum WorkflowErrorType {
|
|
68
|
+
/// A nondeterminism error
|
|
69
|
+
Nondeterminism,
|
|
70
|
+
}
|
|
@@ -3,6 +3,7 @@ use std::{
|
|
|
3
3
|
borrow::Cow,
|
|
4
4
|
fmt::Debug,
|
|
5
5
|
sync::{Arc, OnceLock},
|
|
6
|
+
time::Duration,
|
|
6
7
|
};
|
|
7
8
|
|
|
8
9
|
/// Implementors of this trait are expected to be defined in each language's bridge.
|
|
@@ -23,7 +24,14 @@ pub trait CoreMeter: Send + Sync + Debug {
|
|
|
23
24
|
) -> MetricAttributes;
|
|
24
25
|
fn counter(&self, params: MetricParameters) -> Arc<dyn Counter>;
|
|
25
26
|
fn histogram(&self, params: MetricParameters) -> Arc<dyn Histogram>;
|
|
27
|
+
fn histogram_f64(&self, params: MetricParameters) -> Arc<dyn HistogramF64>;
|
|
28
|
+
/// Create a histogram which records Durations. Implementations should choose to emit in
|
|
29
|
+
/// either milliseconds or seconds depending on how they have been configured.
|
|
30
|
+
/// [MetricParameters::unit] should be overwritten by implementations to be `ms` or `s`
|
|
31
|
+
/// accordingly.
|
|
32
|
+
fn histogram_duration(&self, params: MetricParameters) -> Arc<dyn HistogramDuration>;
|
|
26
33
|
fn gauge(&self, params: MetricParameters) -> Arc<dyn Gauge>;
|
|
34
|
+
fn gauge_f64(&self, params: MetricParameters) -> Arc<dyn GaugeF64>;
|
|
27
35
|
}
|
|
28
36
|
|
|
29
37
|
#[derive(Debug, Clone, derive_builder::Builder)]
|
|
@@ -74,9 +82,22 @@ impl CoreMeter for Arc<dyn CoreMeter> {
|
|
|
74
82
|
fn histogram(&self, params: MetricParameters) -> Arc<dyn Histogram> {
|
|
75
83
|
self.as_ref().histogram(params)
|
|
76
84
|
}
|
|
85
|
+
|
|
86
|
+
fn histogram_f64(&self, params: MetricParameters) -> Arc<dyn HistogramF64> {
|
|
87
|
+
self.as_ref().histogram_f64(params)
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
fn histogram_duration(&self, params: MetricParameters) -> Arc<dyn HistogramDuration> {
|
|
91
|
+
self.as_ref().histogram_duration(params)
|
|
92
|
+
}
|
|
93
|
+
|
|
77
94
|
fn gauge(&self, params: MetricParameters) -> Arc<dyn Gauge> {
|
|
78
95
|
self.as_ref().gauge(params)
|
|
79
96
|
}
|
|
97
|
+
|
|
98
|
+
fn gauge_f64(&self, params: MetricParameters) -> Arc<dyn GaugeF64> {
|
|
99
|
+
self.as_ref().gauge_f64(params)
|
|
100
|
+
}
|
|
80
101
|
}
|
|
81
102
|
|
|
82
103
|
/// Attributes which are provided every time a call to record a specific metric is made.
|
|
@@ -158,22 +179,34 @@ pub trait Histogram: Send + Sync {
|
|
|
158
179
|
// When referring to durations, this value is in millis
|
|
159
180
|
fn record(&self, value: u64, attributes: &MetricAttributes);
|
|
160
181
|
}
|
|
182
|
+
pub trait HistogramF64: Send + Sync {
|
|
183
|
+
// When referring to durations, this value is in seconds
|
|
184
|
+
fn record(&self, value: f64, attributes: &MetricAttributes);
|
|
185
|
+
}
|
|
186
|
+
pub trait HistogramDuration: Send + Sync {
|
|
187
|
+
fn record(&self, value: Duration, attributes: &MetricAttributes);
|
|
188
|
+
}
|
|
161
189
|
|
|
162
190
|
pub trait Gauge: Send + Sync {
|
|
163
191
|
// When referring to durations, this value is in millis
|
|
164
192
|
fn record(&self, value: u64, attributes: &MetricAttributes);
|
|
165
193
|
}
|
|
194
|
+
pub trait GaugeF64: Send + Sync {
|
|
195
|
+
// When referring to durations, this value is in seconds
|
|
196
|
+
fn record(&self, value: f64, attributes: &MetricAttributes);
|
|
197
|
+
}
|
|
166
198
|
|
|
167
199
|
#[derive(Debug, Clone)]
|
|
168
200
|
pub enum MetricEvent<I: BufferInstrumentRef> {
|
|
169
201
|
Create {
|
|
170
202
|
params: MetricParameters,
|
|
171
|
-
///
|
|
203
|
+
/// Once you receive this event, call `set` on this with the initialized instrument
|
|
204
|
+
/// reference
|
|
172
205
|
populate_into: LazyBufferInstrument<I>,
|
|
173
206
|
kind: MetricKind,
|
|
174
207
|
},
|
|
175
208
|
CreateAttributes {
|
|
176
|
-
///
|
|
209
|
+
/// Once you receive this event, call `set` on this with the initialized attributes
|
|
177
210
|
populate_into: BufferAttributes,
|
|
178
211
|
/// If not `None`, use these already-initialized attributes as the base (extended with
|
|
179
212
|
/// `attributes`) for the ones you are about to initialize.
|
|
@@ -190,14 +223,18 @@ pub enum MetricEvent<I: BufferInstrumentRef> {
|
|
|
190
223
|
pub enum MetricKind {
|
|
191
224
|
Counter,
|
|
192
225
|
Gauge,
|
|
226
|
+
GaugeF64,
|
|
193
227
|
Histogram,
|
|
228
|
+
HistogramF64,
|
|
229
|
+
HistogramDuration,
|
|
194
230
|
}
|
|
195
231
|
#[derive(Debug, Clone, Copy)]
|
|
196
232
|
pub enum MetricUpdateVal {
|
|
197
|
-
// Currently all deltas are natural numbers
|
|
198
233
|
Delta(u64),
|
|
199
|
-
|
|
234
|
+
DeltaF64(f64),
|
|
200
235
|
Value(u64),
|
|
236
|
+
ValueF64(f64),
|
|
237
|
+
Duration(Duration),
|
|
201
238
|
}
|
|
202
239
|
|
|
203
240
|
pub trait MetricCallBufferer<I: BufferInstrumentRef>: Send + Sync {
|
|
@@ -260,9 +297,21 @@ impl CoreMeter for NoOpCoreMeter {
|
|
|
260
297
|
Arc::new(NoOpInstrument)
|
|
261
298
|
}
|
|
262
299
|
|
|
300
|
+
fn histogram_f64(&self, _: MetricParameters) -> Arc<dyn HistogramF64> {
|
|
301
|
+
Arc::new(NoOpInstrument)
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
fn histogram_duration(&self, _: MetricParameters) -> Arc<dyn HistogramDuration> {
|
|
305
|
+
Arc::new(NoOpInstrument)
|
|
306
|
+
}
|
|
307
|
+
|
|
263
308
|
fn gauge(&self, _: MetricParameters) -> Arc<dyn Gauge> {
|
|
264
309
|
Arc::new(NoOpInstrument)
|
|
265
310
|
}
|
|
311
|
+
|
|
312
|
+
fn gauge_f64(&self, _: MetricParameters) -> Arc<dyn GaugeF64> {
|
|
313
|
+
Arc::new(NoOpInstrument)
|
|
314
|
+
}
|
|
266
315
|
}
|
|
267
316
|
|
|
268
317
|
pub struct NoOpInstrument;
|
|
@@ -272,9 +321,18 @@ impl Counter for NoOpInstrument {
|
|
|
272
321
|
impl Histogram for NoOpInstrument {
|
|
273
322
|
fn record(&self, _: u64, _: &MetricAttributes) {}
|
|
274
323
|
}
|
|
324
|
+
impl HistogramF64 for NoOpInstrument {
|
|
325
|
+
fn record(&self, _: f64, _: &MetricAttributes) {}
|
|
326
|
+
}
|
|
327
|
+
impl HistogramDuration for NoOpInstrument {
|
|
328
|
+
fn record(&self, _: Duration, _: &MetricAttributes) {}
|
|
329
|
+
}
|
|
275
330
|
impl Gauge for NoOpInstrument {
|
|
276
331
|
fn record(&self, _: u64, _: &MetricAttributes) {}
|
|
277
332
|
}
|
|
333
|
+
impl GaugeF64 for NoOpInstrument {
|
|
334
|
+
fn record(&self, _: f64, _: &MetricAttributes) {}
|
|
335
|
+
}
|
|
278
336
|
|
|
279
337
|
#[derive(Debug, Clone)]
|
|
280
338
|
pub struct NoOpAttributes;
|
|
@@ -331,4 +389,17 @@ mod otel_impls {
|
|
|
331
389
|
}
|
|
332
390
|
}
|
|
333
391
|
}
|
|
392
|
+
|
|
393
|
+
impl HistogramF64 for metrics::Histogram<f64> {
|
|
394
|
+
fn record(&self, value: f64, attributes: &MetricAttributes) {
|
|
395
|
+
if let MetricAttributes::OTel { kvs } = attributes {
|
|
396
|
+
self.record(value, kvs);
|
|
397
|
+
} else {
|
|
398
|
+
debug_assert!(
|
|
399
|
+
false,
|
|
400
|
+
"Must use OTel attributes with an OTel metric implementation"
|
|
401
|
+
);
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
}
|
|
334
405
|
}
|
|
@@ -61,9 +61,12 @@ pub struct OtelCollectorOptions {
|
|
|
61
61
|
/// Specifies the aggregation temporality for metric export. Defaults to cumulative.
|
|
62
62
|
#[builder(default = "MetricTemporality::Cumulative")]
|
|
63
63
|
pub metric_temporality: MetricTemporality,
|
|
64
|
-
|
|
64
|
+
/// A map of tags to be applied to all metrics
|
|
65
65
|
#[builder(default)]
|
|
66
66
|
pub global_tags: HashMap<String, String>,
|
|
67
|
+
/// If set to true, use f64 seconds for durations instead of u64 milliseconds
|
|
68
|
+
#[builder(default)]
|
|
69
|
+
pub use_seconds_for_durations: bool,
|
|
67
70
|
}
|
|
68
71
|
|
|
69
72
|
/// Options for exporting metrics to Prometheus
|
|
@@ -80,6 +83,9 @@ pub struct PrometheusExporterOptions {
|
|
|
80
83
|
/// Ex: "_milliseconds".
|
|
81
84
|
#[builder(default = "false")]
|
|
82
85
|
pub unit_suffix: bool,
|
|
86
|
+
/// If set to true, use f64 seconds for durations instead of u64 milliseconds
|
|
87
|
+
#[builder(default)]
|
|
88
|
+
pub use_seconds_for_durations: bool,
|
|
83
89
|
}
|
|
84
90
|
|
|
85
91
|
/// Control where logs go
|