massively speed up compilation of garage_api_admin by not using async_trait
All checks were successful
ci/woodpecker/push/debug Pipeline was successful
ci/woodpecker/pr/debug Pipeline was successful

This commit is contained in:
Alex 2025-02-05 19:37:38 +01:00
parent f914db057a
commit 7c8fc04b96
11 changed files with 4 additions and 68 deletions

View file

@ -3,7 +3,6 @@ use std::convert::TryFrom;
use std::net::SocketAddr;
use std::sync::Arc;
use async_trait::async_trait;
use paste::paste;
use serde::{Deserialize, Serialize};

View file

@ -1,7 +1,5 @@
use std::sync::Arc;
use async_trait::async_trait;
use garage_util::data::*;
use garage_util::error::Error as GarageError;
use garage_util::time::now_msec;
@ -18,7 +16,6 @@ use crate::api::*;
use crate::error::*;
use crate::{Admin, RequestHandler};
#[async_trait]
impl RequestHandler for LocalListBlockErrorsRequest {
type Response = LocalListBlockErrorsResponse;
@ -43,7 +40,6 @@ impl RequestHandler for LocalListBlockErrorsRequest {
}
}
#[async_trait]
impl RequestHandler for LocalGetBlockInfoRequest {
type Response = LocalGetBlockInfoResponse;
@ -109,7 +105,6 @@ impl RequestHandler for LocalGetBlockInfoRequest {
}
}
#[async_trait]
impl RequestHandler for LocalRetryBlockResyncRequest {
type Response = LocalRetryBlockResyncResponse;
@ -143,7 +138,6 @@ impl RequestHandler for LocalRetryBlockResyncRequest {
}
}
#[async_trait]
impl RequestHandler for LocalPurgeBlocksRequest {
type Response = LocalPurgeBlocksResponse;

View file

@ -2,8 +2,6 @@ use std::collections::HashMap;
use std::sync::Arc;
use std::time::Duration;
use async_trait::async_trait;
use garage_util::crdt::*;
use garage_util::data::*;
use garage_util::time::*;
@ -23,7 +21,6 @@ use crate::api::*;
use crate::error::*;
use crate::{Admin, RequestHandler};
#[async_trait]
impl RequestHandler for ListBucketsRequest {
type Response = ListBucketsResponse;
@ -74,7 +71,6 @@ impl RequestHandler for ListBucketsRequest {
}
}
#[async_trait]
impl RequestHandler for GetBucketInfoRequest {
type Response = GetBucketInfoResponse;
@ -230,7 +226,6 @@ async fn bucket_info_results(
Ok(res)
}
#[async_trait]
impl RequestHandler for CreateBucketRequest {
type Response = CreateBucketResponse;
@ -305,7 +300,6 @@ impl RequestHandler for CreateBucketRequest {
}
}
#[async_trait]
impl RequestHandler for DeleteBucketRequest {
type Response = DeleteBucketResponse;
@ -358,7 +352,6 @@ impl RequestHandler for DeleteBucketRequest {
}
}
#[async_trait]
impl RequestHandler for UpdateBucketRequest {
type Response = UpdateBucketResponse;
@ -409,7 +402,6 @@ impl RequestHandler for UpdateBucketRequest {
}
}
#[async_trait]
impl RequestHandler for CleanupIncompleteUploadsRequest {
type Response = CleanupIncompleteUploadsResponse;
@ -435,7 +427,6 @@ impl RequestHandler for CleanupIncompleteUploadsRequest {
// ---- BUCKET/KEY PERMISSIONS ----
#[async_trait]
impl RequestHandler for AllowBucketKeyRequest {
type Response = AllowBucketKeyResponse;
@ -449,7 +440,6 @@ impl RequestHandler for AllowBucketKeyRequest {
}
}
#[async_trait]
impl RequestHandler for DenyBucketKeyRequest {
type Response = DenyBucketKeyResponse;
@ -502,7 +492,6 @@ pub async fn handle_bucket_change_key_perm(
// ---- BUCKET ALIASES ----
#[async_trait]
impl RequestHandler for AddBucketAliasRequest {
type Response = AddBucketAliasResponse;
@ -537,7 +526,6 @@ impl RequestHandler for AddBucketAliasRequest {
}
}
#[async_trait]
impl RequestHandler for RemoveBucketAliasRequest {
type Response = RemoveBucketAliasResponse;

View file

@ -1,8 +1,6 @@
use std::collections::HashMap;
use std::sync::Arc;
use async_trait::async_trait;
use garage_util::crdt::*;
use garage_util::data::*;
@ -14,7 +12,6 @@ use crate::api::*;
use crate::error::*;
use crate::{Admin, RequestHandler};
#[async_trait]
impl RequestHandler for GetClusterStatusRequest {
type Response = GetClusterStatusResponse;
@ -120,7 +117,6 @@ impl RequestHandler for GetClusterStatusRequest {
}
}
#[async_trait]
impl RequestHandler for GetClusterHealthRequest {
type Response = GetClusterHealthResponse;
@ -150,7 +146,6 @@ impl RequestHandler for GetClusterHealthRequest {
}
}
#[async_trait]
impl RequestHandler for ConnectClusterNodesRequest {
type Response = ConnectClusterNodesResponse;
@ -177,7 +172,6 @@ impl RequestHandler for ConnectClusterNodesRequest {
}
}
#[async_trait]
impl RequestHandler for GetClusterLayoutRequest {
type Response = GetClusterLayoutResponse;
@ -241,7 +235,6 @@ fn format_cluster_layout(layout: &layout::LayoutHistory) -> GetClusterLayoutResp
// ---- update functions ----
#[async_trait]
impl RequestHandler for UpdateClusterLayoutRequest {
type Response = UpdateClusterLayoutResponse;
@ -291,7 +284,6 @@ impl RequestHandler for UpdateClusterLayoutRequest {
}
}
#[async_trait]
impl RequestHandler for ApplyClusterLayoutRequest {
type Response = ApplyClusterLayoutResponse;
@ -316,7 +308,6 @@ impl RequestHandler for ApplyClusterLayoutRequest {
}
}
#[async_trait]
impl RequestHandler for RevertClusterLayoutRequest {
type Response = RevertClusterLayoutResponse;

View file

@ -1,8 +1,6 @@
use std::collections::HashMap;
use std::sync::Arc;
use async_trait::async_trait;
use garage_table::*;
use garage_model::garage::Garage;
@ -12,7 +10,6 @@ use crate::api::*;
use crate::error::*;
use crate::{Admin, RequestHandler};
#[async_trait]
impl RequestHandler for ListKeysRequest {
type Response = ListKeysResponse;
@ -38,7 +35,6 @@ impl RequestHandler for ListKeysRequest {
}
}
#[async_trait]
impl RequestHandler for GetKeyInfoRequest {
type Response = GetKeyInfoResponse;
@ -66,7 +62,6 @@ impl RequestHandler for GetKeyInfoRequest {
}
}
#[async_trait]
impl RequestHandler for CreateKeyRequest {
type Response = CreateKeyResponse;
@ -84,7 +79,6 @@ impl RequestHandler for CreateKeyRequest {
}
}
#[async_trait]
impl RequestHandler for ImportKeyRequest {
type Response = ImportKeyResponse;
@ -112,7 +106,6 @@ impl RequestHandler for ImportKeyRequest {
}
}
#[async_trait]
impl RequestHandler for UpdateKeyRequest {
type Response = UpdateKeyResponse;
@ -147,7 +140,6 @@ impl RequestHandler for UpdateKeyRequest {
}
}
#[async_trait]
impl RequestHandler for DeleteKeyRequest {
type Response = DeleteKeyResponse;

View file

@ -22,8 +22,6 @@ mod worker;
use std::sync::Arc;
use async_trait::async_trait;
use garage_model::garage::Garage;
pub use api_server::AdminApiServer as Admin;
@ -34,13 +32,12 @@ pub enum Authorization {
AdminToken,
}
#[async_trait]
pub trait RequestHandler {
type Response;
async fn handle(
fn handle(
self,
garage: &Arc<Garage>,
admin: &Admin,
) -> Result<Self::Response, error::Error>;
) -> impl std::future::Future<Output = Result<Self::Response, error::Error>> + Send;
}

View file

@ -70,7 +70,6 @@ macro_rules! admin_endpoints {
}
)*
#[async_trait]
impl RequestHandler for AdminApiRequest {
type Response = AdminApiResponse;
@ -133,7 +132,6 @@ macro_rules! local_admin_endpoints {
}
}
#[async_trait]
impl RequestHandler for [< $endpoint Request >] {
type Response = [< $endpoint Response >];
@ -202,7 +200,6 @@ macro_rules! local_admin_endpoints {
}
}
#[async_trait]
impl RequestHandler for LocalAdminApiRequest {
type Response = LocalAdminApiResponse;

View file

@ -2,8 +2,6 @@ use std::collections::HashMap;
use std::fmt::Write;
use std::sync::Arc;
use async_trait::async_trait;
use format_table::format_table_to_string;
use garage_util::data::*;
@ -20,7 +18,6 @@ use crate::api::*;
use crate::error::Error;
use crate::{Admin, RequestHandler};
#[async_trait]
impl RequestHandler for LocalCreateMetadataSnapshotRequest {
type Response = LocalCreateMetadataSnapshotResponse;
@ -34,7 +31,6 @@ impl RequestHandler for LocalCreateMetadataSnapshotRequest {
}
}
#[async_trait]
impl RequestHandler for LocalGetNodeStatisticsRequest {
type Response = LocalGetNodeStatisticsResponse;
@ -99,7 +95,6 @@ impl RequestHandler for LocalGetNodeStatisticsRequest {
}
}
#[async_trait]
impl RequestHandler for GetClusterStatisticsRequest {
type Response = GetClusterStatisticsResponse;

View file

@ -27,7 +27,6 @@ use crate::{Admin, RequestHandler};
const RC_REPAIR_ITER_COUNT: usize = 64;
#[async_trait]
impl RequestHandler for LocalLaunchRepairOperationRequest {
type Response = LocalLaunchRepairOperationResponse;
@ -96,17 +95,16 @@ impl RequestHandler for LocalLaunchRepairOperationRequest {
// ----
#[async_trait]
trait TableRepair: Send + Sync + 'static {
type T: TableSchema;
fn table(garage: &Garage) -> &Table<Self::T, TableShardedReplication>;
async fn process(
fn process(
&mut self,
garage: &Garage,
entry: <<Self as TableRepair>::T as TableSchema>::E,
) -> Result<bool, GarageError>;
) -> impl std::future::Future<Output = Result<bool, GarageError>> + Send;
}
struct TableRepairWorker<T: TableRepair> {
@ -180,7 +178,6 @@ impl<R: TableRepair> Worker for TableRepairWorker<R> {
struct RepairVersions;
#[async_trait]
impl TableRepair for RepairVersions {
type T = VersionTable;
@ -227,7 +224,6 @@ impl TableRepair for RepairVersions {
struct RepairBlockRefs;
#[async_trait]
impl TableRepair for RepairBlockRefs {
type T = BlockRefTable;
@ -267,7 +263,6 @@ impl TableRepair for RepairBlockRefs {
struct RepairMpu;
#[async_trait]
impl TableRepair for RepairMpu {
type T = MultipartUploadTable;

View file

@ -1,7 +1,5 @@
use std::sync::Arc;
use async_trait::async_trait;
use http::header::{
ACCESS_CONTROL_ALLOW_HEADERS, ACCESS_CONTROL_ALLOW_METHODS, ACCESS_CONTROL_ALLOW_ORIGIN, ALLOW,
};
@ -20,7 +18,6 @@ use crate::api_server::ResBody;
use crate::error::*;
use crate::{Admin, RequestHandler};
#[async_trait]
impl RequestHandler for OptionsRequest {
type Response = Response<ResBody>;
@ -39,7 +36,6 @@ impl RequestHandler for OptionsRequest {
}
}
#[async_trait]
impl RequestHandler for MetricsRequest {
type Response = Response<ResBody>;
@ -76,7 +72,6 @@ impl RequestHandler for MetricsRequest {
}
}
#[async_trait]
impl RequestHandler for HealthRequest {
type Response = Response<ResBody>;
@ -110,7 +105,6 @@ impl RequestHandler for HealthRequest {
}
}
#[async_trait]
impl RequestHandler for CheckDomainRequest {
type Response = Response<ResBody>;

View file

@ -1,8 +1,6 @@
use std::collections::HashMap;
use std::sync::Arc;
use async_trait::async_trait;
use garage_util::background::*;
use garage_util::time::now_msec;
@ -12,7 +10,6 @@ use crate::api::*;
use crate::error::Error;
use crate::{Admin, RequestHandler};
#[async_trait]
impl RequestHandler for LocalListWorkersRequest {
type Response = LocalListWorkersResponse;
@ -35,7 +32,6 @@ impl RequestHandler for LocalListWorkersRequest {
}
}
#[async_trait]
impl RequestHandler for LocalGetWorkerInfoRequest {
type Response = LocalGetWorkerInfoResponse;
@ -56,7 +52,6 @@ impl RequestHandler for LocalGetWorkerInfoRequest {
}
}
#[async_trait]
impl RequestHandler for LocalGetWorkerVariableRequest {
type Response = LocalGetWorkerVariableResponse;
@ -78,7 +73,6 @@ impl RequestHandler for LocalGetWorkerVariableRequest {
}
}
#[async_trait]
impl RequestHandler for LocalSetWorkerVariableRequest {
type Response = LocalSetWorkerVariableResponse;