@@ -61,12 +61,12 @@ impl IndexerServiceResponse for SubgraphServiceResponse {
6161}
6262
6363pub struct SubgraphServiceState {
64- pub config : Config ,
64+ pub config : & ' static Config ,
6565 pub database : PgPool ,
6666 pub cost_schema : routes:: cost:: CostSchema ,
6767 pub graph_node_client : reqwest:: Client ,
68- pub graph_node_status_url : Url ,
69- pub graph_node_query_base_url : Url ,
68+ pub graph_node_status_url : & ' static Url ,
69+ pub graph_node_query_base_url : & ' static Url ,
7070}
7171
7272struct SubgraphService {
@@ -130,16 +130,17 @@ pub async fn run() -> anyhow::Result<()> {
130130 // Load the json-rpc service configuration, which is a combination of the
131131 // general configuration options for any indexer service and specific
132132 // options added for JSON-RPC
133- let config = Config :: parse ( indexer_config :: ConfigPrefix :: Service , cli . config . as_ref ( ) )
134- . map_err ( |e| {
133+ let config = Box :: leak ( Box :: new (
134+ Config :: parse ( indexer_config :: ConfigPrefix :: Service , cli . config . as_ref ( ) ) . map_err ( |e| {
135135 error ! (
136136 "Invalid configuration file `{}`: {}, if a value is missing you can also use \
137137 --config to fill the rest of the values",
138138 cli. config. unwrap_or_default( ) . display( ) ,
139139 e
140140 ) ;
141141 anyhow ! ( e)
142- } ) ?;
142+ } ) ?,
143+ ) ) ;
143144
144145 // Parse basic configurations
145146 build_info:: build_info!( fn build_info) ;
@@ -149,7 +150,7 @@ pub async fn run() -> anyhow::Result<()> {
149150 // "state", which will be passed to any request handler, middleware etc.
150151 // that is involved in serving requests
151152 let state = Arc :: new ( SubgraphServiceState {
152- config : config . clone ( ) ,
153+ config,
153154 database : database:: connect ( config. database . clone ( ) . get_formated_postgres_url ( ) . as_ref ( ) )
154155 . await ,
155156 cost_schema : routes:: cost:: build_schema ( ) . await ,
@@ -158,13 +159,13 @@ pub async fn run() -> anyhow::Result<()> {
158159 . timeout ( Duration :: from_secs ( 30 ) )
159160 . build ( )
160161 . expect ( "Failed to init HTTP client for Graph Node" ) ,
161- graph_node_status_url : config. graph_node . status_url . clone ( ) ,
162- graph_node_query_base_url : config. graph_node . query_url . clone ( ) ,
162+ graph_node_status_url : & config. graph_node . status_url ,
163+ graph_node_query_base_url : & config. graph_node . query_url ,
163164 } ) ;
164165
165166 IndexerService :: run ( IndexerServiceOptions {
166167 release,
167- config : config . clone ( ) ,
168+ config,
168169 url_namespace : "subgraphs" ,
169170 service_impl : SubgraphService :: new ( state. clone ( ) ) ,
170171 extra_routes : Router :: new ( )
0 commit comments