Add an extensions API to the collaboration server (#7807)
This PR adds a REST API to the collab server for searching and downloading extensions. Previously, we had implemented this API in zed.dev directly, but this implementation is better, because we use the collab database to store the download counts for extensions. Release Notes: - N/A --------- Co-authored-by: Marshall Bowers <elliott.codes@gmail.com> Co-authored-by: Marshall <marshall@zed.dev> Co-authored-by: Conrad <conrad@zed.dev>
This commit is contained in:
parent
bdc2558eac
commit
e1ae0d46da
28 changed files with 1755 additions and 174 deletions
|
@ -8,11 +8,14 @@ pub mod rpc;
|
|||
#[cfg(test)]
|
||||
mod tests;
|
||||
|
||||
use anyhow::anyhow;
|
||||
use aws_config::{BehaviorVersion, Region};
|
||||
use axum::{http::StatusCode, response::IntoResponse};
|
||||
use db::Database;
|
||||
use executor::Executor;
|
||||
use serde::Deserialize;
|
||||
use std::{path::PathBuf, sync::Arc};
|
||||
use util::ResultExt;
|
||||
|
||||
pub type Result<T, E = Error> = std::result::Result<T, E>;
|
||||
|
||||
|
@ -100,6 +103,11 @@ pub struct Config {
|
|||
pub live_kit_secret: Option<String>,
|
||||
pub rust_log: Option<String>,
|
||||
pub log_json: Option<bool>,
|
||||
pub blob_store_url: Option<String>,
|
||||
pub blob_store_region: Option<String>,
|
||||
pub blob_store_access_key: Option<String>,
|
||||
pub blob_store_secret_key: Option<String>,
|
||||
pub blob_store_bucket: Option<String>,
|
||||
pub zed_environment: Arc<str>,
|
||||
}
|
||||
|
||||
|
@ -118,6 +126,7 @@ pub struct MigrateConfig {
|
|||
pub struct AppState {
|
||||
pub db: Arc<Database>,
|
||||
pub live_kit_client: Option<Arc<dyn live_kit_server::api::Client>>,
|
||||
pub blob_store_client: Option<aws_sdk_s3::Client>,
|
||||
pub config: Config,
|
||||
}
|
||||
|
||||
|
@ -146,8 +155,44 @@ impl AppState {
|
|||
let this = Self {
|
||||
db: Arc::new(db),
|
||||
live_kit_client,
|
||||
blob_store_client: build_blob_store_client(&config).await.log_err(),
|
||||
config,
|
||||
};
|
||||
Ok(Arc::new(this))
|
||||
}
|
||||
}
|
||||
|
||||
async fn build_blob_store_client(config: &Config) -> anyhow::Result<aws_sdk_s3::Client> {
|
||||
let keys = aws_sdk_s3::config::Credentials::new(
|
||||
config
|
||||
.blob_store_access_key
|
||||
.clone()
|
||||
.ok_or_else(|| anyhow!("missing blob_store_access_key"))?,
|
||||
config
|
||||
.blob_store_secret_key
|
||||
.clone()
|
||||
.ok_or_else(|| anyhow!("missing blob_store_secret_key"))?,
|
||||
None,
|
||||
None,
|
||||
"env",
|
||||
);
|
||||
|
||||
let s3_config = aws_config::defaults(BehaviorVersion::latest())
|
||||
.endpoint_url(
|
||||
config
|
||||
.blob_store_url
|
||||
.as_ref()
|
||||
.ok_or_else(|| anyhow!("missing blob_store_url"))?,
|
||||
)
|
||||
.region(Region::new(
|
||||
config
|
||||
.blob_store_region
|
||||
.clone()
|
||||
.ok_or_else(|| anyhow!("missing blob_store_region"))?,
|
||||
))
|
||||
.credentials_provider(keys)
|
||||
.load()
|
||||
.await;
|
||||
|
||||
Ok(aws_sdk_s3::Client::new(&s3_config))
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue