Skip to content

Commit

Permalink
feat: status reqwest timeout and docs
Browse files Browse the repository at this point in the history
  • Loading branch information
hopeyen committed Aug 28, 2023
1 parent 6f0dd93 commit 20c48f9
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@ When developers publish a new version (subgraph deployment) to their subgraph, d

Indexers running the subgraph radio and listening to that channel will in turn receive the message and potentially start to offchain new deployment.

It is still at the subgraph developers' discretion to await for the indexers to sync upto chainhead, in which point they can publish the staged version without disrupting API usage.
It is still at the subgraph developers' discretion to await for the indexers to sync upto chainhead, in which point they can publish the staged version without disrupting API usage. This tool provides a convinence function that allows subgraph developer to ....

## 🆙 Example usage

### UpgradePresync

To send a message on Graphcast mainnet for the subgraph deployment "QmacQnSgia4iDPWHpeY6aWxesRFdb8o5DKZUx96zZqEWrB", we would need its subgraph id "CnJMdCkW3pr619gsJVtUPAWxspALPdCMw6o7obzYBNp3", private key to the graph account or an operator of the graph account, the subgraph owner's graph account, and the new deployment hash. You can supply them as an CLI argument

```
Expand All @@ -40,6 +42,15 @@ The entire process from running the binary to sending the message should take ~4
2023-07-31T17:56:59.328490Z INFO Sent message, msg_id: "0xc6b1131e0f8302abe48057f6fc69722ab46bd4285c2c4a8a8bdca6b221dcda96"
```

### IndexingStatus

After sending `UpgradeIntentMessage`, a developer can periodically check the indexing status of the new subgraph deployment at the public APIs of the indexers who actively allocates on the current version of the subgraph.

Same arguments here can be used as the argument for `UpgradeIntentMessage`. However, gossips are not involved in this operation and the queries are made through deterministic queries.

```
cargo run indexing-status --subgraph-id "0x00000444e5a1a667663b0adfd853e8efa0470698-0" --new-hash QmfDJFYaDX7BdwT6rYa8Bx71vPjTueUVDN99pdwFgysDiZ
```

## 🧪 Testing

Expand Down
2 changes: 0 additions & 2 deletions src/operator/operation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,6 @@ impl RadioOperator {
/// Query the new deployment indexing status at public status endpoints registered
/// by the indexers who are actively allocating the current deployment
pub async fn indexing_status(config: &Config, args: &IndexingStatusArg) {
let _current_attempt: u64 = 0;

// Get list of public status APIs
let public_status_apis = query_indexer_public_api(&config.graph_stack().network_subgraph, &args.subgraph_id).await
.expect("Could not query public status APIs from indexers actively allocated on the network subgraph");
Expand Down
5 changes: 4 additions & 1 deletion src/query/mod.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
use graphcast_sdk::graphql::QueryError;
use serde::{Deserialize, Serialize};
use serde_json::json;
use std::time::Duration;
use tracing::{debug, trace};

use graphcast_sdk::graphql::QueryError;

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct IndexerUrl {
pub id: String,
Expand Down Expand Up @@ -157,6 +159,7 @@ pub async fn query_indexing_status(
.post(status_endpoint)
.header("Content-Type", "application/json")
.json(&query)
.timeout(Duration::from_secs(10))
.send()
.await?;
trace!("response: {:#?}", &response);
Expand Down

0 comments on commit 20c48f9

Please sign in to comment.