Skip to content
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

fix(blueprint-proc-macro): fix bug where job IDs are not written in order to blueprint.json #542

Merged
merged 2 commits into from
Dec 11, 2024
Merged
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
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
4 changes: 4 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,11 @@ 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
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
Loading