@temporalio/core-bridge 1.6.0 → 1.7.1
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 +520 -456
- package/lib/index.d.ts +8 -6
- package/lib/index.js.map +1 -1
- package/package.json +8 -3
- 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/sdk-core/.buildkite/docker/Dockerfile +2 -2
- package/sdk-core/.buildkite/docker/docker-compose.yaml +1 -1
- package/sdk-core/.buildkite/pipeline.yml +1 -1
- package/sdk-core/.github/workflows/heavy.yml +1 -0
- package/sdk-core/README.md +13 -7
- package/sdk-core/client/src/lib.rs +27 -9
- package/sdk-core/client/src/metrics.rs +17 -8
- package/sdk-core/client/src/raw.rs +3 -3
- package/sdk-core/core/Cargo.toml +3 -4
- package/sdk-core/core/src/abstractions/take_cell.rs +28 -0
- package/sdk-core/core/src/abstractions.rs +197 -18
- package/sdk-core/core/src/core_tests/activity_tasks.rs +137 -45
- package/sdk-core/core/src/core_tests/child_workflows.rs +6 -5
- package/sdk-core/core/src/core_tests/determinism.rs +212 -2
- package/sdk-core/core/src/core_tests/local_activities.rs +183 -36
- package/sdk-core/core/src/core_tests/queries.rs +32 -14
- package/sdk-core/core/src/core_tests/workers.rs +8 -5
- package/sdk-core/core/src/core_tests/workflow_tasks.rs +340 -51
- package/sdk-core/core/src/ephemeral_server/mod.rs +110 -8
- package/sdk-core/core/src/internal_flags.rs +141 -0
- package/sdk-core/core/src/lib.rs +14 -9
- package/sdk-core/core/src/replay/mod.rs +16 -27
- package/sdk-core/core/src/telemetry/metrics.rs +69 -35
- package/sdk-core/core/src/telemetry/mod.rs +38 -14
- package/sdk-core/core/src/telemetry/prometheus_server.rs +19 -13
- package/sdk-core/core/src/test_help/mod.rs +65 -13
- package/sdk-core/core/src/worker/activities/activity_heartbeat_manager.rs +119 -160
- package/sdk-core/core/src/worker/activities/activity_task_poller_stream.rs +89 -0
- package/sdk-core/core/src/worker/activities/local_activities.rs +122 -6
- package/sdk-core/core/src/worker/activities.rs +347 -173
- package/sdk-core/core/src/worker/client/mocks.rs +22 -2
- package/sdk-core/core/src/worker/client.rs +18 -2
- package/sdk-core/core/src/worker/mod.rs +137 -44
- package/sdk-core/core/src/worker/workflow/history_update.rs +132 -51
- package/sdk-core/core/src/worker/workflow/machines/activity_state_machine.rs +207 -166
- package/sdk-core/core/src/worker/workflow/machines/cancel_external_state_machine.rs +6 -7
- package/sdk-core/core/src/worker/workflow/machines/cancel_workflow_state_machine.rs +6 -7
- package/sdk-core/core/src/worker/workflow/machines/child_workflow_state_machine.rs +157 -82
- package/sdk-core/core/src/worker/workflow/machines/complete_workflow_state_machine.rs +12 -12
- package/sdk-core/core/src/worker/workflow/machines/continue_as_new_workflow_state_machine.rs +6 -7
- package/sdk-core/core/src/worker/workflow/machines/fail_workflow_state_machine.rs +13 -15
- package/sdk-core/core/src/worker/workflow/machines/local_activity_state_machine.rs +170 -60
- package/sdk-core/core/src/worker/workflow/machines/mod.rs +24 -16
- package/sdk-core/core/src/worker/workflow/machines/modify_workflow_properties_state_machine.rs +6 -8
- package/sdk-core/core/src/worker/workflow/machines/patch_state_machine.rs +320 -204
- package/sdk-core/core/src/worker/workflow/machines/signal_external_state_machine.rs +10 -13
- package/sdk-core/core/src/worker/workflow/machines/timer_state_machine.rs +15 -23
- package/sdk-core/core/src/worker/workflow/machines/upsert_search_attributes_state_machine.rs +187 -46
- package/sdk-core/core/src/worker/workflow/machines/workflow_machines.rs +237 -111
- package/sdk-core/core/src/worker/workflow/machines/workflow_task_state_machine.rs +13 -13
- package/sdk-core/core/src/worker/workflow/managed_run/managed_wf_test.rs +10 -6
- package/sdk-core/core/src/worker/workflow/managed_run.rs +81 -62
- package/sdk-core/core/src/worker/workflow/mod.rs +341 -79
- package/sdk-core/core/src/worker/workflow/run_cache.rs +18 -11
- package/sdk-core/core/src/worker/workflow/wft_extraction.rs +15 -3
- package/sdk-core/core/src/worker/workflow/workflow_stream/saved_wf_inputs.rs +2 -0
- package/sdk-core/core/src/worker/workflow/workflow_stream.rs +75 -52
- package/sdk-core/core-api/Cargo.toml +0 -1
- package/sdk-core/core-api/src/lib.rs +13 -7
- package/sdk-core/core-api/src/telemetry.rs +4 -6
- package/sdk-core/core-api/src/worker.rs +5 -0
- package/sdk-core/fsm/rustfsm_procmacro/src/lib.rs +80 -55
- package/sdk-core/fsm/rustfsm_trait/src/lib.rs +22 -68
- package/sdk-core/histories/ends_empty_wft_complete.bin +0 -0
- package/sdk-core/histories/old_change_marker_format.bin +0 -0
- package/sdk-core/protos/api_upstream/.github/CODEOWNERS +2 -1
- package/sdk-core/protos/api_upstream/Makefile +1 -1
- package/sdk-core/protos/api_upstream/temporal/api/command/v1/message.proto +5 -17
- package/sdk-core/protos/api_upstream/temporal/api/common/v1/message.proto +11 -0
- package/sdk-core/protos/api_upstream/temporal/api/enums/v1/command_type.proto +1 -6
- package/sdk-core/protos/api_upstream/temporal/api/enums/v1/event_type.proto +6 -6
- package/sdk-core/protos/api_upstream/temporal/api/enums/v1/failed_cause.proto +5 -0
- package/sdk-core/protos/api_upstream/temporal/api/enums/v1/update.proto +22 -6
- package/sdk-core/protos/api_upstream/temporal/api/history/v1/message.proto +48 -19
- package/sdk-core/protos/api_upstream/temporal/api/namespace/v1/message.proto +2 -0
- package/sdk-core/protos/api_upstream/temporal/api/operatorservice/v1/request_response.proto +3 -0
- package/sdk-core/protos/api_upstream/temporal/api/{enums/v1/interaction_type.proto → protocol/v1/message.proto} +29 -11
- package/sdk-core/protos/api_upstream/temporal/api/sdk/v1/task_complete_metadata.proto +63 -0
- package/sdk-core/protos/api_upstream/temporal/api/update/v1/message.proto +111 -0
- package/sdk-core/protos/api_upstream/temporal/api/workflowservice/v1/request_response.proto +59 -28
- package/sdk-core/protos/api_upstream/temporal/api/workflowservice/v1/service.proto +2 -2
- package/sdk-core/protos/local/temporal/sdk/core/activity_result/activity_result.proto +7 -8
- package/sdk-core/protos/local/temporal/sdk/core/activity_task/activity_task.proto +10 -7
- package/sdk-core/protos/local/temporal/sdk/core/child_workflow/child_workflow.proto +19 -30
- package/sdk-core/protos/local/temporal/sdk/core/common/common.proto +1 -0
- package/sdk-core/protos/local/temporal/sdk/core/core_interface.proto +1 -0
- package/sdk-core/protos/local/temporal/sdk/core/external_data/external_data.proto +8 -0
- package/sdk-core/protos/local/temporal/sdk/core/workflow_activation/workflow_activation.proto +65 -60
- package/sdk-core/protos/local/temporal/sdk/core/workflow_commands/workflow_commands.proto +85 -84
- package/sdk-core/protos/local/temporal/sdk/core/workflow_completion/workflow_completion.proto +9 -3
- package/sdk-core/sdk/Cargo.toml +1 -1
- package/sdk-core/sdk/src/lib.rs +21 -5
- package/sdk-core/sdk/src/workflow_context/options.rs +7 -1
- package/sdk-core/sdk/src/workflow_context.rs +24 -17
- package/sdk-core/sdk/src/workflow_future.rs +9 -3
- package/sdk-core/sdk-core-protos/src/history_builder.rs +114 -89
- package/sdk-core/sdk-core-protos/src/history_info.rs +6 -1
- package/sdk-core/sdk-core-protos/src/lib.rs +205 -64
- package/sdk-core/test-utils/src/canned_histories.rs +106 -296
- package/sdk-core/test-utils/src/lib.rs +32 -5
- package/sdk-core/tests/heavy_tests.rs +10 -43
- package/sdk-core/tests/integ_tests/ephemeral_server_tests.rs +25 -3
- package/sdk-core/tests/integ_tests/heartbeat_tests.rs +5 -3
- package/sdk-core/tests/integ_tests/metrics_tests.rs +218 -16
- package/sdk-core/tests/integ_tests/polling_tests.rs +3 -8
- package/sdk-core/tests/integ_tests/queries_tests.rs +4 -2
- package/sdk-core/tests/integ_tests/visibility_tests.rs +34 -23
- package/sdk-core/tests/integ_tests/workflow_tests/activities.rs +97 -81
- package/sdk-core/tests/integ_tests/workflow_tests/cancel_external.rs +1 -0
- package/sdk-core/tests/integ_tests/workflow_tests/cancel_wf.rs +1 -0
- package/sdk-core/tests/integ_tests/workflow_tests/child_workflows.rs +80 -3
- package/sdk-core/tests/integ_tests/workflow_tests/continue_as_new.rs +5 -1
- package/sdk-core/tests/integ_tests/workflow_tests/determinism.rs +1 -0
- package/sdk-core/tests/integ_tests/workflow_tests/local_activities.rs +25 -3
- package/sdk-core/tests/integ_tests/workflow_tests/modify_wf_properties.rs +2 -4
- package/sdk-core/tests/integ_tests/workflow_tests/patches.rs +30 -0
- package/sdk-core/tests/integ_tests/workflow_tests/replay.rs +64 -0
- package/sdk-core/tests/integ_tests/workflow_tests/resets.rs +1 -0
- package/sdk-core/tests/integ_tests/workflow_tests/signals.rs +4 -0
- package/sdk-core/tests/integ_tests/workflow_tests/stickyness.rs +3 -1
- package/sdk-core/tests/integ_tests/workflow_tests/timers.rs +7 -2
- package/sdk-core/tests/integ_tests/workflow_tests/upsert_search_attrs.rs +6 -7
- package/sdk-core/tests/integ_tests/workflow_tests.rs +8 -8
- package/sdk-core/tests/main.rs +16 -25
- package/sdk-core/tests/runner.rs +11 -9
- package/src/conversions.rs +14 -8
- package/src/runtime.rs +9 -8
- package/ts/index.ts +8 -6
- package/sdk-core/protos/api_upstream/temporal/api/interaction/v1/message.proto +0 -87
|
@@ -2,19 +2,21 @@ use crate::{
|
|
|
2
2
|
telemetry::metrics::workflow_type,
|
|
3
3
|
worker::workflow::{
|
|
4
4
|
managed_run::{ManagedRun, RunUpdateAct},
|
|
5
|
-
HistoryUpdate, LocalActivityRequestSink, PermittedWFT,
|
|
5
|
+
HistoryUpdate, LocalActivityRequestSink, PermittedWFT, RunBasics,
|
|
6
6
|
},
|
|
7
7
|
MetricsContext,
|
|
8
8
|
};
|
|
9
9
|
use lru::LruCache;
|
|
10
|
-
use std::{mem, num::NonZeroUsize,
|
|
10
|
+
use std::{mem, num::NonZeroUsize, rc::Rc};
|
|
11
|
+
use temporal_sdk_core_protos::temporal::api::workflowservice::v1::get_system_info_response;
|
|
11
12
|
|
|
12
13
|
pub(super) struct RunCache {
|
|
13
14
|
max: usize,
|
|
14
15
|
namespace: String,
|
|
16
|
+
server_capabilities: get_system_info_response::Capabilities,
|
|
15
17
|
/// Run id -> Data
|
|
16
18
|
runs: LruCache<String, ManagedRun>,
|
|
17
|
-
local_activity_request_sink:
|
|
19
|
+
local_activity_request_sink: Rc<dyn LocalActivityRequestSink>,
|
|
18
20
|
|
|
19
21
|
metrics: MetricsContext,
|
|
20
22
|
}
|
|
@@ -23,7 +25,8 @@ impl RunCache {
|
|
|
23
25
|
pub fn new(
|
|
24
26
|
max_cache_size: usize,
|
|
25
27
|
namespace: String,
|
|
26
|
-
|
|
28
|
+
server_capabilities: get_system_info_response::Capabilities,
|
|
29
|
+
local_activity_request_sink: impl LocalActivityRequestSink,
|
|
27
30
|
metrics: MetricsContext,
|
|
28
31
|
) -> Self {
|
|
29
32
|
// The cache needs room for at least one run, otherwise we couldn't do anything. In
|
|
@@ -36,10 +39,11 @@ impl RunCache {
|
|
|
36
39
|
Self {
|
|
37
40
|
max: max_cache_size,
|
|
38
41
|
namespace,
|
|
42
|
+
server_capabilities,
|
|
39
43
|
runs: LruCache::new(
|
|
40
44
|
NonZeroUsize::new(lru_size).expect("LRU size is guaranteed positive"),
|
|
41
45
|
),
|
|
42
|
-
local_activity_request_sink,
|
|
46
|
+
local_activity_request_sink: Rc::new(local_activity_request_sink),
|
|
43
47
|
metrics,
|
|
44
48
|
}
|
|
45
49
|
}
|
|
@@ -63,13 +67,16 @@ impl RunCache {
|
|
|
63
67
|
// with the update.
|
|
64
68
|
let history_update = mem::replace(&mut pwft.work.update, HistoryUpdate::dummy());
|
|
65
69
|
let mut mrh = ManagedRun::new(
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
70
|
+
RunBasics {
|
|
71
|
+
namespace: self.namespace.clone(),
|
|
72
|
+
workflow_id: pwft.work.execution.workflow_id.clone(),
|
|
73
|
+
workflow_type: pwft.work.workflow_type.clone(),
|
|
74
|
+
run_id: pwft.work.execution.run_id.clone(),
|
|
75
|
+
history: history_update,
|
|
76
|
+
metrics,
|
|
77
|
+
capabilities: &self.server_capabilities,
|
|
78
|
+
},
|
|
71
79
|
self.local_activity_request_sink.clone(),
|
|
72
|
-
metrics,
|
|
73
80
|
);
|
|
74
81
|
let run_id = run_id.to_string();
|
|
75
82
|
let rur = mrh.incoming_wft(pwft);
|
|
@@ -12,6 +12,7 @@ use crate::{
|
|
|
12
12
|
use futures::Stream;
|
|
13
13
|
use futures_util::{stream, stream::PollNext, FutureExt, StreamExt};
|
|
14
14
|
use std::{future, sync::Arc};
|
|
15
|
+
use temporal_sdk_core_protos::TaskToken;
|
|
15
16
|
use tracing::Span;
|
|
16
17
|
|
|
17
18
|
/// Transforms incoming validated WFTs and history fetching requests into [PermittedWFT]s ready
|
|
@@ -30,6 +31,7 @@ pub(super) enum WFTExtractorOutput {
|
|
|
30
31
|
FailedFetch {
|
|
31
32
|
run_id: String,
|
|
32
33
|
err: tonic::Status,
|
|
34
|
+
auto_reply_fail_tt: Option<TaskToken>,
|
|
33
35
|
},
|
|
34
36
|
PollerDead,
|
|
35
37
|
}
|
|
@@ -62,13 +64,18 @@ impl WFTExtractor {
|
|
|
62
64
|
match wft {
|
|
63
65
|
Ok(wft) => {
|
|
64
66
|
let run_id = wft.workflow_execution.run_id.clone();
|
|
67
|
+
let tt = wft.task_token.clone();
|
|
65
68
|
Ok(match HistoryPaginator::from_poll(wft, client).await {
|
|
66
69
|
Ok((pag, prep)) => WFTExtractorOutput::NewWFT(PermittedWFT {
|
|
67
70
|
work: prep,
|
|
68
|
-
permit,
|
|
71
|
+
permit: permit.into_used(),
|
|
69
72
|
paginator: pag,
|
|
70
73
|
}),
|
|
71
|
-
Err(err) => WFTExtractorOutput::FailedFetch {
|
|
74
|
+
Err(err) => WFTExtractorOutput::FailedFetch {
|
|
75
|
+
run_id,
|
|
76
|
+
err,
|
|
77
|
+
auto_reply_fail_tt: Some(tt),
|
|
78
|
+
},
|
|
72
79
|
})
|
|
73
80
|
}
|
|
74
81
|
Err(e) => Err(e),
|
|
@@ -96,7 +103,11 @@ impl WFTExtractor {
|
|
|
96
103
|
let run_id = req.original_wft.work.execution.run_id.clone();
|
|
97
104
|
match HistoryPaginator::from_fetchreq(req, client).await {
|
|
98
105
|
Ok(r) => WFTExtractorOutput::FetchResult(r, rc),
|
|
99
|
-
Err(err) => WFTExtractorOutput::FailedFetch {
|
|
106
|
+
Err(err) => WFTExtractorOutput::FailedFetch {
|
|
107
|
+
run_id,
|
|
108
|
+
err,
|
|
109
|
+
auto_reply_fail_tt: None,
|
|
110
|
+
},
|
|
100
111
|
}
|
|
101
112
|
}
|
|
102
113
|
HistoryFetchReq::NextPage(mut req, rc) => {
|
|
@@ -110,6 +121,7 @@ impl WFTExtractor {
|
|
|
110
121
|
Err(err) => WFTExtractorOutput::FailedFetch {
|
|
111
122
|
run_id: req.paginator.run_id,
|
|
112
123
|
err,
|
|
124
|
+
auto_reply_fail_tt: None,
|
|
113
125
|
},
|
|
114
126
|
}
|
|
115
127
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
use crate::{
|
|
2
2
|
telemetry::metrics::MetricsContext,
|
|
3
3
|
worker::{
|
|
4
|
+
client::mocks::DEFAULT_TEST_CAPABILITIES,
|
|
4
5
|
workflow::{
|
|
5
6
|
workflow_stream::{WFStream, WFStreamInput},
|
|
6
7
|
LAReqSink, LocalActivityRequestSink,
|
|
@@ -45,6 +46,7 @@ pub async fn replay_wf_state_inputs(mut config: WorkerConfig, inputs: impl Strea
|
|
|
45
46
|
&mut config,
|
|
46
47
|
MetricsContext::no_op(),
|
|
47
48
|
CancellationToken::new(),
|
|
49
|
+
DEFAULT_TEST_CAPABILITIES.clone(),
|
|
48
50
|
);
|
|
49
51
|
let sink = ReadingFromFileLaReqSink {
|
|
50
52
|
resolutions: la_resp_q,
|
|
@@ -19,10 +19,7 @@ use crate::{
|
|
|
19
19
|
use futures::{stream, stream::PollNext, Stream, StreamExt};
|
|
20
20
|
use std::{collections::VecDeque, fmt::Debug, future, sync::Arc};
|
|
21
21
|
use temporal_sdk_core_api::errors::PollWfError;
|
|
22
|
-
use temporal_sdk_core_protos::
|
|
23
|
-
coresdk::workflow_activation::remove_from_cache::EvictionReason,
|
|
24
|
-
temporal::api::enums::v1::WorkflowTaskFailedCause,
|
|
25
|
-
};
|
|
22
|
+
use temporal_sdk_core_protos::coresdk::workflow_activation::remove_from_cache::EvictionReason;
|
|
26
23
|
use tokio_util::sync::CancellationToken;
|
|
27
24
|
use tracing::{Level, Span};
|
|
28
25
|
|
|
@@ -100,7 +97,8 @@ impl WFStream {
|
|
|
100
97
|
runs: RunCache::new(
|
|
101
98
|
basics.max_cached_workflows,
|
|
102
99
|
basics.namespace.clone(),
|
|
103
|
-
|
|
100
|
+
basics.server_capabilities.clone(),
|
|
101
|
+
local_activity_request_sink,
|
|
104
102
|
basics.metrics.clone(),
|
|
105
103
|
),
|
|
106
104
|
shutdown_token: basics.shutdown_token,
|
|
@@ -165,11 +163,16 @@ impl WFStream {
|
|
|
165
163
|
}
|
|
166
164
|
}
|
|
167
165
|
}
|
|
168
|
-
WFStreamInput::FailedFetch {
|
|
166
|
+
WFStreamInput::FailedFetch {
|
|
167
|
+
run_id,
|
|
168
|
+
err,
|
|
169
|
+
auto_reply_fail_tt,
|
|
170
|
+
} => state
|
|
169
171
|
.request_eviction(RequestEvictMsg {
|
|
170
172
|
run_id,
|
|
171
173
|
message: format!("Fetching history failed: {err:?}"),
|
|
172
174
|
reason: EvictionReason::PaginationOrHistoryFetch,
|
|
175
|
+
auto_reply_fail_tt,
|
|
173
176
|
})
|
|
174
177
|
.into_run_update_resp(),
|
|
175
178
|
WFStreamInput::PollerDead => {
|
|
@@ -282,21 +285,23 @@ impl WFStream {
|
|
|
282
285
|
};
|
|
283
286
|
let mut acts: Vec<_> = match complete {
|
|
284
287
|
NewOrFetchedComplete::New(complete) => match complete.completion {
|
|
285
|
-
ValidatedCompletion::Success {
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
288
|
+
ValidatedCompletion::Success {
|
|
289
|
+
commands,
|
|
290
|
+
used_flags,
|
|
291
|
+
..
|
|
292
|
+
} => match rh.successful_completion(commands, used_flags, complete.response_tx) {
|
|
293
|
+
Ok(acts) => acts,
|
|
294
|
+
Err(npr) => {
|
|
295
|
+
self.runs_needing_fetching
|
|
296
|
+
.push_back(HistoryFetchReq::NextPage(
|
|
297
|
+
npr,
|
|
298
|
+
self.history_fetch_refcounter.clone(),
|
|
299
|
+
));
|
|
300
|
+
None
|
|
296
301
|
}
|
|
297
|
-
}
|
|
302
|
+
},
|
|
298
303
|
ValidatedCompletion::Fail { failure, .. } => rh.failed_completion(
|
|
299
|
-
|
|
304
|
+
failure.force_cause(),
|
|
300
305
|
EvictionReason::LangFail,
|
|
301
306
|
failure,
|
|
302
307
|
complete.response_tx,
|
|
@@ -333,37 +338,39 @@ impl WFStream {
|
|
|
333
338
|
|
|
334
339
|
// If we reported to server, we always want to mark it complete.
|
|
335
340
|
let maybe_t = self.complete_wft(run_id, report.wft_report_status);
|
|
336
|
-
// Delete the activation
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
.
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
if let Some(
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
341
|
+
// Delete the activation, but only if the report came from lang, or we know the outstanding
|
|
342
|
+
// activation is expected to be completed internally.
|
|
343
|
+
if let Some(activation) = self.runs.get_mut(run_id).and_then(|rh| {
|
|
344
|
+
rh.delete_activation(|act| {
|
|
345
|
+
!report.is_autocomplete || matches!(act, OutstandingActivation::Autocomplete)
|
|
346
|
+
})
|
|
347
|
+
}) {
|
|
348
|
+
// Evict the run if the activation contained an eviction
|
|
349
|
+
let mut applied_buffered_poll_for_this_run = false;
|
|
350
|
+
if activation.has_eviction() {
|
|
351
|
+
debug!(run_id=%run_id, "Evicting run");
|
|
352
|
+
|
|
353
|
+
if let Some(mut rh) = self.runs.remove(run_id) {
|
|
354
|
+
if let Some(buff) = rh.take_buffered_wft() {
|
|
355
|
+
// Don't try to apply a buffered poll for this run if we just got a new WFT
|
|
356
|
+
// from completing, because by definition that buffered poll is now an
|
|
357
|
+
// out-of-date WFT.
|
|
358
|
+
if wft_from_complete.is_none() {
|
|
359
|
+
res = self.instantiate_or_update(buff);
|
|
360
|
+
applied_buffered_poll_for_this_run = true;
|
|
361
|
+
}
|
|
355
362
|
}
|
|
356
363
|
}
|
|
357
|
-
}
|
|
358
364
|
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
365
|
+
// Attempt to apply a buffered poll for some *other* run, if we didn't have a wft
|
|
366
|
+
// from complete or a buffered poll for *this* run.
|
|
367
|
+
if wft_from_complete.is_none() && !applied_buffered_poll_for_this_run {
|
|
368
|
+
if let Some(buff) = self.buffered_polls_need_cache_slot.pop_front() {
|
|
369
|
+
res = self.instantiate_or_update(buff);
|
|
370
|
+
}
|
|
364
371
|
}
|
|
365
|
-
}
|
|
366
|
-
}
|
|
372
|
+
};
|
|
373
|
+
}
|
|
367
374
|
|
|
368
375
|
if let Some((wft, pag)) = wft_from_complete {
|
|
369
376
|
debug!(run_id=%wft.execution.run_id, "New WFT from completion");
|
|
@@ -425,6 +432,7 @@ impl WFStream {
|
|
|
425
432
|
run_id,
|
|
426
433
|
message: "Workflow cache full".to_string(),
|
|
427
434
|
reason: EvictionReason::CacheFull,
|
|
435
|
+
auto_reply_fail_tt: None,
|
|
428
436
|
})
|
|
429
437
|
} else {
|
|
430
438
|
// This branch shouldn't really be possible
|
|
@@ -513,6 +521,7 @@ impl WFStream {
|
|
|
513
521
|
run_id,
|
|
514
522
|
message: "Workflow cache full".to_string(),
|
|
515
523
|
reason: EvictionReason::CacheFull,
|
|
524
|
+
auto_reply_fail_tt: None,
|
|
516
525
|
})
|
|
517
526
|
.into_run_update_resp(),
|
|
518
527
|
);
|
|
@@ -581,6 +590,7 @@ enum WFStreamInput {
|
|
|
581
590
|
serde(with = "tonic_status_serde::SerdeStatus")
|
|
582
591
|
)]
|
|
583
592
|
err: tonic::Status,
|
|
593
|
+
auto_reply_fail_tt: Option<TaskToken>,
|
|
584
594
|
},
|
|
585
595
|
}
|
|
586
596
|
|
|
@@ -652,6 +662,7 @@ enum ExternalPollerInputs {
|
|
|
652
662
|
FailedFetch {
|
|
653
663
|
run_id: String,
|
|
654
664
|
err: tonic::Status,
|
|
665
|
+
auto_reply_fail_tt: Option<TaskToken>,
|
|
655
666
|
},
|
|
656
667
|
}
|
|
657
668
|
impl From<ExternalPollerInputs> for WFStreamInput {
|
|
@@ -661,9 +672,15 @@ impl From<ExternalPollerInputs> for WFStreamInput {
|
|
|
661
672
|
ExternalPollerInputs::PollerDead => WFStreamInput::PollerDead,
|
|
662
673
|
ExternalPollerInputs::PollerError(e) => WFStreamInput::PollerError(e),
|
|
663
674
|
ExternalPollerInputs::FetchedUpdate(wft) => WFStreamInput::NewWft(wft),
|
|
664
|
-
ExternalPollerInputs::FailedFetch {
|
|
665
|
-
|
|
666
|
-
|
|
675
|
+
ExternalPollerInputs::FailedFetch {
|
|
676
|
+
run_id,
|
|
677
|
+
err,
|
|
678
|
+
auto_reply_fail_tt,
|
|
679
|
+
} => WFStreamInput::FailedFetch {
|
|
680
|
+
run_id,
|
|
681
|
+
err,
|
|
682
|
+
auto_reply_fail_tt,
|
|
683
|
+
},
|
|
667
684
|
ExternalPollerInputs::NextPage {
|
|
668
685
|
paginator,
|
|
669
686
|
update,
|
|
@@ -692,9 +709,15 @@ impl From<Result<WFTExtractorOutput, tonic::Status>> for ExternalPollerInputs {
|
|
|
692
709
|
update,
|
|
693
710
|
span,
|
|
694
711
|
},
|
|
695
|
-
Ok(WFTExtractorOutput::FailedFetch {
|
|
696
|
-
|
|
697
|
-
|
|
712
|
+
Ok(WFTExtractorOutput::FailedFetch {
|
|
713
|
+
run_id,
|
|
714
|
+
err,
|
|
715
|
+
auto_reply_fail_tt,
|
|
716
|
+
}) => ExternalPollerInputs::FailedFetch {
|
|
717
|
+
run_id,
|
|
718
|
+
err,
|
|
719
|
+
auto_reply_fail_tt,
|
|
720
|
+
},
|
|
698
721
|
Ok(WFTExtractorOutput::PollerDead) => ExternalPollerInputs::PollerDead,
|
|
699
722
|
Err(e) => ExternalPollerInputs::PollerError(e),
|
|
700
723
|
}
|
|
@@ -97,17 +97,23 @@ pub trait Worker: Send + Sync {
|
|
|
97
97
|
fn initiate_shutdown(&self);
|
|
98
98
|
|
|
99
99
|
/// Initiates async shutdown procedure, eventually ceases all polling of the server and shuts
|
|
100
|
-
/// down this worker. [Worker::poll_workflow_activation]
|
|
101
|
-
///
|
|
102
|
-
///
|
|
103
|
-
/// [Worker::complete_workflow_activation] for those
|
|
104
|
-
///
|
|
105
|
-
///
|
|
100
|
+
/// down this worker. [Worker::poll_workflow_activation] and [Worker::poll_activity_task] should
|
|
101
|
+
/// be called until both return a `ShutDown` error to ensure that all outstanding work is
|
|
102
|
+
/// complete. This means that the lang sdk will need to call
|
|
103
|
+
/// [Worker::complete_workflow_activation] and [Worker::complete_activity_task] for those
|
|
104
|
+
/// workflows & activities until they are done. At that point, the lang SDK can end the process,
|
|
105
|
+
/// or drop the [Worker] instance via [Worker::finalize_shutdown], which will close the
|
|
106
|
+
/// connection and free resources. If you have set [WorkerConfig::no_remote_activities], you may
|
|
107
|
+
/// skip calling [Worker::poll_activity_task].
|
|
108
|
+
///
|
|
109
|
+
/// Lang implementations should use [Worker::initiate_shutdown] followed by
|
|
110
|
+
/// [Worker::finalize_shutdown].
|
|
106
111
|
async fn shutdown(&self);
|
|
107
112
|
|
|
108
113
|
/// Completes shutdown and frees all resources. You should avoid simply dropping workers, as
|
|
109
114
|
/// this does not allow async tasks to report any panics that may have occurred cleanly.
|
|
110
115
|
///
|
|
111
|
-
/// This should be called only after [Worker::shutdown] has resolved
|
|
116
|
+
/// This should be called only after [Worker::shutdown] has resolved and/or both polling
|
|
117
|
+
/// functions have returned `ShutDown` errors.
|
|
112
118
|
async fn finalize_shutdown(self);
|
|
113
119
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
use opentelemetry::metrics::Meter;
|
|
2
1
|
use std::{
|
|
3
2
|
collections::HashMap,
|
|
4
3
|
net::SocketAddr,
|
|
@@ -18,11 +17,6 @@ pub trait CoreTelemetry {
|
|
|
18
17
|
/// Returns the list of logs from oldest to newest. Returns an empty vec if the feature is not
|
|
19
18
|
/// configured.
|
|
20
19
|
fn fetch_buffered_logs(&self) -> Vec<CoreLog>;
|
|
21
|
-
|
|
22
|
-
/// If metrics gathering is enabled, returns the OTel meter for core telemetry, which can be
|
|
23
|
-
/// used to create metrics instruments, or passed to things that create/record metrics (ex:
|
|
24
|
-
/// clients).
|
|
25
|
-
fn get_metric_meter(&self) -> Option<&Meter>;
|
|
26
20
|
}
|
|
27
21
|
|
|
28
22
|
/// Telemetry configuration options. Construct with [TelemetryOptionsBuilder]
|
|
@@ -47,6 +41,10 @@ pub struct TelemetryOptions {
|
|
|
47
41
|
/// Specifies the aggregation temporality for metric export. Defaults to cumulative.
|
|
48
42
|
#[builder(default = "MetricTemporality::Cumulative")]
|
|
49
43
|
pub metric_temporality: MetricTemporality,
|
|
44
|
+
|
|
45
|
+
// A map of tags to be applied to all metrics
|
|
46
|
+
#[builder(default)]
|
|
47
|
+
pub global_tags: HashMap<String, String>,
|
|
50
48
|
}
|
|
51
49
|
|
|
52
50
|
/// Options for exporting to an OpenTelemetry Collector
|
|
@@ -118,6 +118,11 @@ pub struct WorkerConfig {
|
|
|
118
118
|
#[builder(default)]
|
|
119
119
|
#[serde(skip)]
|
|
120
120
|
pub wf_state_inputs: Option<UnboundedSender<Vec<u8>>>,
|
|
121
|
+
|
|
122
|
+
/// If set, core will issue cancels for all outstanding activities after shutdown has been
|
|
123
|
+
/// initiated and this amount of time has elapsed.
|
|
124
|
+
#[builder(default)]
|
|
125
|
+
pub graceful_shutdown_period: Option<Duration>,
|
|
121
126
|
}
|
|
122
127
|
|
|
123
128
|
impl WorkerConfig {
|