Skip to content

Commit

Permalink
feat: merge cost model with global fallback and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
hopeyen committed Aug 31, 2023
1 parent 1229b78 commit ea26a77
Show file tree
Hide file tree
Showing 11 changed files with 390 additions and 164 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -9,3 +9,4 @@ indexer.toml
# IDE files
.vscode/
migrations/
.sqlx/
18 changes: 13 additions & 5 deletions README.md
Expand Up @@ -7,6 +7,8 @@ Experimental rust impl for The Graph [indexer service](https://github.com/graphp
- switching from actix-web to `axum` for the service server
- App profiling should utilize `perf`, flamegraphs or cpu profilers, and benches to track and collect performance data. The typescript implementation uses `gcloud-profile`
- Consider replacing and adding parts from TAP manager
- `postgres` database connection required to indexer management server database, shared with the indexer agent
- No migration in indexer service as it might introduce conflicts to the database; indexer agent is solely responsible for database management.

> Don't know if receipt validation is actually correct, need testing
Expand All @@ -16,8 +18,8 @@ Experimental rust impl for The Graph [indexer service](https://github.com/graphp
- [x] basic structure
- [x] CORS
- [x] timeouts
- [ ] Rate limiting levels
- [ ] Logger stream
- [x] Rate limiting levels
- [x] Logger stream
- [ ] Query processor
- [x] graph node query endpoint at specific subgraph path
- [x] wrap request to and response from graph node
Expand Down Expand Up @@ -53,9 +55,10 @@ Experimental rust impl for The Graph [indexer service](https://github.com/graphp
- [ ] Status server
- [x] indexing status resolver - to query indexingStatuses
- [ ] Filter for unsupported queries
- [ ] Cost server
- [ ] Cost graphQL schema
- [ ] query indexer management client for Cost model
- [x] Cost server
- [x] Simple indexer management client to track postgres connection and network subgraph endpoint.
- [x] serve queries with defined graphQL schema and psql resolvers to database: `costModel(deployment)` and `costModels(deployments)`. If deployments is empty, all cost models are returned.
- [x] Global cost model fallback used when specific deployments are queried
- [x] Constant service paths
- [x] health
- [x] ready to roll
Expand All @@ -74,6 +77,11 @@ Experimental rust impl for The Graph [indexer service](https://github.com/graphp
### Indexer common components

Temporarily live inside the indexer-service package under `src/common`.
- Simple indexer management client to track NetworkSubgraph and postgres connection.
- ....
- Keeps cost model schema and resolvers with postgres and graphQL types: `costModel(deployment)` and `costModels(deployments)`. If deployments is empty, all cost models are returned.
- Global cost model fallback used when specific deployments are queried
- No migration in indexer service as it might introduce conflicts to the database; indexer agent is solely responsible for database management.


### Indexer native dependency
Expand Down
7 changes: 6 additions & 1 deletion service/src/common/database.rs
Expand Up @@ -20,7 +20,12 @@ pub async fn connect(config: &config::Postgres) -> PgPool {

std::env::set_var("DATABASE_URL", &url);

debug!("Connecting to database");
debug!(
postgres_host = tracing::field::debug(&config.postgres_host),
postgres_port = tracing::field::debug(&config.postgres_port),
postgres_database = tracing::field::debug(&config.postgres_database),
"Connecting to database"
);

PgPoolOptions::new()
.max_connections(50)
Expand Down
@@ -1,10 +1,14 @@
use sqlx::{PgPool, Pool, Postgres};
// Copyright 2023-, GraphOps and Semiotic Labs.
// SPDX-License-Identifier: Apache-2.0

use sqlx::PgPool;

use reqwest::Client;
use serde::{Deserialize, Serialize};
use serde_json::Value;

use super::database::{self};
pub mod resolver;
pub mod schema;

/// Indexer management client
///
Expand Down

0 comments on commit ea26a77

Please sign in to comment.