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

Chore/update deps #309

Open
wants to merge 48 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
ce775af
waypoint
hwchen Feb 28, 2021
9cdce85
[waypoint] update futures crate, macros
hwchen Feb 28, 2021
ef0126a
[waypoint] update core for futures and anyhow, turn off stream
hwchen Feb 28, 2021
0384fe2
[core, clickhouse] update clickhouse, Backend trait
hwchen Feb 28, 2021
2343067
[mysql] update deps
hwchen Mar 6, 2021
4dbd6be
[postgres] update deps
hwchen Mar 6, 2021
9adea96
[server] comment out logic layer temp
hwchen Mar 7, 2021
41c832e
[server] change lots of fn sigs, clean diagnosis handler
hwchen Mar 21, 2021
42a2598
[server] in handlers::util, comment out macros and redis
hwchen Mar 22, 2021
3640437
[server] clean handlers::metadata
hwchen Mar 22, 2021
a684d21
[server] clean handlers::aggregate
hwchen Mar 22, 2021
84e04b6
more cleanly disable aggregate_stream
hwchen Apr 4, 2021
e800f90
fix LL cache and config
hwchen Apr 4, 2021
18f6d86
fix backend `into` error
hwchen Apr 4, 2021
3d85726
weird fix deref error for Status
hwchen Apr 4, 2021
b4a890b
[server] clean main
hwchen Apr 4, 2021
4e312b3
[server] remove actix::system
hwchen Apr 4, 2021
255c695
[server] fix async problem with ll cache
hwchen Apr 4, 2021
3775479
[server] fix llconfig init
hwchen Apr 5, 2021
ef87055
[test] disable end-to-end, to be reworked
hwchen Oct 4, 2021
3e1b9b4
[clickhouse] fix options for current driver
hwchen Oct 4, 2021
4a52375
[server] derive Default for cache
hwchen Oct 4, 2021
7bf8f8e
[server] cli option for no ll
hwchen Oct 5, 2021
a3f3b86
[server] construct AppState directly in main
hwchen Oct 5, 2021
7c049a9
[server] dont mitigate sql injection if no ll cache available
hwchen Oct 5, 2021
ad350f2
server: simplify handler module structure
hwchen Oct 11, 2021
40a22ee
server: simplifiy ll module structure naming
hwchen Oct 11, 2021
a22d93f
ll server: remove box utils
hwchen Oct 11, 2021
52090c2
ll server: comment out redis
hwchen Oct 11, 2021
513e93f
ll server: replace failure with anyhow
hwchen Oct 11, 2021
7894721
ll server: comment out redis insert cache
hwchen Oct 11, 2021
2553d25
ll server: clean metadata
hwchen Oct 11, 2021
3236231
ll server clean geoservice mod
hwchen Oct 11, 2021
2880823
ll server: clean relations and geoservice
hwchen Oct 11, 2021
ed8e067
ll server: clean aggregate
hwchen Oct 11, 2021
1da1cd3
server: fix app borrowing
hwchen Oct 11, 2021
87e6260
server: diagnosis compiler warnings
hwchen Oct 11, 2021
308ce12
server: ll warnings
hwchen Oct 11, 2021
c66065e
server: more warnings
hwchen Oct 11, 2021
c823c05
clickhouse: rate warning
hwchen Oct 11, 2021
4237359
server: update redis cache
hwchen Oct 11, 2021
132ea78
remove outdated cookie replace
hwchen Oct 11, 2021
59f6f89
temp for acceptance: switch clickhouse readonly
hwchen Nov 6, 2021
bf07d57
fix order for SourceMetadata usin indexmap
hwchen Nov 6, 2021
e9e8ff4
temp hack to use env var to switch clickhouse legacy readonly
hwchen Nov 6, 2021
5a4b23b
switch redis cache back on, add logging
hwchen Nov 6, 2021
26c9b4e
remove unnecessary comment
hwchen Nov 7, 2021
f342857
add logging to jwt auth
hwchen Nov 7, 2021
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
3,837 changes: 2,474 additions & 1,363 deletions Cargo.lock

Large diffs are not rendered by default.

11 changes: 6 additions & 5 deletions tesseract-clickhouse/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,16 @@ name = "tesseract-clickhouse"
version = "0.1.0"

