xitca_server/server/
handle.rs

1use tokio::sync::mpsc::UnboundedSender;
2
3use super::Command;
4
5#[derive(Clone)]
6pub struct ServerHandle {
7    pub(super) tx: UnboundedSender<Command>,
8}
9
10impl ServerHandle {
11    /// Stop xitca-server with graceful flag.
12    pub fn stop(&self, graceful: bool) {
13        let cmd = if graceful {
14            Command::GracefulStop
15        } else {
16            Command::ForceStop
17        };
18
19        let _ = self.tx.send(cmd);
20    }
21}