Skip to content

Commit

Permalink
fix(blueprint-proc-macro): fix bug where job IDs are not written in o…
Browse files Browse the repository at this point in the history
…rder to the blueprint.json file
  • Loading branch information
tbraun96 committed Dec 11, 2024
1 parent 696822c commit 90ec531
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 1 deletion.
4 changes: 4 additions & 0 deletions blueprint-metadata/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,10 @@ fn extract_jobs_from_module<'a>(
_ => continue,
}
}

// Sort jobs by job_id field
jobs.sort_by(|a, b| a.job_id.cmp(&b.job_id));

jobs
}

Expand Down
1 change: 1 addition & 0 deletions macros/blueprint-proc-macro-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ pub struct ServiceMetadata<'a> {
/// It contains the input and output fields of the job with the permitted caller.
#[derive(Default, Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
pub struct JobDefinition<'a> {
pub job_id: u64,
/// The metadata of the job.
pub metadata: JobMetadata<'a>,
/// These are parameters that are required for this job.
Expand Down
8 changes: 8 additions & 0 deletions macros/blueprint-proc-macro/src/job.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,15 @@ pub fn generate_job_const_block(
) -> syn::Result<proc_macro2::TokenStream> {
let (fn_name_string, job_def_name, job_id_name) = get_job_id_field_name(input);
// Creates Job Definition using input parameters
// convert litint to u64
let job_id_as_u64 = u64::from_str(&job_id.to_string()).map_err(|err| {
syn::Error::new_spanned(
job_id,
format!("Failed to convert job id to u64: {err}"),
)
})?;
let job_def = JobDefinition {
job_id: job_id_as_u64,
metadata: JobMetadata {
name: fn_name_string.clone().into(),
// filled later on during the rustdoc gen.
Expand Down

0 comments on commit 90ec531

Please sign in to comment.