Skip to content

Commit

Permalink
H-1000: Split the Graph into multiple lib modules (#5609)
Browse files Browse the repository at this point in the history
  • Loading branch information
TimDiekmann authored Nov 10, 2024
1 parent 5896624 commit 327decb
Show file tree
Hide file tree
Showing 195 changed files with 1,309 additions and 1,300 deletions.
103 changes: 57 additions & 46 deletions Cargo.lock

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

8 changes: 3 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ members = [
"libs/@local/codec",
"libs/@local/graph/api",
"libs/@local/graph/authorization",
"libs/@local/graph/graph",
"libs/@local/graph/postgres-store",
"libs/@local/graph/store",
"libs/@local/graph/temporal-versioning",
"libs/@local/graph/test-server",
Expand Down Expand Up @@ -54,15 +54,12 @@ license = "AGPL-3"
publish = false

[workspace.dependencies]
# TODO: Split into other crates
# see https://linear.app/hash/issue/H-1000/split-the-graph-into-multiple-lib-modules
graph.path = "libs/@local/graph/graph"

# Workspace members
error-stack = { path = "./libs/error-stack", default-features = false }
hash-codec.path = "libs/@local/codec"
hash-graph-authorization.path = "libs/@local/graph/authorization"
hash-graph-api.path = "libs/@local/graph/api"
hash-graph-postgres-store.path = "libs/@local/graph/postgres-store"
hash-graph-store.path = "libs/@local/graph/store"
hash-graph-temporal-versioning.path = "libs/@local/graph/temporal-versioning"
hash-graph-test-data.path = "tests/graph/test-data/rust"
Expand Down Expand Up @@ -160,6 +157,7 @@ clap = { version = "=4.5.20", features = ["std", "color", "help", "usage", "erro
clap_complete = { version = "=4.5.37", default-features = false }
coverage-helper = { version = "=0.2.2", default-features = false }
criterion-macro = { version = "=0.4.0", default-features = false }
derive_more = { version = "=1.0.0", default-features = false }
derive-where = { version = "=1.2.7", default-features = false, features = ["nightly"] }
dotenv-flow = { version = "=0.16.2", default-features = false }
expect-test = { version = "=1.5.0", default-features = false }
Expand Down
3 changes: 1 addition & 2 deletions apps/hash-graph/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,12 @@ package-name = "@apps/hash-graph"
# Workspace dependencies
hash-codec = { workspace = true }
error-stack = { workspace = true }
graph = { workspace = true, features = ["clap"] }
hash-graph-postgres-store = { workspace = true, features = ["clap"] }
hash-graph-api = { workspace = true }
hash-graph-authorization = { workspace = true }
hash-graph-store = { workspace = true }
hash-graph-type-fetcher = { workspace = true }
hash-graph-types = { workspace = true }
hash-graph-validation = { workspace = true }
hash-graph-test-server = { workspace = true, optional = true }
hash-temporal-client = { workspace = true }
hash-tracing = { workspace = true, features = ["clap"] }
Expand Down
2 changes: 2 additions & 0 deletions apps/hash-graph/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ This directory contains the code pertaining to the HASH Graph Query Layer. To ru
cargo install just
```

This crate mainly creates a CLI interface to the graph crates defined in the [`libs/@local/graph`](../../libs/@local/graph) directory.

## Run the Graph

1. In order to set up the database, first the database has to be started:
Expand Down
3 changes: 1 addition & 2 deletions apps/hash-graph/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,16 @@
"dependencies": {
"@blockprotocol/type-system-rs": "0.0.0-private",
"@rust/error-stack": "0.5.0",
"@rust/graph": "0.0.0-private",
"@rust/harpc-codec": "0.0.0-private",
"@rust/harpc-server": "0.0.0-private",
"@rust/hash-codec": "0.0.0-private",
"@rust/hash-graph-api": "0.0.0-private",
"@rust/hash-graph-authorization": "0.0.0-private",
"@rust/hash-graph-postgres-store": "0.0.0-private",
"@rust/hash-graph-store": "0.0.0-private",
"@rust/hash-graph-test-server": "0.0.0-private",
"@rust/hash-graph-type-fetcher": "0.0.0-private",
"@rust/hash-graph-types": "0.0.0-private",
"@rust/hash-graph-validation": "0.0.0-private",
"@rust/hash-temporal-client": "0.0.0-private",
"@rust/hash-tracing": "0.0.0-private"
}
Expand Down
2 changes: 1 addition & 1 deletion apps/hash-graph/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ mod error;
mod subcommand;

use error_stack::Report;
use graph::load_env;
use hash_graph_postgres_store::load_env;
use hash_tracing::sentry::{init, release_name};

use self::{args::Args, error::GraphError};
Expand Down
8 changes: 4 additions & 4 deletions apps/hash-graph/src/subcommand/migrate.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use clap::Parser;
use error_stack::{Report, ResultExt as _};
use graph::store::{
DatabaseConnectionInfo, DatabasePoolConfig, PostgresStorePool, StoreMigration as _,
StorePool as _,
};
use hash_graph_authorization::NoAuthorization;
use hash_graph_postgres_store::store::{
DatabaseConnectionInfo, DatabasePoolConfig, PostgresStorePool,
};
use hash_graph_store::{migration::StoreMigration as _, pool::StorePool as _};
use tokio_postgres::NoTls;

use crate::error::GraphError;
Expand Down
12 changes: 7 additions & 5 deletions apps/hash-graph/src/subcommand/reindex_cache.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
use clap::Parser;
use error_stack::{Report, ResultExt as _, ensure};
use graph::store::{
DatabaseConnectionInfo, DatabasePoolConfig, PostgresStorePool, StorePool as _,
knowledge::EntityStore as _, ontology::EntityTypeStore as _,
};
use hash_graph_authorization::NoAuthorization;
use hash_graph_store::data_type::DataTypeStore as _;
use hash_graph_postgres_store::store::{
DatabaseConnectionInfo, DatabasePoolConfig, PostgresStorePool,
};
use hash_graph_store::{
data_type::DataTypeStore as _, entity::EntityStore as _, entity_type::EntityTypeStore as _,
pool::StorePool as _,
};
use tokio_postgres::NoTls;

use crate::error::GraphError;
Expand Down
12 changes: 6 additions & 6 deletions apps/hash-graph/src/subcommand/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,6 @@ use core::{

use clap::Parser;
use error_stack::{Report, ResultExt as _};
use graph::{
ontology::domain_validator::DomainValidator,
store::{
DatabaseConnectionInfo, DatabasePoolConfig, FetchingPool, PostgresStorePool, StorePool,
},
};
use harpc_codec::json::JsonCodec;
use harpc_server::Server;
use hash_graph_api::{
Expand All @@ -25,12 +19,18 @@ use hash_graph_authorization::{
backend::{SpiceDbOpenApi, ZanzibarBackend as _},
zanzibar::ZanzibarClient,
};
use hash_graph_postgres_store::store::{
DatabaseConnectionInfo, DatabasePoolConfig, PostgresStorePool,
};
use hash_graph_store::pool::StorePool;
use hash_graph_type_fetcher::FetchingPool;
use hash_temporal_client::TemporalClientConfig;
use multiaddr::{Multiaddr, Protocol};
use regex::Regex;
use reqwest::{Client, Url};
use tokio::{net::TcpListener, time::timeout};
use tokio_postgres::NoTls;
use type_system::schema::DomainValidator;

use crate::{
error::{GraphError, HealthcheckError},
Expand Down
9 changes: 5 additions & 4 deletions apps/hash-graph/src/subcommand/snapshot.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
use clap::Parser;
use error_stack::{Report, ResultExt as _};
use graph::{
snapshot::{SnapshotDumpSettings, SnapshotEntry, SnapshotStore},
store::{DatabaseConnectionInfo, DatabasePoolConfig, PostgresStorePool, StorePool as _},
};
use hash_codec::bytes::{JsonLinesDecoder, JsonLinesEncoder};
use hash_graph_authorization::{
AuthorizationApi as _, NoAuthorization,
backend::{SpiceDbOpenApi, ZanzibarBackend as _},
zanzibar::ZanzibarClient,
};
use hash_graph_postgres_store::{
snapshot::{SnapshotDumpSettings, SnapshotEntry, SnapshotStore},
store::{DatabaseConnectionInfo, DatabasePoolConfig, PostgresStorePool},
};
use hash_graph_store::pool::StorePool as _;
use tokio::io;
use tokio_postgres::NoTls;
use tokio_util::codec::{FramedRead, FramedWrite};
Expand Down
Loading

0 comments on commit 327decb

Please sign in to comment.