refactor(handlers): split urls.rs into workers, pipeline and startup repair

urls.rs carried five reasons to change: the job channel and its worker pool,
the single-flight fetch, URL parsing, the per-URL pipeline, and the startup
repair of queued retries. The two with their own lifecycle move out:

- url_workers.rs: the bounded channel, its supervised pool and
  start/stop_url_workers (the pipeline stays in urls.rs, which the workers
  call).
- repair.rs: needs_refetch/apply_refresh/refetch/repair_lost_local_media with
  their tests, moved whole (the live one keeps its #[ignore]).

Also folds the two byte-identical render_fields -> CachedPost mappings
(urls.rs and repair.rs) into urls::cached_snapshot, and moves the shared
permanent_error test fixture into ctx::test_support.
This commit is contained in:
2026-09-21 18:28:41 +08:00
parent 435c8c4cc4
commit 01e097a8b6
6 changed files with 495 additions and 469 deletions
+6 -3
View File
@@ -9,18 +9,20 @@
mod callback;
mod commands;
mod inline;
mod repair;
mod statics;
mod url_workers;
mod urls;
pub use callback::callback_query_handler;
pub use commands::register_commands;
pub use inline::inline_query_handler;
pub(crate) use inline::prune_idle_states;
pub(crate) use repair::repair_lost_local_media;
/// The resolved `$DATA_DIR/task_queue.db` path, for the startup config line.
pub(crate) use statics::db_path;
pub use statics::{CHAT_STORE, CONFIG, LINK_CACHE, TASK_QUEUE};
pub(crate) use urls::repair_lost_local_media;
pub use urls::{start_url_workers, stop_url_workers};
pub use url_workers::{start_url_workers, stop_url_workers};
use crate::ctx::AppContext;
use crate::media_sender::MediaSender;
@@ -29,7 +31,8 @@ use teloxide::RequestError;
use teloxide::prelude::*;
use teloxide::types::{ChatId, Message, MessageId};
use teloxide::utils::command::BotCommands;
use urls::{URL_JOBS, extract_urls};
use url_workers::URL_JOBS;
use urls::extract_urls;
/// Reply to a message by id, keeping the reply decoration even if the
/// original was already deleted.