Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: auto add column #749

Merged
merged 21 commits into from
Mar 22, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Feat proxy prom query (#727)
* feat: impl prom query with proxy

* refactor code
  • Loading branch information
chunshao90 authored Mar 13, 2023
commit 7c4b886e987913725e3c08ed8975e3cf2d18d7df
31 changes: 29 additions & 2 deletions server/src/grpc/storage/mod.rs
Original file line number Diff line number Diff line change
@@ -153,9 +153,36 @@ impl<Q: QueryExecutor + 'static> StorageServiceImpl<Q> {

async fn prom_query_internal(
&self,
_req: tonic::Request<PrometheusQueryRequest>,
req: tonic::Request<PrometheusQueryRequest>,
) -> std::result::Result<tonic::Response<PrometheusQueryResponse>, tonic::Status> {
todo!()
let req = req.into_inner();
let proxy = self.proxy.clone();
let join_handle = self.runtimes.read_runtime.spawn(async move {
if req.context.is_none() {
return PrometheusQueryResponse {
header: Some(error::build_err_header(
StatusCode::BAD_REQUEST.as_u16() as u32,
"database is not set".to_string(),
)),
..Default::default()
};
}

proxy.handle_prom_query(Context::default(), req).await
});

let resp = match join_handle.await {
Ok(v) => v,
Err(e) => PrometheusQueryResponse {
header: Some(error::build_err_header(
StatusCode::INTERNAL_SERVER_ERROR.as_u16() as u32,
format!("fail to join the spawn task, err:{e:?}"),
)),
..Default::default()
},
};

Ok(tonic::Response::new(resp))
}

async fn stream_write_internal(
1 change: 1 addition & 0 deletions server/src/proxy/grpc/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Copyright 2023 CeresDB Project Authors. Licensed under Apache-2.0.

mod prom_query;
mod route;
mod sql_query;
mod write;
Loading