pub fn start_watching(
engine: Arc<Mutex<Option<Engine>>>,
attachments: Arc<AttachRegistry>,
registry: Arc<WatcherRegistry>,
subscriptions: Option<Arc<SubscriptionRegistry>>,
dir: PathBuf,
table: String,
target_db: Option<String>,
options: WatchOptions,
) -> Result<WatcherStats, McpError>Expand description
Begin watching dir. Builds a dedicated connection pool, runs the
initial sweep (sequentially — there’s no benefit to parallelism for
startup since the pool isn’t under load yet), then installs a
notify watcher that streams events to an async tokio task.
Returns a snapshot of the initial-sweep stats.
The engine Arc must point to an already-initialized engine (the caller
in server.rs eagerly calls ensure_engine before invoking this).
§Errors
- Returns
ErrorCode::FileNotFoundifdirdoes not exist, is not a directory, or cannot be canonicalized. - Returns
ErrorCode::InternalErrorif the watcher registry mutex or engine mutex is poisoned, if the engine has not been initialized, ifstart_watchingis not called from a Tokio runtime, or if the watcher pool / OS file-system watcher cannot be constructed. - Returns
ErrorCode::InternalErrorwrapping the error string whennotify::RecommendedWatchersetup fails. - Propagates any error from the initial sweep’s per-file ingest
(file read, schema inference, or Hyper
COPY/INSERTerrors).