From 9a7849c69250a59f25ed083e4204c29ff6836a46 Mon Sep 17 00:00:00 2001 From: Titouan Rigoudy Date: Sat, 23 Jan 2021 15:24:11 +0100 Subject: [PATCH] Rename FakeServer to Server, same with ServerHandle. --- src/proto/server/testing.rs | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/src/proto/server/testing.rs b/src/proto/server/testing.rs index 5a5c050..843e210 100644 --- a/src/proto/server/testing.rs +++ b/src/proto/server/testing.rs @@ -137,7 +137,7 @@ impl GracefulHandler { } } -/// A builder for FakeServer instances. +/// A builder for Server instances. #[derive(Default)] pub struct ServerBuilder { user_status_map: Option>>, @@ -152,7 +152,7 @@ impl ServerBuilder { } /// Binds to a localhost port, then returns a server and its handle. - pub async fn bind(self) -> io::Result<(FakeServer, FakeServerHandle)> { + pub async fn bind(self) -> io::Result<(Server, ServerHandle)> { let listener = TcpListener::bind("localhost:0").await?; let address = listener.local_addr()?; @@ -164,12 +164,12 @@ impl ServerBuilder { let (shutdown_tx, shutdown_rx) = watch::channel(()); Ok(( - FakeServer { + Server { listener, shutdown_rx, user_status_map, }, - FakeServerHandle { + ServerHandle { shutdown_tx, address, }, @@ -177,21 +177,20 @@ impl ServerBuilder { } } -// TODO: Rename all FakeServer* to Server*. -/// A fake server for connecting to in tests. -pub struct FakeServer { +/// A simple server for connecting to in tests. +pub struct Server { listener: TcpListener, shutdown_rx: watch::Receiver<()>, user_status_map: Arc>, } -/// Allows interacting with a running `FakeServer`. -pub struct FakeServerHandle { +/// Allows interacting with a running `Server`. +pub struct ServerHandle { shutdown_tx: watch::Sender<()>, address: SocketAddr, } -impl FakeServerHandle { +impl ServerHandle { /// Returns the address on which the server is accepting connections. pub fn address(&self) -> SocketAddr { self.address @@ -205,7 +204,7 @@ impl FakeServerHandle { } } -impl FakeServer { +impl Server { /// Returns the address to which this server is bound. /// This is always localhost and a random port chosen by the OS. pub fn address(&self) -> io::Result { @@ -244,7 +243,7 @@ impl FakeServer { ); } - info!("FakeServer: shutting down"); + info!("Server: shutting down"); // TODO: pass results back instead through an mpsc channel. for task in handler_tasks {