refactor(steps): consolidate duplicate strip_protocol function (#16318)
This commit is contained in:
@@ -6,6 +6,7 @@ use async_trait::async_trait;
|
|||||||
use reqwest::Client;
|
use reqwest::Client;
|
||||||
use tracing::debug;
|
use tracing::debug;
|
||||||
|
|
||||||
|
use super::strip_protocol;
|
||||||
use crate::{
|
use crate::{
|
||||||
app_context::AppContext,
|
app_context::AppContext,
|
||||||
core::ConnectionMode,
|
core::ConnectionMode,
|
||||||
@@ -14,14 +15,6 @@ use crate::{
|
|||||||
workflow::{StepExecutor, StepId, StepResult, WorkflowContext, WorkflowError, WorkflowResult},
|
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.
|
/// Try HTTP health check.
|
||||||
async fn try_http_health_check(
|
async fn try_http_health_check(
|
||||||
url: &str,
|
url: &str,
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ use serde::{Deserialize, Serialize};
|
|||||||
use serde_json::Value;
|
use serde_json::Value;
|
||||||
use tracing::{debug, warn};
|
use tracing::{debug, warn};
|
||||||
|
|
||||||
|
use super::strip_protocol;
|
||||||
use crate::{
|
use crate::{
|
||||||
core::ConnectionMode,
|
core::ConnectionMode,
|
||||||
protocols::worker_spec::WorkerConfigRequest,
|
protocols::worker_spec::WorkerConfigRequest,
|
||||||
@@ -50,14 +51,6 @@ pub struct ModelInfo {
|
|||||||
pub architectures: Option<Vec<String>>,
|
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.
|
/// Fallback function to GET JSON from old endpoint (with "get_" prefix) for backward compatibility.
|
||||||
async fn get_json_fallback(
|
async fn get_json_fallback(
|
||||||
base_url: &str,
|
base_url: &str,
|
||||||
|
|||||||
@@ -13,6 +13,14 @@ mod update_worker_properties;
|
|||||||
|
|
||||||
use std::{sync::Arc, time::Duration};
|
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 create_worker::CreateLocalWorkerStep;
|
||||||
pub use detect_connection::DetectConnectionModeStep;
|
pub use detect_connection::DetectConnectionModeStep;
|
||||||
pub use discover_dp::{get_dp_info, DiscoverDPInfoStep, DpInfo};
|
pub use discover_dp::{get_dp_info, DiscoverDPInfoStep, DpInfo};
|
||||||
|
|||||||
Reference in New Issue
Block a user