admin api: rename EndpointHandler into RequestHandler to avoid confusion with RPC

This commit is contained in:
Alex 2025-01-30 19:19:33 +01:00
parent 8e61d149f2
commit de7bbe8be0
12 changed files with 41 additions and 41 deletions

View file

@ -11,7 +11,7 @@ use garage_model::garage::Garage;
use crate::admin::error::Error; use crate::admin::error::Error;
use crate::admin::macros::*; use crate::admin::macros::*;
use crate::admin::EndpointHandler; use crate::admin::RequestHandler;
use crate::helpers::is_default; use crate::helpers::is_default;
// This generates the following: // This generates the following:

View file

@ -26,7 +26,7 @@ use crate::admin::error::*;
use crate::admin::router_v0; use crate::admin::router_v0;
use crate::admin::router_v1; use crate::admin::router_v1;
use crate::admin::Authorization; use crate::admin::Authorization;
use crate::admin::EndpointHandler; use crate::admin::RequestHandler;
use crate::helpers::*; use crate::helpers::*;
pub type ResBody = BoxBody<Error>; pub type ResBody = BoxBody<Error>;

View file

@ -19,11 +19,11 @@ use garage_model::s3::object_table::*;
use crate::admin::api::*; use crate::admin::api::*;
use crate::admin::error::*; use crate::admin::error::*;
use crate::admin::EndpointHandler; use crate::admin::RequestHandler;
use crate::common_error::CommonError; use crate::common_error::CommonError;
#[async_trait] #[async_trait]
impl EndpointHandler for ListBucketsRequest { impl RequestHandler for ListBucketsRequest {
type Response = ListBucketsResponse; type Response = ListBucketsResponse;
async fn handle(self, garage: &Arc<Garage>) -> Result<ListBucketsResponse, Error> { async fn handle(self, garage: &Arc<Garage>) -> Result<ListBucketsResponse, Error> {
@ -70,7 +70,7 @@ impl EndpointHandler for ListBucketsRequest {
} }
#[async_trait] #[async_trait]
impl EndpointHandler for GetBucketInfoRequest { impl RequestHandler for GetBucketInfoRequest {
type Response = GetBucketInfoResponse; type Response = GetBucketInfoResponse;
async fn handle(self, garage: &Arc<Garage>) -> Result<GetBucketInfoResponse, Error> { async fn handle(self, garage: &Arc<Garage>) -> Result<GetBucketInfoResponse, Error> {
@ -222,7 +222,7 @@ async fn bucket_info_results(
} }
#[async_trait] #[async_trait]
impl EndpointHandler for CreateBucketRequest { impl RequestHandler for CreateBucketRequest {
type Response = CreateBucketResponse; type Response = CreateBucketResponse;
async fn handle(self, garage: &Arc<Garage>) -> Result<CreateBucketResponse, Error> { async fn handle(self, garage: &Arc<Garage>) -> Result<CreateBucketResponse, Error> {
@ -293,7 +293,7 @@ impl EndpointHandler for CreateBucketRequest {
} }
#[async_trait] #[async_trait]
impl EndpointHandler for DeleteBucketRequest { impl RequestHandler for DeleteBucketRequest {
type Response = DeleteBucketResponse; type Response = DeleteBucketResponse;
async fn handle(self, garage: &Arc<Garage>) -> Result<DeleteBucketResponse, Error> { async fn handle(self, garage: &Arc<Garage>) -> Result<DeleteBucketResponse, Error> {
@ -342,7 +342,7 @@ impl EndpointHandler for DeleteBucketRequest {
} }
#[async_trait] #[async_trait]
impl EndpointHandler for UpdateBucketRequest { impl RequestHandler for UpdateBucketRequest {
type Response = UpdateBucketResponse; type Response = UpdateBucketResponse;
async fn handle(self, garage: &Arc<Garage>) -> Result<UpdateBucketResponse, Error> { async fn handle(self, garage: &Arc<Garage>) -> Result<UpdateBucketResponse, Error> {
@ -389,7 +389,7 @@ impl EndpointHandler for UpdateBucketRequest {
} }
#[async_trait] #[async_trait]
impl EndpointHandler for CleanupIncompleteUploadsRequest { impl RequestHandler for CleanupIncompleteUploadsRequest {
type Response = CleanupIncompleteUploadsResponse; type Response = CleanupIncompleteUploadsResponse;
async fn handle(self, garage: &Arc<Garage>) -> Result<CleanupIncompleteUploadsResponse, Error> { async fn handle(self, garage: &Arc<Garage>) -> Result<CleanupIncompleteUploadsResponse, Error> {
@ -411,7 +411,7 @@ impl EndpointHandler for CleanupIncompleteUploadsRequest {
// ---- BUCKET/KEY PERMISSIONS ---- // ---- BUCKET/KEY PERMISSIONS ----
#[async_trait] #[async_trait]
impl EndpointHandler for AllowBucketKeyRequest { impl RequestHandler for AllowBucketKeyRequest {
type Response = AllowBucketKeyResponse; type Response = AllowBucketKeyResponse;
async fn handle(self, garage: &Arc<Garage>) -> Result<AllowBucketKeyResponse, Error> { async fn handle(self, garage: &Arc<Garage>) -> Result<AllowBucketKeyResponse, Error> {
@ -421,7 +421,7 @@ impl EndpointHandler for AllowBucketKeyRequest {
} }
#[async_trait] #[async_trait]
impl EndpointHandler for DenyBucketKeyRequest { impl RequestHandler for DenyBucketKeyRequest {
type Response = DenyBucketKeyResponse; type Response = DenyBucketKeyResponse;
async fn handle(self, garage: &Arc<Garage>) -> Result<DenyBucketKeyResponse, Error> { async fn handle(self, garage: &Arc<Garage>) -> Result<DenyBucketKeyResponse, Error> {
@ -470,7 +470,7 @@ pub async fn handle_bucket_change_key_perm(
// ---- BUCKET ALIASES ---- // ---- BUCKET ALIASES ----
#[async_trait] #[async_trait]
impl EndpointHandler for AddBucketAliasRequest { impl RequestHandler for AddBucketAliasRequest {
type Response = AddBucketAliasResponse; type Response = AddBucketAliasResponse;
async fn handle(self, garage: &Arc<Garage>) -> Result<AddBucketAliasResponse, Error> { async fn handle(self, garage: &Arc<Garage>) -> Result<AddBucketAliasResponse, Error> {
@ -501,7 +501,7 @@ impl EndpointHandler for AddBucketAliasRequest {
} }
#[async_trait] #[async_trait]
impl EndpointHandler for RemoveBucketAliasRequest { impl RequestHandler for RemoveBucketAliasRequest {
type Response = RemoveBucketAliasResponse; type Response = RemoveBucketAliasResponse;
async fn handle(self, garage: &Arc<Garage>) -> Result<RemoveBucketAliasResponse, Error> { async fn handle(self, garage: &Arc<Garage>) -> Result<RemoveBucketAliasResponse, Error> {

View file

@ -12,10 +12,10 @@ use garage_model::garage::Garage;
use crate::admin::api::*; use crate::admin::api::*;
use crate::admin::error::*; use crate::admin::error::*;
use crate::admin::EndpointHandler; use crate::admin::RequestHandler;
#[async_trait] #[async_trait]
impl EndpointHandler for GetClusterStatusRequest { impl RequestHandler for GetClusterStatusRequest {
type Response = GetClusterStatusResponse; type Response = GetClusterStatusResponse;
async fn handle(self, garage: &Arc<Garage>) -> Result<GetClusterStatusResponse, Error> { async fn handle(self, garage: &Arc<Garage>) -> Result<GetClusterStatusResponse, Error> {
@ -117,7 +117,7 @@ impl EndpointHandler for GetClusterStatusRequest {
} }
#[async_trait] #[async_trait]
impl EndpointHandler for GetClusterHealthRequest { impl RequestHandler for GetClusterHealthRequest {
type Response = GetClusterHealthResponse; type Response = GetClusterHealthResponse;
async fn handle(self, garage: &Arc<Garage>) -> Result<GetClusterHealthResponse, Error> { async fn handle(self, garage: &Arc<Garage>) -> Result<GetClusterHealthResponse, Error> {
@ -143,7 +143,7 @@ impl EndpointHandler for GetClusterHealthRequest {
} }
#[async_trait] #[async_trait]
impl EndpointHandler for ConnectClusterNodesRequest { impl RequestHandler for ConnectClusterNodesRequest {
type Response = ConnectClusterNodesResponse; type Response = ConnectClusterNodesResponse;
async fn handle(self, garage: &Arc<Garage>) -> Result<ConnectClusterNodesResponse, Error> { async fn handle(self, garage: &Arc<Garage>) -> Result<ConnectClusterNodesResponse, Error> {
@ -166,7 +166,7 @@ impl EndpointHandler for ConnectClusterNodesRequest {
} }
#[async_trait] #[async_trait]
impl EndpointHandler for GetClusterLayoutRequest { impl RequestHandler for GetClusterLayoutRequest {
type Response = GetClusterLayoutResponse; type Response = GetClusterLayoutResponse;
async fn handle(self, garage: &Arc<Garage>) -> Result<GetClusterLayoutResponse, Error> { async fn handle(self, garage: &Arc<Garage>) -> Result<GetClusterLayoutResponse, Error> {
@ -226,7 +226,7 @@ fn format_cluster_layout(layout: &layout::LayoutHistory) -> GetClusterLayoutResp
// ---- update functions ---- // ---- update functions ----
#[async_trait] #[async_trait]
impl EndpointHandler for UpdateClusterLayoutRequest { impl RequestHandler for UpdateClusterLayoutRequest {
type Response = UpdateClusterLayoutResponse; type Response = UpdateClusterLayoutResponse;
async fn handle(self, garage: &Arc<Garage>) -> Result<UpdateClusterLayoutResponse, Error> { async fn handle(self, garage: &Arc<Garage>) -> Result<UpdateClusterLayoutResponse, Error> {
@ -272,7 +272,7 @@ impl EndpointHandler for UpdateClusterLayoutRequest {
} }
#[async_trait] #[async_trait]
impl EndpointHandler for ApplyClusterLayoutRequest { impl RequestHandler for ApplyClusterLayoutRequest {
type Response = ApplyClusterLayoutResponse; type Response = ApplyClusterLayoutResponse;
async fn handle(self, garage: &Arc<Garage>) -> Result<ApplyClusterLayoutResponse, Error> { async fn handle(self, garage: &Arc<Garage>) -> Result<ApplyClusterLayoutResponse, Error> {
@ -293,7 +293,7 @@ impl EndpointHandler for ApplyClusterLayoutRequest {
} }
#[async_trait] #[async_trait]
impl EndpointHandler for RevertClusterLayoutRequest { impl RequestHandler for RevertClusterLayoutRequest {
type Response = RevertClusterLayoutResponse; type Response = RevertClusterLayoutResponse;
async fn handle(self, garage: &Arc<Garage>) -> Result<RevertClusterLayoutResponse, Error> { async fn handle(self, garage: &Arc<Garage>) -> Result<RevertClusterLayoutResponse, Error> {

View file

@ -10,10 +10,10 @@ use garage_model::key_table::*;
use crate::admin::api::*; use crate::admin::api::*;
use crate::admin::error::*; use crate::admin::error::*;
use crate::admin::EndpointHandler; use crate::admin::RequestHandler;
#[async_trait] #[async_trait]
impl EndpointHandler for ListKeysRequest { impl RequestHandler for ListKeysRequest {
type Response = ListKeysResponse; type Response = ListKeysResponse;
async fn handle(self, garage: &Arc<Garage>) -> Result<ListKeysResponse, Error> { async fn handle(self, garage: &Arc<Garage>) -> Result<ListKeysResponse, Error> {
@ -39,7 +39,7 @@ impl EndpointHandler for ListKeysRequest {
} }
#[async_trait] #[async_trait]
impl EndpointHandler for GetKeyInfoRequest { impl RequestHandler for GetKeyInfoRequest {
type Response = GetKeyInfoResponse; type Response = GetKeyInfoResponse;
async fn handle(self, garage: &Arc<Garage>) -> Result<GetKeyInfoResponse, Error> { async fn handle(self, garage: &Arc<Garage>) -> Result<GetKeyInfoResponse, Error> {
@ -63,7 +63,7 @@ impl EndpointHandler for GetKeyInfoRequest {
} }
#[async_trait] #[async_trait]
impl EndpointHandler for CreateKeyRequest { impl RequestHandler for CreateKeyRequest {
type Response = CreateKeyResponse; type Response = CreateKeyResponse;
async fn handle(self, garage: &Arc<Garage>) -> Result<CreateKeyResponse, Error> { async fn handle(self, garage: &Arc<Garage>) -> Result<CreateKeyResponse, Error> {
@ -77,7 +77,7 @@ impl EndpointHandler for CreateKeyRequest {
} }
#[async_trait] #[async_trait]
impl EndpointHandler for ImportKeyRequest { impl RequestHandler for ImportKeyRequest {
type Response = ImportKeyResponse; type Response = ImportKeyResponse;
async fn handle(self, garage: &Arc<Garage>) -> Result<ImportKeyResponse, Error> { async fn handle(self, garage: &Arc<Garage>) -> Result<ImportKeyResponse, Error> {
@ -101,7 +101,7 @@ impl EndpointHandler for ImportKeyRequest {
} }
#[async_trait] #[async_trait]
impl EndpointHandler for UpdateKeyRequest { impl RequestHandler for UpdateKeyRequest {
type Response = UpdateKeyResponse; type Response = UpdateKeyResponse;
async fn handle(self, garage: &Arc<Garage>) -> Result<UpdateKeyResponse, Error> { async fn handle(self, garage: &Arc<Garage>) -> Result<UpdateKeyResponse, Error> {
@ -132,7 +132,7 @@ impl EndpointHandler for UpdateKeyRequest {
} }
#[async_trait] #[async_trait]
impl EndpointHandler for DeleteKeyRequest { impl RequestHandler for DeleteKeyRequest {
type Response = DeleteKeyResponse; type Response = DeleteKeyResponse;
async fn handle(self, garage: &Arc<Garage>) -> Result<DeleteKeyResponse, Error> { async fn handle(self, garage: &Arc<Garage>) -> Result<DeleteKeyResponse, Error> {

View file

@ -71,7 +71,7 @@ macro_rules! admin_endpoints {
)* )*
#[async_trait] #[async_trait]
impl EndpointHandler for AdminApiRequest { impl RequestHandler for AdminApiRequest {
type Response = AdminApiResponse; type Response = AdminApiResponse;
async fn handle(self, garage: &Arc<Garage>) -> Result<AdminApiResponse, Error> { async fn handle(self, garage: &Arc<Garage>) -> Result<AdminApiResponse, Error> {
@ -137,7 +137,7 @@ macro_rules! local_admin_endpoints {
} }
#[async_trait] #[async_trait]
impl EndpointHandler for [< $endpoint Request >] { impl RequestHandler for [< $endpoint Request >] {
type Response = [< $endpoint Response >]; type Response = [< $endpoint Response >];
async fn handle(self, garage: &Arc<Garage>) -> Result<Self::Response, Error> { async fn handle(self, garage: &Arc<Garage>) -> Result<Self::Response, Error> {
@ -157,7 +157,7 @@ macro_rules! local_admin_endpoints {
} }
#[async_trait] #[async_trait]
impl EndpointHandler for LocalAdminApiRequest { impl RequestHandler for LocalAdminApiRequest {
type Response = LocalAdminApiResponse; type Response = LocalAdminApiResponse;
async fn handle(self, garage: &Arc<Garage>) -> Result<LocalAdminApiResponse, Error> { async fn handle(self, garage: &Arc<Garage>) -> Result<LocalAdminApiResponse, Error> {

View file

@ -29,7 +29,7 @@ pub enum Authorization {
} }
#[async_trait] #[async_trait]
pub trait EndpointHandler { pub trait RequestHandler {
type Response; type Response;
async fn handle(self, garage: &Arc<Garage>) -> Result<Self::Response, error::Error>; async fn handle(self, garage: &Arc<Garage>) -> Result<Self::Response, error::Error>;

View file

@ -12,7 +12,7 @@ use garage_rpc::*;
use garage_model::garage::Garage; use garage_model::garage::Garage;
use crate::admin::api::{LocalAdminApiRequest, LocalAdminApiResponse}; use crate::admin::api::{LocalAdminApiRequest, LocalAdminApiResponse};
use crate::admin::EndpointHandler as AdminApiEndpoint; use crate::admin::RequestHandler as AdminApiEndpoint;
use crate::generic_server::ApiError; use crate::generic_server::ApiError;
pub const ADMIN_RPC_PATH: &str = "garage_api/admin/rpc.rs/Rpc"; pub const ADMIN_RPC_PATH: &str = "garage_api/admin/rpc.rs/Rpc";

View file

@ -13,11 +13,11 @@ use garage_rpc::system::ClusterHealthStatus;
use crate::admin::api::{CheckDomainRequest, HealthRequest, OptionsRequest}; use crate::admin::api::{CheckDomainRequest, HealthRequest, OptionsRequest};
use crate::admin::api_server::ResBody; use crate::admin::api_server::ResBody;
use crate::admin::error::*; use crate::admin::error::*;
use crate::admin::EndpointHandler; use crate::admin::RequestHandler;
use crate::helpers::*; use crate::helpers::*;
#[async_trait] #[async_trait]
impl EndpointHandler for OptionsRequest { impl RequestHandler for OptionsRequest {
type Response = Response<ResBody>; type Response = Response<ResBody>;
async fn handle(self, _garage: &Arc<Garage>) -> Result<Response<ResBody>, Error> { async fn handle(self, _garage: &Arc<Garage>) -> Result<Response<ResBody>, Error> {
@ -32,7 +32,7 @@ impl EndpointHandler for OptionsRequest {
} }
#[async_trait] #[async_trait]
impl EndpointHandler for CheckDomainRequest { impl RequestHandler for CheckDomainRequest {
type Response = Response<ResBody>; type Response = Response<ResBody>;
async fn handle(self, garage: &Arc<Garage>) -> Result<Response<ResBody>, Error> { async fn handle(self, garage: &Arc<Garage>) -> Result<Response<ResBody>, Error> {
@ -102,7 +102,7 @@ async fn check_domain(garage: &Arc<Garage>, domain: &str) -> Result<bool, Error>
} }
#[async_trait] #[async_trait]
impl EndpointHandler for HealthRequest { impl RequestHandler for HealthRequest {
type Response = Response<ResBody>; type Response = Response<ResBody>;
async fn handle(self, garage: &Arc<Garage>) -> Result<Response<ResBody>, Error> { async fn handle(self, garage: &Arc<Garage>) -> Result<Response<ResBody>, Error> {

View file

@ -6,10 +6,10 @@ use garage_model::garage::Garage;
use crate::admin::api::*; use crate::admin::api::*;
use crate::admin::error::Error; use crate::admin::error::Error;
use crate::admin::EndpointHandler; use crate::admin::RequestHandler;
#[async_trait] #[async_trait]
impl EndpointHandler for LocalGetWorkerParamRequest { impl RequestHandler for LocalGetWorkerParamRequest {
type Response = LocalGetWorkerParamResponse; type Response = LocalGetWorkerParamResponse;
async fn handle(self, garage: &Arc<Garage>) -> Result<LocalGetWorkerParamResponse, Error> { async fn handle(self, garage: &Arc<Garage>) -> Result<LocalGetWorkerParamResponse, Error> {

View file

@ -27,7 +27,7 @@ use garage_model::s3::mpu_table::MultipartUpload;
use garage_model::s3::version_table::Version; use garage_model::s3::version_table::Version;
use garage_api::admin::api::{AdminApiRequest, TaggedAdminApiResponse}; use garage_api::admin::api::{AdminApiRequest, TaggedAdminApiResponse};
use garage_api::admin::EndpointHandler as AdminApiEndpoint; use garage_api::admin::RequestHandler as AdminApiEndpoint;
use garage_api::generic_server::ApiError; use garage_api::generic_server::ApiError;
use crate::cli::*; use crate::cli::*;

View file

@ -13,7 +13,7 @@ use garage_rpc::system::*;
use garage_rpc::*; use garage_rpc::*;
use garage_api::admin::api::*; use garage_api::admin::api::*;
use garage_api::admin::EndpointHandler as AdminApiEndpoint; use garage_api::admin::RequestHandler as AdminApiEndpoint;
use crate::admin::*; use crate::admin::*;
use crate::cli as cli_v1; use crate::cli as cli_v1;