@@ -267,9 +267,9 @@ impl From<(WorkerContextInitOpts, SupervisorPolicy)> for CreateWorkerArgs {
267
267
}
268
268
}
269
269
270
- impl From < ( WorkerContextInitOpts , TerminationToken ) > for CreateWorkerArgs {
271
- fn from ( val : ( WorkerContextInitOpts , TerminationToken ) ) -> Self {
272
- CreateWorkerArgs ( val. 0 , None , Some ( val. 1 ) )
270
+ impl < T : Into < Option < TerminationToken > > > From < ( WorkerContextInitOpts , T ) > for CreateWorkerArgs {
271
+ fn from ( val : ( WorkerContextInitOpts , T ) ) -> Self {
272
+ CreateWorkerArgs ( val. 0 , None , val. 1 . into ( ) )
273
273
}
274
274
}
275
275
@@ -417,6 +417,7 @@ pub async fn create_main_worker(
417
417
no_module_cache : bool ,
418
418
user_worker_msgs_tx : mpsc:: UnboundedSender < UserWorkerMsgs > ,
419
419
maybe_entrypoint : Option < String > ,
420
+ termination_token : Option < TerminationToken > ,
420
421
) -> Result < mpsc:: UnboundedSender < WorkerRequestMsg > , Error > {
421
422
let mut service_path = main_worker_path. clone ( ) ;
422
423
let mut maybe_eszip = None ;
@@ -427,20 +428,23 @@ pub async fn create_main_worker(
427
428
}
428
429
}
429
430
430
- let main_worker_req_tx = create_worker ( WorkerContextInitOpts {
431
- service_path,
432
- import_map_path,
433
- no_module_cache,
434
- events_rx : None ,
435
- timing : None ,
436
- maybe_eszip,
437
- maybe_entrypoint,
438
- maybe_module_code : None ,
439
- conf : WorkerRuntimeOpts :: MainWorker ( MainWorkerRuntimeOpts {
440
- worker_pool_tx : user_worker_msgs_tx,
441
- } ) ,
442
- env_vars : std:: env:: vars ( ) . collect ( ) ,
443
- } )
431
+ let main_worker_req_tx = create_worker ( (
432
+ WorkerContextInitOpts {
433
+ service_path,
434
+ import_map_path,
435
+ no_module_cache,
436
+ events_rx : None ,
437
+ timing : None ,
438
+ maybe_eszip,
439
+ maybe_entrypoint,
440
+ maybe_module_code : None ,
441
+ conf : WorkerRuntimeOpts :: MainWorker ( MainWorkerRuntimeOpts {
442
+ worker_pool_tx : user_worker_msgs_tx,
443
+ } ) ,
444
+ env_vars : std:: env:: vars ( ) . collect ( ) ,
445
+ } ,
446
+ termination_token,
447
+ ) )
444
448
. await
445
449
. map_err ( |err| anyhow ! ( "main worker boot error: {}" , err) ) ?;
446
450
@@ -452,6 +456,7 @@ pub async fn create_events_worker(
452
456
import_map_path : Option < String > ,
453
457
no_module_cache : bool ,
454
458
maybe_entrypoint : Option < String > ,
459
+ termination_token : Option < TerminationToken > ,
455
460
) -> Result < mpsc:: UnboundedSender < WorkerEventWithMetadata > , Error > {
456
461
let ( events_tx, events_rx) = mpsc:: unbounded_channel :: < WorkerEventWithMetadata > ( ) ;
457
462
@@ -466,18 +471,21 @@ pub async fn create_events_worker(
466
471
}
467
472
}
468
473
469
- let _ = create_worker ( WorkerContextInitOpts {
470
- service_path,
471
- no_module_cache,
472
- import_map_path,
473
- env_vars : std:: env:: vars ( ) . collect ( ) ,
474
- events_rx : Some ( events_rx) ,
475
- timing : None ,
476
- maybe_eszip,
477
- maybe_entrypoint,
478
- maybe_module_code : None ,
479
- conf : WorkerRuntimeOpts :: EventsWorker ( EventWorkerRuntimeOpts { } ) ,
480
- } )
474
+ let _ = create_worker ( (
475
+ WorkerContextInitOpts {
476
+ service_path,
477
+ no_module_cache,
478
+ import_map_path,
479
+ env_vars : std:: env:: vars ( ) . collect ( ) ,
480
+ events_rx : Some ( events_rx) ,
481
+ timing : None ,
482
+ maybe_eszip,
483
+ maybe_entrypoint,
484
+ maybe_module_code : None ,
485
+ conf : WorkerRuntimeOpts :: EventsWorker ( EventWorkerRuntimeOpts { } ) ,
486
+ } ,
487
+ termination_token,
488
+ ) )
481
489
. await
482
490
. map_err ( |err| anyhow ! ( "events worker boot error: {}" , err) ) ?;
483
491
0 commit comments