#workflow #runner #automation #docker #ci

astro-run-remote-runner

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.

6 releases

new 0.1.5 Feb 25, 2024
0.1.4 Oct 1, 2023
0.1.3 Sep 10, 2023
0.1.1 Aug 23, 2023

#235 in Unix APIs

Download history 2/week @ 2023-11-12 14/week @ 2023-11-19 22/week @ 2023-11-26 16/week @ 2023-12-03 10/week @ 2023-12-10 9/week @ 2023-12-17 16/week @ 2023-12-24 2/week @ 2023-12-31 5/week @ 2024-01-14 7/week @ 2024-01-21 26/week @ 2024-01-28 2/week @ 2024-02-04 31/week @ 2024-02-11 144/week @ 2024-02-18

204 downloads per month

MIT license

240KB
6.5K SLoC

Astro Run Remote Runner

astro-run-remote-runner is an extension of astro-run that allows runners to act as remote services and lets astro-run act as a client to connect via gRPC requests. The remote runner streams runtime logs, events, etc. to the client using streams.

Example

Add astro-run and astro-run-remote-runner as dependencies in your Cargo.toml:

[dependencies]
astro-run = "0.1"
astro-run-remote-runner = "0.1"

Remote Runner Server

use astro_run::{stream, Context, Result, RunResult};
use astro_run_remote_runner::AstroRunRemoteRunnerServer;

// Simulated implementation of a Runner
struct Runner {}

impl Runner {
  fn new() -> Self {
    Runner {}
  }
}

#[astro_run::async_trait]
impl astro_run::Runner for Runner {
  async fn run(&self, ctx: Context) -> astro_run::RunResponse {
    let (tx, rx) = stream();

    tx.log(ctx.command.run);
    tx.end(RunResult::Succeeded);

    Ok(rx)
  }
}

#[tokio::main]
async fn main() -> Result<()> {
  let runner = Runner::new();

  let runner_server = AstroRunRemoteRunnerServer::builder()
    .runner(runner)
    .build()
    .unwrap();

  runner_server.serve("127.0.0.1:5002").await.unwrap();

  Ok(())
}

Astro-Run Client

use astro_run::{AstroRun, Result, Workflow};
use astro_run_remote_runner::AstroRunRemoteRunnerClient;

#[tokio::main]
async fn main() -> Result<()> {
  let client_runner = AstroRunRemoteRunnerClient::builder().build().unwrap();

  let handle = tokio::task::spawn({
    let mut client_runner = client_runner.clone();
    async move {
      // Run the client runner in background
      client_runner
        .start(vec!["http://127.0.0.1:5002"])
        .await
        .unwrap();
    }
  });

  let astro_run = AstroRun::builder().runner(client_runner).build();

  let workflow = r#"
    jobs:
      job-id:
        steps:
          - run: Hello World
      "#;

  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;

  // Wait for the client runner to finish
  handle.await.unwrap();

  Ok(())
}

In the above example, you can replace the runner with a specific implementation from astro-runner.

Dependencies

~16–31MB
~583K SLoC