aboutsummaryrefslogtreecommitdiff
path: root/src/api/k2v
diff options
context:
space:
mode:
authorAlex Auvolat <lx@deuxfleurs.fr>2025-01-31 18:34:57 +0100
committerAlex Auvolat <lx@deuxfleurs.fr>2025-01-31 18:34:57 +0100
commit84f1db91c4e53a8d0c037fd01adb695fd9400ed5 (patch)
tree9f80c50a55bcde668f487957b88cf00e682e4190 /src/api/k2v
parent9fa20d45bebab2a3f66b9721c3643dbd607d944d (diff)
downloadgarage-84f1db91c4e53a8d0c037fd01adb695fd9400ed5.tar.gz
garage-84f1db91c4e53a8d0c037fd01adb695fd9400ed5.zip
fix things up
Diffstat (limited to 'src/api/k2v')
-rw-r--r--src/api/k2v/api_server.rs9
-rw-r--r--src/api/k2v/batch.rs9
-rw-r--r--src/api/k2v/error.rs15
-rw-r--r--src/api/k2v/index.rs3
-rw-r--r--src/api/k2v/item.rs3
-rw-r--r--src/api/k2v/range.rs3
6 files changed, 18 insertions, 24 deletions
diff --git a/src/api/k2v/api_server.rs b/src/api/k2v/api_server.rs
index 1fc512f9..0791c07d 100644
--- a/src/api/k2v/api_server.rs
+++ b/src/api/k2v/api_server.rs
@@ -12,17 +12,16 @@ use garage_util::socket_address::UnixOrTCPSocketAddress;
use garage_model::garage::Garage;
-use crate::error::*;
use garage_api_common::generic_server::*;
-
+use garage_api_common::helpers::*;
use garage_api_common::signature::verify_request;
+use garage_api_s3::cors::*;
use crate::batch::*;
+use crate::error::*;
use crate::index::*;
use crate::item::*;
use crate::router::Endpoint;
-use garage_api_common::helpers::*;
-use garage_api_s3::cors::*;
pub use garage_api_common::signature::streaming::ReqBody;
pub type ResBody = BoxBody<Error>;
@@ -31,7 +30,7 @@ pub struct K2VApiServer {
garage: Arc<Garage>,
}
-pub(crate) struct K2VApiEndpoint {
+pub struct K2VApiEndpoint {
bucket_name: String,
endpoint: Endpoint,
}
diff --git a/src/api/k2v/batch.rs b/src/api/k2v/batch.rs
index 1dd90456..c284dbd4 100644
--- a/src/api/k2v/batch.rs
+++ b/src/api/k2v/batch.rs
@@ -6,12 +6,13 @@ use garage_table::{EnumerationOrder, TableSchema};
use garage_model::k2v::item_table::*;
-use crate::k2v::api_server::{ReqBody, ResBody};
-use crate::k2v::error::*;
-use crate::k2v::item::parse_causality_token;
-use crate::k2v::range::read_range;
use garage_api_common::helpers::*;
+use crate::api_server::{ReqBody, ResBody};
+use crate::error::*;
+use crate::item::parse_causality_token;
+use crate::range::read_range;
+
pub async fn handle_insert_batch(
ctx: ReqCtx,
req: Request<ReqBody>,
diff --git a/src/api/k2v/error.rs b/src/api/k2v/error.rs
index a4d3be1c..3cd0e6f7 100644
--- a/src/api/k2v/error.rs
+++ b/src/api/k2v/error.rs
@@ -2,7 +2,7 @@ use err_derive::Error;
use hyper::header::HeaderValue;
use hyper::{HeaderMap, StatusCode};
-use garage_api_common::common_error::CommonError;
+use garage_api_common::common_error::{commonErrorDerivative, CommonError};
pub(crate) use garage_api_common::common_error::{helper_error_as_internal, pass_helper_error};
pub use garage_api_common::common_error::{
CommonErrorDerivative, OkOrBadRequest, OkOrInternalError,
@@ -16,7 +16,7 @@ use garage_api_common::signature::error::Error as SignatureError;
pub enum Error {
#[error(display = "{}", _0)]
/// Error from common error
- Common(CommonError),
+ Common(#[error(source)] CommonError),
// Category: cannot process
/// Authorization Header Malformed
@@ -44,16 +44,7 @@ pub enum Error {
InvalidUtf8Str(#[error(source)] std::str::Utf8Error),
}
-impl<T> From<T> for Error
-where
- CommonError: From<T>,
-{
- fn from(err: T) -> Self {
- Error::Common(CommonError::from(err))
- }
-}
-
-impl CommonErrorDerivative for Error {}
+commonErrorDerivative!(Error);
impl From<SignatureError> for Error {
fn from(err: SignatureError) -> Self {
diff --git a/src/api/k2v/index.rs b/src/api/k2v/index.rs
index 423c1f97..fbfaad98 100644
--- a/src/api/k2v/index.rs
+++ b/src/api/k2v/index.rs
@@ -5,10 +5,11 @@ use garage_table::util::*;
use garage_model::k2v::item_table::{BYTES, CONFLICTS, ENTRIES, VALUES};
+use garage_api_common::helpers::*;
+
use crate::api_server::ResBody;
use crate::error::*;
use crate::range::read_range;
-use garage_api_common::helpers::*;
pub async fn handle_read_index(
ctx: ReqCtx,
diff --git a/src/api/k2v/item.rs b/src/api/k2v/item.rs
index 315f647c..4e28b499 100644
--- a/src/api/k2v/item.rs
+++ b/src/api/k2v/item.rs
@@ -6,9 +6,10 @@ use hyper::{Request, Response, StatusCode};
use garage_model::k2v::causality::*;
use garage_model::k2v::item_table::*;
+use garage_api_common::helpers::*;
+
use crate::api_server::{ReqBody, ResBody};
use crate::error::*;
-use garage_api_common::helpers::*;
pub const X_GARAGE_CAUSALITY_TOKEN: &str = "X-Garage-Causality-Token";
diff --git a/src/api/k2v/range.rs b/src/api/k2v/range.rs
index fdb17e22..eb4738db 100644
--- a/src/api/k2v/range.rs
+++ b/src/api/k2v/range.rs
@@ -7,9 +7,10 @@ use std::sync::Arc;
use garage_table::replication::TableShardedReplication;
use garage_table::*;
-use crate::error::*;
use garage_api_common::helpers::key_after_prefix;
+use crate::error::*;
+
/// Read range in a Garage table.
/// Returns (entries, more?, nextStart)
#[allow(clippy::too_many_arguments)]