8000 [TASK] Tangle job metadata generation · Issue #795 · tangle-network/blueprint · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

[TASK] Tangle job metadata generation #795

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

Open
Seri 8000 al-ATA opened this issue Mar 25, 2025 · 0 comments
Open

[TASK] Tangle job metadata generation #795

Serial-ATA opened this issue Mar 25, 2025 · 0 comments
Assignees
Labels
feature ➕ Tasks that are functional additions or enhancements task ✔️

Comments

@Serial-ATA
Copy link
Contributor
Serial-ATA commented Mar 25, 2025

Overview

Using the type system, we can already determine all of the parameter and return types to put them in the blueprint.json.

What we can't know, though, is the description and the argument names.

Proposed Solution

Add a small proc macro to generate a struct holding the extra job metadata.

// The `tangle_job` proc macro has much more information available than the type system provides

/// My job
#[tangle_job]
fn foo(arg: TangleArg<u16>) -> TangleResult<()>;

The #[tangle_job] macro generates the following:

/// My job
fn foo(arg: TangleArg<u16>) -> TangleResult<()>;

struct FooMetadata {
    name: &'static str,
    description: &'static str,
    params: [&'static str; 1]
}

impl FooMetadata {
    fn init() -> Self {
        Self {
            name: "foo",
            description: "My job",
            params: ["arg"]
        }
    }
}

It does so by taking the function name and parameter names (pretty much for free), and then building the description string from the doc comments.

Then, to apply the metadata to the job, just specify it in your blueprint! macro:

blueprint! {
   job: [(foo, FooMetadata::init())]
}

Meaning this only adds 2 small extra steps for defining a job:

  1. Putting #[tangle_job] on your job
  2. Specifying the metadata type in the blueprint! macro
@Serial-ATA Serial-ATA added feature ➕ Tasks that are functional additions or enhancements task ✔️ labels Mar 25, 2025
@github-project-automation github-project-automation bot moved this to Not Started 🕧 in Tangle Universe Mar 25, 2025
@Serial-ATA Serial-ATA moved this from Not Started 🕧 to Planning 🗺️ in Tangle Universe Mar 25, 2025
@drewstone drewstone moved this from Planning 🗺️ to Not Started 🕧 in Tangle Universe Apr 7, 2025
@drewstone drewstone moved this from Not Started 🕧 to Planning 🗺️ in Tangle Universe Apr 7, 2025
@drewstone drewstone moved this from Planning 🗺️ to Not Started 🕧 in Tangle Universe May 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature ➕ Tasks that are functional additions or enhancements task ✔️
Projects
Status: Not Started 🕧
Development

No branches or pull requests

2 participants
0