Skip to content

Commit e9f7d1a

Browse files
authored
chore(dips): add rpc and db feature flags to indexer-dips crate (#636)
Signed-off-by: Lorenzo Delgado <[email protected]>
1 parent fed7619 commit e9f7d1a

File tree

6 files changed

+48
-44
lines changed

6 files changed

+48
-44
lines changed

Cargo.lock

Lines changed: 5 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/dips/Cargo.toml

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,33 +3,33 @@ name = "indexer-dips"
33
version = "0.1.0"
44
edition = "2021"
55

6+
[features]
7+
default = ["rpc", "db"]
8+
rpc = ["dep:prost", "dep:tonic", "dep:tonic-build", "dep:bytes"]
9+
db = ["dep:sqlx"]
10+
611
[dependencies]
7-
axum.workspace = true
8-
build-info.workspace = true
9-
thiserror.workspace = true
1012
anyhow.workspace = true
11-
alloy-rlp = "0.3.10"
12-
thegraph-core.workspace = true
13-
tonic.workspace = true
14-
async-trait.workspace = true
15-
prost.workspace = true
16-
prost-types.workspace = true
17-
uuid.workspace = true
18-
base64.workspace = true
19-
tokio.workspace = true
20-
sqlx.workspace = true
13+
async-trait.workspace = true
14+
build-info.workspace = true
15+
bytes = { version = "1.10.0", optional = true }
16+
derivative = "2.2.0"
2117
futures = "0.3"
22-
2318
http = "0.2"
24-
derivative = "2.2.0"
25-
ipfs-api-backend-hyper = {version = "0.6.0", features = ["with-send-sync"] }
26-
ipfs-api-prelude = {version = "0.6.0", features = ["with-send-sync"] }
27-
bytes = "1.10.0"
28-
serde_yaml.workspace = true
19+
ipfs-api-backend-hyper = { version = "0.6.0", features = ["with-send-sync"] }
20+
ipfs-api-prelude = { version = "0.6.0", features = ["with-send-sync"] }
21+
prost = { workspace = true, optional = true }
2922
serde.workspace = true
23+
serde_yaml.workspace = true
24+
sqlx = { workspace = true, optional = true }
25+
thegraph-core.workspace = true
26+
thiserror.workspace = true
27+
tokio.workspace = true
28+
tonic = { workspace = true, optional = true }
29+
uuid.workspace = true
3030

3131
[dev-dependencies]
3232
rand = "0.9.0"
3333

3434
[build-dependencies]
35-
tonic-build = { workspace = true }
35+
tonic-build = { workspace = true, optional = true }

crates/dips/build.rs

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,22 @@
22
// SPDX-License-Identifier: Apache-2.0
33

44
fn main() {
5-
println!("cargo:rerun-if-changed=proto");
6-
tonic_build::configure()
7-
.out_dir("src/proto")
8-
.include_file("indexer.rs")
9-
.protoc_arg("--experimental_allow_proto3_optional")
10-
.compile_protos(&["proto/indexer.proto"], &["proto/"])
11-
.expect("Failed to compile DIPs indexer RPC proto(s)");
5+
#[cfg(feature = "rpc")]
6+
{
7+
println!("cargo:rerun-if-changed=proto");
128

13-
tonic_build::configure()
14-
.out_dir("src/proto")
15-
.include_file("gateway.rs")
16-
.protoc_arg("--experimental_allow_proto3_optional")
17-
.compile_protos(&["proto/gateway.proto"], &["proto"])
18-
.expect("Failed to compile DIPs gateway RPC proto(s)");
9+
tonic_build::configure()
10+
.out_dir("src/proto")
11+
.include_file("indexer.rs")
12+
.protoc_arg("--experimental_allow_proto3_optional")
13+
.compile_protos(&["proto/indexer.proto"], &["proto/"])
14+
.expect("Failed to compile DIPs indexer RPC proto(s)");
15+
16+
tonic_build::configure()
17+
.out_dir("src/proto")
18+
.include_file("gateway.rs")
19+
.protoc_arg("--experimental_allow_proto3_optional")
20+
.compile_protos(&["proto/gateway.proto"], &["proto"])
21+
.expect("Failed to compile DIPs gateway RPC proto(s)");
22+
}
1923
}

crates/dips/src/database.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
use std::str::FromStr;
55

6-
use axum::async_trait;
6+
use async_trait::async_trait;
77
use build_info::chrono::{DateTime, Utc};
88
use sqlx::{types::BigDecimal, PgPool};
99
use thegraph_core::alloy::{core::primitives::U256 as uint256, hex::ToHexExt, sol_types::SolType};

crates/dips/src/ipfs.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33

44
use std::{str::FromStr, sync::Arc};
55

6+
use async_trait::async_trait;
67
use derivative::Derivative;
78
use futures::TryStreamExt;
89
use http::Uri;
910
use ipfs_api_prelude::{IpfsApi, TryFromUri};
1011
use serde::Deserialize;
11-
use tonic::async_trait;
1212

1313
use crate::DipsError;
1414

crates/dips/src/lib.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,13 @@ use thegraph_core::alloy::{
1313
sol_types::{eip712_domain, Eip712Domain, SolStruct, SolValue},
1414
};
1515

16+
#[cfg(feature = "db")]
1617
pub mod database;
1718
pub mod ipfs;
1819
pub mod price;
20+
#[cfg(feature = "rpc")]
1921
pub mod proto;
22+
#[cfg(feature = "rpc")]
2023
pub mod server;
2124
pub mod store;
2225

@@ -165,6 +168,7 @@ pub enum DipsError {
165168
}
166169

167170
// TODO: send back messages
171+
#[cfg(feature = "rpc")]
168172
impl From<DipsError> for tonic::Status {
169173
fn from(_val: DipsError) -> Self {
170174
tonic::Status::internal("unknown errr")

0 commit comments

Comments
 (0)