@temporalio/core-bridge 0.16.0 → 0.16.3
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 +1 -0
- package/index.d.ts +14 -0
- package/index.node +0 -0
- package/package.json +2 -2
- 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/Cargo.toml +1 -0
- package/sdk-core/fsm/rustfsm_procmacro/Cargo.toml +1 -1
- package/sdk-core/fsm/rustfsm_procmacro/src/lib.rs +8 -9
- package/sdk-core/fsm/rustfsm_trait/Cargo.toml +1 -1
- package/sdk-core/fsm/rustfsm_trait/src/lib.rs +1 -1
- package/sdk-core/sdk-core-protos/src/lib.rs +36 -48
- package/sdk-core/src/core_tests/activity_tasks.rs +5 -5
- package/sdk-core/src/core_tests/mod.rs +2 -2
- package/sdk-core/src/core_tests/workflow_tasks.rs +2 -2
- package/sdk-core/src/errors.rs +11 -9
- package/sdk-core/src/lib.rs +2 -2
- package/sdk-core/src/machines/activity_state_machine.rs +3 -3
- package/sdk-core/src/machines/child_workflow_state_machine.rs +5 -5
- package/sdk-core/src/machines/complete_workflow_state_machine.rs +1 -1
- package/sdk-core/src/machines/continue_as_new_workflow_state_machine.rs +1 -1
- package/sdk-core/src/machines/mod.rs +16 -22
- package/sdk-core/src/machines/patch_state_machine.rs +8 -8
- package/sdk-core/src/machines/signal_external_state_machine.rs +2 -2
- package/sdk-core/src/machines/timer_state_machine.rs +4 -4
- package/sdk-core/src/machines/transition_coverage.rs +3 -3
- package/sdk-core/src/machines/workflow_machines.rs +9 -9
- package/sdk-core/src/pending_activations.rs +19 -20
- package/sdk-core/src/pollers/gateway.rs +3 -3
- package/sdk-core/src/pollers/poll_buffer.rs +2 -2
- package/sdk-core/src/pollers/retry.rs +4 -4
- package/sdk-core/src/prototype_rust_sdk/workflow_context.rs +3 -3
- package/sdk-core/src/prototype_rust_sdk/workflow_future.rs +4 -4
- package/sdk-core/src/prototype_rust_sdk.rs +3 -11
- package/sdk-core/src/telemetry/metrics.rs +2 -4
- package/sdk-core/src/telemetry/mod.rs +6 -7
- package/sdk-core/src/test_help/canned_histories.rs +8 -5
- package/sdk-core/src/test_help/history_builder.rs +2 -2
- package/sdk-core/src/test_help/history_info.rs +2 -2
- package/sdk-core/src/test_help/mod.rs +18 -30
- package/sdk-core/src/worker/activities/activity_heartbeat_manager.rs +246 -138
- package/sdk-core/src/worker/activities.rs +46 -45
- package/sdk-core/src/worker/config.rs +11 -0
- package/sdk-core/src/worker/dispatcher.rs +5 -5
- package/sdk-core/src/worker/mod.rs +8 -6
- package/sdk-core/src/workflow/driven_workflow.rs +3 -3
- package/sdk-core/src/workflow/history_update.rs +1 -1
- package/sdk-core/src/workflow/mod.rs +1 -1
- package/sdk-core/src/workflow/workflow_tasks/cache_manager.rs +13 -17
- package/sdk-core/src/workflow/workflow_tasks/concurrency_manager.rs +4 -8
- package/sdk-core/src/workflow/workflow_tasks/mod.rs +14 -19
- package/sdk-core/test_utils/src/lib.rs +2 -2
- package/sdk-core/tests/integ_tests/workflow_tests/activities.rs +61 -1
- package/src/conversions.rs +17 -0
package/Cargo.lock
CHANGED
package/index.d.ts
CHANGED
|
@@ -125,6 +125,20 @@ export interface WorkerOptions {
|
|
|
125
125
|
* Maximum number of Workflow instances to cache before automatic eviction
|
|
126
126
|
*/
|
|
127
127
|
maxCachedWorkflows: number;
|
|
128
|
+
/**
|
|
129
|
+
* Longest interval for throttling activity heartbeats
|
|
130
|
+
* @default 60 seconds
|
|
131
|
+
*/
|
|
132
|
+
maxHeartbeatThrottleIntervalMs: number;
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Default interval for throttling activity heartbeats in case
|
|
136
|
+
* `ActivityOptions.heartbeat_timeout` is unset.
|
|
137
|
+
* When the timeout *is* set in the `ActivityOptions`, throttling is set to
|
|
138
|
+
* `heartbeat_timeout * 0.8`.
|
|
139
|
+
* @default 30 seconds
|
|
140
|
+
*/
|
|
141
|
+
defaultHeartbeatThrottleIntervalMs: number;
|
|
128
142
|
}
|
|
129
143
|
|
|
130
144
|
/** Log level - must match rust log level names */
|
package/index.node
CHANGED
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@temporalio/core-bridge",
|
|
3
|
-
"version": "0.16.
|
|
3
|
+
"version": "0.16.3",
|
|
4
4
|
"description": "Temporal.io SDK Core<>Node bridge",
|
|
5
5
|
"main": "index.node",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -40,5 +40,5 @@
|
|
|
40
40
|
"publishConfig": {
|
|
41
41
|
"access": "public"
|
|
42
42
|
},
|
|
43
|
-
"gitHead": "
|
|
43
|
+
"gitHead": "af54140a4da7e191c06627c5e06b92a3fd929bcc"
|
|
44
44
|
}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/sdk-core/Cargo.toml
CHANGED
|
@@ -43,6 +43,7 @@ ringbuf = "0.2"
|
|
|
43
43
|
slotmap = "1.0"
|
|
44
44
|
thiserror = "1.0"
|
|
45
45
|
tokio = { version = "1.1", features = ["rt", "rt-multi-thread", "parking_lot", "time", "fs"] }
|
|
46
|
+
tokio-util = { version = "0.6.9" }
|
|
46
47
|
tokio-stream = "0.1"
|
|
47
48
|
tonic = { version = "0.6", features = ["tls", "tls-roots"] }
|
|
48
49
|
tower = "0.4"
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
extern crate proc_macro;
|
|
2
|
-
|
|
3
1
|
use proc_macro::TokenStream;
|
|
4
2
|
use quote::{quote, quote_spanned};
|
|
5
3
|
use std::collections::{hash_map::Entry, HashMap, HashSet};
|
|
@@ -82,7 +80,7 @@ use syn::{
|
|
|
82
80
|
/// ReadingCard { card_data: data.clone() }.into(),
|
|
83
81
|
/// SharedState { last_id: Some(data) }
|
|
84
82
|
/// )
|
|
85
|
-
/// }
|
|
83
|
+
/// }
|
|
86
84
|
/// }
|
|
87
85
|
/// }
|
|
88
86
|
/// }
|
|
@@ -200,7 +198,7 @@ impl Parse for StateMachineDefinition {
|
|
|
200
198
|
// Parse visibility if present
|
|
201
199
|
let visibility = input.parse()?;
|
|
202
200
|
// parse the state machine name, command type, and error type
|
|
203
|
-
let (name, command_type, error_type, shared_state_type) = parse_machine_types(
|
|
201
|
+
let (name, command_type, error_type, shared_state_type) = parse_machine_types(input)
|
|
204
202
|
.map_err(|mut e| {
|
|
205
203
|
e.combine(Error::new(
|
|
206
204
|
e.span(),
|
|
@@ -235,7 +233,7 @@ impl Parse for StateMachineDefinition {
|
|
|
235
233
|
}
|
|
236
234
|
}
|
|
237
235
|
|
|
238
|
-
fn parse_machine_types(input:
|
|
236
|
+
fn parse_machine_types(input: ParseStream) -> Result<(Ident, Ident, Ident, Option<Type>)> {
|
|
239
237
|
let _: kw::name = input.parse()?;
|
|
240
238
|
let name: Ident = input.parse()?;
|
|
241
239
|
input.parse::<Token![;]>()?;
|
|
@@ -443,7 +441,7 @@ impl StateMachineDefinition {
|
|
|
443
441
|
},
|
|
444
442
|
multi_dests => {
|
|
445
443
|
let string_dests: Vec<_> = multi_dests.iter()
|
|
446
|
-
.map(
|
|
444
|
+
.map(ToString::to_string).collect();
|
|
447
445
|
let enum_ident = Ident::new(&string_dests.join("Or"),
|
|
448
446
|
multi_dests[0].span());
|
|
449
447
|
let multi_dest_enum = quote! {
|
|
@@ -558,6 +556,7 @@ impl StateMachineDefinition {
|
|
|
558
556
|
fn state(&self) -> &Self::State {
|
|
559
557
|
&self.state
|
|
560
558
|
}
|
|
559
|
+
|
|
561
560
|
fn set_state(&mut self, new: Self::State) {
|
|
562
561
|
self.state = new
|
|
563
562
|
}
|
|
@@ -590,7 +589,7 @@ impl StateMachineDefinition {
|
|
|
590
589
|
#trait_impl
|
|
591
590
|
};
|
|
592
591
|
|
|
593
|
-
output
|
|
592
|
+
TokenStream::from(output)
|
|
594
593
|
}
|
|
595
594
|
|
|
596
595
|
fn all_states(&self) -> HashSet<Ident> {
|
|
@@ -628,7 +627,7 @@ impl StateMachineDefinition {
|
|
|
628
627
|
/// Merge transition's dest state lists for those with the same from state & handler
|
|
629
628
|
fn merge_transition_dests(transitions: Vec<Transition>) -> Vec<Transition> {
|
|
630
629
|
let mut map = HashMap::<_, Transition>::new();
|
|
631
|
-
|
|
630
|
+
for t in transitions {
|
|
632
631
|
// We want to use the transition sans-destinations as the key
|
|
633
632
|
let without_dests = {
|
|
634
633
|
let mut wd = t.clone();
|
|
@@ -643,6 +642,6 @@ fn merge_transition_dests(transitions: Vec<Transition>) -> Vec<Transition> {
|
|
|
643
642
|
v.insert(t);
|
|
644
643
|
}
|
|
645
644
|
}
|
|
646
|
-
}
|
|
645
|
+
}
|
|
647
646
|
map.into_iter().map(|(_, v)| v).collect()
|
|
648
647
|
}
|
|
@@ -38,7 +38,7 @@ pub mod coresdk {
|
|
|
38
38
|
activity_id: String,
|
|
39
39
|
reason: ActivityCancelReason,
|
|
40
40
|
) -> Self {
|
|
41
|
-
|
|
41
|
+
Self {
|
|
42
42
|
task_token,
|
|
43
43
|
activity_id,
|
|
44
44
|
variant: Some(activity_task::Variant::Cancel(Cancel {
|
|
@@ -75,7 +75,7 @@ pub mod coresdk {
|
|
|
75
75
|
})),
|
|
76
76
|
}
|
|
77
77
|
}
|
|
78
|
-
pub fn will_complete_async() -> Self {
|
|
78
|
+
pub const fn will_complete_async() -> Self {
|
|
79
79
|
Self {
|
|
80
80
|
status: Some(activity_result::Status::WillCompleteAsync(
|
|
81
81
|
WillCompleteAsync {},
|
|
@@ -195,7 +195,7 @@ pub mod coresdk {
|
|
|
195
195
|
"jobs: {})",
|
|
196
196
|
self.jobs
|
|
197
197
|
.iter()
|
|
198
|
-
.map(
|
|
198
|
+
.map(ToString::to_string)
|
|
199
199
|
.collect::<Vec<_>>()
|
|
200
200
|
.as_slice()
|
|
201
201
|
.join(", ")
|
|
@@ -264,18 +264,18 @@ pub mod coresdk {
|
|
|
264
264
|
}
|
|
265
265
|
|
|
266
266
|
pub mod workflow_completion {
|
|
267
|
-
use crate::coresdk::workflow_completion::wf_activation_completion::Status;
|
|
268
267
|
tonic::include_proto!("coresdk.workflow_completion");
|
|
269
268
|
|
|
270
269
|
impl wf_activation_completion::Status {
|
|
271
|
-
pub fn is_success(&self) -> bool {
|
|
270
|
+
pub const fn is_success(&self) -> bool {
|
|
272
271
|
match &self {
|
|
273
|
-
|
|
274
|
-
|
|
272
|
+
Self::Successful(_) => true,
|
|
273
|
+
Self::Failed(_) => false,
|
|
275
274
|
}
|
|
276
275
|
}
|
|
277
276
|
}
|
|
278
277
|
}
|
|
278
|
+
|
|
279
279
|
pub mod child_workflow {
|
|
280
280
|
tonic::include_proto!("coresdk.child_workflow");
|
|
281
281
|
}
|
|
@@ -370,7 +370,7 @@ pub mod coresdk {
|
|
|
370
370
|
|
|
371
371
|
impl From<wf_activation_job::Variant> for WfActivationJob {
|
|
372
372
|
fn from(a: wf_activation_job::Variant) -> Self {
|
|
373
|
-
|
|
373
|
+
Self { variant: Some(a) }
|
|
374
374
|
}
|
|
375
375
|
}
|
|
376
376
|
|
|
@@ -382,7 +382,7 @@ pub mod coresdk {
|
|
|
382
382
|
|
|
383
383
|
impl From<workflow_command::Variant> for WorkflowCommand {
|
|
384
384
|
fn from(v: workflow_command::Variant) -> Self {
|
|
385
|
-
|
|
385
|
+
Self { variant: Some(v) }
|
|
386
386
|
}
|
|
387
387
|
}
|
|
388
388
|
|
|
@@ -591,7 +591,7 @@ pub mod coresdk {
|
|
|
591
591
|
}
|
|
592
592
|
|
|
593
593
|
impl ActivityResult {
|
|
594
|
-
pub fn ok(result: Payload) -> Self {
|
|
594
|
+
pub const fn ok(result: Payload) -> Self {
|
|
595
595
|
Self {
|
|
596
596
|
status: Some(activity_result::activity_result::Status::Completed(
|
|
597
597
|
activity_result::Success {
|
|
@@ -615,24 +615,18 @@ pub mod coresdk {
|
|
|
615
615
|
.workflow_execution
|
|
616
616
|
.map(|we| (we.workflow_id, we.run_id))
|
|
617
617
|
.unwrap_or_default();
|
|
618
|
-
|
|
618
|
+
Self {
|
|
619
619
|
task_token: r.task_token,
|
|
620
620
|
activity_id: r.activity_id,
|
|
621
621
|
variant: Some(activity_task::activity_task::Variant::Start(
|
|
622
622
|
activity_task::Start {
|
|
623
623
|
workflow_namespace: r.workflow_namespace,
|
|
624
|
-
workflow_type: r
|
|
625
|
-
.workflow_type
|
|
626
|
-
.map(|wt| wt.name)
|
|
627
|
-
.unwrap_or_else(|| "".to_string()),
|
|
624
|
+
workflow_type: r.workflow_type.map_or_else(|| "".to_string(), |wt| wt.name),
|
|
628
625
|
workflow_execution: Some(common::WorkflowExecution {
|
|
629
626
|
workflow_id,
|
|
630
627
|
run_id,
|
|
631
628
|
}),
|
|
632
|
-
activity_type: r
|
|
633
|
-
.activity_type
|
|
634
|
-
.map(|at| at.name)
|
|
635
|
-
.unwrap_or_else(|| "".to_string()),
|
|
629
|
+
activity_type: r.activity_type.map_or_else(|| "".to_string(), |at| at.name),
|
|
636
630
|
header_fields: r.header.map(Into::into).unwrap_or_default(),
|
|
637
631
|
input: Vec::from_payloads(r.input),
|
|
638
632
|
heartbeat_details: Vec::from_payloads(r.heartbeat_details),
|
|
@@ -664,7 +658,7 @@ pub mod coresdk {
|
|
|
664
658
|
|
|
665
659
|
impl From<common::WorkflowExecution> for WorkflowExecution {
|
|
666
660
|
fn from(exc: common::WorkflowExecution) -> Self {
|
|
667
|
-
|
|
661
|
+
Self {
|
|
668
662
|
workflow_id: exc.workflow_id,
|
|
669
663
|
run_id: exc.run_id,
|
|
670
664
|
}
|
|
@@ -767,7 +761,7 @@ pub mod coresdk {
|
|
|
767
761
|
T: AsRef<[u8]>,
|
|
768
762
|
{
|
|
769
763
|
fn from(v: T) -> Self {
|
|
770
|
-
|
|
764
|
+
Self {
|
|
771
765
|
payloads: vec![v.into()],
|
|
772
766
|
}
|
|
773
767
|
}
|
|
@@ -786,10 +780,10 @@ pub mod coresdk {
|
|
|
786
780
|
match v.payloads.pop() {
|
|
787
781
|
None => Err(PayloadsToPayloadError::NoPayload),
|
|
788
782
|
Some(p) => {
|
|
789
|
-
if
|
|
790
|
-
Err(PayloadsToPayloadError::MoreThanOnePayload)
|
|
791
|
-
} else {
|
|
783
|
+
if v.payloads.is_empty() {
|
|
792
784
|
Ok(p.into())
|
|
785
|
+
} else {
|
|
786
|
+
Err(PayloadsToPayloadError::MoreThanOnePayload)
|
|
793
787
|
}
|
|
794
788
|
}
|
|
795
789
|
}
|
|
@@ -1091,26 +1085,22 @@ pub mod temporal {
|
|
|
1091
1085
|
impl HistoryEvent {
|
|
1092
1086
|
/// Returns true if this is an event created to mirror a command
|
|
1093
1087
|
pub fn is_command_event(&self) -> bool {
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
}
|
|
1111
|
-
} else {
|
|
1112
|
-
false
|
|
1113
|
-
}
|
|
1088
|
+
EventType::from_i32(self.event_type).map_or(false, |et| match et {
|
|
1089
|
+
EventType::ActivityTaskScheduled
|
|
1090
|
+
| EventType::ActivityTaskCancelRequested
|
|
1091
|
+
| EventType::MarkerRecorded
|
|
1092
|
+
| EventType::RequestCancelExternalWorkflowExecutionInitiated
|
|
1093
|
+
| EventType::SignalExternalWorkflowExecutionInitiated
|
|
1094
|
+
| EventType::StartChildWorkflowExecutionInitiated
|
|
1095
|
+
| EventType::TimerCanceled
|
|
1096
|
+
| EventType::TimerStarted
|
|
1097
|
+
| EventType::UpsertWorkflowSearchAttributes
|
|
1098
|
+
| EventType::WorkflowExecutionCanceled
|
|
1099
|
+
| EventType::WorkflowExecutionCompleted
|
|
1100
|
+
| EventType::WorkflowExecutionContinuedAsNew
|
|
1101
|
+
| EventType::WorkflowExecutionFailed => true,
|
|
1102
|
+
_ => false,
|
|
1103
|
+
})
|
|
1114
1104
|
}
|
|
1115
1105
|
|
|
1116
1106
|
/// Returns the command's initiating event id, if present. This is the id of the
|
|
@@ -1262,16 +1252,14 @@ pub mod temporal {
|
|
|
1262
1252
|
let last_event = self
|
|
1263
1253
|
.history
|
|
1264
1254
|
.as_ref()
|
|
1265
|
-
.
|
|
1266
|
-
.flatten()
|
|
1255
|
+
.and_then(|h| h.events.last().map(|he| he.event_id))
|
|
1267
1256
|
.unwrap_or(0);
|
|
1268
1257
|
write!(
|
|
1269
1258
|
f,
|
|
1270
1259
|
"PollWFTQResp(run_id: {}, attempt: {}, last_event: {})",
|
|
1271
1260
|
self.workflow_execution
|
|
1272
1261
|
.as_ref()
|
|
1273
|
-
.
|
|
1274
|
-
.unwrap_or(""),
|
|
1262
|
+
.map_or("", |we| we.run_id.as_str()),
|
|
1275
1263
|
self.attempt,
|
|
1276
1264
|
last_event
|
|
1277
1265
|
)
|
|
@@ -76,7 +76,7 @@ async fn max_activities_respected() {
|
|
|
76
76
|
core.register_worker(
|
|
77
77
|
WorkerConfigBuilder::default()
|
|
78
78
|
.task_queue(TEST_Q)
|
|
79
|
-
.max_outstanding_activities(
|
|
79
|
+
.max_outstanding_activities(2_usize)
|
|
80
80
|
.build()
|
|
81
81
|
.unwrap(),
|
|
82
82
|
)
|
|
@@ -163,7 +163,7 @@ async fn heartbeats_report_cancels_only_once() {
|
|
|
163
163
|
core.record_activity_heartbeat(ActivityHeartbeat {
|
|
164
164
|
task_token: act.task_token.clone(),
|
|
165
165
|
task_queue: TEST_Q.to_string(),
|
|
166
|
-
details: vec![vec![
|
|
166
|
+
details: vec![vec![1_u8, 2, 3].into()],
|
|
167
167
|
});
|
|
168
168
|
// We have to wait a beat for the heartbeat to be processed
|
|
169
169
|
sleep(Duration::from_millis(10)).await;
|
|
@@ -183,7 +183,7 @@ async fn heartbeats_report_cancels_only_once() {
|
|
|
183
183
|
core.record_activity_heartbeat(ActivityHeartbeat {
|
|
184
184
|
task_token: act.task_token,
|
|
185
185
|
task_queue: TEST_Q.to_string(),
|
|
186
|
-
details: vec![vec![
|
|
186
|
+
details: vec![vec![1_u8, 2, 3].into()],
|
|
187
187
|
});
|
|
188
188
|
sleep(Duration::from_millis(10)).await;
|
|
189
189
|
// Since cancels always come before new tasks, if we get a new non-cancel task, we did not
|
|
@@ -251,7 +251,7 @@ async fn activity_cancel_interrupts_poll() {
|
|
|
251
251
|
core.record_activity_heartbeat(ActivityHeartbeat {
|
|
252
252
|
task_token: act.task_token,
|
|
253
253
|
task_queue: TEST_Q.to_string(),
|
|
254
|
-
details: vec![vec![
|
|
254
|
+
details: vec![vec![1_u8, 2, 3].into()],
|
|
255
255
|
});
|
|
256
256
|
last_finisher.store(1, Ordering::SeqCst);
|
|
257
257
|
},
|
|
@@ -358,7 +358,7 @@ async fn many_concurrent_heartbeat_cancels() {
|
|
|
358
358
|
.task_queue(TEST_Q)
|
|
359
359
|
.max_outstanding_activities(CONCURRENCY_NUM)
|
|
360
360
|
// Only 1 poll at a time to avoid over-polling and running out of responses
|
|
361
|
-
.max_concurrent_at_polls(
|
|
361
|
+
.max_concurrent_at_polls(1_usize)
|
|
362
362
|
.build()
|
|
363
363
|
.unwrap(),
|
|
364
364
|
)
|
|
@@ -91,8 +91,8 @@ async fn shutdown_interrupts_both_polls() {
|
|
|
91
91
|
WorkerConfigBuilder::default()
|
|
92
92
|
.task_queue(TEST_Q)
|
|
93
93
|
// Need only 1 concurrent pollers for mock expectations to work here
|
|
94
|
-
.max_concurrent_wft_polls(
|
|
95
|
-
.max_concurrent_at_polls(
|
|
94
|
+
.max_concurrent_wft_polls(1_usize)
|
|
95
|
+
.max_concurrent_at_polls(1_usize)
|
|
96
96
|
.build()
|
|
97
97
|
.unwrap(),
|
|
98
98
|
)
|
|
@@ -642,9 +642,9 @@ async fn workflow_update_random_seed_on_workflow_reset() {
|
|
|
642
642
|
UpdateRandomSeed{randomness_seed})),
|
|
643
643
|
}] => {
|
|
644
644
|
assert_ne!(randomness_seed_from_start.load(Ordering::SeqCst),
|
|
645
|
-
*randomness_seed)
|
|
645
|
+
*randomness_seed);
|
|
646
646
|
}
|
|
647
|
-
)
|
|
647
|
+
);
|
|
648
648
|
},
|
|
649
649
|
vec![CompleteWorkflowExecution { result: None }.into()],
|
|
650
650
|
),
|
package/sdk-core/src/errors.rs
CHANGED
|
@@ -18,7 +18,7 @@ pub(crate) struct WorkflowUpdateError {
|
|
|
18
18
|
|
|
19
19
|
impl From<WorkflowMissingError> for WorkflowUpdateError {
|
|
20
20
|
fn from(wme: WorkflowMissingError) -> Self {
|
|
21
|
-
|
|
21
|
+
Self {
|
|
22
22
|
source: WFMachinesError::Fatal("Workflow machines missing".to_string()),
|
|
23
23
|
run_id: wme.run_id,
|
|
24
24
|
task_token: None,
|
|
@@ -72,8 +72,8 @@ pub enum PollWfError {
|
|
|
72
72
|
impl From<WorkerLookupErr> for PollWfError {
|
|
73
73
|
fn from(e: WorkerLookupErr) -> Self {
|
|
74
74
|
match e {
|
|
75
|
-
WorkerLookupErr::Shutdown(_) =>
|
|
76
|
-
WorkerLookupErr::NoWorker(s) =>
|
|
75
|
+
WorkerLookupErr::Shutdown(_) => Self::ShutDown,
|
|
76
|
+
WorkerLookupErr::NoWorker(s) => Self::NoWorkerForQueue(s),
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
79
|
}
|
|
@@ -97,8 +97,8 @@ pub enum PollActivityError {
|
|
|
97
97
|
impl From<WorkerLookupErr> for PollActivityError {
|
|
98
98
|
fn from(e: WorkerLookupErr) -> Self {
|
|
99
99
|
match e {
|
|
100
|
-
WorkerLookupErr::Shutdown(_) =>
|
|
101
|
-
WorkerLookupErr::NoWorker(s) =>
|
|
100
|
+
WorkerLookupErr::Shutdown(_) => Self::ShutDown,
|
|
101
|
+
WorkerLookupErr::NoWorker(s) => Self::NoWorkerForQueue(s),
|
|
102
102
|
}
|
|
103
103
|
}
|
|
104
104
|
}
|
|
@@ -127,8 +127,9 @@ pub enum CompleteWfError {
|
|
|
127
127
|
impl From<WorkerLookupErr> for CompleteWfError {
|
|
128
128
|
fn from(e: WorkerLookupErr) -> Self {
|
|
129
129
|
match e {
|
|
130
|
-
WorkerLookupErr::Shutdown(s)
|
|
131
|
-
|
|
130
|
+
WorkerLookupErr::Shutdown(s) | WorkerLookupErr::NoWorker(s) => {
|
|
131
|
+
Self::NoWorkerForQueue(s)
|
|
132
|
+
}
|
|
132
133
|
}
|
|
133
134
|
}
|
|
134
135
|
}
|
|
@@ -156,8 +157,9 @@ pub enum CompleteActivityError {
|
|
|
156
157
|
impl From<WorkerLookupErr> for CompleteActivityError {
|
|
157
158
|
fn from(e: WorkerLookupErr) -> Self {
|
|
158
159
|
match e {
|
|
159
|
-
WorkerLookupErr::Shutdown(s)
|
|
160
|
-
|
|
160
|
+
WorkerLookupErr::Shutdown(s) | WorkerLookupErr::NoWorker(s) => {
|
|
161
|
+
Self::NoWorkerForQueue(s)
|
|
162
|
+
}
|
|
161
163
|
}
|
|
162
164
|
}
|
|
163
165
|
}
|
package/sdk-core/src/lib.rs
CHANGED
|
@@ -202,7 +202,7 @@ pub struct CoreInitOptions {
|
|
|
202
202
|
|
|
203
203
|
/// Initializes an instance of the core sdk and establishes a connection to the temporal server.
|
|
204
204
|
///
|
|
205
|
-
/// Note: Also creates a tokio runtime that will be used for all client-server interactions.
|
|
205
|
+
/// Note: Also creates a tokio runtime that will be used for all client-server interactions.
|
|
206
206
|
///
|
|
207
207
|
/// # Panics
|
|
208
208
|
/// * Will panic if called from within an async context, as it will construct a runtime and you
|
|
@@ -272,7 +272,7 @@ impl Core for CoreSDK {
|
|
|
272
272
|
}
|
|
273
273
|
}
|
|
274
274
|
|
|
275
|
-
#[instrument(level = "debug", skip(self, completion),
|
|
275
|
+
#[instrument(level = "debug", skip(self, completion),
|
|
276
276
|
fields(completion=%&completion, run_id=%completion.run_id))]
|
|
277
277
|
async fn complete_workflow_activation(
|
|
278
278
|
&self,
|
|
@@ -128,7 +128,7 @@ impl ActivityMachine {
|
|
|
128
128
|
{
|
|
129
129
|
r.push(MachineResponse::PushWFJob(
|
|
130
130
|
self.create_cancelation_resolve(None).into(),
|
|
131
|
-
))
|
|
131
|
+
));
|
|
132
132
|
}
|
|
133
133
|
r
|
|
134
134
|
}
|
|
@@ -685,7 +685,7 @@ fn notify_lang_activity_cancelled(
|
|
|
685
685
|
) -> ActivityMachineTransition<Canceled> {
|
|
686
686
|
ActivityMachineTransition::ok_shared(
|
|
687
687
|
vec![ActivityMachineCommand::Cancel(
|
|
688
|
-
canceled_event.
|
|
688
|
+
canceled_event.and_then(|e| e.details),
|
|
689
689
|
)],
|
|
690
690
|
Canceled::default(),
|
|
691
691
|
dat,
|
|
@@ -871,7 +871,7 @@ mod test {
|
|
|
871
871
|
};
|
|
872
872
|
let cmds = s.cancel().unwrap();
|
|
873
873
|
assert_eq!(cmds.len(), 0);
|
|
874
|
-
assert_eq!(discriminant(&state), discriminant(&s.state))
|
|
874
|
+
assert_eq!(discriminant(&state), discriminant(&s.state));
|
|
875
875
|
}
|
|
876
876
|
}
|
|
877
877
|
}
|
|
@@ -650,11 +650,11 @@ mod test {
|
|
|
650
650
|
}
|
|
651
651
|
|
|
652
652
|
impl Expectation {
|
|
653
|
-
fn try_from_u8(x: u8) -> Option<Self> {
|
|
653
|
+
const fn try_from_u8(x: u8) -> Option<Self> {
|
|
654
654
|
Some(match x {
|
|
655
|
-
0 =>
|
|
656
|
-
1 =>
|
|
657
|
-
2 =>
|
|
655
|
+
0 => Self::Success,
|
|
656
|
+
1 => Self::Failure,
|
|
657
|
+
2 => Self::StartFailure,
|
|
658
658
|
_ => return None,
|
|
659
659
|
})
|
|
660
660
|
}
|
|
@@ -820,7 +820,7 @@ mod test {
|
|
|
820
820
|
};
|
|
821
821
|
let cmds = s.cancel().unwrap();
|
|
822
822
|
assert_eq!(cmds.len(), 0);
|
|
823
|
-
assert_eq!(discriminant(&state), discriminant(&s.state))
|
|
823
|
+
assert_eq!(discriminant(&state), discriminant(&s.state));
|
|
824
824
|
}
|
|
825
825
|
}
|
|
826
826
|
}
|
|
@@ -117,7 +117,7 @@ pub(super) struct CompleteWorkflowCommandRecorded {}
|
|
|
117
117
|
|
|
118
118
|
impl From<CompleteWorkflowCommandCreated> for CompleteWorkflowCommandRecorded {
|
|
119
119
|
fn from(_: CompleteWorkflowCommandCreated) -> Self {
|
|
120
|
-
|
|
120
|
+
Self::default()
|
|
121
121
|
}
|
|
122
122
|
}
|
|
123
123
|
|
|
@@ -77,38 +77,34 @@ impl TryFrom<WorkflowCommand> for WFCommand {
|
|
|
77
77
|
|
|
78
78
|
fn try_from(c: WorkflowCommand) -> Result<Self, Self::Error> {
|
|
79
79
|
match c.variant.ok_or(EmptyWorkflowCommandErr)? {
|
|
80
|
-
workflow_command::Variant::StartTimer(s) => Ok(
|
|
81
|
-
workflow_command::Variant::CancelTimer(s) => Ok(
|
|
82
|
-
workflow_command::Variant::ScheduleActivity(s) => Ok(
|
|
80
|
+
workflow_command::Variant::StartTimer(s) => Ok(Self::AddTimer(s)),
|
|
81
|
+
workflow_command::Variant::CancelTimer(s) => Ok(Self::CancelTimer(s)),
|
|
82
|
+
workflow_command::Variant::ScheduleActivity(s) => Ok(Self::AddActivity(s)),
|
|
83
83
|
workflow_command::Variant::RequestCancelActivity(s) => {
|
|
84
|
-
Ok(
|
|
84
|
+
Ok(Self::RequestCancelActivity(s))
|
|
85
85
|
}
|
|
86
86
|
workflow_command::Variant::CompleteWorkflowExecution(c) => {
|
|
87
|
-
Ok(
|
|
87
|
+
Ok(Self::CompleteWorkflow(c))
|
|
88
88
|
}
|
|
89
|
-
workflow_command::Variant::FailWorkflowExecution(s) => Ok(
|
|
90
|
-
workflow_command::Variant::RespondToQuery(s) => Ok(
|
|
89
|
+
workflow_command::Variant::FailWorkflowExecution(s) => Ok(Self::FailWorkflow(s)),
|
|
90
|
+
workflow_command::Variant::RespondToQuery(s) => Ok(Self::QueryResponse(s)),
|
|
91
91
|
workflow_command::Variant::ContinueAsNewWorkflowExecution(s) => {
|
|
92
|
-
Ok(
|
|
92
|
+
Ok(Self::ContinueAsNew(s))
|
|
93
93
|
}
|
|
94
|
-
workflow_command::Variant::CancelWorkflowExecution(s) =>
|
|
95
|
-
|
|
96
|
-
}
|
|
97
|
-
workflow_command::Variant::SetPatchMarker(s) => Ok(WFCommand::SetPatchMarker(s)),
|
|
94
|
+
workflow_command::Variant::CancelWorkflowExecution(s) => Ok(Self::CancelWorkflow(s)),
|
|
95
|
+
workflow_command::Variant::SetPatchMarker(s) => Ok(Self::SetPatchMarker(s)),
|
|
98
96
|
workflow_command::Variant::StartChildWorkflowExecution(s) => {
|
|
99
|
-
Ok(
|
|
97
|
+
Ok(Self::AddChildWorkflow(s))
|
|
100
98
|
}
|
|
101
99
|
workflow_command::Variant::RequestCancelExternalWorkflowExecution(s) => {
|
|
102
|
-
Ok(
|
|
100
|
+
Ok(Self::RequestCancelExternalWorkflow(s))
|
|
103
101
|
}
|
|
104
102
|
workflow_command::Variant::SignalExternalWorkflowExecution(s) => {
|
|
105
|
-
Ok(
|
|
106
|
-
}
|
|
107
|
-
workflow_command::Variant::CancelSignalWorkflow(s) => {
|
|
108
|
-
Ok(WFCommand::CancelSignalWorkflow(s))
|
|
103
|
+
Ok(Self::SignalExternalWorkflow(s))
|
|
109
104
|
}
|
|
105
|
+
workflow_command::Variant::CancelSignalWorkflow(s) => Ok(Self::CancelSignalWorkflow(s)),
|
|
110
106
|
workflow_command::Variant::CancelUnstartedChildWorkflowExecution(s) => {
|
|
111
|
-
Ok(
|
|
107
|
+
Ok(Self::CancelUnstartedChild(s))
|
|
112
108
|
}
|
|
113
109
|
}
|
|
114
110
|
}
|
|
@@ -170,9 +166,7 @@ where
|
|
|
170
166
|
+ Clone
|
|
171
167
|
+ Send
|
|
172
168
|
+ 'static,
|
|
173
|
-
<SM as StateMachine>::Event: TryFrom<HistoryEvent
|
|
174
|
-
<SM as StateMachine>::Event: TryFrom<CommandType>,
|
|
175
|
-
<SM as StateMachine>::Event: Display,
|
|
169
|
+
<SM as StateMachine>::Event: TryFrom<HistoryEvent> + TryFrom<CommandType> + Display,
|
|
176
170
|
WFMachinesError: From<<<SM as StateMachine>::Event as TryFrom<HistoryEvent>>::Error>,
|
|
177
171
|
<SM as StateMachine>::Command: Debug + Display,
|
|
178
172
|
<SM as StateMachine>::State: Display,
|