diff --git a/lib/crates/fabro-api/src/lib.rs b/lib/crates/fabro-api/src/lib.rs index 86ba4c414..ca2774c83 100644 --- a/lib/crates/fabro-api/src/lib.rs +++ b/lib/crates/fabro-api/src/lib.rs @@ -13,4 +13,4 @@ mod generated { include!(concat!(env!("OUT_DIR"), "/codegen.rs")); } -pub use generated::{Client, types}; +pub use generated::{Client as ApiClient, types}; diff --git a/lib/crates/fabro-cli/src/command_context.rs b/lib/crates/fabro-cli/src/command_context.rs index 7d5bcf0e9..c8f6635b8 100644 --- a/lib/crates/fabro-cli/src/command_context.rs +++ b/lib/crates/fabro-cli/src/command_context.rs @@ -9,7 +9,7 @@ use fabro_util::printer::Printer; use tokio::sync::OnceCell; use crate::args::{ServerConnectionArgs, ServerTargetArgs}; -use crate::server_client::ServerStoreClient; +use crate::server_client::Client; use crate::{server_client, user_config}; #[derive(Clone, Debug)] @@ -35,7 +35,7 @@ pub(crate) struct CommandContext { machine_settings: SettingsLayer, cli_settings: CliSettings, server_mode: ServerMode, - server: OnceCell>, + server: OnceCell>, } impl CommandContext { @@ -135,7 +135,7 @@ impl CommandContext { &self.cli_settings } - pub(crate) async fn server(&self) -> Result> { + pub(crate) async fn server(&self) -> Result> { let server_mode = self.server_mode.clone(); let base_config_path = self.base_config_path.clone(); let machine_settings = self.machine_settings.clone(); diff --git a/lib/crates/fabro-cli/src/commands/artifact/cp.rs b/lib/crates/fabro-cli/src/commands/artifact/cp.rs index 9fa791919..a465af4f7 100644 --- a/lib/crates/fabro-cli/src/commands/artifact/cp.rs +++ b/lib/crates/fabro-cli/src/commands/artifact/cp.rs @@ -11,7 +11,7 @@ use fabro_types::settings::cli::{CliLayer, OutputFormat}; use fabro_util::printer::Printer; use crate::args::ArtifactCpArgs; -use crate::server_client::ServerStoreClient; +use crate::server_client::Client; use crate::shared::{print_json_pretty, split_run_path}; pub(super) async fn cp_command( @@ -140,7 +140,7 @@ pub(super) async fn cp_command( } async fn write_artifact_file( - client: &ServerStoreClient, + client: &Client, run_id: &fabro_types::RunId, entry: &super::ArtifactEntry, dest_file: &Path, diff --git a/lib/crates/fabro-cli/src/commands/artifact/mod.rs b/lib/crates/fabro-cli/src/commands/artifact/mod.rs index 8eae5a937..56cfa6ad8 100644 --- a/lib/crates/fabro-cli/src/commands/artifact/mod.rs +++ b/lib/crates/fabro-cli/src/commands/artifact/mod.rs @@ -9,7 +9,7 @@ use fabro_util::printer::Printer; use crate::args::{ArtifactCommand, ArtifactNamespace, ServerTargetArgs}; use crate::command_context::CommandContext; -use crate::server_client::ServerStoreClient; +use crate::server_client::Client; #[derive(Clone, Debug, serde::Serialize)] pub(super) struct ArtifactEntry { @@ -29,7 +29,7 @@ pub(super) async fn resolve_artifacts( cli: &CliSettings, cli_layer: &CliLayer, printer: Printer, -) -> Result<(RunId, ServerStoreClient, Vec)> { +) -> Result<(RunId, Client, Vec)> { let ctx = CommandContext::for_target(server, printer, cli.clone(), cli_layer)?; let client = ctx.server().await?; let run_id = client.resolve_run(run_selector).await?.run_id; diff --git a/lib/crates/fabro-cli/src/commands/install.rs b/lib/crates/fabro-cli/src/commands/install.rs index 5a21ad30f..4809b5172 100644 --- a/lib/crates/fabro-cli/src/commands/install.rs +++ b/lib/crates/fabro-cli/src/commands/install.rs @@ -1094,7 +1094,7 @@ async fn setup_github_app( } async fn persist_vault_secrets_via_server( - client: &fabro_api::Client, + client: &fabro_api::ApiClient, secrets: &[CreateSecretRequest], ) -> Result<()> { for secret in secrets { @@ -1117,7 +1117,7 @@ async fn persist_vault_secrets_with( storage_dir: &Path, secrets: &[CreateSecretRequest], server_was_running: bool, - connect_api_client: impl for<'a> Fn(&'a Path) -> BoxFuture<'a, Result>, + connect_api_client: impl for<'a> Fn(&'a Path) -> BoxFuture<'a, Result>, stop_server: impl for<'a> Fn(&'a Path, Duration) -> BoxFuture<'a, bool>, ) -> Result<()> { if secrets.is_empty() { @@ -1303,7 +1303,7 @@ async fn persist_install_outputs_with_settings( vault_secrets: &[CreateSecretRequest], settings_write: Option>, server_was_running: bool, - connect_api_client: impl for<'a> Fn(&'a Path) -> BoxFuture<'a, Result>, + connect_api_client: impl for<'a> Fn(&'a Path) -> BoxFuture<'a, Result>, stop_server: impl for<'a> Fn(&'a Path, Duration) -> BoxFuture<'a, bool>, ) -> Result<()> { persist_server_env_secrets(storage_dir, server_env_secrets)?; @@ -2486,7 +2486,7 @@ client_id = "client-id" &vault_secrets, false, |_| { - let client = fabro_api::Client::new_with_client( + let client = fabro_api::ApiClient::new_with_client( &server.base_url(), fabro_test::test_http_client(), ); @@ -2548,7 +2548,7 @@ client_id = "client-id" &vault_secrets, true, |_| { - let client = fabro_api::Client::new_with_client( + let client = fabro_api::ApiClient::new_with_client( &server.base_url(), fabro_test::test_http_client(), ); diff --git a/lib/crates/fabro-cli/src/commands/model.rs b/lib/crates/fabro-cli/src/commands/model.rs index f50bf43ed..d0cf03cc8 100644 --- a/lib/crates/fabro-cli/src/commands/model.rs +++ b/lib/crates/fabro-cli/src/commands/model.rs @@ -207,7 +207,7 @@ where } async fn fetch_models_from_server( - client: &fabro_api::Client, + client: &fabro_api::ApiClient, provider: Option<&str>, query: Option<&str>, ) -> Result> { @@ -237,7 +237,7 @@ async fn fetch_models_from_server( } async fn test_model_via_server( - client: &fabro_api::Client, + client: &fabro_api::ApiClient, model_id: &str, mode: Option, ) -> Result { @@ -255,7 +255,7 @@ async fn test_model_via_server( reason = "Progress goes to stderr while tables or JSON results go to stdout." )] async fn test_models_via_server( - client: &fabro_api::Client, + client: &fabro_api::ApiClient, provider: Option<&str>, model: Option<&str>, deep: bool, @@ -432,7 +432,7 @@ async fn test_models_via_server( )] async fn run_models( command: ModelsCommand, - client: &fabro_api::Client, + client: &fabro_api::ApiClient, json_output: bool, ) -> Result<()> { let styles = Styles::detect_stdout(); @@ -483,8 +483,8 @@ mod tests { use super::*; - fn test_api_client(api_url: &str) -> fabro_api::Client { - fabro_api::Client::new_with_client(api_url, fabro_test::test_http_client()) + fn test_api_client(api_url: &str) -> fabro_api::ApiClient { + fabro_api::ApiClient::new_with_client(api_url, fabro_test::test_http_client()) } fn test_model_json(id: &str, provider: Provider) -> serde_json::Value { diff --git a/lib/crates/fabro-cli/src/commands/run/attach.rs b/lib/crates/fabro-cli/src/commands/run/attach.rs index 007e14e25..c39fc605c 100644 --- a/lib/crates/fabro-cli/src/commands/run/attach.rs +++ b/lib/crates/fabro-cli/src/commands/run/attach.rs @@ -74,7 +74,7 @@ pub(crate) async fn attach_run( } pub(crate) async fn attach_run_with_client( - client: &server_client::ServerStoreClient, + client: &server_client::Client, run_id: &RunId, kill_on_detach: bool, styles: &'static Styles, @@ -152,7 +152,7 @@ fn replay_run_with_client( } async fn attach_live_run_with_client( - client: &server_client::ServerStoreClient, + client: &server_client::Client, run_id: &RunId, existing_events: Vec, mut stream: server_client::RunAttachEventStream, @@ -226,7 +226,7 @@ async fn attach_live_run_with_client( } async fn handle_pending_server_interview( - client: &server_client::ServerStoreClient, + client: &server_client::Client, run_id: &RunId, auto_approve: bool, progress_ui: &mut run_progress::ProgressUI, @@ -262,7 +262,7 @@ async fn handle_pending_server_interview( } async fn handle_detach_signal( - client: &server_client::ServerStoreClient, + client: &server_client::Client, run_id: &RunId, kill_on_detach: bool, printer: Printer, @@ -316,7 +316,7 @@ fn api_question_to_question(question: &types::ApiQuestion) -> Question { } async fn submit_server_interview_answer( - client: &server_client::ServerStoreClient, + client: &server_client::Client, run_id: &RunId, qid: &str, answer: &fabro_interview::Answer, @@ -625,7 +625,7 @@ mod tests { .header("Content-Type", "application/json") .body(terminal_run_state_response().to_string()); }); - let client = server_client::ServerStoreClient::new_no_proxy(&server.base_url()).unwrap(); + let client = server_client::Client::new_no_proxy(&server.base_url()).unwrap(); handle_detach_signal(&client, &run_id, true, Printer::Default).await; diff --git a/lib/crates/fabro-cli/src/commands/run/cp.rs b/lib/crates/fabro-cli/src/commands/run/cp.rs index b02426ca4..732312219 100644 --- a/lib/crates/fabro-cli/src/commands/run/cp.rs +++ b/lib/crates/fabro-cli/src/commands/run/cp.rs @@ -9,7 +9,7 @@ use tracing::{debug, info}; use crate::args::{CpArgs, ServerTargetArgs}; use crate::command_context::CommandContext; -use crate::server_client::ServerStoreClient; +use crate::server_client::Client; use crate::shared::{print_json_pretty, split_run_path}; #[derive(Debug)] @@ -131,7 +131,7 @@ async fn resolve_client_and_run_id( cli: &CliSettings, cli_layer: &CliLayer, printer: Printer, -) -> Result<(ServerStoreClient, fabro_types::RunId)> { +) -> Result<(Client, fabro_types::RunId)> { let ctx = CommandContext::for_target(server, printer, cli.clone(), cli_layer)?; let client = ctx.server().await?; let run_id = client.resolve_run(run_prefix).await?.run_id; @@ -139,7 +139,7 @@ async fn resolve_client_and_run_id( } async fn write_sandbox_file( - client: &ServerStoreClient, + client: &Client, run_id: &fabro_types::RunId, remote_path: &str, local_path: &Path, @@ -157,7 +157,7 @@ async fn write_sandbox_file( } async fn upload_sandbox_file( - client: &ServerStoreClient, + client: &Client, run_id: &fabro_types::RunId, local_path: &Path, remote_path: &str, @@ -169,7 +169,7 @@ async fn upload_sandbox_file( } async fn download_recursive( - client: &ServerStoreClient, + client: &Client, run_id: &fabro_types::RunId, remote_path: &str, local_path: &Path, @@ -194,7 +194,7 @@ async fn download_recursive( } async fn upload_recursive( - client: &ServerStoreClient, + client: &Client, run_id: &fabro_types::RunId, local_path: &Path, remote_path: &str, diff --git a/lib/crates/fabro-cli/src/commands/run/logs.rs b/lib/crates/fabro-cli/src/commands/run/logs.rs index 6ce41b8fb..dae03d121 100644 --- a/lib/crates/fabro-cli/src/commands/run/logs.rs +++ b/lib/crates/fabro-cli/src/commands/run/logs.rs @@ -152,7 +152,7 @@ fn try_parse_relative_duration(s: &str) -> Option { } async fn follow_store_logs( - client: &server_client::ServerStoreClient, + client: &server_client::Client, run_id: &fabro_types::RunId, seq: u32, pretty: bool, @@ -225,7 +225,7 @@ async fn follow_store_logs( } async fn run_concluded( - client: &server_client::ServerStoreClient, + client: &server_client::Client, run_id: &fabro_types::RunId, ) -> Result { let state = client @@ -239,7 +239,7 @@ async fn run_concluded( } async fn flush_remaining_store_events( - client: &server_client::ServerStoreClient, + client: &server_client::Client, run_id: &fabro_types::RunId, next_seq: u32, pretty: bool, diff --git a/lib/crates/fabro-cli/src/commands/run/output.rs b/lib/crates/fabro-cli/src/commands/run/output.rs index 95383e294..7e89a13d7 100644 --- a/lib/crates/fabro-cli/src/commands/run/output.rs +++ b/lib/crates/fabro-cli/src/commands/run/output.rs @@ -131,7 +131,7 @@ pub(crate) fn api_check_report_to_local(report: &types::PreflightCheckReport) -> } pub(crate) async fn print_run_summary_with_client( - client: &server_client::ServerStoreClient, + client: &server_client::Client, run_id: &fabro_types::RunId, local_run_dir: Option<&Path>, styles: &Styles, @@ -292,7 +292,7 @@ pub(crate) fn print_final_output(output: Option<&str>, styles: &Styles, printer: } async fn resolve_final_output_with_client( - client: &server_client::ServerStoreClient, + client: &server_client::Client, run_id: &RunId, checkpoint: Option<&fabro_types::Checkpoint>, ) -> Result> { @@ -317,7 +317,7 @@ async fn resolve_final_output_with_client( } async fn resolve_response_string( - client: &server_client::ServerStoreClient, + client: &server_client::Client, run_id: &RunId, response: &str, ) -> Result> { @@ -342,7 +342,7 @@ fn blob_id_from_response(response: &str) -> Option { } async fn list_artifact_display_entries_with_client( - client: &server_client::ServerStoreClient, + client: &server_client::Client, run_id: &RunId, ) -> Result> { let mut entries = Vec::new(); @@ -356,7 +356,7 @@ async fn list_artifact_display_entries_with_client( } async fn print_assets_with_client( - client: &server_client::ServerStoreClient, + client: &server_client::Client, run_id: &RunId, styles: &Styles, printer: Printer, diff --git a/lib/crates/fabro-cli/src/commands/run/rewind.rs b/lib/crates/fabro-cli/src/commands/run/rewind.rs index b0423f949..9486b6756 100644 --- a/lib/crates/fabro-cli/src/commands/run/rewind.rs +++ b/lib/crates/fabro-cli/src/commands/run/rewind.rs @@ -18,7 +18,7 @@ use serde::Serialize; use crate::args::RewindArgs; use crate::command_context::CommandContext; use crate::commands::store::rebuild::rebuild_run_store; -use crate::server_client::ServerStoreClient; +use crate::server_client::Client; use crate::shared::repo::ensure_matching_repo_origin; use crate::shared::{color_if, print_json_pretty}; @@ -111,7 +111,7 @@ pub(crate) fn timeline_entries_json(timeline: &RunTimeline) -> Vec, ) -> Arc { match artifact_upload_token { @@ -254,7 +254,7 @@ fn build_artifact_uploader( struct HttpArtifactUploader { run_id: RunId, - client: server_client::ServerStoreClient, + client: server_client::Client, bearer_token: String, } @@ -318,16 +318,13 @@ impl StageArtifactUploader for MissingArtifactUploadTokenUploader { #[derive(Clone)] struct HttpRunStore { run_id: RunId, - client: server_client::ServerStoreClient, + client: server_client::Client, state: Arc>, events: Arc>>>, } impl HttpRunStore { - async fn connect( - run_id: RunId, - client: server_client::ServerStoreClient, - ) -> Result { + async fn connect(run_id: RunId, client: server_client::Client) -> Result { let state = client .get_run_state(&run_id) .await diff --git a/lib/crates/fabro-cli/src/commands/run/start.rs b/lib/crates/fabro-cli/src/commands/run/start.rs index 1b8e7c46b..0af737d81 100644 --- a/lib/crates/fabro-cli/src/commands/run/start.rs +++ b/lib/crates/fabro-cli/src/commands/run/start.rs @@ -4,7 +4,7 @@ use fabro_types::RunId; use crate::server_client; pub(crate) async fn start_run_with_client( - client: &server_client::ServerStoreClient, + client: &server_client::Client, run_id: &RunId, resume: bool, ) -> Result<()> { diff --git a/lib/crates/fabro-cli/src/commands/runs/archive.rs b/lib/crates/fabro-cli/src/commands/runs/archive.rs index 1673b858a..4a0627759 100644 --- a/lib/crates/fabro-cli/src/commands/runs/archive.rs +++ b/lib/crates/fabro-cli/src/commands/runs/archive.rs @@ -65,7 +65,7 @@ impl Action { async fn run_bulk( action: Action, identifiers: &[String], - client: &server_client::ServerStoreClient, + client: &server_client::Client, cli: &CliSettings, printer: Printer, ) -> Result<()> { diff --git a/lib/crates/fabro-cli/src/commands/runs/rm.rs b/lib/crates/fabro-cli/src/commands/runs/rm.rs index 8ea688a5d..becdc9969 100644 --- a/lib/crates/fabro-cli/src/commands/runs/rm.rs +++ b/lib/crates/fabro-cli/src/commands/runs/rm.rs @@ -21,7 +21,7 @@ pub(crate) async fn remove_command( async fn remove_from( args: &RunsRemoveArgs, - client: &server_client::ServerStoreClient, + client: &server_client::Client, cli: &CliSettings, printer: Printer, ) -> Result<()> { @@ -83,7 +83,7 @@ async fn remove_from( } async fn delete_server_run( - client: &server_client::ServerStoreClient, + client: &server_client::Client, run_id: &fabro_types::RunId, force: bool, ) -> Result<()> { diff --git a/lib/crates/fabro-cli/src/commands/secret/list.rs b/lib/crates/fabro-cli/src/commands/secret/list.rs index 95dc999a0..0b53cc330 100644 --- a/lib/crates/fabro-cli/src/commands/secret/list.rs +++ b/lib/crates/fabro-cli/src/commands/secret/list.rs @@ -2,7 +2,7 @@ use anyhow::Result; use chrono::{DateTime, Utc}; use cli_table::format::{Border, Separator}; use cli_table::{Cell, CellStruct, Style, Table}; -use fabro_api::Client; +use fabro_api::ApiClient; use fabro_types::settings::CliSettings; use fabro_types::settings::cli::OutputFormat; use fabro_util::printer::Printer; @@ -24,7 +24,7 @@ fn format_age(dt: DateTime, now: DateTime) -> String { } pub(super) async fn list_command( - client: &Client, + client: &ApiClient, _args: &SecretListArgs, cli: &CliSettings, printer: Printer, diff --git a/lib/crates/fabro-cli/src/commands/secret/rm.rs b/lib/crates/fabro-cli/src/commands/secret/rm.rs index 08e8fa430..5b71d5c6b 100644 --- a/lib/crates/fabro-cli/src/commands/secret/rm.rs +++ b/lib/crates/fabro-cli/src/commands/secret/rm.rs @@ -1,5 +1,5 @@ use anyhow::Result; -use fabro_api::{Client, types}; +use fabro_api::{ApiClient, types}; use fabro_types::settings::CliSettings; use fabro_types::settings::cli::OutputFormat; use fabro_util::printer::Printer; @@ -9,7 +9,7 @@ use crate::server_client; use crate::shared::print_json_pretty; pub(super) async fn rm_command( - client: &Client, + client: &ApiClient, args: &SecretRmArgs, cli: &CliSettings, printer: Printer, diff --git a/lib/crates/fabro-cli/src/commands/secret/set.rs b/lib/crates/fabro-cli/src/commands/secret/set.rs index 9812b3ec8..1a88f9fac 100644 --- a/lib/crates/fabro-cli/src/commands/secret/set.rs +++ b/lib/crates/fabro-cli/src/commands/secret/set.rs @@ -10,7 +10,7 @@ use std::io::{IsTerminal, Read as _}; use anyhow::{Context as _, Result, bail}; -use fabro_api::{Client, types}; +use fabro_api::{ApiClient, types}; use fabro_types::settings::CliSettings; use fabro_types::settings::cli::OutputFormat; use fabro_util::printer::Printer; @@ -58,7 +58,7 @@ async fn resolve_value(args: &SecretSetArgs) -> Result { } pub(super) async fn set_command( - client: &Client, + client: &ApiClient, args: &SecretSetArgs, cli: &CliSettings, printer: Printer, diff --git a/lib/crates/fabro-cli/src/commands/store/dump.rs b/lib/crates/fabro-cli/src/commands/store/dump.rs index 3dc495c99..9cd3cc2cd 100644 --- a/lib/crates/fabro-cli/src/commands/store/dump.rs +++ b/lib/crates/fabro-cli/src/commands/store/dump.rs @@ -23,7 +23,7 @@ use tokio::task::spawn_blocking; use super::run_export::StoreRunExport; use crate::args::StoreDumpArgs; use crate::command_context::CommandContext; -use crate::server_client::ServerStoreClient; +use crate::server_client::Client; use crate::shared::{absolute_or_current, print_json_pretty}; pub(crate) async fn dump_command( @@ -164,12 +164,12 @@ impl DumpDataSource for LocalDumpSource<'_> { } struct ServerDumpSource<'a> { - client: &'a ServerStoreClient, + client: &'a Client, run_id: &'a RunId, } impl<'a> ServerDumpSource<'a> { - fn new(client: &'a ServerStoreClient, run_id: &'a RunId) -> Self { + fn new(client: &'a Client, run_id: &'a RunId) -> Self { Self { client, run_id } } } diff --git a/lib/crates/fabro-cli/src/server_client.rs b/lib/crates/fabro-cli/src/server_client.rs index c4b00872e..1a17ea309 100644 --- a/lib/crates/fabro-cli/src/server_client.rs +++ b/lib/crates/fabro-cli/src/server_client.rs @@ -30,8 +30,12 @@ use crate::user_config::cli_http_client_builder; use crate::{sse, user_config}; #[derive(Clone)] -pub(crate) struct ServerStoreClient { - client: fabro_api::Client, +#[expect( + clippy::struct_field_names, + reason = "fields name the underlying clients (api client, http client); renaming to avoid the struct's own name would obscure them" +)] +pub(crate) struct Client { + client: fabro_api::ApiClient, http_client: fabro_http::HttpClient, base_url: String, } @@ -86,11 +90,11 @@ impl RunAttachEventStream { pub(crate) use fabro_store::RunProjection; #[cfg(test)] -pub(crate) async fn connect_server(storage_dir: &Path) -> Result { +pub(crate) async fn connect_server(storage_dir: &Path) -> Result { connect_api_client_bundle(storage_dir).await } -pub(crate) async fn connect_server_target_direct(target: &str) -> Result { +pub(crate) async fn connect_server_target_direct(target: &str) -> Result { if target.starts_with("http://") || target.starts_with("https://") { connect_remote_api_client_bundle(target, None, RemoteDevTokenAuth::Ambient) } else { @@ -106,7 +110,7 @@ pub(crate) async fn connect_server_with_settings( args: &ServerTargetArgs, settings: &SettingsLayer, base_config_path: &Path, -) -> Result { +) -> Result { let target = user_config::resolve_server_target(args, settings)?; let runtime = LocalServerRuntime { active_config_path: base_config_path.to_path_buf(), @@ -115,7 +119,7 @@ pub(crate) async fn connect_server_with_settings( connect_target_api_client_bundle(&target, &runtime).await } -async fn connect_api_client_bundle(storage_dir: &Path) -> Result { +async fn connect_api_client_bundle(storage_dir: &Path) -> Result { let config_path = user_config::active_settings_path(None); let bind = start::ensure_server_running_for_storage(storage_dir, &config_path) .await @@ -127,8 +131,8 @@ async fn connect_api_client_bundle(storage_dir: &Path) -> Result Result Result { +pub(crate) async fn connect_api_client(storage_dir: &Path) -> Result { connect_api_client_bundle(storage_dir) .await .map(|client| client.client) @@ -146,7 +150,7 @@ pub(crate) async fn connect_api_client(storage_dir: &Path) -> Result Result { +) -> Result { match target { user_config::ServerTarget::HttpUrl { api_url, tls } => connect_remote_api_client_bundle( api_url, @@ -184,7 +188,7 @@ fn connect_remote_api_client_bundle( api_url: &str, tls: Option<&user_config::ClientTlsSettings>, dev_token_auth: RemoteDevTokenAuth<'_>, -) -> Result { +) -> Result { let normalized = normalize_remote_server_target(api_url); let mut builder = user_config::build_server_client_builder(tls)?; builder = match dev_token_auth { @@ -202,8 +206,8 @@ fn connect_remote_api_client_bundle( RemoteDevTokenAuth::Ambient => apply_dev_token_auth(builder, None)?, }; let http_client = builder.build()?; - let client = fabro_api::Client::new_with_client(&normalized, http_client.clone()); - Ok(ServerStoreClient { + let client = fabro_api::ApiClient::new_with_client(&normalized, http_client.clone()); + Ok(Client { client, http_client, base_url: normalized, @@ -357,10 +361,10 @@ fn apply_dev_token_auth( apply_bearer_token_auth(builder, &token) } -fn unix_socket_api_client_bundle(http_client: fabro_http::HttpClient) -> ServerStoreClient { +fn unix_socket_api_client_bundle(http_client: fabro_http::HttpClient) -> Client { let base_url = "http://fabro".to_string(); - let client = fabro_api::Client::new_with_client(&base_url, http_client.clone()); - ServerStoreClient { + let client = fabro_api::ApiClient::new_with_client(&base_url, http_client.clone()); + Client { client, http_client, base_url, @@ -370,7 +374,7 @@ fn unix_socket_api_client_bundle(http_client: fabro_http::HttpClient) -> ServerS async fn build_authed_unix_socket_client( path: &Path, storage_dir: Option<&Path>, -) -> Result { +) -> Result { let http_client = if let Some(storage_dir) = storage_dir { let token = wait_for_local_dev_token(storage_dir).await?; apply_bearer_token_auth( @@ -398,7 +402,7 @@ fn build_unix_socket_probe_client(path: &Path) -> Result async fn try_connect_unix_socket_api_client_bundle( path: &Path, storage_dir: Option<&Path>, -) -> Result { +) -> Result { check_server_ready(&build_unix_socket_probe_client(path)?).await?; build_authed_unix_socket_client(path, storage_dir).await } @@ -406,7 +410,7 @@ async fn try_connect_unix_socket_api_client_bundle( async fn connect_unix_socket_api_client_bundle( path: &Path, storage_dir: Option<&Path>, -) -> Result { +) -> Result { wait_for_server_ready(&build_unix_socket_probe_client(path)?).await?; build_authed_unix_socket_client(path, storage_dir).await } @@ -453,12 +457,12 @@ struct ArtifactBatchUploadEntry { content_type: Option, } -impl ServerStoreClient { +impl Client { /// Build a client for tests that bypasses proxy discovery. #[cfg(test)] pub(crate) fn new_no_proxy(base_url: &str) -> Result { let http_client = cli_http_client_builder().no_proxy().build()?; - let client = fabro_api::Client::new_with_client(base_url, http_client.clone()); + let client = fabro_api::ApiClient::new_with_client(base_url, http_client.clone()); Ok(Self { client, http_client, @@ -470,7 +474,7 @@ impl ServerStoreClient { self.clone() } - pub(crate) fn api(&self) -> &fabro_api::Client { + pub(crate) fn api(&self) -> &fabro_api::ApiClient { &self.client } diff --git a/lib/crates/fabro-cli/src/server_runs.rs b/lib/crates/fabro-cli/src/server_runs.rs index 7a8b9dffa..99010132f 100644 --- a/lib/crates/fabro-cli/src/server_runs.rs +++ b/lib/crates/fabro-cli/src/server_runs.rs @@ -6,7 +6,7 @@ use chrono::{DateTime, Utc}; use fabro_store::RunSummary; use fabro_types::{RunId, RunStatus, StatusReason}; -use crate::server_client::ServerStoreClient; +use crate::server_client::Client; #[derive(Debug, Clone)] pub(crate) struct ServerRunSummaryInfo { @@ -75,12 +75,12 @@ impl ServerRunSummaryInfo { } pub(crate) struct ServerSummaryLookup { - client: Arc, + client: Arc, runs: Vec, } impl ServerSummaryLookup { - pub(crate) async fn from_client(client: Arc) -> Result { + pub(crate) async fn from_client(client: Arc) -> Result { let summaries = client.list_store_runs().await?; let mut runs = summaries .into_iter() @@ -94,7 +94,7 @@ impl ServerSummaryLookup { Ok(Self { client, runs }) } - pub(crate) fn client(&self) -> &ServerStoreClient { + pub(crate) fn client(&self) -> &Client { self.client.as_ref() }