From c0630ac15182fa1d499dbcb5c227e45993297548 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luiz=20Felipe=20Gon=C3=A7alves?= Date: Wed, 19 Jun 2024 21:45:12 -0300 Subject: [PATCH 1/2] refac: centralize http clients into `proto` --- Cargo.lock | 3 ++ Cargo.toml | 2 + README.md | 2 +- ctl/src/http/deployer.rs | 29 +++++++++++ ctl/src/http/deployer/mod.rs | 12 ----- ctl/src/http/mod.rs | 10 +++- ctl/src/http/worker.rs | 8 +++ ctl/src/http/worker/mod.rs | 7 --- proto/Cargo.toml | 4 +- proto/src/clients/ctl.rs | 92 +++++++++++++++++++++++++++++++++++ proto/src/clients/mod.rs | 42 ++++++++++++++++ proto/src/clients/worker.rs | 52 ++++++++++++++++++++ proto/src/ctl/deployer.rs | 8 +-- proto/src/ctl/mod.rs | 1 + proto/src/ctl/worker.rs | 17 +++---- proto/src/lib.rs | 3 ++ proto/src/well_known.rs | 4 ++ proto/src/worker/runner.rs | 4 +- worker/Cargo.toml | 1 + worker/src/args.rs | 6 +-- worker/src/http/mod.rs | 8 ++- worker/src/http/runner/mod.rs | 8 +-- worker/src/main.rs | 11 ++--- worker/src/monitor/pusher.rs | 14 +++--- worker/src/runner/mod.rs | 16 +++--- worker/src/sender/mod.rs | 41 ---------------- 26 files changed, 297 insertions(+), 108 deletions(-) create mode 100644 ctl/src/http/deployer.rs delete mode 100644 ctl/src/http/deployer/mod.rs create mode 100644 ctl/src/http/worker.rs delete mode 100644 ctl/src/http/worker/mod.rs create mode 100644 proto/src/clients/ctl.rs create mode 100644 proto/src/clients/mod.rs create mode 100644 proto/src/clients/worker.rs delete mode 100644 worker/src/sender/mod.rs diff --git a/Cargo.lock b/Cargo.lock index 749e8aa..3ad450a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1072,6 +1072,8 @@ name = "proto" version = "0.1.0" dependencies = [ "chrono", + "eyre", + "reqwest", "serde", "serde_json", "uuid", @@ -1990,6 +1992,7 @@ version = "0.1.0" dependencies = [ "axum", "bollard", + "chrono", "clap", "eyre", "futures-util", diff --git a/Cargo.toml b/Cargo.toml index d15f5ed..0573869 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,6 +18,7 @@ bollard = "0.16.1" clap = { version = "4.5", features = ["derive"] } chrono = { version = "0.4.38", default-features = false, features = [ "std", + "now", "serde", ] } eyre = "0.6" @@ -46,3 +47,4 @@ module_name_repetitions = "allow" cast_precision_loss = "allow" unused_async = "allow" enum_glob_use = "allow" +missing_errors_doc = "allow" diff --git a/README.md b/README.md index be88fe4..e3d5916 100644 --- a/README.md +++ b/README.md @@ -15,5 +15,5 @@ cargo run -p ctl Worker: ``` -cargo run -p worker -- --controller-addr '127.0.0.1:3000' +cargo run -p worker -- --controller-addr '127.0.0.1' ``` diff --git a/ctl/src/http/deployer.rs b/ctl/src/http/deployer.rs new file mode 100644 index 0000000..78ff7aa --- /dev/null +++ b/ctl/src/http/deployer.rs @@ -0,0 +1,29 @@ +use axum::{extract::State, Json}; +use proto::ctl::deployer::{ + DeployServiceReq, DeployServiceRes, ReportDeployInstanceStatusReq, + ReportDeployInstanceStatusRes, TerminateServiceReq, TerminateServiceRes, +}; + +use crate::http::HttpState; + +pub async fn report_instance_status( + State(state): State, + Json(_payload): Json, +) -> Json { + _ = state.discovery; + todo!(); +} + +pub async fn deploy_service( + State(_state): State, + Json(_payload): Json, +) -> Json { + todo!(); +} + +pub async fn terminate_service( + State(_state): State, + Json(_payload): Json, +) -> Json { + todo!(); +} diff --git a/ctl/src/http/deployer/mod.rs b/ctl/src/http/deployer/mod.rs deleted file mode 100644 index 1104cf0..0000000 --- a/ctl/src/http/deployer/mod.rs +++ /dev/null @@ -1,12 +0,0 @@ -use axum::{extract::State, Json}; -use proto::ctl::deployer::{DeployReq, DeployRes}; - -use crate::http::HttpState; - -pub async fn deploy( - State(state): State, - Json(_payload): Json, -) -> Json { - _ = state.discovery; - todo!(); -} diff --git a/ctl/src/http/mod.rs b/ctl/src/http/mod.rs index a0179c0..76012bd 100644 --- a/ctl/src/http/mod.rs +++ b/ctl/src/http/mod.rs @@ -13,8 +13,14 @@ pub struct HttpState { pub async fn run_server(state: HttpState) { let app = Router::new() - .route("/worker/metrics", post(worker::push_metrics)) - .route("/deploy", post(deployer::deploy)) + .route("/worker/push-metrics", post(worker::push_metrics)) + .nest( + "/deployer", + Router::new() + .route("/deploy-service", post(deployer::deploy_service)) + .route("/terminate-service", post(deployer::terminate_service)) + .route("/status", post(deployer::report_instance_status)), + ) .with_state(state); let listener = tokio::net::TcpListener::bind("0.0.0.0:3000").await.unwrap(); diff --git a/ctl/src/http/worker.rs b/ctl/src/http/worker.rs new file mode 100644 index 0000000..f349d9c --- /dev/null +++ b/ctl/src/http/worker.rs @@ -0,0 +1,8 @@ +use axum::Json; +use proto::{common::node::Metrics, ctl::worker::PushWorkerMetricsRes}; +use tracing::info; + +pub async fn push_metrics(Json(payload): Json) -> Json { + info!("{payload:#?}"); + todo!() +} diff --git a/ctl/src/http/worker/mod.rs b/ctl/src/http/worker/mod.rs deleted file mode 100644 index d387dc2..0000000 --- a/ctl/src/http/worker/mod.rs +++ /dev/null @@ -1,7 +0,0 @@ -use axum::Json; -use proto::common::node::Metrics; -use tracing::info; - -pub async fn push_metrics(Json(payload): Json) { - info!("{payload:#?}"); -} diff --git a/proto/Cargo.toml b/proto/Cargo.toml index 50c2bd8..64cd841 100644 --- a/proto/Cargo.toml +++ b/proto/Cargo.toml @@ -8,6 +8,8 @@ workspace = true [dependencies] chrono.workspace = true -serde.workspace = true +eyre.workspace = true +reqwest.workspace = true serde_json.workspace = true +serde.workspace = true uuid.workspace = true diff --git a/proto/src/clients/ctl.rs b/proto/src/clients/ctl.rs new file mode 100644 index 0000000..88b7b3b --- /dev/null +++ b/proto/src/clients/ctl.rs @@ -0,0 +1,92 @@ +use std::{net::IpAddr, sync::Arc}; + +use chrono::{DateTime, Utc}; + +use crate::{ + clients::BaseClient, + common::{ + instance::{self, InstanceId}, + node::Metrics, + service::{ServiceId, ServiceSpec}, + }, + ctl::{ + deployer::{ + DeployServiceReq, DeployServiceRes, RedeploymentPolicy, ReportDeployInstanceStatusReq, + ReportDeployInstanceStatusRes, TerminateServiceReq, TerminateServiceRes, + }, + worker::{PushWorkerMetricsReq, PushWorkerMetricsRes}, + }, + well_known::CTL_HTTP_PORT, +}; + +#[derive(Clone)] +pub struct CtlClient { + base_url: Arc, + client: BaseClient, +} + +impl CtlClient { + #[must_use] + pub fn new(ctl_addr: IpAddr) -> Self { + let base_url = format!("http://{ctl_addr}:{CTL_HTTP_PORT}") + .into_boxed_str() + .into(); + let client = BaseClient::new(); + CtlClient { base_url, client } + } + + fn url(&self, path: &str) -> String { + assert!(path.starts_with('/')); + format!("{base}{path}", base = self.base_url) + } + + pub async fn push_metrics( + &self, + metrics: Metrics, + recorded_at: DateTime, + ) -> eyre::Result { + let body = PushWorkerMetricsReq { + metrics, + recorded_at, + }; + self.client + .send(self.url("/worker/push-metrics"), &body) + .await + } + + pub async fn deploy_service( + &self, + service_spec: ServiceSpec, + redeployment_policy: RedeploymentPolicy, + ) -> eyre::Result { + let body = DeployServiceReq { + service_spec, + redeployment_policy, + }; + self.client + .send(self.url("/deployer/deploy-service"), &body) + .await + } + + pub async fn terminate_service( + &self, + service_id: ServiceId, + ) -> eyre::Result { + let body = TerminateServiceReq { service_id }; + self.client + .send(self.url("/deployer/terminate-service"), &body) + .await + } + + pub async fn report_instance_status( + &self, + instance_id: InstanceId, + status: instance::Status, + ) -> eyre::Result { + let body = ReportDeployInstanceStatusReq { + instance_id, + status, + }; + self.client.send(self.url("/deployer/status"), &body).await + } +} diff --git a/proto/src/clients/mod.rs b/proto/src/clients/mod.rs new file mode 100644 index 0000000..0949a24 --- /dev/null +++ b/proto/src/clients/mod.rs @@ -0,0 +1,42 @@ +mod ctl; +pub use ctl::CtlClient; + +mod worker; +pub use worker::WorkerClient; + +use eyre::Context as _; +use serde::{de::DeserializeOwned, Serialize}; + +#[derive(Clone)] +pub struct BaseClient { + client: reqwest::Client, +} + +impl BaseClient { + #[must_use] + fn new() -> Self { + let client = reqwest::Client::new(); + Self { client } + } + + /// Sends a request to the given path, on the given worker. + /// + /// Paths must start with a `/`. + async fn send(&self, url: impl AsRef, body: &Req) -> eyre::Result + where + Req: Serialize, + Res: DeserializeOwned, + { + let res = self + .client + .post(url.as_ref()) + .json(body) + .send() + .await + .wrap_err("failed to send request to worker")? + .json::() + .await + .wrap_err("failed to parse response from worker")?; + Ok(res) + } +} diff --git a/proto/src/clients/worker.rs b/proto/src/clients/worker.rs new file mode 100644 index 0000000..209f248 --- /dev/null +++ b/proto/src/clients/worker.rs @@ -0,0 +1,52 @@ +use std::net::IpAddr; + +use crate::{ + clients::BaseClient, + common::instance::{InstanceId, InstanceSpec}, + well_known::WORKER_HTTP_PORT, + worker::runner::{ + DeployInstanceReq, DeployInstanceRes, TerminateInstanceReq, TerminateInstanceRes, + }, +}; + +#[derive(Clone)] +pub struct WorkerClient { + client: BaseClient, +} + +impl WorkerClient { + #[must_use] + #[allow(clippy::new_without_default)] + pub fn new() -> Self { + let client = BaseClient::new(); + WorkerClient { client } + } + + #[allow(clippy::unused_self)] + fn url(&self, worker: IpAddr, path: &str) -> String { + assert!(path.starts_with('/')); + format!("http://{worker}:{WORKER_HTTP_PORT}{path}") + } + + pub async fn deploy_instance( + &self, + worker: IpAddr, + instance_spec: InstanceSpec, + ) -> eyre::Result { + let body = DeployInstanceReq { instance_spec }; + self.client + .send(self.url(worker, "/runner/deploy-instance"), &body) + .await + } + + pub async fn terminate_instance( + &self, + worker: IpAddr, + instance_id: InstanceId, + ) -> eyre::Result { + let body = TerminateInstanceReq { instance_id }; + self.client + .send(self.url(worker, "/runner/terminate-instance"), &body) + .await + } +} diff --git a/proto/src/ctl/deployer.rs b/proto/src/ctl/deployer.rs index 340c4c2..9738534 100644 --- a/proto/src/ctl/deployer.rs +++ b/proto/src/ctl/deployer.rs @@ -16,7 +16,7 @@ pub struct DeploymentId(pub Uuid); /// Starts a new deploy in the system. #[derive(Debug, Serialize, Deserialize)] -pub struct DeployReq { +pub struct DeployServiceReq { pub service_spec: ServiceSpec, pub redeployment_policy: RedeploymentPolicy, } @@ -32,20 +32,20 @@ pub enum RedeploymentPolicy { /// Response for [`DeployReq`]. #[derive(Debug, Serialize, Deserialize)] -pub struct DeployRes { +pub struct DeployServiceRes { pub deployment_id: DeploymentId, pub instances_mapping: HashMap, } /// Stops a given service from running in the system. #[derive(Debug, Serialize, Deserialize)] -pub struct TerminateReq { +pub struct TerminateServiceReq { pub service_id: ServiceId, } /// Response for [`TerminateReq`]. #[derive(Debug, Serialize, Deserialize)] -pub struct TerminateRes {} +pub struct TerminateServiceRes {} #[derive(Debug, Serialize, Deserialize)] pub struct ReportDeployInstanceStatusReq { diff --git a/proto/src/ctl/mod.rs b/proto/src/ctl/mod.rs index 0fa4d83..a44063a 100644 --- a/proto/src/ctl/mod.rs +++ b/proto/src/ctl/mod.rs @@ -1 +1,2 @@ pub mod deployer; +pub mod worker; diff --git a/proto/src/ctl/worker.rs b/proto/src/ctl/worker.rs index 1788e7e..77e6b45 100644 --- a/proto/src/ctl/worker.rs +++ b/proto/src/ctl/worker.rs @@ -1,23 +1,18 @@ -use std::collections::HashMap; - use chrono::{DateTime, Utc}; use serde::{Deserialize, Serialize}; -use crate::common::node::{Metrics, NodeName}; +use crate::common::node::Metrics; -/// Pushes new metrics of a given **worker** node. +/// Pushes new metrics of a given worker node. /// -/// The server must validate whether the node name corresponds to the -/// appropriate node address. If they don't match, the operation fails. +/// The controller associates the provided metrics to the node that sent them, +/// using its peer IP address. /// -/// The server *may* ignore older requests that are received out-of-order with -/// respect to the `recorded_at` field. +/// The controller server *may* ignore older requests that are received +/// out-of-order with respect to the `recorded_at` field. #[derive(Debug, Serialize, Deserialize)] pub struct PushWorkerMetricsReq { - pub node_name: NodeName, pub metrics: Metrics, - /// The number of services that are being executed on the node. - pub services: HashMap, pub recorded_at: DateTime, } diff --git a/proto/src/lib.rs b/proto/src/lib.rs index eba42be..f33f470 100644 --- a/proto/src/lib.rs +++ b/proto/src/lib.rs @@ -3,3 +3,6 @@ pub mod ctl; pub mod etc; pub mod well_known; pub mod worker; + +/// Clients for accessing worker and controller APIs. +pub mod clients; diff --git a/proto/src/well_known.rs b/proto/src/well_known.rs index 97d1d91..640bc67 100644 --- a/proto/src/well_known.rs +++ b/proto/src/well_known.rs @@ -4,4 +4,8 @@ pub const GRACEFUL_SHUTDOWN_DEADLINE: Duration = Duration::from_secs(20); pub const PROXY_INSTANCE_HEADER_NAME: &str = "X-Tuc-Inst"; +pub const CTL_HTTP_PORT: u16 = 6968; +pub const CTL_BALANCER_PORT: u16 = 8080; + pub const WORKER_PROXY_PORT: u16 = 8080; +pub const WORKER_HTTP_PORT: u16 = 6969; diff --git a/proto/src/worker/runner.rs b/proto/src/worker/runner.rs index f87b27c..b2f9e36 100644 --- a/proto/src/worker/runner.rs +++ b/proto/src/worker/runner.rs @@ -17,9 +17,9 @@ pub struct DeployInstanceRes {} /// Stops a given service from running in the system. #[derive(Debug, Serialize, Deserialize)] -pub struct TerminateReq { +pub struct TerminateInstanceReq { pub instance_id: InstanceId, } #[derive(Debug, Serialize, Deserialize)] -pub struct TerminateRes {} +pub struct TerminateInstanceRes {} diff --git a/worker/Cargo.toml b/worker/Cargo.toml index 328084b..2132aa0 100644 --- a/worker/Cargo.toml +++ b/worker/Cargo.toml @@ -13,6 +13,7 @@ proto.workspace = true # External deps (keep alphabetically sorted) axum.workspace = true bollard.workspace = true +chrono.workspace = true clap.workspace = true eyre.workspace = true futures-util.workspace = true diff --git a/worker/src/args.rs b/worker/src/args.rs index c40daa8..5c11db6 100644 --- a/worker/src/args.rs +++ b/worker/src/args.rs @@ -1,4 +1,4 @@ -use std::{net::SocketAddr, time::Duration}; +use std::{net::IpAddr, time::Duration}; use clap::{value_parser, Parser}; @@ -6,7 +6,7 @@ use clap::{value_parser, Parser}; pub struct WorkerArgs { /// Controller's address. #[allow(dead_code)] - pub controller_addr: SocketAddr, + pub controller_addr: IpAddr, /// Interval at which metrics are pushed to the controller. pub metrics_report_interval: Duration, @@ -29,7 +29,7 @@ impl WorkerArgs { struct RawWorkerArgs { /// Controller's HTTP address. #[arg(short, long)] - controller_addr: SocketAddr, + controller_addr: IpAddr, /// Interval at which metrics are pushed to the controller. /// diff --git a/worker/src/http/mod.rs b/worker/src/http/mod.rs index df6f4c7..0ebaf3b 100644 --- a/worker/src/http/mod.rs +++ b/worker/src/http/mod.rs @@ -11,8 +11,12 @@ pub struct HttpState { pub async fn run_server(state: HttpState) { let app = Router::new() - .route("/instance/deploy", post(runner::deploy_instance)) - .route("/instance/terminate", post(runner::terminate_instance)) + .nest( + "/runner", + Router::new() + .route("/deploy-instance", post(runner::deploy_instance)) + .route("/terminate-instance", post(runner::terminate_instance)), + ) .with_state(state); let listener = tokio::net::TcpListener::bind("0.0.0.0:6969").await.unwrap(); diff --git a/worker/src/http/runner/mod.rs b/worker/src/http/runner/mod.rs index c75ea4d..95c835b 100644 --- a/worker/src/http/runner/mod.rs +++ b/worker/src/http/runner/mod.rs @@ -1,5 +1,7 @@ use axum::{extract::State, response::IntoResponse, Json}; -use proto::worker::runner::{DeployInstanceReq, DeployInstanceRes, TerminateReq, TerminateRes}; +use proto::worker::runner::{ + DeployInstanceReq, DeployInstanceRes, TerminateInstanceReq, TerminateInstanceRes, +}; use reqwest::StatusCode; use setup::http; @@ -15,8 +17,8 @@ pub async fn deploy_instance( pub async fn terminate_instance( State(state): State, - Json(payload): Json, + Json(payload): Json, ) -> http::Result { state.runner.terminate_instance(payload.instance_id).await?; - Ok((StatusCode::ACCEPTED, Json(TerminateRes {}))) + Ok((StatusCode::ACCEPTED, Json(TerminateInstanceRes {}))) } diff --git a/worker/src/main.rs b/worker/src/main.rs index 197a86b..9defe14 100644 --- a/worker/src/main.rs +++ b/worker/src/main.rs @@ -4,7 +4,7 @@ use axum::handler::Handler; use bollard::Docker; use eyre::Result; use http::HttpState; -use proto::well_known; +use proto::{clients::CtlClient, well_known}; use runner::Runner; use tracing::info; @@ -15,7 +15,6 @@ mod http; mod monitor; mod proxy; mod runner; -mod sender; #[tokio::main] async fn main() -> Result<()> { @@ -24,13 +23,13 @@ async fn main() -> Result<()> { let args = Arc::new(WorkerArgs::parse()); info!(?args, "started worker"); - let sender = Arc::new(sender::Sender::new(args.controller_addr)); + let ctl_client = CtlClient::new(args.controller_addr); let pusher_handle = tokio::spawn({ let args = Arc::clone(&args); - let sender = Arc::clone(&sender); + let ctl_client = ctl_client.clone(); async move { - pusher::start_pusher(args, sender).await; + pusher::start_pusher(args, ctl_client).await; } }); @@ -50,7 +49,7 @@ async fn main() -> Result<()> { }); let docker = Arc::new(Docker::connect_with_defaults().unwrap()); - let (runner, runner_handle) = Runner::new(docker, sender, proxy_handle); + let (runner, runner_handle) = Runner::new(docker, ctl_client, proxy_handle); let runner_actor_handle = tokio::spawn(async move { runner.run().await; }); diff --git a/worker/src/monitor/pusher.rs b/worker/src/monitor/pusher.rs index acb3ca0..07386b3 100644 --- a/worker/src/monitor/pusher.rs +++ b/worker/src/monitor/pusher.rs @@ -1,18 +1,20 @@ use std::sync::Arc; +use chrono::Utc; +use proto::clients::CtlClient; use tokio::time::sleep; use tracing::error; -use crate::{args::WorkerArgs, monitor::collector::MetricsCollector, sender}; +use crate::{args::WorkerArgs, monitor::collector::MetricsCollector}; -pub async fn start_pusher(args: Arc, sender: Arc) { +pub async fn start_pusher(args: Arc, ctl_client: CtlClient) { let mut metrics_report: MetricsCollector = MetricsCollector::new(); loop { sleep(args.metrics_report_interval).await; let metrics = metrics_report.get_metrics(); - match sender.send_metrics(metrics).await { - Ok(()) => {} - Err(e) => error!("Failed to send metrics: {e}"), - }; + let now = Utc::now(); + if let Err(error) = ctl_client.push_metrics(metrics, now).await { + error!(?error, "failed to send metrics to ctl"); + } } } diff --git a/worker/src/runner/mod.rs b/worker/src/runner/mod.rs index 2ccc4f8..9b26244 100644 --- a/worker/src/runner/mod.rs +++ b/worker/src/runner/mod.rs @@ -6,7 +6,10 @@ use std::{ use bollard::Docker; use container_rt::ContainerRuntime; use eyre::{Context as _, Ok, Report}; -use proto::common::instance::{self, InstanceId, InstanceSpec}; +use proto::{ + clients::CtlClient, + common::instance::{self, InstanceId, InstanceSpec}, +}; use tokio::{ net::TcpListener, sync::{mpsc, oneshot}, @@ -14,7 +17,6 @@ use tokio::{ }; mod container_rt; -use super::sender; use crate::proxy::ProxyHandle; mod handle; @@ -27,14 +29,14 @@ pub struct Runner { handle: RunnerHandle, proxy_handle: ProxyHandle, container_runtime: Arc, - ctl_sender: Arc, + ctl_client: CtlClient, } impl Runner { #[must_use] pub fn new( docker: Arc, - sender: Arc, + ctl_client: CtlClient, proxy: ProxyHandle, ) -> (Runner, RunnerHandle) { let (tx, rx) = mpsc::channel(16); @@ -46,7 +48,7 @@ impl Runner { handle: handle.clone(), proxy_handle: proxy, container_runtime: Arc::new(ContainerRuntime::new(docker)), - ctl_sender: sender, + ctl_client, }; (actor, handle) } @@ -101,9 +103,9 @@ impl Runner { } } - let s = self.ctl_sender.clone(); + let ctl_client = self.ctl_client.clone(); tokio::spawn(async move { - let _ = s.send_status(id, status).await; + let _ = ctl_client.report_instance_status(id, status).await; }); } diff --git a/worker/src/sender/mod.rs b/worker/src/sender/mod.rs deleted file mode 100644 index 67769e6..0000000 --- a/worker/src/sender/mod.rs +++ /dev/null @@ -1,41 +0,0 @@ -use std::net::SocketAddr; - -use proto::common::{ - instance::{self, InstanceId}, - node::Metrics, -}; -use reqwest::Client; - -/// Sends a http request to `ctl::http` component with body -/// containing `instance::Status` information used in `ctl::discovery` -#[derive(Clone, Debug)] -pub struct Sender { - pub client: Client, - - /// The `ctl::http` URL should be known by the worker since the start. - /// So it should be passed via `args` to the main function. - pub ctl_path: SocketAddr, -} - -impl Sender { - /// Creates a `Sender` instance wrapped by an `Arc`. - #[must_use] - pub fn new(path: SocketAddr) -> Self { - Sender { - client: Client::new(), - ctl_path: path, - } - } - - pub async fn send_status(&self, id: InstanceId, status: instance::Status) -> eyre::Result<()> { - let path = format!("{:?}/deploy/status", self.ctl_path); - let _ = self.client.post(path).json(&(&id, &status)).send().await?; - Ok(()) - } - - pub async fn send_metrics(&self, metrics: Metrics) -> eyre::Result<()> { - let path = format!("{:?}/worker/metrics", self.ctl_path); - let _ = self.client.post(path).json(&metrics).send().await?; - Ok(()) - } -} From b2bd2b20ea84913399d68cfd44307da76ed2cac5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luiz=20Felipe=20Gon=C3=A7alves?= Date: Wed, 19 Jun 2024 21:49:34 -0300 Subject: [PATCH 2/2] fmt --- proto/src/clients/mod.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/proto/src/clients/mod.rs b/proto/src/clients/mod.rs index 0949a24..7a94c07 100644 --- a/proto/src/clients/mod.rs +++ b/proto/src/clients/mod.rs @@ -2,10 +2,9 @@ mod ctl; pub use ctl::CtlClient; mod worker; -pub use worker::WorkerClient; - use eyre::Context as _; use serde::{de::DeserializeOwned, Serialize}; +pub use worker::WorkerClient; #[derive(Clone)] pub struct BaseClient {