Skip to content

Commit 75800f1

Browse files
authored
Move user metadata to command from variant (#851)
1 parent 4a2368d commit 75800f1

36 files changed

+574
-486
lines changed

core/src/abstractions.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ struct UseCtx<'a, SK: SlotKind> {
189189
permit: &'a SlotSupplierPermit,
190190
}
191191

192-
impl<'a, SK: SlotKind> SlotMarkUsedContext for UseCtx<'a, SK> {
192+
impl<SK: SlotKind> SlotMarkUsedContext for UseCtx<'_, SK> {
193193
type SlotKind = SK;
194194

195195
fn permit(&self) -> &SlotSupplierPermit {

core/src/core_tests/updates.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,6 @@ async fn replay_with_signal_and_update_same_task() {
291291
StartTimer {
292292
seq: 1,
293293
start_to_fire_timeout: Some(prost_dur!(from_secs(1))),
294-
summary: None,
295294
}
296295
.into(),
297296
UpdateResponse {

core/src/core_tests/workers.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ async fn after_shutdown_of_worker_get_shutdown_err() {
4545
workflow_command::Variant::StartTimer(StartTimer {
4646
seq: 1,
4747
start_to_fire_timeout: Some(prost_dur!(from_secs(1))),
48-
summary: None,
4948
}),
5049
))
5150
.await
@@ -349,7 +348,6 @@ async fn worker_shutdown_api(#[case] use_cache: bool, #[case] api_success: bool)
349348
workflow_command::Variant::StartTimer(StartTimer {
350349
seq: 1,
351350
start_to_fire_timeout: Some(prost_dur!(from_secs(1))),
352-
summary: None,
353351
}),
354352
))
355353
.await

core/src/telemetry/log_export.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ impl fmt::Debug for CoreLogStreamConsumer {
168168

169169
struct JsonVisitor<'a>(&'a mut HashMap<String, serde_json::Value>);
170170

171-
impl<'a> tracing::field::Visit for JsonVisitor<'a> {
171+
impl tracing::field::Visit for JsonVisitor<'_> {
172172
fn record_f64(&mut self, field: &tracing::field::Field, value: f64) {
173173
self.0
174174
.insert(field.name().to_string(), serde_json::json!(value));

core/src/telemetry/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,11 +276,13 @@ where
276276
}
277277
}
278278

279+
/// Helpers for test initialization
279280
#[cfg(test)]
280281
pub mod test_initters {
281282
use super::*;
282283
use temporal_sdk_core_api::telemetry::TelemetryOptionsBuilder;
283284

285+
/// Turn on logging to the console
284286
#[allow(dead_code)] // Not always used, called to enable for debugging when needed
285287
pub fn test_telem_console() {
286288
telemetry_init_global(

core/src/test_help/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1026,6 +1026,7 @@ macro_rules! advance_fut {
10261026
};
10271027
}
10281028

1029+
/// Helps easily construct prost proto durations from stdlib duration constructors
10291030
#[macro_export]
10301031
macro_rules! prost_dur {
10311032
($dur_call:ident $args:tt) => {

core/src/worker/workflow/driven_workflow.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use crate::{
22
telemetry::VecDisplayer,
3-
worker::workflow::{OutgoingJob, WFCommand, WorkflowStartedInfo},
3+
worker::workflow::{OutgoingJob, WFCommand, WFCommandVariant, WorkflowStartedInfo},
44
};
55
use prost_types::Timestamp;
66
use std::{
@@ -86,7 +86,12 @@ impl DrivenWorkflow {
8686
/// from a buffer that the language side sinks into when it calls [crate::Core::complete_task]
8787
pub(super) fn fetch_workflow_iteration_output(&mut self) -> Vec<WFCommand> {
8888
let in_cmds = self.incoming_commands.try_recv();
89-
let in_cmds = in_cmds.unwrap_or_else(|_| vec![WFCommand::NoCommandsFromLang]);
89+
let in_cmds = in_cmds.unwrap_or_else(|_| {
90+
vec![WFCommand {
91+
variant: WFCommandVariant::NoCommandsFromLang,
92+
metadata: None,
93+
}]
94+
});
9095
debug!(in_cmds = %in_cmds.display(), "wf bridge iteration fetch");
9196
in_cmds
9297
}

core/src/worker/workflow/machines/activity_state_machine.rs

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ use temporal_sdk_core_protos::{
3030
ActivityTaskCompletedEventAttributes, ActivityTaskFailedEventAttributes,
3131
ActivityTaskTimedOutEventAttributes,
3232
},
33-
sdk::v1::UserMetadata,
3433
},
3534
};
3635

@@ -115,10 +114,6 @@ impl ActivityMachine {
115114
internal_flags: InternalFlagsRef,
116115
use_compatible_version: bool,
117116
) -> NewMachineWithCommand {
118-
let user_metadata = attrs.summary.clone().map(|x| UserMetadata {
119-
summary: Some(x),
120-
details: None,
121-
});
122117
let mut s = Self::from_parts(
123118
Created {}.into(),
124119
SharedState {
@@ -133,16 +128,11 @@ impl ActivityMachine {
133128
);
134129
OnEventWrapper::on_event_mut(&mut s, ActivityMachineEvents::Schedule)
135130
.expect("Scheduling activities doesn't fail");
136-
let command = Command {
137-
command_type: CommandType::ScheduleActivityTask as i32,
138-
attributes: Some(schedule_activity_cmd_to_api(
131+
NewMachineWithCommand {
132+
command: schedule_activity_cmd_to_api(
139133
s.shared_state().attrs.clone(),
140134
use_compatible_version,
141-
)),
142-
user_metadata,
143-
};
144-
NewMachineWithCommand {
145-
command,
135+
),
146136
machine: s.into(),
147137
}
148138
}

core/src/worker/workflow/machines/cancel_external_state_machine.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use temporal_sdk_core_protos::{
1111
workflow_activation::ResolveRequestCancelExternalWorkflow,
1212
},
1313
temporal::api::{
14-
command::v1::{command, Command, RequestCancelExternalWorkflowExecutionCommandAttributes},
14+
command::v1::{command, RequestCancelExternalWorkflowExecutionCommandAttributes},
1515
enums::v1::{CancelExternalWorkflowExecutionFailedCause, CommandType, EventType},
1616
failure::v1::{failure::FailureInfo, ApplicationFailureInfo, Failure},
1717
history::v1::history_event,
@@ -75,13 +75,8 @@ pub(super) fn new_external_cancel(
7575
reason,
7676
},
7777
);
78-
let cmd = Command {
79-
command_type: CommandType::RequestCancelExternalWorkflowExecution as i32,
80-
attributes: Some(cmd_attrs),
81-
user_metadata: Default::default(),
82-
};
8378
NewMachineWithCommand {
84-
command: cmd,
79+
command: cmd_attrs,
8580
machine: s.into(),
8681
}
8782
}

core/src/worker/workflow/machines/cancel_workflow_state_machine.rs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,7 @@ use rustfsm::{fsm, StateMachine, TransitionResult};
77
use std::convert::TryFrom;
88
use temporal_sdk_core_protos::{
99
coresdk::workflow_commands::CancelWorkflowExecution,
10-
temporal::api::{
11-
command::v1::Command,
12-
enums::v1::{CommandType, EventType},
13-
},
10+
temporal::api::enums::v1::{CommandType, EventType},
1411
};
1512

1613
fsm! {
@@ -34,13 +31,8 @@ pub(super) fn cancel_workflow(attribs: CancelWorkflowExecution) -> NewMachineWit
3431
let mut machine = CancelWorkflowMachine::from_parts(Created {}.into(), ());
3532
OnEventWrapper::on_event_mut(&mut machine, CancelWorkflowMachineEvents::Schedule)
3633
.expect("Scheduling continue as new machine doesn't fail");
37-
let command = Command {
38-
command_type: CommandType::CancelWorkflowExecution as i32,
39-
attributes: Some(attribs.into()),
40-
user_metadata: Default::default(),
41-
};
4234
NewMachineWithCommand {
43-
command,
35+
command: attribs.into(),
4436
machine: machine.into(),
4537
}
4638
}

0 commit comments

Comments
 (0)