hyperlane/hook/struct.rs
1use crate::*;
2
3/// Represents the hooks for managing the server's lifecycle, specifically for waiting and shutting down.
4///
5/// This struct is returned by the `run` method and provides two key hooks:
6/// - `wait_hook`- A future that resolves when the server has stopped accepting new connections.
7/// - `shutdown_hook`- A function that can be called to gracefully shut down the server.
8#[derive(Clone, CustomDebug, DisplayDebug, Getter, Setter)]
9pub struct ServerControlHook {
10 /// A hook that returns a future, which completes when the server's main task finishes.
11 /// This is typically used to wait for the server to stop accepting connections before
12 /// the application exits.
13 #[debug(skip)]
14 #[get(pub)]
15 #[set(pub(crate))]
16 pub(super) wait_hook: SharedAsyncTaskFactory<()>,
17 /// A hook that, when called, initiates a graceful shutdown of the server.
18 /// This will stop the server from accepting new connections and allow existing ones
19 /// to complete.
20 #[debug(skip)]
21 #[get(pub)]
22 #[set(pub(crate))]
23 pub(super) shutdown_hook: SharedAsyncTaskFactory<()>,
24}