feat: search reindex, worker improvements, person IDs, user display names
- add admin POST /api/v1/admin/reindex-search endpoint + event-driven handler - backfill persons from movie_cast/movie_crew into persons table - paginate person list_page/backfill_from_credits_batch to cap memory - concurrent worker event dispatch with semaphore (max 8) - graceful worker shutdown (drain in-flight tasks on SIGINT) - always ack events, log handler errors as warnings (no infinite retry) - NATS ack_wait 600s, AtomicBool guard against concurrent reindex - add username/display_name to UserSummaryDto and users list - add person_id to CastMemberDto/CrewMemberDto via get_movie_profile use case - add movie_id to wrapup MovieRef, person_id to wrapup PersonStat - thread tmdb_person_id through wrapup cast pipeline - add is_federated to FeedEntryDto - cap orphaned persons query with LIMIT 500 - add SPA link to classic site footer
This commit is contained in:
@@ -6,7 +6,7 @@ use std::sync::Arc;
|
||||
|
||||
use anyhow::Context;
|
||||
use application::{
|
||||
MovieDiscoveryIndexer, SearchCleanupHandler,
|
||||
MovieDiscoveryIndexer, SearchCleanupHandler, SearchReindexHandler,
|
||||
config::AppConfig,
|
||||
context::{AppContext, Repositories, Services},
|
||||
worker::WorkerService,
|
||||
@@ -232,12 +232,15 @@ async fn main() -> anyhow::Result<()> {
|
||||
let wrapup_handler = Arc::new(
|
||||
application::wrapup::event_handler::WrapUpEventHandler::new(ctx.clone()),
|
||||
) as Arc<dyn EventHandler>;
|
||||
let reindex_handler =
|
||||
Arc::new(SearchReindexHandler::new(ctx.clone())) as Arc<dyn EventHandler>;
|
||||
let mut h = vec![
|
||||
poster,
|
||||
cleanup,
|
||||
search_cleanup,
|
||||
discovery_indexer,
|
||||
wrapup_handler,
|
||||
reindex_handler,
|
||||
];
|
||||
if let Some(e) = enrichment_handler {
|
||||
h.push(e);
|
||||
@@ -282,6 +285,8 @@ async fn main() -> anyhow::Result<()> {
|
||||
let wrapup_handler = Arc::new(
|
||||
application::wrapup::event_handler::WrapUpEventHandler::new(ctx.clone()),
|
||||
) as Arc<dyn EventHandler>;
|
||||
let reindex_handler =
|
||||
Arc::new(SearchReindexHandler::new(ctx.clone())) as Arc<dyn EventHandler>;
|
||||
let mut h = vec![
|
||||
poster,
|
||||
cleanup,
|
||||
@@ -290,6 +295,7 @@ async fn main() -> anyhow::Result<()> {
|
||||
search_cleanup,
|
||||
discovery_indexer,
|
||||
wrapup_handler,
|
||||
reindex_handler,
|
||||
];
|
||||
if let Some(e) = enrichment_handler {
|
||||
h.push(e);
|
||||
@@ -303,10 +309,15 @@ async fn main() -> anyhow::Result<()> {
|
||||
|
||||
// ── Run ───────────────────────────────────────────────────────────────────
|
||||
|
||||
let (shutdown_tx, shutdown_rx) = tokio::sync::watch::channel(false);
|
||||
tokio::spawn(async move {
|
||||
tokio::signal::ctrl_c().await.ok();
|
||||
let _ = shutdown_tx.send(true);
|
||||
});
|
||||
|
||||
let worker = WorkerService::new(consumer_arc, handlers);
|
||||
tracing::info!("worker started");
|
||||
worker.run().await;
|
||||
tracing::info!("worker stopped");
|
||||
worker.run(shutdown_rx).await;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user