[dependencies]
clickhouse-rs = "0.1.20"
failure = "0.1.2"
futures = "0.1.25"
itertools = "0.8.0"
async-trait = "0.1.42"
clickhouse-rs = "1.0.0-alpha.1"
anyhow = "1"
futures = "0.3.13"
itertools = "0.10.0"
log = "0.4.3"
regex = "1"

[dependencies.tesseract-core]
path = "../tesseract-core"

[dev-dependencies]
tokio = "0.1.22"
tokio = { version = "1.0", features = ["rt", "macros"] }
2 changes: 1 addition & 1 deletion tesseract-clickhouse/src/df.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Convert clickhouse Block to tesseract_core::DataFrame

use failure::{Error, bail};
use anyhow::{Error, bail};

use clickhouse_rs::types::{Block, ColumnType, Complex, Simple, SqlType};
use tesseract_core::{DataFrame, Column, ColumnData};
Expand Down
63 changes: 29 additions & 34 deletions tesseract-clickhouse/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use anyhow::Error;
use async_trait::async_trait;
use clickhouse_rs::Pool;
use clickhouse_rs::types::{Options, Simple, Complex, Block};
use failure::{Error, format_err};
use futures::{future, Future, Stream};
use clickhouse_rs::types::Options;
use log::*;
use std::time::{Duration, Instant};
use tesseract_core::{Backend, DataFrame, QueryIr};
Expand All @@ -11,7 +11,7 @@ use regex::Regex;
mod df;
mod sql;

use self::df::{block_to_df};
use self::df::block_to_df;
use self::sql::clickhouse_sql;

// Ping timeout in millis
Expand Down Expand Up @@ -47,42 +47,37 @@ impl Clickhouse {
}
}

