Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions crates/client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1150,6 +1150,7 @@ where
workflow_run_timeout: options.run_timeout.and_then(|d| d.try_into().ok()),
workflow_task_timeout: options.task_timeout.and_then(|d| d.try_into().ok()),
search_attributes: options.search_attributes.map(|d| d.into()),
memo: options.memo.map(|fields| Memo { fields }),
cron_schedule: options.cron_schedule.unwrap_or_default(),
header: options.header.or(start_signal.header),
user_metadata,
Expand Down Expand Up @@ -1186,6 +1187,7 @@ where
workflow_run_timeout: options.run_timeout.and_then(|d| d.try_into().ok()),
workflow_task_timeout: options.task_timeout.and_then(|d| d.try_into().ok()),
search_attributes: options.search_attributes.map(|d| d.into()),
memo: options.memo.map(|fields| Memo { fields }),
cron_schedule: options.cron_schedule.unwrap_or_default(),
request_eager_execution: options.enable_eager_workflow_start,
retry_policy: options.retry_policy,
Expand Down
49 changes: 49 additions & 0 deletions crates/client/src/options_structs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,13 @@ pub struct WorkflowStartOptions {

/// Multi-line static details for the workflow, shown in the Temporal UI.
pub static_details: Option<String>,

/// Optional memo attached to the workflow execution. Memos are returned by
/// `list_workflows` and `describe_workflow_execution` so callers can stash small
/// caller-supplied metadata on a workflow without round-tripping through a query.
/// Each value must already be a serialized `Payload`; the builder does not encode
/// values for you.
pub memo: Option<HashMap<String, Payload>>,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm sure you're just following the pattern with search_attributes here, but, this field (and search_attributes) I think both need helpers on the builder that accept T: TemporalSerializable types, to make the actual serialization easy for users.

Then inside this struct we can store Box<dyn TemporalSerializable>s instead of Payloads and convert them later when these options are passed to the client call.

If you'd rather not do all that we can take over the PR.

}

/// A signal to send atomically when starting a workflow.
Expand Down Expand Up @@ -539,3 +546,45 @@ pub struct WorkflowListOptions {
#[derive(Debug, Clone, Default, bon::Builder)]
#[non_exhaustive]
pub struct WorkflowCountOptions {}

#[cfg(test)]
mod tests {
use super::*;

fn payload(s: &str) -> Payload {
Payload {
metadata: std::collections::HashMap::new(),
data: s.as_bytes().to_vec(),
..Default::default()
}
}

#[test]
fn workflow_start_options_memo_defaults_to_none() {
let opts = WorkflowStartOptions::new("tq", "wf-id").build();
assert!(opts.memo.is_none());
}

#[test]
fn workflow_start_options_memo_is_settable_via_builder() {
let mut fields = HashMap::new();
fields.insert("interview_start_time".to_owned(), payload("2026-06-09T18:00:00Z"));
fields.insert("deadline".to_owned(), payload("2026-06-09T19:30:00Z"));
let opts = WorkflowStartOptions::new("tq", "wf-id").memo(fields.clone()).build();
let stored = opts.memo.as_ref().expect("memo should be set");
assert_eq!(stored.len(), 2);
assert_eq!(stored.get("interview_start_time"), fields.get("interview_start_time"));
assert_eq!(stored.get("deadline"), fields.get("deadline"));
}

#[test]
fn workflow_start_options_round_trip_through_clone() {
// Cloning the options must preserve the memo (callers can construct one set of
// options and reuse them across signal-with-start variants).
let mut fields = HashMap::new();
fields.insert("k".to_owned(), payload("v"));
let opts = WorkflowStartOptions::new("tq", "wf-id").memo(fields).build();
let cloned = opts.clone();
assert_eq!(opts.memo.as_ref().unwrap().get("k"), cloned.memo.as_ref().unwrap().get("k"));
}
}