refactor(steps): consolidate duplicate strip_protocol function (#16318)

This commit is contained in:
Chang Su
2026-01-02 16:02:42 -08:00
committed by GitHub
parent a2d4f58a96
commit e93433892b
3 changed files with 10 additions and 16 deletions

View File

@@ -6,6 +6,7 @@ use async_trait::async_trait;
use reqwest::Client;
use tracing::debug;
use super::strip_protocol;
use crate::{
app_context::AppContext,
core::ConnectionMode,
@@ -14,14 +15,6 @@ use crate::{
workflow::{StepExecutor, StepId, StepResult, WorkflowContext, WorkflowError, WorkflowResult},
};
/// Strip protocol prefix from URL.
fn strip_protocol(url: &str) -> String {
url.trim_start_matches("http://")
.trim_start_matches("https://")
.trim_start_matches("grpc://")
.to_string()
}
/// Try HTTP health check.
async fn try_http_health_check(
url: &str,

View File

@@ -9,6 +9,7 @@ use serde::{Deserialize, Serialize};
use serde_json::Value;
use tracing::{debug, warn};
use super::strip_protocol;
use crate::{
core::ConnectionMode,
protocols::worker_spec::WorkerConfigRequest,
@@ -50,14 +51,6 @@ pub struct ModelInfo {
pub architectures: Option<Vec<String>>,
}
/// Strip protocol prefix from URL.
fn strip_protocol(url: &str) -> String {
url.trim_start_matches("http://")
.trim_start_matches("https://")
.trim_start_matches("grpc://")
.to_string()
}
/// Fallback function to GET JSON from old endpoint (with "get_" prefix) for backward compatibility.
async fn get_json_fallback(
base_url: &str,

View File

@@ -13,6 +13,14 @@ mod update_worker_properties;
use std::{sync::Arc, time::Duration};
/// Strip protocol prefix (http://, https://, grpc://) from URL.
pub(crate) fn strip_protocol(url: &str) -> String {
url.trim_start_matches("http://")
.trim_start_matches("https://")
.trim_start_matches("grpc://")
.to_string()
}
pub use create_worker::CreateLocalWorkerStep;
pub use detect_connection::DetectConnectionModeStep;
pub use discover_dp::{get_dp_info, DiscoverDPInfoStep, DpInfo};