@@ -131,6 +131,7 @@ impl RunRouter<state::Run> {
131
131
spawn : Spawn ,
132
132
temp_router_dir : & Utf8Path ,
133
133
studio_client_config : StudioClientConfig ,
134
+ supergraph_schema : String ,
134
135
) -> Result < RunRouter < state:: Watch > , RunRouterBinaryError >
135
136
where
136
137
Spawn : Service < ExecCommandConfig , Response = Child > + Send + Clone + ' static ,
@@ -160,15 +161,17 @@ impl RunRouter<state::Run> {
160
161
path : hot_reload_config_path. clone ( ) ,
161
162
err : Box :: new ( err) ,
162
163
} ) ?;
164
+
163
165
let hot_reload_schema_path = temp_router_dir. join ( "supergraph.graphql" ) ;
164
166
tracing:: debug!(
165
- "Creating temporary schema path at {}" ,
167
+ "Creating temporary supergraph schema path at {}" ,
166
168
hot_reload_schema_path
167
169
) ;
168
170
write_file
169
171
. call (
170
172
WriteFileRequest :: builder ( )
171
173
. path ( hot_reload_schema_path. clone ( ) )
174
+ . contents ( supergraph_schema. into_bytes ( ) )
172
175
. build ( ) ,
173
176
)
174
177
. await
@@ -185,7 +188,7 @@ impl RunRouter<state::Run> {
185
188
. spawn ( spawn)
186
189
. build ( ) ;
187
190
188
- let ( _router_log_events , run_router_binary_subtask) : (
191
+ let ( router_logs , run_router_binary_subtask) : (
189
192
UnboundedReceiverStream < Result < RouterLog , RunRouterBinaryError > > ,
190
193
_ ,
191
194
) = Subtask :: new ( run_router_binary) ;
@@ -200,6 +203,7 @@ impl RunRouter<state::Run> {
200
203
config_path : self . state . config_path ,
201
204
hot_reload_config_path,
202
205
hot_reload_schema_path,
206
+ router_logs,
203
207
} ,
204
208
} )
205
209
}
@@ -277,7 +281,7 @@ impl RunRouter<state::Watch> {
277
281
. write_file_impl ( write_file_impl)
278
282
. build ( ) ;
279
283
280
- let ( _hot_reload_events , hot_reload_subtask) : ( UnboundedReceiverStream < HotReloadEvent > , _ ) =
284
+ let ( hot_reload_events , hot_reload_subtask) : ( UnboundedReceiverStream < HotReloadEvent > , _ ) =
281
285
Subtask :: new ( hot_reload_watcher) ;
282
286
283
287
let router_config_updates = router_config_updates
@@ -286,26 +290,37 @@ impl RunRouter<state::Watch> {
286
290
287
291
let abort_hot_reload = SubtaskRunStream :: run ( hot_reload_subtask, router_config_updates) ;
288
292
289
- let abort_config_watcher = config_watcher_subtask
290
- . map ( |config_watcher_subtask| SubtaskRunUnit :: run ( config_watcher_subtask) ) ;
293
+ let abort_config_watcher = config_watcher_subtask. map ( SubtaskRunUnit :: run) ;
291
294
292
295
RunRouter {
293
296
state : state:: Abort {
294
297
abort_router : self . state . abort_router ,
295
298
abort_hot_reload,
296
299
abort_config_watcher,
300
+ hot_reload_events,
301
+ router_logs : self . state . router_logs ,
297
302
} ,
298
303
}
299
304
}
300
305
}
301
306
307
+ impl RunRouter < state:: Abort > {
308
+ pub fn router_logs (
309
+ & mut self ,
310
+ ) -> & mut UnboundedReceiverStream < Result < RouterLog , RunRouterBinaryError > > {
311
+ & mut self . state . router_logs
312
+ }
313
+ }
314
+
302
315
mod state {
303
316
use camino:: Utf8PathBuf ;
304
317
use tokio:: task:: AbortHandle ;
318
+ use tokio_stream:: wrappers:: UnboundedReceiverStream ;
305
319
306
320
use crate :: command:: dev:: next:: router:: {
307
- binary:: RouterBinary ,
321
+ binary:: { RouterBinary , RouterLog , RunRouterBinaryError } ,
308
322
config:: { remote:: RemoteRouterConfig , RouterConfigFinal } ,
323
+ hot_reload:: HotReloadEvent ,
309
324
} ;
310
325
311
326
#[ derive( Default ) ]
@@ -329,8 +344,11 @@ mod state {
329
344
pub config_path : Option < Utf8PathBuf > ,
330
345
pub hot_reload_config_path : Utf8PathBuf ,
331
346
pub hot_reload_schema_path : Utf8PathBuf ,
347
+ pub router_logs : UnboundedReceiverStream < Result < RouterLog , RunRouterBinaryError > > ,
332
348
}
333
349
pub struct Abort {
350
+ pub router_logs : UnboundedReceiverStream < Result < RouterLog , RunRouterBinaryError > > ,
351
+ pub hot_reload_events : UnboundedReceiverStream < HotReloadEvent > ,
334
352
pub abort_router : AbortHandle ,
335
353
pub abort_config_watcher : Option < AbortHandle > ,
336
354
pub abort_hot_reload : AbortHandle ,
0 commit comments