Skip to content

Commit

Permalink
fix: use graph-node-status-endpoint for DeploymentDetail status_url
Browse files Browse the repository at this point in the history
  • Loading branch information
hopeyen committed Nov 8, 2023
1 parent f43900c commit 7966e7e
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 12 deletions.
52 changes: 40 additions & 12 deletions common/src/subgraph_client/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,13 @@ pub struct DeploymentDetails {

impl DeploymentDetails {
pub fn for_graph_node(
graph_node_status_url: &str,
graph_node_base_url: &str,
deployment: DeploymentId,
) -> Result<Self, anyhow::Error> {
Ok(Self {
deployment: Some(deployment),
status_url: Some(Url::parse(&format!("{graph_node_base_url}/status"))?),
status_url: Some(Url::parse(graph_node_status_url)?),
query_url: Url::parse(&format!("{graph_node_base_url}/subgraphs/id/{deployment}"))?,
})
}
Expand Down Expand Up @@ -206,8 +207,8 @@ mod test {
let deployment =
DeploymentId::from_str("QmAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA").unwrap();

let mock_server_local = MockServer::start().await;
mock_server_local
let mock_server_status = MockServer::start().await;
mock_server_status
.register(
Mock::given(method("POST"))
.and(path("/status"))
Expand All @@ -223,6 +224,8 @@ mod test {
}))),
)
.await;

let mock_server_local = MockServer::start().await;
mock_server_local
.register(
Mock::given(method("POST"))
Expand Down Expand Up @@ -255,7 +258,14 @@ mod test {
// Create the subgraph client
let client = SubgraphClient::new(
reqwest::Client::new(),
Some(DeploymentDetails::for_graph_node(&mock_server_local.uri(), deployment).unwrap()),
Some(
DeploymentDetails::for_graph_node(
&mock_server_status.uri(),
&mock_server_local.uri(),
deployment,
)
.unwrap(),
),
DeploymentDetails::for_query_url(&format!(
"{}/subgraphs/id/{}",
mock_server_remote.uri(),
Expand All @@ -278,8 +288,8 @@ mod test {
let deployment =
DeploymentId::from_str("QmAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA").unwrap();

let mock_server_local = MockServer::start().await;
mock_server_local
let mock_server_status = MockServer::start().await;
mock_server_status
.register(
Mock::given(method("POST"))
.and(path("/status"))
Expand All @@ -288,13 +298,15 @@ mod test {
"indexingStatuses": [
{
"synced": true,
"health": "unhealthy"
"health": "healthy"
}
]
}
}))),
)
.await;

let mock_server_local = MockServer::start().await;
mock_server_local
.register(
Mock::given(method("POST"))
Expand Down Expand Up @@ -327,7 +339,14 @@ mod test {
// Create the subgraph client
let client = SubgraphClient::new(
reqwest::Client::new(),
Some(DeploymentDetails::for_graph_node(&mock_server_local.uri(), deployment).unwrap()),
Some(
DeploymentDetails::for_graph_node(
&mock_server_status.uri(),
&mock_server_local.uri(),
deployment,
)
.unwrap(),
),
DeploymentDetails::for_query_url(&format!(
"{}/subgraphs/id/{}",
mock_server_remote.uri(),
Expand All @@ -350,23 +369,25 @@ mod test {
let deployment =
DeploymentId::from_str("QmAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA").unwrap();

let mock_server_local = MockServer::start().await;
mock_server_local
let mock_server_status = MockServer::start().await;
mock_server_status
.register(
Mock::given(method("POST"))
.and(path("/status"))
.respond_with(ResponseTemplate::new(200).set_body_json(json!({
"data": {
"indexingStatuses": [
{
"synced": false,
"synced": true,
"health": "healthy"
}
]
}
}))),
)
.await;

let mock_server_local = MockServer::start().await;
mock_server_local
.register(
Mock::given(method("POST"))
Expand Down Expand Up @@ -399,7 +420,14 @@ mod test {
// Create the subgraph client
let client = SubgraphClient::new(
reqwest::Client::new(),
Some(DeploymentDetails::for_graph_node(&mock_server_local.uri(), deployment).unwrap()),
Some(
DeploymentDetails::for_graph_node(
&mock_server_status.uri(),
&mock_server_local.uri(),
deployment,
)
.unwrap(),
),
DeploymentDetails::for_query_url(&format!(
"{}/subgraphs/id/{}",
mock_server_remote.uri(),
Expand Down
2 changes: 2 additions & 0 deletions service/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ async fn main() -> Result<(), std::io::Error> {
.network_subgraph_deployment
.map(|deployment| {
DeploymentDetails::for_graph_node(
&config.indexer_infrastructure.graph_node_status_endpoint,
&config.indexer_infrastructure.graph_node_query_endpoint,
deployment,
)
Expand Down Expand Up @@ -128,6 +129,7 @@ async fn main() -> Result<(), std::io::Error> {
.escrow_subgraph_deployment
.map(|deployment| {
DeploymentDetails::for_graph_node(
&config.indexer_infrastructure.graph_node_status_endpoint,
&config.indexer_infrastructure.graph_node_query_endpoint,
deployment,
)
Expand Down

0 comments on commit 7966e7e

Please sign in to comment.