#[async_trait]
impl Backend for Clickhouse {
fn exec_sql(&self, sql: String) -> Box<dyn Future<Item=DataFrame, Error=Error>> {
async fn exec_sql(&self, sql: String) -> Result<DataFrame, Error> {
let time_start = Instant::now();

let fut = self.pool
.get_handle()
.and_then(move |c| c.query(&sql[..]).fetch_all())
.from_err()
.and_then(move |(_, block): (_, Block<Complex>)| {
let timing = time_start.elapsed();
info!("Time for sql execution: {}.{:03}", timing.as_secs(), timing.subsec_millis());
//debug!("Block: {:?}", block);
let mut client = self.pool.get_handle().await?;
let block = client.query(&sql[..]).fetch_all().await?;
let timing = time_start.elapsed();
info!("Time for sql execution: {}.{:03}", timing.as_secs(), timing.subsec_millis());
//debug!("Block: {:?}", block);

Ok(block_to_df(block)?)
});

Box::new(fut)
Ok(block_to_df(block)?)
}

fn exec_sql_stream(&self, sql: String) -> Box<dyn Stream<Item=Result<DataFrame, Error>, Error=Error>> {
let fut_stream = self.pool
.get_handle()
.and_then(move |c| {
future::ok(
c.query(&sql[..])
.stream_blocks()
.map(move |block: Block<Simple>| {
block_to_df(block)
})
)
})
.flatten_stream()
.map_err(|err| format_err!("{}", err));

Box::new(fut_stream)
}
//fn exec_sql_stream(&self, sql: String) -> Box<dyn Stream<Item=Result<DataFrame, Error>, Error=Error>> {
// let fut_stream = self.pool
// .get_handle()
// .and_then(move |c| {
// future::ok(
// c.query(&sql[..])
// .stream_blocks()
// .map(move |block: Block<Simple>| {
// block_to_df(block)
// })
// )
// })
// .flatten_stream()
// .map_err(|err| format_err!("{}", err));

// Box::new(fut_stream)
//}

// https://users.rust-lang.org/t/solved-is-it-possible-to-clone-a-boxed-trait-object/1714/4
fn box_clone(&self) -> Box<dyn Backend + Send + Sync> {
Expand Down
74 changes: 23 additions & 51 deletions tesseract-clickhouse/tests/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,43 +3,26 @@ extern crate tokio;

// Basic testing structured taken from
// clickhouse-rs database tests by suharev7.
use tokio::prelude::*;
use std::{
env
};
use clickhouse_rs::{
types::Block, ClientHandle, Pool,
};
use clickhouse_rs::types::Complex;
use std::env;
use clickhouse_rs::Pool;

fn database_url() -> String {
let tmp = env::var("TESSERACT_DATABASE_URL").unwrap_or_else(|_| "tcp://localhost:9000?compression=lz4".into());
tmp.replace("clickhouse://", "tcp://")
}

fn run<F, T, U>(future: F) -> Result<T, U>
where
F: Future<Item = T, Error = U> + Send + 'static,
T: Send + 'static,
U: Send + 'static,
{
let mut runtime = tokio::runtime::Runtime::new().unwrap();
let result = runtime.block_on(future);
runtime.shutdown_on_idle().wait().unwrap();
result
}

#[test]
fn test_ping() {
#[tokio::test]
async fn test_ping() {
// This test is meant as a sanity check
// to ensure the docker provisioning process worked
let pool = Pool::new(database_url());
let done = pool.get_handle().and_then(ClientHandle::ping).map(|_| ());
run(done).unwrap()
println!("{:?}", pool);
let mut client = pool.get_handle().await.unwrap();
client.ping().await.unwrap();
}

#[test]
fn test_query() {
#[tokio::test]
async fn test_query() {
#[derive(Debug, Clone, PartialEq)]
pub struct RowResult {
pub month_name: String,
Expand All @@ -49,29 +32,18 @@ fn test_query() {
// to ensure the SQL ingestion worked
let pool = Pool::new(database_url());
let sql = "SELECT month_name FROM tesseract_webshop_time;";
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@frabarz wanted to ask about this table in the test. It seems to be hardcoded, without any initialization. I'm not quite sure why the test needed here, seems like it's testing something very specific in a workflow.

let fut = pool.get_handle()
.and_then(move |c| {
c.query(&sql).fetch_all()
})
.and_then(move |(_, block): (_, Block<Complex>)| {
let schema_vec: Vec<RowResult> = block.rows().map(|row| {
RowResult {
month_name: row.get("month_name").expect("missing month_name"),
}
}).collect();
Ok(schema_vec)
});
let mut client = pool.get_handle().await.unwrap();
let block = client.query(&sql).fetch_all().await.unwrap();

let res = run(fut);
let status = match res {
Ok(val) => {
println!("Value={:?}", val);
val.len() == 12
}
Err(err) => {
println!("Query failed. Error={:?}", err);
false
}
};
assert!(status);
}
let schema_vec: Vec<RowResult> = block.rows()
.map(|row| {
RowResult {
month_name: row.get("month_name").expect("missing month_name"),
}
}).collect();

assert_eq!(
schema_vec.len(),
12
);
}
5 changes: 3 additions & 2 deletions tesseract-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ name = "tesseract-core"
version = "0.1.0"

[dependencies]
anyhow = "1"
async-trait = "0.1.42"
bytes = "0.4.12"
csv = "1.0.2"
failure = "0.1.3"
futures = "0.1.25"
futures = "0.3.13"
itertools = "0.7.11"
log = "0.4.3"
serde = "1.0.71"
Expand Down
19 changes: 10 additions & 9 deletions tesseract-core/src/backend.rs
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
use failure::Error;
use futures::{Future, Stream};
use anyhow::Error;
use async_trait::async_trait;

use crate::dataframe::DataFrame;
use crate::query_ir::QueryIr;
use crate::sql;


#[async_trait]
pub trait Backend {
/// Takes in a SQL string, outputs a DataFrame, which will go on to be formatted into the
/// desired query output format.
fn exec_sql(&self, sql: String) -> Box<dyn Future<Item=DataFrame, Error=Error>>;
async fn exec_sql(&self, sql: String) -> Result<DataFrame, Error>;

/// Takes in a SQL string, outputs a stream of
/// DataFrames, which will go on to be formatted into the
/// desired query output format.
fn exec_sql_stream(&self, sql: String) -> Box<dyn Stream<Item=Result<DataFrame, Error>, Error=Error>> {
unimplemented!()
}
///// Takes in a SQL string, outputs a stream of
///// DataFrames, which will go on to be formatted into the
///// desired query output format.
//fn exec_sql_stream(&self, sql: String) -> Box<dyn Stream<Item=Result<DataFrame, Error>>> {
// unimplemented!()
//}

fn box_clone(&self) -> Box<dyn Backend + Send + Sync>;

Expand Down
2 changes: 1 addition & 1 deletion tesseract-core/src/dataframe.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use failure::{Error, format_err};
use anyhow::{Error, format_err};


#[derive(Debug)]
Expand Down
2 changes: 1 addition & 1 deletion tesseract-core/src/format.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use csv;
use failure::{Error, format_err};
use anyhow::{Error, format_err};
use indexmap::IndexMap;
use serde::Serializer;
use serde::ser::{SerializeSeq};
Expand Down
2 changes: 2 additions & 0 deletions tesseract-core/src/format_stream.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/// Currently dead code, until module gets switched back on.

use bytes::Bytes;
use csv;
use failure::{Error, format_err};
Expand Down
7 changes: 5 additions & 2 deletions tesseract-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@ mod backend;
mod dataframe;
mod sql;
pub mod format;
pub mod format_stream;

// fix Stream later; it's kind of a pain for now.
//pub mod format_stream;

pub mod names;
pub mod schema;
pub mod query;
pub mod query_ir;

use failure::{Error, format_err, bail};
use anyhow::{Error, format_err, bail};
use log::*;
use serde_xml_rs as serde_xml;
use serde_xml::from_reader;
Expand Down
2 changes: 1 addition & 1 deletion tesseract-core/src/names.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
// - Dimension.Level
// etc.

use failure::{Error, bail, format_err, ensure};
use anyhow::{Error, bail, format_err, ensure};
use serde_derive::{Deserialize, Serialize};
use std::fmt;
use std::str::FromStr;
Expand Down
2 changes: 1 addition & 1 deletion tesseract-core/src/query.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use itertools::join;

use failure::{Error, format_err, bail};
use anyhow::{Error, format_err, bail};
use std::str::FromStr;

use crate::names::{
Expand Down
2 changes: 1 addition & 1 deletion tesseract-core/src/schema.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use serde_derive::{Serialize, Deserialize};
use std::convert::From;
use failure::{Error, format_err};
use anyhow::{Error, format_err};

pub mod aggregator;
pub mod metadata;
Expand Down
30 changes: 15 additions & 15 deletions tesseract-server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,18 @@ edition = "2018"
name = "tesseract-olap"
version = "0.14.13"

[package.metadata.deb]
maintainer = "Walther Chen <[email protected]>"
extended-description = "Olap engine for serving web applications"
depends = "$auto"
section = "Web Servers"
priority = "optional"
assets = [ [ "../target/release/tesseract-olap", "usr/bin/", "755",], [ "pkg/deb/tesseract-olap.service", "/etc/systemd/system/tesseract-olap.service", "644",],]
maintainer-scripts = "pkg/deb/maintainer-scripts"

[dependencies]
actix = "0.7.7"
anyhow = "1"
dotenv = "0.13.0"
failure = "0.1.2"
futures = "0.1.25"
lazy_static = "1.2.0"
log = "0.4.3"
pretty_env_logger = "0.2.4"
Expand All @@ -20,14 +27,16 @@ serde_derive = "1.0.70"
serde_json = "1.0.33"
serde_qs = "0.4.1"
structopt = "0.2.13"
thiserror = "1"
mime = "0.3.13"
url = "2.1.0"
jsonwebtoken = "6"
jsonwebtoken = "7"
r2d2_redis = "0.13.0"
futures = "0.3.13"

[dependencies.actix-web]
version = "0.7.18"
features = [ "ssl",]
version = "4.0.0-beta.3"
features = [ "rustls",]

[dependencies.tesseract-clickhouse]
path = "../tesseract-clickhouse"
Expand All @@ -40,12 +49,3 @@ path = "../tesseract-postgres"

[dependencies.tesseract-core]
path = "../tesseract-core"

[package.metadata.deb]
maintainer = "Walther Chen <[email protected]>"
extended-description = "Olap engine for serving web applications"
depends = "$auto"
section = "Web Servers"
priority = "optional"
assets = [ [ "../target/release/tesseract-olap", "usr/bin/", "755",], [ "pkg/deb/tesseract-olap.service", "/etc/systemd/system/tesseract-olap.service", "644",],]
maintainer-scripts = "pkg/deb/maintainer-scripts"
Loading