1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
use tokio::sync::mpsc::UnboundedSender;

use super::Command;

#[derive(Clone)]
pub struct ServerHandle {
    pub(super) tx: UnboundedSender<Command>,
}

impl ServerHandle {
    /// Stop xitca-server with graceful flag.
    pub fn stop(&self, graceful: bool) {
        let cmd = if graceful {
            Command::GracefulStop
        } else {
            Command::ForceStop
        };

        let _ = self.tx.send(cmd);
    }
}