@@ -96,7 +96,7 @@ pub struct UdpServer<S> {
9696/// A stopped UDP server state.
9797
9898pub struct Stopped {
99- launcher : Launcher ,
99+ launcher : Spawner ,
100100}
101101
102102/// A running UDP server state.
@@ -105,13 +105,13 @@ pub struct Running {
105105 /// The address where the server is bound.
106106 pub binding : SocketAddr ,
107107 pub halt_task : tokio:: sync:: oneshot:: Sender < Halted > ,
108- pub task : JoinHandle < Launcher > ,
108+ pub task : JoinHandle < Spawner > ,
109109}
110110
111111impl UdpServer < Stopped > {
112112 /// Creates a new `UdpServer` instance in `stopped`state.
113113 #[ must_use]
114- pub fn new ( launcher : Launcher ) -> Self {
114+ pub fn new ( launcher : Spawner ) -> Self {
115115 Self {
116116 state : Stopped { launcher } ,
117117 }
@@ -140,7 +140,7 @@ impl UdpServer<Stopped> {
140140 let binding = rx_start. await . expect ( "it should be able to start the service" ) . address ;
141141 let local_addr = format ! ( "udp://{binding}" ) ;
142142
143- form. send ( ServiceRegistration :: new ( binding, Udp :: check) )
143+ form. send ( ServiceRegistration :: new ( binding, Launcher :: check) )
144144 . expect ( "it should be able to send service registration" ) ;
145145
146146 let running_udp_server: UdpServer < Running > = UdpServer {
@@ -186,12 +186,12 @@ impl UdpServer<Running> {
186186}
187187
188188#[ derive( Constructor , Copy , Clone , Debug ) ]
189- pub struct Launcher {
189+ pub struct Spawner {
190190 bind_to : SocketAddr ,
191191}
192192
193- impl Launcher {
194- /// It starts the UDP server instance.
193+ impl Spawner {
194+ /// It spawns a new tasks to run the UDP server instance.
195195 ///
196196 /// # Panics
197197 ///
@@ -201,10 +201,10 @@ impl Launcher {
201201 tracker : Arc < Tracker > ,
202202 tx_start : oneshot:: Sender < Started > ,
203203 rx_halt : oneshot:: Receiver < Halted > ,
204- ) -> JoinHandle < Launcher > {
205- let launcher = Launcher :: new ( self . bind_to ) ;
204+ ) -> JoinHandle < Spawner > {
205+ let launcher = Spawner :: new ( self . bind_to ) ;
206206 tokio:: spawn ( async move {
207- Udp :: run_with_graceful_shutdown ( tracker, launcher. bind_to , tx_start, rx_halt) . await ;
207+ Launcher :: run_with_graceful_shutdown ( tracker, launcher. bind_to , tx_start, rx_halt) . await ;
208208 launcher
209209 } )
210210 }
@@ -388,9 +388,9 @@ impl Stream for Receiver {
388388
389389/// A UDP server instance launcher.
390390#[ derive( Constructor ) ]
391- pub struct Udp ;
391+ pub struct Launcher ;
392392
393- impl Udp {
393+ impl Launcher {
394394 /// It starts the UDP server instance with graceful shutdown.
395395 ///
396396 /// # Panics
@@ -502,7 +502,8 @@ impl Udp {
502502 */
503503
504504 let abort_handle =
505- tokio:: task:: spawn ( Udp :: process_request ( req, tracker. clone ( ) , receiver. bound_socket . clone ( ) ) ) . abort_handle ( ) ;
505+ tokio:: task:: spawn ( Launcher :: process_request ( req, tracker. clone ( ) , receiver. bound_socket . clone ( ) ) )
506+ . abort_handle ( ) ;
506507
507508 if abort_handle. is_finished ( ) {
508509 continue ;
@@ -589,7 +590,7 @@ mod tests {
589590
590591 use crate :: bootstrap:: app:: initialize_with_configuration;
591592 use crate :: servers:: registar:: Registar ;
592- use crate :: servers:: udp:: server:: { Launcher , UdpServer } ;
593+ use crate :: servers:: udp:: server:: { Spawner , UdpServer } ;
593594
594595 #[ tokio:: test]
595596 async fn it_should_be_able_to_start_and_stop ( ) {
@@ -600,7 +601,7 @@ mod tests {
600601 let bind_to = config. bind_address ;
601602 let register = & Registar :: default ( ) ;
602603
603- let stopped = UdpServer :: new ( Launcher :: new ( bind_to) ) ;
604+ let stopped = UdpServer :: new ( Spawner :: new ( bind_to) ) ;
604605
605606 let started = stopped
606607 . start ( tracker, register. give_form ( ) )
@@ -622,7 +623,7 @@ mod tests {
622623 let bind_to = config. bind_address ;
623624 let register = & Registar :: default ( ) ;
624625
625- let stopped = UdpServer :: new ( Launcher :: new ( bind_to) ) ;
626+ let stopped = UdpServer :: new ( Spawner :: new ( bind_to) ) ;
626627
627628 let started = stopped
628629 . start ( tracker, register. give_form ( ) )
0 commit comments