@@ -9,7 +9,6 @@ use anyhow::anyhow;
99use async_graphql:: { EmptySubscription , Schema } ;
1010use async_graphql_axum:: GraphQL ;
1111use axum:: {
12- async_trait,
1312 routing:: { post, post_service} ,
1413 Json , Router ,
1514} ;
@@ -28,7 +27,7 @@ use crate::{
2827 dips:: { AgreementStore , InMemoryAgreementStore } ,
2928 } ,
3029 routes:: dips:: Price ,
31- service:: indexer_service:: { IndexerService , IndexerServiceOptions , IndexerServiceRelease } ,
30+ service:: indexer_service:: { IndexerServiceOptions , IndexerServiceRelease } ,
3231} ;
3332use clap:: Parser ;
3433use tracing:: error;
@@ -37,13 +36,12 @@ mod indexer_service;
3736mod tap_receipt_header;
3837
3938pub use indexer_service:: {
40- AttestationOutput , IndexerServiceError , IndexerServiceImpl , IndexerServiceResponse ,
41- IndexerServiceState ,
39+ AttestationOutput , IndexerServiceError , IndexerServiceResponse , IndexerServiceState ,
4240} ;
4341pub use tap_receipt_header:: TapReceipt ;
4442
4543#[ derive( Debug ) ]
46- struct SubgraphServiceResponse {
44+ pub struct SubgraphServiceResponse {
4745 inner : String ,
4846 attestable : bool ,
4947}
@@ -78,6 +76,7 @@ impl IndexerServiceResponse for SubgraphServiceResponse {
7876 }
7977}
8078
79+ #[ derive( Clone ) ]
8180pub struct SubgraphServiceState {
8281 pub config : & ' static Config ,
8382 pub database : PgPool ,
@@ -87,27 +86,22 @@ pub struct SubgraphServiceState {
8786 pub graph_node_query_base_url : & ' static Url ,
8887}
8988
90- struct SubgraphService {
91- state : Arc < SubgraphServiceState > ,
89+ pub struct SubgraphService {
90+ state : SubgraphServiceState ,
9291}
9392
9493impl SubgraphService {
95- fn new ( state : Arc < SubgraphServiceState > ) -> Self {
94+ fn new ( state : SubgraphServiceState ) -> Self {
9695 Self { state }
9796 }
9897}
9998
100- #[ async_trait]
101- impl IndexerServiceImpl for SubgraphService {
102- type Error = SubgraphServiceError ;
103- type Response = SubgraphServiceResponse ;
104- type State = SubgraphServiceState ;
105-
106- async fn process_request < Request : DeserializeOwned + Send + std:: fmt:: Debug + Serialize > (
99+ impl SubgraphService {
100+ pub async fn process_request < Request : DeserializeOwned + Send + std:: fmt:: Debug + Serialize > (
107101 & self ,
108102 deployment : DeploymentId ,
109103 request : Request ,
110- ) -> Result < Self :: Response , Self :: Error > {
104+ ) -> Result < SubgraphServiceResponse , SubgraphServiceError > {
111105 let deployment_url = self
112106 . state
113107 . graph_node_query_base_url
@@ -166,7 +160,7 @@ pub async fn run() -> anyhow::Result<()> {
166160 // Some of the subgraph service configuration goes into the so-called
167161 // "state", which will be passed to any request handler, middleware etc.
168162 // that is involved in serving requests
169- let state = Arc :: new ( SubgraphServiceState {
163+ let state = SubgraphServiceState {
170164 config,
171165 database : database:: connect ( config. database . clone ( ) . get_formated_postgres_url ( ) . as_ref ( ) )
172166 . await ,
@@ -178,7 +172,7 @@ pub async fn run() -> anyhow::Result<()> {
178172 . expect ( "Failed to init HTTP client for Graph Node" ) ,
179173 graph_node_status_url : & config. graph_node . status_url ,
180174 graph_node_query_base_url : & config. graph_node . query_url ,
181- } ) ;
175+ } ;
182176
183177 let agreement_store: Arc < dyn AgreementStore > = Arc :: new ( InMemoryAgreementStore :: default ( ) ) ;
184178 let prices: Vec < Price > = vec ! [ ] ;
@@ -215,7 +209,7 @@ pub async fn run() -> anyhow::Result<()> {
215209 router = router. route ( "/dips" , post_service ( GraphQL :: new ( schema) ) ) ;
216210 }
217211
218- IndexerService :: run ( IndexerServiceOptions {
212+ indexer_service :: run ( IndexerServiceOptions {
219213 release,
220214 config,
221215 url_namespace : "subgraphs" ,
0 commit comments