build(deps): upgrade opendal to 0.46 (#4037)

* build(deps): upgrade opendal to 0.46

Signed-off-by: tison <wander4096@gmail.com>

* migrate writes

Signed-off-by: tison <wander4096@gmail.com>

* migrate reads

Signed-off-by: tison <wander4096@gmail.com>

* fixup object safety

Signed-off-by: tison <wander4096@gmail.com>

* fixup names

Signed-off-by: tison <wander4096@gmail.com>

* fixup compilation

Signed-off-by: tison <wander4096@gmail.com>

* fixup compilation

Signed-off-by: tison <wander4096@gmail.com>

* a few Buffer to Vec

Signed-off-by: tison <wander4096@gmail.com>

* Make greptime buildable with opendal 0.46 (#5)

Signed-off-by: Xuanwo <github@xuanwo.io>

* fixup toml check

Signed-off-by: tison <wander4096@gmail.com>

* test_orc_opener

Signed-off-by: tison <wander4096@gmail.com>

* Fix lru cache (#6)

Signed-off-by: Xuanwo <github@xuanwo.io>

* clippy

Signed-off-by: tison <wander4096@gmail.com>

* improve comments

Signed-off-by: tison <wander4096@gmail.com>

* address comments

Signed-off-by: tison <wander4096@gmail.com>

* reduce buf copy

Signed-off-by: tison <wander4096@gmail.com>

* upgrade to reqwest 0.12

Signed-off-by: tison <wander4096@gmail.com>

---------

Signed-off-by: tison <wander4096@gmail.com>
Signed-off-by: Xuanwo <github@xuanwo.io>
Co-authored-by: Xuanwo <github@xuanwo.io>
This commit is contained in:
tison
2024-05-27 17:12:23 +08:00
committed by GitHub
parent 20ce7d428d
commit f9db5ff0d6
31 changed files with 631 additions and 443 deletions

View File

@@ -16,14 +16,12 @@ use std::collections::HashMap;
use std::sync::Arc;
use std::time::Duration;
use axum::http::HeaderValue;
use common_base::Plugins;
use common_telemetry::metric::{convert_metric_to_write_request, MetricFilter};
use common_telemetry::{error, info};
use common_time::Timestamp;
use hyper::HeaderMap;
use prost::Message;
use reqwest::header::HeaderName;
use reqwest::header::{HeaderMap, HeaderName, HeaderValue};
use serde::{Deserialize, Serialize};
use session::context::QueryContextBuilder;
use snafu::{ensure, ResultExt};
@@ -115,7 +113,7 @@ impl ExportMetricsTask {
}
);
}
let mut headers = reqwest::header::HeaderMap::new();
let mut headers = HeaderMap::new();
if let Some(remote_write) = &config.remote_write {
ensure!(
!remote_write.url.is_empty(),

View File

@@ -14,10 +14,10 @@
use std::collections::HashMap;
use axum::headers::HeaderValue;
use axum::response::{IntoResponse, Response};
use axum::Json;
use common_query::Output;
use reqwest::header::HeaderValue;
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
use serde_json::Value;

View File

@@ -32,6 +32,7 @@
use std::convert::TryFrom;
use std::net::{SocketAddr, TcpListener};
use std::str::FromStr;
use axum::body::HttpBody;
use axum::BoxError;
@@ -169,7 +170,15 @@ impl RequestBuilder {
HeaderValue: TryFrom<V>,
<HeaderValue as TryFrom<V>>::Error: Into<http::Error>,
{
// TODO(tisonkun): revert once http bump to 1.x
let key: HeaderName = key.try_into().map_err(Into::into).unwrap();
let key = reqwest::header::HeaderName::from_bytes(key.as_ref()).unwrap();
let value: HeaderValue = value.try_into().map_err(Into::into).unwrap();
let value = reqwest::header::HeaderValue::from_bytes(value.as_bytes()).unwrap();
self.builder = self.builder.header(key, value);
self
}
@@ -210,12 +219,19 @@ impl TestResponse {
/// Get the response status.
pub fn status(&self) -> StatusCode {
self.response.status()
StatusCode::from_u16(self.response.status().as_u16()).unwrap()
}
/// Get the response headers.
pub fn headers(&self) -> &http::HeaderMap {
self.response.headers()
pub fn headers(&self) -> http::HeaderMap {
// TODO(tisonkun): revert once http bump to 1.x
let mut headers = http::HeaderMap::new();
for (key, value) in self.response.headers() {
let key = HeaderName::from_str(key.as_str()).unwrap();
let value = HeaderValue::from_bytes(value.as_bytes()).unwrap();
headers.insert(key, value);
}
headers
}
/// Get the response in chunks.