DEVELOPMENT ENVIRONMENT

~liljamo/emerwen

150282df06095c35a15a12fc7edd351868582d7b — Jonni Liljamo 12 days ago 37248b4
feat(worker): config from CLI
2 files changed, 14 insertions(+), 7 deletions(-)

M README.md
M emerwen-worker/src/main.rs
M README.md => README.md +0 -1
@@ 14,7 14,6 @@ tldr: gRPC was easier lmao.

## What's next (short-term TODO)

- Worker configuration with CLI args.
- Actually checking auth tokens.
- Master database (redb?)
- Master web UI (leptos + leptos_oidc) for configuring workers.

M emerwen-worker/src/main.rs => emerwen-worker/src/main.rs +14 -6
@@ 19,6 19,14 @@ struct Args {
    /// Enable debug logging
    #[arg(long)]
    debug: bool,

    /// Address of the Master
    #[arg(long, default_value = "http://127.0.0.1:8000")]
    master_address: String,

    /// Auth token
    #[arg(long, default_value = "avain_perkele")]
    auth_token: String,
}

#[tokio::main]


@@ 46,15 54,15 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
    info!("Starting emerwen worker...");
    debug!("Hello, debug!");

    // TODO: token from cli, also addr from cli
    let channel = Channel::builder(args.master_address.parse()?)
        .connect()
        .await?;

    // Client is cheap to clone, clone one to every monitoring task
    // Client is cheap to clone.
    let mut client = EmerwenProtocolClient::with_interceptor(
        Channel::from_static("http://127.0.0.1:8000")
            .connect()
            .await?,
        channel,
        AuthInterceptor {
            token: "Bearer avain_perkele".parse()?,
            token: format!("Bearer {}", args.auth_token).parse()?,
        },
    );