Skip to content

Commit

Permalink
Merge pull request #187 from cornucopia-rs/workspace_improvements
Browse files Browse the repository at this point in the history
Workspace improvements
  • Loading branch information
LouisGariepy authored Feb 8, 2023
2 parents 282cada + b5b3c9d commit 5098729
Show file tree
Hide file tree
Showing 83 changed files with 874 additions and 1,425 deletions.
118 changes: 85 additions & 33 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 5 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
[workspace]
members = [
"examples/*",
"clients/*",
"integration",
"codegen_test",
"bench",
"cornucopia",
"codegen_template",
"examples/*",
"test_integration",
"test_codegen",
"benches",
"crates/*",
]
Binary file removed assets/CornucopiaDiagram.png
Binary file not shown.
24 changes: 16 additions & 8 deletions bench/Cargo.toml → benches/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,27 +1,35 @@
[package]
name = "bench"
name = "benches"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
# Path dependencies
cornucopia = { path = "../crates/cornucopia" }
cornucopia_sync = { path = "../crates/client_sync" }
cornucopia_async = { path = "../crates/client_async" }

# benchmarking
criterion = { version = "0.4.0", features = ["html_reports"] }

# async
tokio = { version = "1.24.2", features = ["full"] }
futures = "0.3.25"
criterion = { version = "0.4.0", features = ["html_reports"] }

# rust-postgres interaction
postgres = "0.19.4"
tokio-postgres = "0.7.7"
postgres-types = "0.2.4"
diesel = { version = "2.0.2", features = ["postgres"] }

cornucopia = { path = "../cornucopia" }
cornucopia_sync = { path = "../clients/sync" }
cornucopia_async = { path = "../clients/async" }
# diesel
diesel = { version = "2.0.2", features = ["postgres"] }

[[bench]]
name = "usage"
name = "execution"
harness = false
path = "usage/main.rs"
path = "execution/main.rs"

[[bench]]
name = "codegen"
Expand Down
3 changes: 3 additions & 0 deletions benches/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Benchmarking suite for code generation and code execution, heavily based on [the diesel benchmarking suite](https://github.com/diesel-rs/diesel/tree/master/diesel_bench).

Note that the benchmarks use the `diesel` crate which links directly against `libpq`, so you will need to install it. On debian-based distros, the package is `libpq-dev`, and on RHEl-based distros, it is named `libpq-devel`.
4 changes: 2 additions & 2 deletions bench/codegen.rs → benches/codegen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ fn bench(c: &mut Criterion) {
b.iter(|| {
cornucopia::generate_live(
client,
"../codegen_test/queries",
"../test_codegen/queries",
None,
CodegenSettings {
gen_sync: true,
Expand All @@ -26,7 +26,7 @@ fn bench(c: &mut Criterion) {
b.iter(|| {
cornucopia::generate_live(
client,
"../codegen_test/queries",
"../test_codegen/queries",
None,
CodegenSettings {
gen_sync: true,
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions bench/usage/main.rs → benches/execution/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ fn bench(c: &mut Criterion) {
let conn =
&mut PgConnection::establish("postgresql://postgres:postgres@127.0.0.1:5435/postgres")
.unwrap();

cornucopia::load_schema(client, &["usage/cornucopia_benches/schema.sql"]).unwrap();
{
let mut group = c.benchmark_group("bench_trivial_query");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use criterion::Bencher;
use postgres::fallible_iterator::FallibleIterator;
use postgres::types::ToSql;
use postgres::Client;
use postgres::{fallible_iterator::FallibleIterator, Client};
use std::collections::HashMap;
use std::fmt::Write;

Expand Down Expand Up @@ -65,7 +64,7 @@ pub fn bench_medium_complex_query(b: &mut Bencher, client: &mut Client) {
name: row.get(1),
hair_color: row.get(2),
};
let post = row.get::<usize, Option<i32>>(3).map(|id| Post {
let post = row.get::<_, Option<i32>>(3).map(|id| Post {
id,
user_id: row.get(4),
title: row.get(5),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ pub fn bench_medium_complex_query(b: &mut Bencher, client: &mut Client) {
name: row.get(1),
hair_color: row.get(2),
},
row.get::<usize, Option<i32>>(3).map(|id| Post {
row.get::<_, Option<i32>>(3).map(|id| Post {
id,
user_id: row.get(4),
title: row.get(5),
Expand Down
13 changes: 0 additions & 13 deletions codegen_template/Cargo.toml

This file was deleted.

12 changes: 9 additions & 3 deletions clients/async/Cargo.toml → crates/client_async/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,14 @@ with-serde_json-1 = ["cornucopia_client_core/with-serde_json-1"]
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
tokio-postgres = "0.7.7"
# Path dependencies
cornucopia_client_core = { path = "../client_core", version = "0.4.0" }

# async
async-trait = "0.1.63"
deadpool-postgres = { version = "0.10.4", optional = true }

cornucopia_client_core = { path = "../core", version = "0.4.0" }
# rust-postgres interaction
tokio-postgres = "0.7.7"

# connection pooling
deadpool-postgres = { version = "0.10.4", optional = true }
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
19 changes: 11 additions & 8 deletions clients/core/Cargo.toml → crates/client_core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,19 @@ keywords = ["postgresql", "query", "generator", "sql", "tokio-postgres"]

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[features]
with-serde_json-1 = ["postgres-types/with-serde_json-1", "serde", "serde_json"]

[dependencies]
# Postgres interaction
postgres-protocol = "0.6.4"
postgres-types = "0.2.4"
## Iterator utils required for working with `postgres_protocol::types::ArrayValues`
fallible-iterator = "0.2.0"
serde-1 = { version = "1.0.152", package = "serde", optional = true }
serde_json-1 = { version = "1.0.91", package = "serde_json", optional = true }

[features]
with-serde_json-1 = [
"postgres-types/with-serde_json-1",
"serde-1",
"serde_json-1",
]
# json
## This crate implements the "ergonomic paramters" for
## `serde_json::Value` and `serde_json::raw::RawValue`.
serde_json = { version = "1.0.91", optional = true }
## Used for `postgres_types::Json` `Serialize` trait bounds
serde = { version = "1.0.152", optional = true }
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,9 @@ pub trait JsonSql: std::fmt::Debug + ToSql + Sync + Send {}
#[cfg(feature = "with-serde_json-1")]
impl<T: JsonSql> JsonSql for &T {}
#[cfg(feature = "with-serde_json-1")]
impl JsonSql for serde_json_1::value::Value {}
impl JsonSql for serde_json::value::Value {}
#[cfg(feature = "with-serde_json-1")]
impl<T: serde_1::ser::Serialize + std::fmt::Debug + Sync + Send> JsonSql
for postgres_types::Json<T>
{
}
impl<T: serde::ser::Serialize + std::fmt::Debug + Sync + Send> JsonSql for postgres_types::Json<T> {}

pub trait ArraySql: std::fmt::Debug + ToSql + Send + Sync {
type Item;
Expand Down
File renamed without changes.
12 changes: 7 additions & 5 deletions clients/sync/Cargo.toml → crates/client_sync/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@ keywords = ["postgresql", "query", "generator", "sql", "tokio-postgres"]

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
postgres = "0.19.4"

cornucopia_client_core = { path = "../core", version = "0.4.0" }

[features]
with-serde_json-1 = ["cornucopia_client_core/with-serde_json-1"]

[dependencies]
# Path dependencies
cornucopia_client_core = { path = "../client_core", version = "0.4.0" }

# postgres interaction
postgres = "0.19.4"
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 5098729

Please sign in to comment.