refactor cozohttp into own crate

main
Ziyang Hu 2 years ago
parent 709159e6e3
commit c5a2dd4a84

@ -27,10 +27,7 @@ rmpv = "1.0.0"
base64 = "0.13.0"
chrono = "0.4.19"
ordered-float = { version = "3.0", features = ["serde"] }
actix-web = "4.1.0"
clap = { version = "3.2.8", features = ["derive"] }
itertools = "0.10.3"
actix-cors = "0.6.1"
cozorocks = { path = "cozorocks" }
[target.'cfg(not(target_env = "msvc"))'.dependencies]
@ -40,4 +37,4 @@ tikv-jemallocator = "0.5"
lto = true
[workspace]
members = ["cozorocks"]
members = ["cozorocks", "cozohttp"]

@ -0,0 +1,15 @@
[package]
name = "cozohttp"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
actix-web = "4.1.0"
clap = { version = "3.2.8", features = ["derive"] }
actix-cors = "0.6.1"
log = "0.4.16"
env_logger = "0.9.0"
serde_json = "1.0.81"
cozo = { path = ".." }

@ -2,17 +2,16 @@ use std::fmt::{Debug, Display, Formatter};
use std::path::Path;
use actix_cors::Cors;
use actix_web::{App, HttpResponse, HttpServer, post, Responder, web};
use actix_web::{post, web, App, HttpResponse, HttpServer, Responder};
use clap::Parser;
use log::info;
use cozo::Db;
use cozorocks::DbBuilder;
use cozo::{Db, DbBuilder};
use log::info;
type Result<T> = std::result::Result<T, RespError>;
struct RespError {
err: anyhow::Error,
err: cozo::Error,
}
impl Debug for RespError {
@ -29,8 +28,8 @@ impl Display for RespError {
impl actix_web::error::ResponseError for RespError {}
impl From<anyhow::Error> for RespError {
fn from(err: anyhow::Error) -> RespError {
impl From<cozo::Error> for RespError {
fn from(err: cozo::Error) -> RespError {
RespError { err }
}
}
@ -88,6 +87,7 @@ async fn query(
#[actix_web::main]
async fn main() -> std::io::Result<()> {
env_logger::init();
let args = Args::parse();
if args.temp && Path::new(&args.path).exists() {
panic!(
@ -117,7 +117,7 @@ async fn main() -> std::io::Result<()> {
.service(transact)
.service(transact_attr)
})
.bind(addr)?
.run()
.await
.bind(addr)?
.run()
.await
}

@ -1,8 +1,10 @@
#![warn(rust_2018_idioms, future_incompatible)]
pub use anyhow::Error;
#[cfg(not(target_env = "msvc"))]
use tikv_jemallocator::Jemalloc;
pub use cozorocks::DbBuilder;
pub use data::encode::EncodedVec;
pub use data::id::{AttrId, EntityId, TxId, Validity};
pub use parse::schema::AttrTxItem;
@ -14,7 +16,7 @@ static GLOBAL: Jemalloc = Jemalloc;
pub(crate) mod data;
pub(crate) mod parse;
pub(crate) mod query;
pub(crate) mod runtime;
pub(crate) mod transact;
pub(crate) mod utils;
pub(crate) mod query;

Loading…
Cancel
Save