Crates.io | astro-run-protocol |
lib.rs | astro-run-protocol |
version | 0.1.6 |
source | src |
created_at | 2023-08-17 13:31:06.514076 |
updated_at | 2024-03-15 02:19:26.460644 |
description | AstroRun is a highly customizable workflow orchestrator that allows users to define their own core runners. Whether it's Docker or other platforms, AstroRun empowers users to run workflows with ease and flexibility. |
homepage | https://github.com/panghu-huang/astro-run |
repository | https://github.com/panghu-huang/astro-run |
max_upload_size | |
id | 947009 |
size | 103,311 |
Astro Run is a highly extensible runner that can execute any workflow.
Add the following to your Cargo.toml
file:
[dependencies]
astro-run = "0.1"
use astro_run::{stream, AstroRun, RunResult, Workflow};
struct Runner;
impl Runner {
fn new() -> Self {
Runner
}
}
#[astro_run::async_trait]
impl astro_run::Runner for Runner {
async fn run(&self, ctx: astro_run::Context) -> astro_run::RunResponse {
let (tx, rx) = stream();
tokio::task::spawn(async move {
// Send running log
tx.log(ctx.command.run);
// Send success log
tx.end(RunResult::Succeeded);
});
Ok(rx)
}
}
#[tokio::main]
async fn main() {
// Create astro run
let astro_run = AstroRun::builder().runner(Runner::new()).build();
// Workflow
let workflow = r#"
jobs:
job:
name: Job
steps:
- run: Hello World
"#;
// Create workflow
let workflow = Workflow::builder()
.config(workflow)
.build(&astro_run)
.unwrap();
// Create a new execution context
let ctx = astro_run.execution_context().build();
// Run workflow
let _res = workflow.run(ctx).await;
}
Astro Run only defines the interface for Runners. Users can implement their own desired Runners, e.g., Docker runner.
Contributions are welcome! Feel free to open issues or submit pull requests to improve the project.
This project is licensed under the MIT License.