1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
use astro_run::{stream, Context, Result, RunResult};
use astro_run_server::AstroRunRunner;

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 mut astro_run_runner = AstroRunRunner::builder()
    .runner(runner)
    .url("http://127.0.0.1:5338")
    .id("test-runner")
    .build()
    .await
    .unwrap();

  astro_run_runner.start().await.unwrap();

  Ok(())
}