Skip to main content

task_call_id

Function task_call_id 

Source
pub fn task_call_id(
    task_name: &str,
    ordinal: usize,
    args: &[Option<Value>],
) -> String
Available on crate features functional and graph only.
Expand description

Builds the execution-log key for one call of a task.

The key has the form {task}#{ordinal} or {task}#{ordinal}:{arg_hash}:

PartMeaning
taskThe task function’s name.
ordinalHow many calls of this task preceded this one in the run, from 0. A replay reaches the same calls in the same order, so the n-th call of a resumed run matches the n-th call of the run it resumes.
arg_hashA stable 64-bit FNV-1a hash, as 16 hex digits, of the canonical JSON of the arguments. Present when at least one argument implements Serialize; an argument that does not is hashed as null.

A replayed call whose arguments differ from the recorded call at the same position gets a different key and runs again rather than returning another call’s result.

#[task] computes this through TaskContext; call it directly only to inspect an ExecutionLog.

§Example

use adk_graph::functional::task_call_id;
use serde_json::json;

assert_eq!(task_call_id("fetch", 0, &[]), "fetch#0");

let first = task_call_id("process", 0, &[Some(json!("a"))]);
let second = task_call_id("process", 1, &[Some(json!("b"))]);
assert_ne!(first, second);
assert!(first.starts_with("process#0:"));