-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix!: Only load schemas for allocated subgraphs
BREAKING CHANGE: autoagora-processor needs to communicate with the indexer-agent API (--indexer-agent-mgmt-endpoint) instead of graph-node's PG DB (--graph-postgres-... args are gone). Fixes #33 Signed-off-by: Alexis Asseman <[email protected]>
- Loading branch information
Showing
6 changed files
with
100 additions
and
115 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# Copyright 2023-, Semiotic AI, Inc. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
import logging | ||
from typing import Mapping, Optional, Set | ||
|
||
import backoff | ||
from gql import Client, gql | ||
from gql.transport.requests import RequestsHTTPTransport | ||
from requests import RequestException | ||
|
||
from autoagora_processor.config import args | ||
|
||
|
||
@backoff.on_exception(backoff.expo, RequestException, max_time=30, logger=logging.root) | ||
def query_indexer_agent(query: str, variables: Optional[Mapping] = None): | ||
client = Client( | ||
transport=RequestsHTTPTransport(args.indexer_agent_mgmt_endpoint), | ||
fetch_schema_from_transport=False, | ||
) | ||
result = client.execute(gql(query), variable_values=variables) # type: ignore | ||
return result | ||
|
||
|
||
def get_network_allocated_subgraphs(network: str) -> Set[str]: | ||
"""Get the indexer's subgraph allocations for the given Graph network.""" | ||
|
||
result = query_indexer_agent( | ||
""" | ||
query ($protocolNetwork: String!) { | ||
indexerAllocations (protocolNetwork: $protocolNetwork) { | ||
subgraphDeployment | ||
} | ||
} | ||
""", | ||
variables={ | ||
"protocolNetwork": network, | ||
}, | ||
) | ||
|
||
return set(e["subgraphDeployment"] for e in result["indexerAllocations"]) | ||
|
||
|
||
def get_allocated_subgraphs() -> Set[str]: | ||
"""Get the indexer's subgraph allocations for all Graph networks.""" | ||
|
||
networks = ("mainnet", "arbitrum-one") | ||
results = map(get_network_allocated_subgraphs, networks) | ||
|
||
return set.union(*results) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters