-
Notifications
You must be signed in to change notification settings - Fork 77
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support user metadata in child workflow, timer, and activity #846
Changes from 3 commits
4bda68a
6da7a69
6b075c1
0c69f2c
81f5b50
ac81e2b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,7 @@ use temporal_sdk_core_protos::{ | |
command::v1::Command, | ||
enums::v1::{CommandType, EventType}, | ||
history::v1::{history_event, TimerFiredEventAttributes}, | ||
sdk::v1::UserMetadata, | ||
}, | ||
}; | ||
|
||
|
@@ -73,13 +74,17 @@ pub(super) fn new_timer(attribs: StartTimer) -> NewMachineWithCommand { | |
impl TimerMachine { | ||
/// Create a new timer and immediately schedule it | ||
fn new_scheduled(attribs: StartTimer) -> (Self, Command) { | ||
let user_metadata = attribs.summary.clone().map(|x| UserMetadata { | ||
summary: Some(x), | ||
details: None, | ||
}); | ||
let mut s = Self::new(attribs); | ||
OnEventWrapper::on_event_mut(&mut s, TimerMachineEvents::Schedule) | ||
.expect("Scheduling timers doesn't fail"); | ||
let cmd = Command { | ||
command_type: CommandType::StartTimer as i32, | ||
attributes: Some(s.shared_state().attrs.into()), | ||
user_metadata: Default::default(), | ||
attributes: Some(s.shared_state().attrs.clone().into()), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This clone shouldn't be needed, and we don't want to clone the entire attributes for commands, generally speaking, as it can have a lot of stuff in it (though, for timer, that's likely not the case) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Without the clone, I get the error
Looks like we clone the attrs of Activity https://github.com/yuandrew/sdk-core/blob/dd37e2946a385090ded0fc3312180027002d4b16/core/src/worker/workflow/machines/activity_state_machine.rs#L134 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hmm, curious why we're even getting this error in the first place.. the line I added for Is there a different workaround here, or would we have to clone (or implement There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, yeah I didn't see it getting moved later. This clone is fine to keep then, but we could change the line above to also And yeah, in general I want to reduce how many places lots of various strings get cloned, like the place you linked, but that's a bigger project. We may not ever do it since ultimately it's not that big of a deal but, I want to avoid adding more spots where we unnecessarily clone. |
||
user_metadata, | ||
}; | ||
(s, cmd) | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a little nitpicky, but, instead of cloning here, since these values aren't used by
start_child_workflow_cmd_to_api
, let's instead https://doc.rust-lang.org/std/mem/fn.take.html the string out and we avoid a clone