aboutsummaryrefslogtreecommitdiff
path: root/src/api/k2v/batch.rs
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2024-02-05 19:27:12 +0100
committerAlex Auvolat <alex@adnab.me>2024-02-05 19:27:12 +0100
commita22bd319202f05bce4ad13072238c7ba81d518fb (patch)
tree817d90efaeaa51ea8aebaf5b25ad56c8b968dc0c /src/api/k2v/batch.rs
parent0bb5b77530ad432e4c77f13b395fe74613812337 (diff)
downloadgarage-a22bd319202f05bce4ad13072238c7ba81d518fb.tar.gz
garage-a22bd319202f05bce4ad13072238c7ba81d518fb.zip
[dep-upgrade-202402] migration to http/hyper 1.0 for k2v api
Diffstat (limited to 'src/api/k2v/batch.rs')
-rw-r--r--src/api/k2v/batch.rs31
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())?)
}
}