diff options
author | Alex <alex@adnab.me> | 2024-02-07 14:59:40 +0000 |
---|---|---|
committer | Alex <alex@adnab.me> | 2024-02-07 14:59:40 +0000 |
commit | 5d941e0100489fff552b59f0679a2a010403a21c (patch) | |
tree | 5c5cef9af72d48dd7347922341e43f0013380c60 /src/api/k2v/batch.rs | |
parent | feeb076b7f5db7fe6fdbe3d2903fae054cde6219 (diff) | |
parent | e011941964b1c1e0b90f85014d166d64a83ae8e2 (diff) | |
download | garage-5d941e0100489fff552b59f0679a2a010403a21c.tar.gz garage-5d941e0100489fff552b59f0679a2a010403a21c.zip |
Merge pull request 'Dependency upgrades: http, hyper, aws-sdk, smaller deps' (#703) from dep-upgrade-202402 into main
Reviewed-on: https://git.deuxfleurs.fr/Deuxfleurs/garage/pulls/703
Diffstat (limited to 'src/api/k2v/batch.rs')
-rw-r--r-- | src/api/k2v/batch.rs | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/src/api/k2v/batch.rs b/src/api/k2v/batch.rs index 294380ea..ae2778b1 100644 --- a/src/api/k2v/batch.rs +++ b/src/api/k2v/batch.rs @@ -1,7 +1,7 @@ use std::sync::Arc; use base64::prelude::*; -use hyper::{Body, Request, Response, StatusCode}; +use hyper::{Request, Response, StatusCode}; use serde::{Deserialize, Serialize}; use garage_util::data::*; @@ -13,15 +13,16 @@ use garage_model::k2v::causality::*; use garage_model::k2v::item_table::*; use crate::helpers::*; +use crate::k2v::api_server::{ReqBody, ResBody}; use crate::k2v::error::*; use crate::k2v::range::read_range; pub async fn handle_insert_batch( garage: Arc<Garage>, bucket_id: Uuid, - req: Request<Body>, -) -> Result<Response<Body>, Error> { - let items = parse_json_body::<Vec<InsertBatchItem>>(req).await?; + req: Request<ReqBody>, +) -> Result<Response<ResBody>, Error> { + let items = parse_json_body::<Vec<InsertBatchItem>, _, Error>(req).await?; let mut items2 = vec![]; for it in items { @@ -41,15 +42,15 @@ pub async fn handle_insert_batch( Ok(Response::builder() .status(StatusCode::NO_CONTENT) - .body(Body::empty())?) + .body(empty_body())?) } pub async fn handle_read_batch( garage: Arc<Garage>, bucket_id: Uuid, - req: Request<Body>, -) -> Result<Response<Body>, Error> { - let queries = parse_json_body::<Vec<ReadBatchQuery>>(req).await?; + req: Request<ReqBody>, +) -> Result<Response<ResBody>, Error> { + let queries = parse_json_body::<Vec<ReadBatchQuery>, _, Error>(req).await?; let resp_results = futures::future::join_all( queries @@ -139,9 +140,9 @@ async fn handle_read_batch_query( pub async fn handle_delete_batch( garage: Arc<Garage>, bucket_id: Uuid, - req: Request<Body>, -) -> Result<Response<Body>, Error> { - let queries = parse_json_body::<Vec<DeleteBatchQuery>>(req).await?; + req: Request<ReqBody>, +) -> Result<Response<ResBody>, Error> { + let queries = parse_json_body::<Vec<DeleteBatchQuery>, _, Error>(req).await?; let resp_results = futures::future::join_all( queries @@ -253,11 +254,11 @@ pub(crate) async fn handle_poll_range( garage: Arc<Garage>, bucket_id: Uuid, partition_key: &str, - req: Request<Body>, -) -> Result<Response<Body>, Error> { + req: Request<ReqBody>, +) -> Result<Response<ResBody>, Error> { use garage_model::k2v::sub::PollRange; - let query = parse_json_body::<PollRangeQuery>(req).await?; + let query = parse_json_body::<PollRangeQuery, _, Error>(req).await?; let timeout_msec = query.timeout.unwrap_or(300).clamp(1, 600) * 1000; @@ -292,7 +293,7 @@ pub(crate) async fn handle_poll_range( } else { Ok(Response::builder() .status(StatusCode::NOT_MODIFIED) - .body(Body::empty())?) + .body(empty_body())?) } } |