Replace isahc with async ureq (#18414)
REplace isahc with ureq everywhere gpui is used. This should allow us to make http requests without libssl; and avoid a long-tail of panics caused by ishac. Release Notes: - (potentially breaking change) updated our http client --------- Co-authored-by: Mikayla <mikayla@zed.dev>
This commit is contained in:
parent
f809787275
commit
3a5deb5c6f
33 changed files with 1068 additions and 401 deletions
|
@ -37,7 +37,7 @@ futures.workspace = true
|
|||
google_ai.workspace = true
|
||||
hex.workspace = true
|
||||
http_client.workspace = true
|
||||
isahc_http_client.workspace = true
|
||||
reqwest_client.workspace = true
|
||||
jsonwebtoken.workspace = true
|
||||
live_kit_server.workspace = true
|
||||
log.workspace = true
|
||||
|
|
|
@ -674,7 +674,7 @@ pub struct EditorEventRow {
|
|||
copilot_enabled_for_language: bool,
|
||||
historical_event: bool,
|
||||
architecture: String,
|
||||
is_staff: Option<bool>,
|
||||
is_staff: bool,
|
||||
major: Option<i32>,
|
||||
minor: Option<i32>,
|
||||
patch: Option<i32>,
|
||||
|
@ -708,7 +708,7 @@ impl EditorEventRow {
|
|||
installation_id: body.installation_id.clone().unwrap_or_default(),
|
||||
session_id: body.session_id.clone(),
|
||||
metrics_id: body.metrics_id.clone().unwrap_or_default(),
|
||||
is_staff: body.is_staff,
|
||||
is_staff: body.is_staff.unwrap_or_default(),
|
||||
time: time.timestamp_millis(),
|
||||
operation: event.operation,
|
||||
file_extension: event.file_extension.unwrap_or_default(),
|
||||
|
@ -741,7 +741,7 @@ pub struct InlineCompletionEventRow {
|
|||
region_code: String,
|
||||
city: String,
|
||||
time: i64,
|
||||
is_staff: Option<bool>,
|
||||
is_staff: bool,
|
||||
major: Option<i32>,
|
||||
minor: Option<i32>,
|
||||
patch: Option<i32>,
|
||||
|
@ -772,7 +772,7 @@ impl InlineCompletionEventRow {
|
|||
os_version: body.os_version.clone().unwrap_or_default(),
|
||||
installation_id: body.installation_id.clone().unwrap_or_default(),
|
||||
session_id: body.session_id.clone(),
|
||||
is_staff: body.is_staff,
|
||||
is_staff: body.is_staff.unwrap_or_default(),
|
||||
time: time.timestamp_millis(),
|
||||
file_extension: event.file_extension.unwrap_or_default(),
|
||||
signed_in: wrapper.signed_in,
|
||||
|
@ -800,7 +800,7 @@ pub struct CallEventRow {
|
|||
// ClientEventBase
|
||||
installation_id: String,
|
||||
session_id: Option<String>,
|
||||
is_staff: Option<bool>,
|
||||
is_staff: bool,
|
||||
time: i64,
|
||||
|
||||
// CallEventRow
|
||||
|
@ -832,7 +832,7 @@ impl CallEventRow {
|
|||
os_version: body.os_version.clone().unwrap_or_default(),
|
||||
installation_id: body.installation_id.clone().unwrap_or_default(),
|
||||
session_id: body.session_id.clone(),
|
||||
is_staff: body.is_staff,
|
||||
is_staff: body.is_staff.unwrap_or_default(),
|
||||
time: time.timestamp_millis(),
|
||||
operation: event.operation,
|
||||
room_id: event.room_id,
|
||||
|
@ -856,7 +856,7 @@ pub struct AssistantEventRow {
|
|||
// ClientEventBase
|
||||
installation_id: Option<String>,
|
||||
session_id: Option<String>,
|
||||
is_staff: Option<bool>,
|
||||
is_staff: bool,
|
||||
time: i64,
|
||||
|
||||
// AssistantEventRow
|
||||
|
@ -891,7 +891,7 @@ impl AssistantEventRow {
|
|||
os_version: body.os_version.clone().unwrap_or_default(),
|
||||
installation_id: body.installation_id.clone(),
|
||||
session_id: body.session_id.clone(),
|
||||
is_staff: body.is_staff,
|
||||
is_staff: body.is_staff.unwrap_or_default(),
|
||||
time: time.timestamp_millis(),
|
||||
conversation_id: event.conversation_id.unwrap_or_default(),
|
||||
kind: event.kind.to_string(),
|
||||
|
@ -909,7 +909,7 @@ impl AssistantEventRow {
|
|||
pub struct CpuEventRow {
|
||||
installation_id: Option<String>,
|
||||
session_id: Option<String>,
|
||||
is_staff: Option<bool>,
|
||||
is_staff: bool,
|
||||
usage_as_percentage: f32,
|
||||
core_count: u32,
|
||||
app_version: String,
|
||||
|
@ -947,7 +947,7 @@ impl CpuEventRow {
|
|||
os_version: body.os_version.clone().unwrap_or_default(),
|
||||
installation_id: body.installation_id.clone(),
|
||||
session_id: body.session_id.clone(),
|
||||
is_staff: body.is_staff,
|
||||
is_staff: body.is_staff.unwrap_or_default(),
|
||||
time: time.timestamp_millis(),
|
||||
usage_as_percentage: event.usage_as_percentage,
|
||||
core_count: event.core_count,
|
||||
|
@ -970,7 +970,7 @@ pub struct MemoryEventRow {
|
|||
// ClientEventBase
|
||||
installation_id: Option<String>,
|
||||
session_id: Option<String>,
|
||||
is_staff: Option<bool>,
|
||||
is_staff: bool,
|
||||
time: i64,
|
||||
|
||||
// MemoryEventRow
|
||||
|
@ -1001,7 +1001,7 @@ impl MemoryEventRow {
|
|||
os_version: body.os_version.clone().unwrap_or_default(),
|
||||
installation_id: body.installation_id.clone(),
|
||||
session_id: body.session_id.clone(),
|
||||
is_staff: body.is_staff,
|
||||
is_staff: body.is_staff.unwrap_or_default(),
|
||||
time: time.timestamp_millis(),
|
||||
memory_in_bytes: event.memory_in_bytes,
|
||||
virtual_memory_in_bytes: event.virtual_memory_in_bytes,
|
||||
|
@ -1024,7 +1024,7 @@ pub struct AppEventRow {
|
|||
// ClientEventBase
|
||||
installation_id: Option<String>,
|
||||
session_id: Option<String>,
|
||||
is_staff: Option<bool>,
|
||||
is_staff: bool,
|
||||
time: i64,
|
||||
|
||||
// AppEventRow
|
||||
|
@ -1054,7 +1054,7 @@ impl AppEventRow {
|
|||
os_version: body.os_version.clone().unwrap_or_default(),
|
||||
installation_id: body.installation_id.clone(),
|
||||
session_id: body.session_id.clone(),
|
||||
is_staff: body.is_staff,
|
||||
is_staff: body.is_staff.unwrap_or_default(),
|
||||
time: time.timestamp_millis(),
|
||||
operation: event.operation,
|
||||
}
|
||||
|
@ -1076,7 +1076,7 @@ pub struct SettingEventRow {
|
|||
// ClientEventBase
|
||||
installation_id: Option<String>,
|
||||
session_id: Option<String>,
|
||||
is_staff: Option<bool>,
|
||||
is_staff: bool,
|
||||
time: i64,
|
||||
// SettingEventRow
|
||||
setting: String,
|
||||
|
@ -1106,7 +1106,7 @@ impl SettingEventRow {
|
|||
os_version: body.os_version.clone().unwrap_or_default(),
|
||||
installation_id: body.installation_id.clone(),
|
||||
session_id: body.session_id.clone(),
|
||||
is_staff: body.is_staff,
|
||||
is_staff: body.is_staff.unwrap_or_default(),
|
||||
time: time.timestamp_millis(),
|
||||
setting: event.setting,
|
||||
value: event.value,
|
||||
|
@ -1129,7 +1129,7 @@ pub struct ExtensionEventRow {
|
|||
// ClientEventBase
|
||||
installation_id: Option<String>,
|
||||
session_id: Option<String>,
|
||||
is_staff: Option<bool>,
|
||||
is_staff: bool,
|
||||
time: i64,
|
||||
|
||||
// ExtensionEventRow
|
||||
|
@ -1164,7 +1164,7 @@ impl ExtensionEventRow {
|
|||
os_version: body.os_version.clone().unwrap_or_default(),
|
||||
installation_id: body.installation_id.clone(),
|
||||
session_id: body.session_id.clone(),
|
||||
is_staff: body.is_staff,
|
||||
is_staff: body.is_staff.unwrap_or_default(),
|
||||
time: time.timestamp_millis(),
|
||||
extension_id: event.extension_id,
|
||||
extension_version: event.version,
|
||||
|
@ -1198,7 +1198,7 @@ pub struct ReplEventRow {
|
|||
// ClientEventBase
|
||||
installation_id: Option<String>,
|
||||
session_id: Option<String>,
|
||||
is_staff: Option<bool>,
|
||||
is_staff: bool,
|
||||
time: i64,
|
||||
|
||||
// ReplEventRow
|
||||
|
@ -1230,7 +1230,7 @@ impl ReplEventRow {
|
|||
os_version: body.os_version.clone().unwrap_or_default(),
|
||||
installation_id: body.installation_id.clone(),
|
||||
session_id: body.session_id.clone(),
|
||||
is_staff: body.is_staff,
|
||||
is_staff: body.is_staff.unwrap_or_default(),
|
||||
time: time.timestamp_millis(),
|
||||
kernel_language: event.kernel_language,
|
||||
kernel_status: event.kernel_status,
|
||||
|
|
|
@ -22,7 +22,8 @@ use chrono::{DateTime, Duration, Utc};
|
|||
use collections::HashMap;
|
||||
use db::{usage_measure::UsageMeasure, ActiveUserCount, LlmDatabase};
|
||||
use futures::{Stream, StreamExt as _};
|
||||
use isahc_http_client::IsahcHttpClient;
|
||||
|
||||
use reqwest_client::ReqwestClient;
|
||||
use rpc::ListModelsResponse;
|
||||
use rpc::{
|
||||
proto::Plan, LanguageModelProvider, PerformCompletionParams, EXPIRED_LLM_TOKEN_HEADER_NAME,
|
||||
|
@ -43,7 +44,7 @@ pub struct LlmState {
|
|||
pub config: Config,
|
||||
pub executor: Executor,
|
||||
pub db: Arc<LlmDatabase>,
|
||||
pub http_client: IsahcHttpClient,
|
||||
pub http_client: ReqwestClient,
|
||||
pub clickhouse_client: Option<clickhouse::Client>,
|
||||
active_user_count_by_model:
|
||||
RwLock<HashMap<(LanguageModelProvider, String), (DateTime<Utc>, ActiveUserCount)>>,
|
||||
|
@ -69,11 +70,8 @@ impl LlmState {
|
|||
let db = Arc::new(db);
|
||||
|
||||
let user_agent = format!("Zed Server/{}", env!("CARGO_PKG_VERSION"));
|
||||
let http_client = IsahcHttpClient::builder()
|
||||
.default_header("User-Agent", user_agent)
|
||||
.build()
|
||||
.map(IsahcHttpClient::from)
|
||||
.context("failed to construct http client")?;
|
||||
let http_client =
|
||||
ReqwestClient::user_agent(&user_agent).context("failed to construct http client")?;
|
||||
|
||||
let this = Self {
|
||||
executor,
|
||||
|
|
|
@ -36,8 +36,8 @@ use collections::{HashMap, HashSet};
|
|||
pub use connection_pool::{ConnectionPool, ZedVersion};
|
||||
use core::fmt::{self, Debug, Formatter};
|
||||
use http_client::HttpClient;
|
||||
use isahc_http_client::IsahcHttpClient;
|
||||
use open_ai::{OpenAiEmbeddingModel, OPEN_AI_API_URL};
|
||||
use reqwest_client::ReqwestClient;
|
||||
use sha2::Digest;
|
||||
use supermaven_api::{CreateExternalUserRequest, SupermavenAdminApi};
|
||||
|
||||
|
@ -954,8 +954,8 @@ impl Server {
|
|||
tracing::info!("connection opened");
|
||||
|
||||
let user_agent = format!("Zed Server/{}", env!("CARGO_PKG_VERSION"));
|
||||
let http_client = match IsahcHttpClient::builder().default_header("User-Agent", user_agent).build() {
|
||||
Ok(http_client) => Arc::new(IsahcHttpClient::from(http_client)),
|
||||
let http_client = match ReqwestClient::user_agent(&user_agent) {
|
||||
Ok(http_client) => Arc::new(http_client),
|
||||
Err(error) => {
|
||||
tracing::error!(?error, "failed to create HTTP client");
|
||||
return;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue