use super::*;
use crate::request::request_group::{DownloadOptions, DownloadStatus, HaltReason};
fn test_ctx(keep_alive: bool) -> EngineLoopContext {
EngineLoopContext {
group_man: Arc::new(RequestGroupMan::new()),
dns_cache: Arc::new(tokio::sync::Mutex::new(DnsCache::new())),
outbound_network_policy: Arc::new(crate::network::OutboundNetworkPolicy::direct()),
auto_save: None,
auto_save_dirty_signal: None,
event_hooks: Arc::new(DownloadEventHooks::new()),
file_alloc_man: Arc::new(tokio::sync::RwLock::new(FileAllocationMan::new())),
keep_alive,
server_stat_man: ServerStatMan::shared().clone(),
server_stat_max_age: Some(Duration::from_secs(24 * 60 * 60)),
server_stat_save_path: None,
server_stat_save_interval: None,
server_stat_next_save: None,
global_limiter: None,
#[cfg(feature = "bittorrent")]
public_tracker_catalog: Arc::new(
aria2_protocol::bittorrent::tracker::public_list::PublicTrackerList::new(),
),
#[cfg(feature = "bittorrent")]
bt_registry: Arc::new(std::sync::RwLock::new(
crate::engine::bittorrent::registry::BtRegistry::new(),
)),
#[cfg(feature = "bittorrent")]
bt_listener: Arc::new(
crate::engine::bittorrent::peer::listener::BtPeerListenerManager::new(),
),
#[cfg(feature = "bittorrent")]
lpd_manager: Arc::new(crate::engine::bittorrent::discovery::lpd::LpdManager::new()),
}
}
async fn run_until_exit(
ctx: EngineLoopContext,
cmd_rx: EngineCommandReceiver,
shutdown_rx: tokio::sync::oneshot::Receiver<()>,
budget: Duration,
) {
let loop_fut = run_engine_loop(ctx, cmd_rx, shutdown_rx);
tokio::time::timeout(budget, loop_fut)
.await
.expect("engine loop failed to terminate after halt");
}
#[path = "commands.rs"]
mod commands;
#[path = "completions.rs"]
mod completions;
#[path = "lifecycle.rs"]
mod lifecycle;
#[path = "maintenance.rs"]
mod maintenance;