Skip to content

Commit

Permalink
feat(worker): filter machine port to recv message
Browse files Browse the repository at this point in the history
  • Loading branch information
eatradish committed Jun 18, 2024
1 parent cad1fca commit b80dedc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
7 changes: 4 additions & 3 deletions worker/src/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use common::{JobOk, WorkerJobUpdateRequest, WorkerPollRequest, WorkerPollRespons
use flume::{unbounded, Receiver, Sender};
use futures_util::StreamExt;
use log::{error, info, warn};
use reqwest::Url;
use std::{
path::Path,
process::{Output, Stdio},
Expand Down Expand Up @@ -371,7 +372,7 @@ async fn build_worker_inner(args: &Args) -> anyhow::Result<()> {
logical_cores: num_cpus::get() as i32,
};

let ws = args.websocket.clone();
let ws = Url::parse(&args.websocket)?.join(&args.port.to_string())?;

let (tx, rx) = unbounded();

Expand Down Expand Up @@ -430,10 +431,10 @@ pub async fn build_worker(args: Args) -> ! {
}
}

pub async fn websocket_connect(rx: Receiver<Message>, ws: String) -> ! {
pub async fn websocket_connect(rx: Receiver<Message>, ws: Url) -> ! {
loop {
info!("Starting websocket connect");
match connect_async(&ws).await {
match connect_async(ws.as_str()).await {
Ok((ws_stream, _)) => {
let (write, _) = ws_stream.split();
let rx = rx.clone().into_stream();
Expand Down
4 changes: 4 additions & 0 deletions worker/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ pub struct Args {
/// Websocket uri
#[arg(short = 'w', long, env = "BUILDIT_WS")]
pub websocket: String,

/// Worker machine relay port
#[arg(short = 'w', long, env = "BUILDIT_RELAY_PORT")]
pub port: u16,
}

pub fn get_memory_bytes() -> i64 {
Expand Down

0 comments on commit b80dedc

Please sign in to comment.