@@ -7,9 +7,9 @@ use futures::future::BoxFuture;
77use crate :: signals:: shutdown_signal;
88use crate :: tracker:: Tracker ;
99
10- /// Trait to be implemented by a http interface for the tracker.
10+ /// Trait to be implemented by a http server launcher for the tracker.
1111#[ allow( clippy:: module_name_repetitions) ]
12- pub trait TrackerInterfaceTrait : Sync + Send {
12+ pub trait HttpServerLauncher : Sync + Send {
1313 fn new ( ) -> Self ;
1414
1515 fn start_with_graceful_shutdown < F > (
@@ -28,54 +28,54 @@ pub enum Error {
2828}
2929
3030#[ allow( clippy:: module_name_repetitions) ]
31- pub type StoppedHttpServer < I > = TrackerInterface < Stopped < I > > ;
31+ pub type StoppedHttpServer < I > = HttpServer < Stopped < I > > ;
3232#[ allow( clippy:: module_name_repetitions) ]
33- pub type RunningHttpServer < I > = TrackerInterface < Running < I > > ;
33+ pub type RunningHttpServer < I > = HttpServer < Running < I > > ;
3434
35- pub struct TrackerInterface < S > {
35+ pub struct HttpServer < S > {
3636 cfg : torrust_tracker_configuration:: HttpTracker ,
3737 state : S ,
3838}
3939
40- pub struct Stopped < I : TrackerInterfaceTrait > {
41- interface : I ,
40+ pub struct Stopped < I : HttpServerLauncher > {
41+ launcher : I ,
4242}
4343
44- pub struct Running < I : TrackerInterfaceTrait > {
44+ pub struct Running < I : HttpServerLauncher > {
4545 bind_addr : SocketAddr ,
4646 task_killer : tokio:: sync:: oneshot:: Sender < u8 > ,
4747 task : tokio:: task:: JoinHandle < I > ,
4848}
4949
50- impl < I : TrackerInterfaceTrait + ' static > TrackerInterface < Stopped < I > > {
51- pub fn new ( cfg : torrust_tracker_configuration:: HttpTracker , interface : I ) -> Self {
50+ impl < I : HttpServerLauncher + ' static > HttpServer < Stopped < I > > {
51+ pub fn new ( cfg : torrust_tracker_configuration:: HttpTracker , launcher : I ) -> Self {
5252 Self {
5353 cfg,
54- state : Stopped { interface } ,
54+ state : Stopped { launcher } ,
5555 }
5656 }
5757
58- pub async fn start ( self , tracker : Arc < Tracker > ) -> Result < TrackerInterface < Running < I > > , Error > {
58+ pub async fn start ( self , tracker : Arc < Tracker > ) -> Result < HttpServer < Running < I > > , Error > {
5959 let ( shutdown_sender, shutdown_receiver) = tokio:: sync:: oneshot:: channel :: < u8 > ( ) ;
6060 let ( addr_sender, addr_receiver) = tokio:: sync:: oneshot:: channel :: < SocketAddr > ( ) ;
6161
6262 let configuration = self . cfg . clone ( ) ;
63- let interface = self . state . interface ;
63+ let launcher = self . state . launcher ;
6464
6565 let task = tokio:: spawn ( async move {
6666 let ( bind_addr, server) =
67- interface . start_with_graceful_shutdown ( configuration, tracker, shutdown_signal ( shutdown_receiver) ) ;
67+ launcher . start_with_graceful_shutdown ( configuration, tracker, shutdown_signal ( shutdown_receiver) ) ;
6868
6969 addr_sender. send ( bind_addr) . unwrap ( ) ;
7070
7171 server. await ;
7272
73- interface
73+ launcher
7474 } ) ;
7575
7676 let bind_address = addr_receiver. await . expect ( "Could not receive bind_address." ) ;
7777
78- Ok ( TrackerInterface {
78+ Ok ( HttpServer {
7979 cfg : self . cfg ,
8080 state : Running {
8181 bind_addr : bind_address,
@@ -86,15 +86,15 @@ impl<I: TrackerInterfaceTrait + 'static> TrackerInterface<Stopped<I>> {
8686 }
8787}
8888
89- impl < I : TrackerInterfaceTrait > TrackerInterface < Running < I > > {
90- pub async fn stop ( self ) -> Result < TrackerInterface < Stopped < I > > , Error > {
89+ impl < I : HttpServerLauncher > HttpServer < Running < I > > {
90+ pub async fn stop ( self ) -> Result < HttpServer < Stopped < I > > , Error > {
9191 self . state . task_killer . send ( 0 ) . unwrap ( ) ;
9292
93- let interface = self . state . task . await . map_err ( |e| Error :: Error ( e. to_string ( ) ) ) ?;
93+ let launcher = self . state . task . await . map_err ( |e| Error :: Error ( e. to_string ( ) ) ) ?;
9494
95- Ok ( TrackerInterface {
95+ Ok ( HttpServer {
9696 cfg : self . cfg ,
97- state : Stopped { interface } ,
97+ state : Stopped { launcher } ,
9898 } )
9999 }
100100}
0 commit comments